1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
#!/bin/bash
#
# Copyright (C) 2012 Ruben Rodriguez <ruben@trisquel.info>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# This script builds Dextrose patched, Sugar rpms from git repositories
# Requirements: git, yum-utils, rpmbuild, patch, libtool, intltool, createrepo
if [ $# != 2 ]
then
echo Usage: sh $0 version package
echo Example: sh $0 0.94.1 sugar-toolkit
exit 1
fi
# Let's make sure we have all we need
yum -y install git yum-utils rpmbuild patch libtool intltool createrepo
WD=$PWD
VERSION=$1
PACKAGE=$2
FUZZ=20
ARCH=$(rpm -q glibc |sed 's/.*\.//;s/i686/i386/')
TEST=$(mktemp -d)
rm -rf ~/rpmbuild/SOURCES ~/rpmbuild/SPECS
mkdir -p ~/rpmbuild/BUILD ~/rpmbuild/BUILDROOT ~/rpmbuild/RPMS ~/rpmbuild/SOURCES ~/rpmbuild/SPECS/$PACKAGE ~/rpmbuild/SRPMS
cp $PACKAGE/$PACKAGE.spec ~/rpmbuild/SPECS/$PACKAGE/
[ $PACKAGE = "sugar-toolkit" ] && cp $PACKAGE/macros.sugar ~/rpmbuild/SOURCES/
git clone git://git.sugarlabs.org/$PACKAGE/mainline.git ~/rpmbuild/SOURCES/$PACKAGE-$VERSION
cd ~/rpmbuild/SOURCES/$PACKAGE-$VERSION
git checkout v$VERSION
cd $WD
sed "s/Version:.*/Version: $VERSION/" ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec -i
sed "s/Release:.*/Release: $(date +%Y%m%d)dx3/" ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec -i
# Since sugar and sugar-artwork DX3 specs *already* have epoch set to the
# date number, we will continue that hack for DX3. BUT THIS IS WRONG!!!
sed '/^Epoch:/d' -i ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec
sed "/^Name:/s/$/\nEpoch: $(date +%Y%m%d)/" -i ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec
# Let's allow some fuzz
sed "1s/$/\n%define _default_patch_fuzz $FUZZ/" -i ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec
cd ~/rpmbuild/SOURCES/$PACKAGE-$VERSION
[ $PACKAGE = "sugar-artwork" ] && sed '/GNOME_COMPILE_WARNINGS/d' configure.ac -i
sh autogen.sh
cd ..
tar -jcvf $PACKAGE-$VERSION.tar.bz2 $PACKAGE-$VERSION
cd $WD
############################################################################
# Set tokens for adding patches to the spec file
sed "/^Source0/s/$/\n\#ListPatches/" ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec -i
sed "/^%setup/s/$/\n\#MakePatches/" ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec -i
sed "/^Patch/d" ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec -i
sed "/^%*patch/d" ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec -i
# number, name, string, strip
addpatch(){
sed "/ListPatches/s%^%Patch$1: $3\n%" ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec -i
sed "/MakePatches/s/^/%patch$1 -p$4 -b $2\n/" ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec -i
}
rm -rf ~/rpmbuild/RPMS/$PACKAGE-$VERSION.*patches
cp ~/rpmbuild/SOURCES/$PACKAGE-$VERSION $TEST/src -a
cd $TEST/src
for i in $WD/$PACKAGE/*patch
do
file=${i//*\//}
number=${file//-*/}
log=$(patch -N -t -F$FUZZ --dry-run -p1 < $i 2>&1)
if [ $? = 0 ]
then
echo APPLIED PATCH: $file | tee -a ~/rpmbuild/RPMS/$PACKAGE-$VERSION.appliedpatches
patch -F$FUZZ -p1 < $i
cp $i ~/rpmbuild/SOURCES/
addpatch $number .$number "$file" 1
else
if echo $log |grep -q "previously applied"
then
echo ALREADY APPLIED: $file | tee -a ~/rpmbuild/RPMS/$PACKAGE-$VERSION.failedpatches
else
echo FAILED TO APPLY: $file | tee -a ~/rpmbuild/RPMS/$PACKAGE-$VERSION.failedpatches
fi
fi
done
cd $WD
rm -rf $TEST
# Clean tokens
sed '/ListPatches/d; /MakePatches/d' ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec -i
############################################################################
grep BuildRequires ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec |sed s/.*\ //|xargs yum -y install
rpmbuild --clean ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec
if rpm -q glibc |grep -q armv5
then
rpmbuild --target armv5tel -ba ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec
else
rpmbuild -ba ~/rpmbuild/SPECS/$PACKAGE/$PACKAGE.spec
fi
|