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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
|
#!/bin/bash
#
# Copyright (C) 2011-2014 Ruben Rodriguez <ruben@gnu.org>
#
# 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
#
set -e
export DEBIAN_FRONTEND=noninteractive
MEM=$(cat /proc/meminfo |grep MemTotal| awk '{print $2}')
GPGKEY=8D8AEBF1
for VAR in LANG LANGUAGE LC_ALL LC_TIME LC_MONETARY LC_ADDRESS LC_TELEPHONE LC_MESSAGES LC_NAME LC_MEASUREMENT LC_IDENTIFICATION LC_IDENTIFICATION LC_NUMERIC LC_PAPER LANG
do
unset $VAR
done
export LANG=C
export HOME=/root
export DATE=$(date +'%a, %d %b %Y %T %z')
cd $(dirname $0)
if [ $# -lt 2 ]
then
echo "Usage: $0 trisquel_version_codename (toutatis|belenos) branding (trisquel|gnu)"
echo example: $0 belenos gnu
exit 1
fi
PACKAGE=firefox
export CODENAME=$1
export BRAND=$2
WORKDIR=tmp/makepackage
REPOSITORY=$PWD/repos/$CODENAME
HELPERS=$PWD/helpers
for REPO in toutatis belenos
do
[ -d $REPOSITORY ] && continue
mkdir -p repos/$REPO/conf repos/$REPO/incoming
cat << EOF > repos/$REPO/conf/distributions
Origin: Trisquel
Label: Trisquel
Suite: $REPO
Version: 42
Codename: $REPO
Architectures: i386 amd64 source
Components: main
UDebComponents: main
DebIndices: Packages Release . .gz .bz2
UDebIndices: Packages . .gz .bz2
DscIndices: Sources Release .gz .bz2
Log: $REPO.log
Description: Trisquel GNU/Linux packages
EOF
if gpg -K | grep -q $GPGKEY
then
echo "SignWith: $GPGKEY" >> repos/$REPO/conf/distributions
fi
cd repos/$REPO
reprepro -v export
cd ../..
done
disablescripts(){
# Disable service starter scripts
for i in /usr/sbin/invoke-rc.d /sbin/start /sbin/start-stop-daemon /usr/sbin/service
do
mv $CHROOT/$i $CHROOT/$i.real
cp $CHROOT/bin/true $CHROOT/$i
done
}
createjail () {
[ -d jails ] || mkdir jails
CHROOT=jails/$CODENAME-$ARCH
C="chroot $CHROOT"
MIRROR=http://archive.trisquel.info/trisquel
mkdir $CHROOT-tmp
mount -t tmpfs -o size=500M none $CHROOT-tmp
debootstrap --arch=$ARCH $CODENAME $CHROOT-tmp $MIRROR
fuser -k $CHROOT-tmp || true
cp -a $CHROOT-tmp $CHROOT
umount $CHROOT-tmp
rm $CHROOT-tmp -rf
echo "127.0.0.1 localhost" > $CHROOT/etc/hosts
mount none $CHROOT/proc -t proc
mount none $CHROOT/dev/pts -t devpts
disablescripts
if gpg -K | grep $GPGKEY -q
then
cp /root/.gnupg $CHROOT/root -a
else
echo GPG private key for $GPGKEY not found, the packages and repositories will not be signed.
fi
echo $CODENAME-$ARCH > $CHROOT/etc/debian_chroot
cat << EOF > $CHROOT/etc/apt/sources.list
deb $MIRROR $CODENAME main
deb $MIRROR $CODENAME-updates main
deb $MIRROR $CODENAME-security main
deb $MIRROR $CODENAME-backports main
EOF
cat << EOF > $CHROOT/etc/apt/apt.conf.d/90recommends
APT::Install-Recommends "0";
APT::Install-Suggests "0";
EOF
export DEBIAN_FRONTEND=noninteractive
echo "force-unsafe-io" > $CHROOT/etc/dpkg/dpkg.cfg.d/02apt-speedup
$C apt-get update
$C apt-get --force-yes -y install eatmydata sysv-rc dpkg sysvinit-utils upstart
disablescripts
$C apt-get --force-yes -y dist-upgrade
$C apt-get --force-yes -y install devscripts build-essential liburi-perl python-setuptools pkgbinarymangler wget rpl aptitude quilt fakeroot ccache ubuntu-keyring
$C apt-key add /usr/share/keyrings/ubuntu-archive-keyring.gpg
$C apt-get clean
wget -o /dev/null -O $CHROOT/tmp/key.gpg http://archive.trisquel.info/trisquel/trisquel-archive-signkey.gpg
$C apt-key add /tmp/key.gpg
# Hack for i386
if [ $ARCH = "i386" ]
then
for BIN in /bin/uname /usr/bin/arch
do
[ -f $CHROOT/$BIN ] || continue
mv $CHROOT/$BIN $CHROOT/$BIN.orig
cat << EOF > $CHROOT/$BIN
#!/bin/bash
if [ \$# -eq 0 ]
then
$BIN.orig | sed s/x86_64/i686/g
else
$BIN.orig "\$*" | sed s/x86_64/i686/g
fi
EOF
chmod 755 $CHROOT/$BIN
done
fi
umount $CHROOT/proc $CHROOT/dev/pts
}
prepare(){
[ -d jails/$CODENAME-$ARCH ] || createjail
cat << EOF > jails/$CODENAME-$ARCH/tmp/update
mount -t proc none /proc
export DEBIAN_FRONTEND=noninteractive
export LANG=C
apt-get update
apt-get --force-yes -y install sysv-rc dpkg sysvinit-utils upstart
for i in /usr/sbin/invoke-rc.d /sbin/start /sbin/start-stop-daemon /usr/sbin/service /sbin/initctl
do
mv \$i \$i.real
cp /bin/true \$i
done
export DEBIAN_FRONTEND=noninteractive
apt-get -q --force-yes -y dist-upgrade
umount /proc
EOF
chroot jails/$CODENAME-$ARCH bash /tmp/update
if [ -f jails/$CODENAME-$ARCH/CurrentlyBuilding ]
then
echo The $CODENAME-$ARCH jail appears to be running $(cat jails/$CODENAME-$ARCH/CurrentlyBuilding |grep Package: |sed 's/Package:\ //'), aborting.
exit 1
fi
CHROOT=jails/$CODENAME-$ARCH disablescripts
}
tmpumount(){
grep jails/$CODENAME-$ARCH/tmp /proc/mounts -q || return 0
umount jails/$CODENAME-$ARCH/tmp && return
echo ERROR: could not umount tmpfs at jails/$CODENAME-$ARCH/tmp
exit 1
}
tmpmount(){
[ $MEM -lt 16000000 ] && return
grep jails/$CODENAME-$ARCH/tmp /proc/mounts -q && tmpumount
mount -t tmpfs -o size=20G none jails/$CODENAME-$ARCH/tmp
}
compile(){
[ -d jails/$CODENAME-$ARCH/$WORKDIR ] && rm -rf jails/$CODENAME-$ARCH/$WORKDIR/
tmpmount
cp -a helpers/ jails/$CODENAME-$ARCH/$WORKDIR/
cat << EOF > jails/$CODENAME-$ARCH/usr/local/sbin/makepackage-handler
#!/bin/bash
WORKDIR=$WORKDIR
PACKAGE=$PACKAGE
cd $WORKDIR
[ -d LOGS ] || mkdir LOGS
[ -d PACKAGES ] || mkdir PACKAGES
export LD_PRELOAD="${LD_PRELOAD:+$LD_PRELOAD:}/usr/lib/libeatmydata/libeatmydata.so"
export PATH="/usr/lib/ccache:${PATH}"
bash -e make-$PACKAGE 2>&1 || exit 1
EOF
cat << EOF > jails/$CODENAME-$ARCH/etc/pkgbinarymangler/striptranslations.conf
enable: true
components: main
invalid_currentlybuilding: ignore
posuffix: translations
oem_blacklist: partner
EOF
cat << EOF > jails/$CODENAME-$ARCH/etc/pkgbinarymangler/sanitychecks.conf
enable: true
EOF
cat << EOF > jails/$CODENAME-$ARCH/etc/pkgbinarymangler/maintainermangler.conf
enable: true
invalid_currentlybuilding: ignore
EOF
cat << EOF > jails/$CODENAME-$ARCH/etc/pkgbinarymangler/maintainermangler.overrides
default: Trisquel GNU/Linux developers <trisquel-devel@listas.trisquel.info>
ignore_domains: trisquel.info sognus.com listas.trisquel.info gnu.org fsf.org
ignore_emails: ruben@trisquel.info
EOF
chmod 755 jails/$CODENAME-$ARCH/usr/local/sbin/makepackage-handler
if ! chroot jails/$CODENAME-$ARCH makepackage-handler /$WORKDIR/make-$PACKAGE
then
rm jails/$CODENAME-$ARCH/CurrentlyBuilding
exit 1
fi
find jails/$CODENAME-$ARCH/$WORKDIR/PACKAGES/$PACKAGE/ -maxdepth 1 -type f -exec cp {} $REPOSITORY/incoming/ \;
tmpumount
}
ARCH=i386 prepare
ARCH=amd64 prepare
ARCH=i386 compile
ARCH=amd64 compile
cd $REPOSITORY
for dsc in incoming/*.dsc
do
if gpg -K | grep $GPGKEY -q
then
debsign -k$GPGKEY $dsc
else
echo GPG private key for $GPGKEY not found, the packages and repositories will not be signed.
fi
reprepro -v -C main includedsc $CODENAME $dsc || reprepro -S admin -P optional -v -b . -C main includedsc $CODENAME $dsc
done
find incoming -name *.deb -exec reprepro -v -C main includedeb $CODENAME {} \;
find incoming -name *.udeb -exec reprepro -v -C main includeudeb $CODENAME {} \;
rm incoming/*
|