rev |
line source |
pankso@1
|
1 #!/bin/sh
|
pankso@1
|
2 #
|
pankso@1
|
3 # Cook - A tool to cook and generate SliTaz packages. Read the README
|
pankso@1
|
4 # before adding or modifing any code in cook!
|
pankso@1
|
5 #
|
pankso@1
|
6 # Copyright (C) SliTaz GNU/Linux - GNU gpl v3
|
pankso@1
|
7 # Author: Christophe Lincoln <pankso@slitaz.org>
|
pankso@1
|
8 #
|
pankso@422
|
9 . /usr/lib/slitaz/libcook.sh
|
pankso@1
|
10
|
pankso@1
|
11 #
|
pankso@1
|
12 # Functions
|
pankso@1
|
13 #
|
pankso@1
|
14
|
pankso@1
|
15 usage() {
|
pankso@1
|
16 cat << EOT
|
pankso@1
|
17
|
pankso@147
|
18 $(echo -e "\033[1m$(gettext "Usage:")\033[0m") cook [package|command] [list|--option]
|
pankso@1
|
19
|
pankso@1
|
20 $(echo -e "\033[1m$(gettext "Commands:")\033[0m")
|
paul@214
|
21 usage|help $(gettext "Display this short usage.")
|
paul@214
|
22 setup $(gettext "Setup your build environment.")
|
pankso@424
|
23 *-setup $(gettext "Setup a cross environment.")
|
paul@214
|
24 test $(gettext "Test environment and cook a package.")
|
paul@214
|
25 list-wok $(gettext "List packages in the wok.")
|
paul@214
|
26 search $(gettext "Simple packages search function.")
|
paul@214
|
27 new $(gettext "Create a new package with a receipt".)
|
pankso@358
|
28 list $(gettext "Cook a list of packages.")
|
paul@214
|
29 clean-wok $(gettext "Clean-up all packages files.")
|
paul@214
|
30 clean-src $(gettext "Clean-up all packages sources.")
|
pankso@239
|
31 pkgdb $(gettext "Create packages DB lists and flavors.")
|
pankso@1
|
32
|
pankso@1
|
33 $(echo -e "\033[1m$(gettext "Options:")\033[0m")
|
paul@214
|
34 --clean|-c Cook : $(gettext "clean the package in the wok.")
|
paul@214
|
35 --install|-i Cook : $(gettext "cook and install the package.")
|
paul@214
|
36 --getsrc|-gs Cook : $(gettext "get the package source tarball.")
|
paul@214
|
37 --block|-b Cook : $(gettext "Block a package so cook will skip it.")
|
paul@214
|
38 --unblock|-ub Cook : $(gettext "Unblock a blocked package.")
|
pankso@230
|
39 --interactive|-x New : $(gettext "create a receipt interactively.")
|
pankso@397
|
40 --wok Setup: $(gettext "clone the cooking wok from Hg repo.")
|
pankso@230
|
41 --stable Setup: $(gettext "clone the stable wok from Hg repo.")
|
pankso@230
|
42 --undigest Setup: $(gettext "clone the undigest wok from Hg repo.")
|
pankso@397
|
43 --tiny Setup: $(gettext "clone the tiny SliTaz wok from Hg repo.")
|
pankso@397
|
44 --forced Setup: $(gettext "force reinstall of chroot packages.")
|
pankso@239
|
45 --flavors Pkgdb: $(gettext "create up-to-date flavors files.")
|
pankso@1
|
46
|
pankso@1
|
47 EOT
|
pankso@1
|
48 exit 0
|
pankso@1
|
49 }
|
pankso@1
|
50
|
paul@62
|
51 # We don't want these escapes in web interface.
|
pankso@1
|
52 clean_log() {
|
pankso@1
|
53 sed -i -e s'|\[70G\[ \[1;32m| |' \
|
pankso@1
|
54 -e s'|\[0;39m \]||' $LOGS/$pkg.log
|
pankso@1
|
55 }
|
pankso@1
|
56
|
paul@62
|
57 # Be sure package exists in wok.
|
pankso@1
|
58 check_pkg_in_wok() {
|
pankso@1
|
59 if [ ! -d "$WOK/$pkg" ]; then
|
pankso@1
|
60 gettext -e "\nUnable to find package in the wok:"
|
pankso@1
|
61 echo -e " $pkg\n" && exit 1
|
pankso@1
|
62 fi
|
pankso@1
|
63 }
|
pankso@1
|
64
|
pankso@9
|
65 if_empty_value() {
|
pankso@9
|
66 if [ -z "$value" ]; then
|
pankso@9
|
67 gettext "QA: empty variable:"; echo -e " ${var}=\"\"\n"
|
pankso@9
|
68 exit 1
|
pankso@9
|
69 fi
|
pankso@9
|
70 }
|
pankso@9
|
71
|
paul@62
|
72 # Initialize files used in $CACHE
|
pankso@52
|
73 init_db_files() {
|
pankso@52
|
74 gettext "Creating directories structure in:"; echo " $SLITAZ"
|
pankso@52
|
75 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS
|
pankso@52
|
76 gettext "Creating DB files in:"; echo " $CACHE"
|
pankso@52
|
77 for f in $activity $command $broken $blocked
|
pankso@52
|
78 do
|
pankso@52
|
79 touch $f
|
pankso@52
|
80 done
|
pankso@52
|
81 }
|
pankso@52
|
82
|
paul@62
|
83 # QA: check a receipt consistency before building.
|
pankso@9
|
84 receipt_quality() {
|
pankso@9
|
85 gettext -e "QA: checking package receipt...\n"
|
pankso@9
|
86 unset online
|
pankso@9
|
87 if ifconfig | grep -q -A 1 "^[a-z]*[0-9]" | fgrep 'addr:'; then
|
pankso@9
|
88 online="online"
|
pankso@9
|
89 fi
|
pankso@9
|
90 for var in PACKAGE VERSION CATEGORY SHORT_DESC MAINTAINER WEB_SITE
|
pankso@9
|
91 do
|
pankso@9
|
92 unset value
|
pascal@279
|
93 value="$(. $receipt ; eval echo \$$var)"
|
pankso@9
|
94 case "$var" in
|
pankso@9
|
95 PACKAGE|VERSION|SHORT_DESC)
|
pankso@9
|
96 if_empty_value ;;
|
pankso@9
|
97 CATEGORY)
|
pankso@9
|
98 [ -z "$value" ] && value="empty"
|
slaxemulator@497
|
99 valid="$PKGS_CATEGORIES"
|
pankso@9
|
100 if ! echo "$valid" | grep -q -w "$value"; then
|
paul@62
|
101 gettext "QA: unknown category:"; echo -e " $value\n"
|
pankso@9
|
102 exit 1
|
pankso@9
|
103 fi ;;
|
pankso@9
|
104 WEB_SITE)
|
paul@62
|
105 # We don't check WGET_URL since if dl is needed it will fail.
|
paul@62
|
106 # Break also if we're not online. Here error is not fatal.
|
pankso@9
|
107 if_empty_value
|
pankso@9
|
108 [ -z "$online" ] || break
|
pankso@199
|
109 if ! busybox wget -T 12 -s $value 2>/dev/null; then
|
pankso@61
|
110 gettext "QA: Unable to reach:"; echo -e " $value"
|
pankso@9
|
111 fi ;;
|
pankso@9
|
112 esac
|
pankso@9
|
113 done
|
pankso@9
|
114 }
|
pankso@9
|
115
|
paul@62
|
116 # Paths used in receipt and by cook itself.
|
pankso@1
|
117 set_paths() {
|
pankso@1
|
118 pkgdir=$WOK/$PACKAGE
|
slaxemulator@492
|
119 basesrc=$pkgdir/source
|
slaxemulator@492
|
120 tmpsrc=$basesrc/tmp
|
slaxemulator@492
|
121 src=$basesrc/$PACKAGE-$VERSION
|
pankso@44
|
122 taz=$pkgdir/taz
|
pankso@44
|
123 pack=$taz/$PACKAGE-${VERSION}${EXTRAVERSION}
|
pankso@1
|
124 fs=$pack/fs
|
pankso@1
|
125 stuff=$pkgdir/stuff
|
pankso@1
|
126 install=$pkgdir/install
|
slaxemulator@492
|
127 pkgsrc="${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}"
|
slaxemulator@492
|
128 lzma_tarball="$pkgsrc.tar.lzma"
|
slaxemulator@492
|
129 if [ "$PATCH" ]; then
|
slaxemulator@492
|
130 [ "${PTARBALL}" ] || PTARBALL="$(basename $PATCH)"
|
slaxemulator@492
|
131 fi
|
pankso@1
|
132 if [ "$WANTED" ]; then
|
slaxemulator@492
|
133 basesrc=$WOK/$WANTED/source
|
slaxemulator@492
|
134 src=$basesrc/$WANTED-$VERSION
|
slaxemulator@492
|
135 install=$WOK/$WANTED/install
|
slaxemulator@492
|
136 wanted_stuff=$WOK/$WANTED/stuff
|
pankso@1
|
137 fi
|
slaxemulator@456
|
138 if [ "$SOURCE" ]; then
|
slaxemulator@456
|
139 source_stuff=$WOK/$SOURCE/stuff
|
slaxemulator@456
|
140 fi
|
slaxemulator@492
|
141 # Kernel version is set from linux
|
slaxemulator@492
|
142 if [ -f "$WOK/linux/receipt" ]; then
|
slaxemulator@492
|
143 kvers=$(grep ^VERSION= $WOK/linux/receipt | cut -d '"' -f 2)
|
slaxemulator@492
|
144 kbasevers=${kvers:0:3}
|
slaxemulator@492
|
145 fi
|
slaxemulator@492
|
146 # Python version
|
slaxemulator@492
|
147 if [ -f "$WOK/python/receipt" ]; then
|
slaxemulator@492
|
148 pyvers=$(grep ^VERSION= $WOK/python/receipt | cut -d '"' -f 2)
|
slaxemulator@492
|
149 fi
|
slaxemulator@492
|
150 # perl version for some packages needed it
|
slaxemulator@492
|
151 if [ -f "$WOK/perl/receipt" ]; then
|
slaxemulator@492
|
152 perlvers=$(grep ^VERSION= $WOK/perl/receipt | cut -d '"' -f 2)
|
pankso@232
|
153 fi
|
pankso@9
|
154 # Old way compatibility.
|
pankso@1
|
155 _pkg=$install
|
pankso@1
|
156 }
|
pankso@1
|
157
|
pankso@144
|
158 # Create source tarball when URL is a SCM.
|
pankso@144
|
159 create_tarball() {
|
pankso@144
|
160 gettext "Creating tarball: "; echo "$tarball"
|
pascal@494
|
161 TARBALL=$tarball
|
pankso@162
|
162 if [ "$LZMA_SRC" ]; then
|
pankso@162
|
163 tar -c $pkgsrc | lzma e $SRC/$tarball -si || exit 1
|
pankso@162
|
164 else
|
pankso@162
|
165 tar cjf $tarball $pkgsrc || exit 1
|
pankso@162
|
166 mv $tarball $SRC && rm -rf $pkgsrc
|
pankso@162
|
167 fi
|
pankso@144
|
168 }
|
pankso@144
|
169
|
pankso@145
|
170 # Get package source. For SCM we are in cache so clone here and create a
|
pankso@145
|
171 # tarball here.
|
pankso@1
|
172 get_source() {
|
pankso@115
|
173 pwd=$(pwd)
|
pankso@144
|
174 pkgsrc=${SOURCE:-$PACKAGE}-$VERSION
|
pankso@144
|
175 tarball=$pkgsrc.tar.bz2
|
pankso@162
|
176 [ "$LZMA_SRC" ] && tarball=$pkgsrc.tar.lzma
|
pankso@9
|
177 case "$WGET_URL" in
|
pankso@145
|
178 http://*|ftp://*)
|
pankso@9
|
179 # Busybox Wget is better!
|
pascal@268
|
180 busybox wget -T 60 -c -O $SRC/$TARBALL $WGET_URL || \
|
pankso@145
|
181 (echo -e "ERROR: wget $WGET_URL" && exit 1) ;;
|
pankso@145
|
182 https://*)
|
pankso@250
|
183 wget -c --no-check-certificate -O $SRC/$TARBALL $WGET_URL || \
|
pankso@15
|
184 (echo -e "ERROR: wget $WGET_URL" && exit 1) ;;
|
pankso@9
|
185 hg*|mercurial*)
|
pankso@29
|
186 if $(echo "$WGET_URL" | fgrep -q "hg|"); then
|
pankso@9
|
187 url=${WGET_URL#hg|}
|
pankso@9
|
188 else
|
pankso@9
|
189 url=${WGET_URL#mercurial|}
|
pankso@9
|
190 fi
|
pankso@61
|
191 gettext -e "Getting source from Hg...\n"
|
pankso@61
|
192 echo "URL: $url"
|
pankso@9
|
193 gettext "Cloning to: "; echo "$pwd/$pkgsrc"
|
pankso@246
|
194 if [ "$BRANCH" ]; then
|
pankso@246
|
195 echo "Hg branch: $BRANCH"
|
pankso@246
|
196 hg clone $url --rev $BRANCH $pkgsrc || \
|
pankso@246
|
197 (echo "ERROR: hg clone $url --rev $BRANCH" && exit 1)
|
pankso@246
|
198 else
|
pankso@246
|
199 hg clone $url $pkgsrc || (echo "ERROR: hg clone $url" && exit 1)
|
pankso@246
|
200 fi
|
pankso@255
|
201 rm -rf $pkgsrc/.hg
|
pankso@144
|
202 create_tarball ;;
|
pankso@9
|
203 git*)
|
pankso@61
|
204 url=${WGET_URL#git|}
|
pankso@61
|
205 gettext -e "Getting source from Git...\n"
|
pankso@61
|
206 echo "URL: $url"
|
pankso@64
|
207 git clone $url $pkgsrc || (echo "ERROR: git clone $url" && exit 1)
|
pankso@63
|
208 if [ "$BRANCH" ]; then
|
pankso@146
|
209 echo "Git branch: $BRANCH"
|
pankso@358
|
210 cd $pkgsrc && git checkout $BRANCH && cd ..
|
pankso@63
|
211 fi
|
pankso@144
|
212 create_tarball ;;
|
pankso@144
|
213 cvs*)
|
pankso@144
|
214 url=${WGET_URL#cvs|}
|
pankso@144
|
215 mod=$PACKAGE
|
pankso@144
|
216 [ "$CVS_MODULE" ] && mod=$CVS_MODULE
|
pankso@144
|
217 gettext -e "Getting source from CVS...\n"
|
pankso@144
|
218 echo "URL: $url"
|
pankso@146
|
219 [ "$CVS_MODULE" ] && echo "CVS module: $mod"
|
pankso@144
|
220 gettext "Cloning to: "; echo "$pwd/$mod"
|
pankso@144
|
221 cvs -d:$url co $mod && mv $mod $pkgsrc
|
pankso@144
|
222 create_tarball ;;
|
pankso@69
|
223 svn*|subversion*)
|
pankso@159
|
224 if $(echo "$WGET_URL" | fgrep -q "svn|"); then
|
pankso@146
|
225 url=${WGET_URL#svn|}
|
pankso@146
|
226 else
|
pankso@146
|
227 url=${WGET_URL#subversion|}
|
pankso@146
|
228 fi
|
pankso@146
|
229 gettext -e "Getting source from SVN...\n"
|
pankso@146
|
230 echo "URL: $url"
|
pankso@161
|
231 if [ "$BRANCH" ]; then
|
pankso@161
|
232 echo t | svn co $url -r $BRANCH $pkgsrc
|
pankso@161
|
233 else
|
pankso@161
|
234 echo t | svn co $url $pkgsrc
|
pankso@161
|
235 fi
|
pankso@146
|
236 create_tarball ;;
|
pankso@9
|
237 *)
|
pankso@9
|
238 gettext -e "\nERROR: Unable to handle:"; echo -e " $WGET_URL \n" | \
|
pankso@9
|
239 tee -a $LOGS/$PACKAGE.log
|
pankso@9
|
240 exit 1 ;;
|
pankso@9
|
241 esac
|
pankso@1
|
242 }
|
pankso@1
|
243
|
pankso@9
|
244 # Extract source package.
|
pankso@1
|
245 extract_source() {
|
pankso@177
|
246 if [ ! -s "$SRC/$TARBALL" ]; then
|
pankso@177
|
247 local url
|
slaxemulator@458
|
248 url="$MIRROR_URL/sources/packages"
|
pankso@177
|
249 url=$url/${TARBALL:0:1}/$TARBALL
|
pankso@177
|
250 gettext "Getting source from mirror:"; echo " $url"
|
pankso@177
|
251 busybox wget -c -P $SRC $url || echo -e "ERROR: wget $url"
|
pankso@177
|
252 fi
|
pankso@1
|
253 gettext "Extracting:"; echo " $TARBALL"
|
pankso@1
|
254 case "$TARBALL" in
|
pankso@120
|
255 *.tar.gz|*.tgz) tar xzf $SRC/$TARBALL 2>/dev/null ;;
|
pankso@178
|
256 *.tar.bz2|*.tbz|*.tbz2) tar xjf $SRC/$TARBALL 2>/dev/null ;;
|
pankso@1
|
257 *.tar.lzma) tar xaf $SRC/$TARBALL ;;
|
pankso@42
|
258 *.tar) tar xf $SRC/$TARBALL ;;
|
pankso@42
|
259 *.zip|*.xpi) unzip -o $SRC/$TARBALL ;;
|
pankso@42
|
260 *.xz) unxz -c $SRC/$TARBALL | tar xf - ;;
|
pankso@42
|
261 *.Z) uncompress -c $SRC/$TARBALL | tar xf - ;;
|
pankso@42
|
262 *.rpm) rpm2cpio $SRC/$TARBALL | cpio -idm --quiet ;;
|
pankso@238
|
263 *.run) /bin/sh $SRC/$TARBALL $RUN_OPTS ;;
|
pankso@191
|
264 *) cp $SRC/$TARBALL $(pwd) ;;
|
pankso@1
|
265 esac
|
pankso@1
|
266 }
|
pankso@1
|
267
|
pankso@9
|
268 # Display cooked package summary.
|
pankso@1
|
269 summary() {
|
pankso@1
|
270 cd $WOK/$pkg
|
pankso@1
|
271 [ -d install ] && prod=$(du -sh install | awk '{print $1}' 2>/dev/null)
|
pankso@1
|
272 fs=$(du -sh taz/* | awk '{print $1}')
|
pankso@44
|
273 size=$(du -sh $PKGS/$pkg-${VERSION}*.tazpkg | awk '{print $1}')
|
pankso@44
|
274 files=$(cat taz/$pkg-*/files.list | wc -l)
|
pankso@18
|
275 cookdate=$(date "+%Y-%m-%d %H:%M")
|
pankso@101
|
276 sec=$time
|
pascal@280
|
277 div=$(( ($time + 30) / 60))
|
pankso@112
|
278 [ "$div" != 0 ] && min="~ ${div}m"
|
pankso@1
|
279 gettext "Summary for:"; echo " $PACKAGE $VERSION"
|
pankso@1
|
280 separator
|
pankso@67
|
281 [ "$prod" ] && echo "Produced : $prod"
|
pankso@1
|
282 cat << EOT
|
pankso@1
|
283 Packed : $fs
|
pankso@1
|
284 Compressed : $size
|
pankso@18
|
285 Files : $files
|
pankso@102
|
286 Cook time : ${sec}s $min
|
pankso@18
|
287 Cook date : $cookdate
|
pankso@392
|
288 Host arch : $ARCH
|
pankso@1
|
289 $(separator)
|
pankso@1
|
290 EOT
|
pankso@1
|
291 }
|
pankso@1
|
292
|
paul@62
|
293 # Display debugging error info.
|
pankso@15
|
294 debug_info() {
|
pankso@17
|
295 echo -e "\nDebug information"
|
pankso@15
|
296 separator
|
pankso@48
|
297 echo "Cook date: $(date '+%Y-%m-%d %H:%M')"
|
pankso@76
|
298 for error in \
|
pankso@77
|
299 ERROR "No package" "cp: can't" "can't open" "can't cd" \
|
pascal@473
|
300 "error:" "fatal error:" "undefined reference to" \
|
pascal@473
|
301 "Unable to connect to" "link: cannot find the library"
|
pankso@34
|
302 do
|
pankso@34
|
303 fgrep "$error" $LOGS/$pkg.log
|
pankso@34
|
304 done
|
pankso@427
|
305 separator && newline
|
pankso@15
|
306 }
|
pankso@15
|
307
|
pankso@1
|
308 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
|
pankso@1
|
309 # so some packages need to copy these files with the receipt and genpkg_rules.
|
pankso@421
|
310 copy_generic_files() {
|
pankso@1
|
311 # $LOCALE is set in cook.conf
|
pankso@281
|
312 if [ "$LOCALE" ]; then
|
pankso@260
|
313 if [ -d "$install/usr/share/locale" ]; then
|
pankso@1
|
314 mkdir -p $fs/usr/share/locale
|
pankso@1
|
315 for i in $LOCALE
|
pankso@1
|
316 do
|
pankso@260
|
317 if [ -d "$install/usr/share/locale/$i" ]; then
|
pankso@260
|
318 cp -a $install/usr/share/locale/$i $fs/usr/share/locale
|
pankso@1
|
319 fi
|
pankso@1
|
320 done
|
pankso@1
|
321 fi
|
pankso@1
|
322 fi
|
pankso@1
|
323
|
pankso@1
|
324 # Generic pixmaps copy can be disabled with GENERIC_PIXMAPS="no"
|
pankso@1
|
325 if [ "$GENERIC_PIXMAPS" != "no" ]; then
|
pankso@260
|
326 if [ -d "$install/usr/share/pixmaps" ]; then
|
pankso@1
|
327 mkdir -p $fs/usr/share/pixmaps
|
pankso@260
|
328 cp -a $install/usr/share/pixmaps/$PACKAGE.png \
|
pankso@281
|
329 $fs/usr/share/pixmaps 2>/dev/null || continue
|
pankso@260
|
330 cp -a $install/usr/share/pixmaps/$PACKAGE.xpm \
|
pankso@281
|
331 $fs/usr/share/pixmaps 2>/dev/null || continue
|
pankso@1
|
332 fi
|
pankso@1
|
333
|
pankso@1
|
334 # Custom or homemade PNG pixmap can be in stuff.
|
pankso@1
|
335 if [ -f "$stuff/$PACKAGE.png" ]; then
|
pankso@1
|
336 mkdir -p $fs/usr/share/pixmaps
|
pankso@1
|
337 cp -a $stuff/$PACKAGE.png $fs/usr/share/pixmaps
|
pankso@1
|
338 fi
|
pankso@1
|
339 fi
|
pankso@1
|
340
|
pankso@1
|
341 # Desktop entry (.desktop).
|
erjo@284
|
342 # Generic desktop entry copy can be disabled with GENERIC_MENUS="no"
|
erjo@284
|
343 if [ "$GENERIC_MENUS" != "no" ]; then
|
erjo@284
|
344 if [ -d "$install/usr/share/applications" ] && [ "$WANTED" == "" ]; then
|
erjo@284
|
345 cp -a $install/usr/share/applications $fs/usr/share
|
erjo@284
|
346 fi
|
pankso@1
|
347 fi
|
pankso@1
|
348
|
pankso@1
|
349 # Homemade desktop file(s) can be in stuff.
|
pankso@1
|
350 if [ -d "$stuff/applications" ]; then
|
pankso@1
|
351 mkdir -p $fs/usr/share
|
pankso@1
|
352 cp -a $stuff/applications $fs/usr/share
|
pankso@1
|
353 fi
|
pankso@1
|
354 if [ -f "$stuff/$PACKAGE.desktop" ]; then
|
pankso@1
|
355 mkdir -p $fs/usr/share/applications
|
pankso@1
|
356 cp -a $stuff/$PACKAGE.desktop $fs/usr/share/applications
|
pankso@1
|
357 fi
|
pankso@1
|
358 }
|
pankso@1
|
359
|
pankso@67
|
360 # Find and strip : --strip-all (-s) or --strip-debug on static libs as well
|
pankso@415
|
361 # as removing uneeded files like in Python packages. Cross compiled binaries
|
pankso@415
|
362 # must be stripped with cross-tools aka $ARCH-slitaz-*-strip
|
pankso@421
|
363 strip_package() {
|
pankso@415
|
364 case "$ARCH" in
|
pankso@415
|
365 arm|x86_64) export STRIP=${HOST_SYSTEM}-strip ;;
|
pankso@415
|
366 *) export STRIP=strip ;;
|
pankso@415
|
367 esac
|
pankso@67
|
368 gettext "Executing strip on all files..."
|
pankso@1
|
369 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
|
pankso@1
|
370 do
|
pankso@1
|
371 if [ -d "$dir" ]; then
|
pankso@414
|
372 find $dir -type f -exec $STRIP -s '{}' 2>/dev/null \;
|
pankso@1
|
373 fi
|
pankso@1
|
374 done
|
pankso@414
|
375 find $fs -name "*.so*" -exec $STRIP -s '{}' 2>/dev/null \;
|
pankso@414
|
376 find $fs -name "*.a" -exec $STRIP --strip-debug '{}' 2>/dev/null \;
|
pankso@1
|
377 status
|
pankso@67
|
378
|
pankso@117
|
379 # Remove Python .pyc and .pyo from packages.
|
pankso@150
|
380 if echo "$PACKAGE $DEPENDS" | fgrep -q "python"; then
|
pankso@68
|
381 gettext "Removing Python compiled files..."
|
pankso@67
|
382 find $fs -type f -name "*.pyc" -delete 2>/dev/null
|
pankso@67
|
383 find $fs -type f -name "*.pyo" -delete 2>/dev/null
|
pankso@117
|
384 status
|
pankso@117
|
385 fi
|
pankso@117
|
386
|
pankso@117
|
387 # Remove Perl perllocal.pod and .packlist from packages.
|
pankso@117
|
388 if echo "$DEPENDS" | fgrep -q "perl"; then
|
pankso@117
|
389 gettext "Removing Perl compiled files..."
|
pankso@67
|
390 find $fs -type f -name "perllocal.pod" -delete 2>/dev/null
|
pankso@67
|
391 find $fs -type f -name ".packlist" -delete 2>/dev/null
|
pankso@67
|
392 status
|
pankso@67
|
393 fi
|
pankso@1
|
394 }
|
pankso@1
|
395
|
pankso@8
|
396 # Remove installed deps.
|
pankso@8
|
397 remove_deps() {
|
pankso@8
|
398 # Now remove installed build deps.
|
pankso@113
|
399 diff="$CACHE/installed.cook.diff"
|
pankso@113
|
400 if [ -s "$CACHE/installed.cook.diff" ]; then
|
pankso@113
|
401 deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
|
pankso@113
|
402 nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l)
|
pankso@426
|
403 gettext "Build dependencies to remove:"; echo " $nb $root"
|
pankso@8
|
404 gettext "Removing:"
|
pankso@8
|
405 for dep in $deps
|
pankso@8
|
406 do
|
pankso@8
|
407 echo -n " $dep"
|
pankso@426
|
408 echo 'y' | tazpkg remove $dep --root=$root >/dev/null
|
pankso@8
|
409 done
|
pankso@16
|
410 echo -e "\n"
|
pankso@113
|
411 # Keep the last diff for debug and info.
|
pankso@113
|
412 mv -f $CACHE/installed.cook.diff $CACHE/installed.diff
|
pankso@1
|
413 fi
|
pankso@1
|
414 }
|
pankso@1
|
415
|
pankso@1
|
416 # The main cook function.
|
pankso@1
|
417 cookit() {
|
pankso@11
|
418 echo "Cook: $PACKAGE $VERSION"
|
pankso@9
|
419 separator
|
pankso@1
|
420 set_paths
|
pankso@359
|
421
|
pankso@377
|
422 # Handle cross-tools.
|
pankso@359
|
423 case "$ARCH" in
|
pankso@359
|
424 arm|x86_64)
|
paul@387
|
425 # CROSS_COMPILE is used by at least Busybox and the kernel to set
|
pankso@443
|
426 # the cross-tools prefix. Sysroot the the root of our target arch
|
pankso@443
|
427 sysroot=$CROSS_TREE/sysroot
|
pankso@443
|
428 tools=$CROSS_TREE/tools
|
pankso@443
|
429 # Set root path when cross compiling. ARM tested but not x86_64
|
pankso@443
|
430 # When cross compiling we must install build deps in $sysroot.
|
pankso@443
|
431 arch="-${ARCH}"
|
pankso@443
|
432 root=$sysroot
|
pankso@443
|
433 echo "$ARCH sysroot: $sysroot"
|
pankso@443
|
434 echo "Adding $tools/bin to PATH"
|
pankso@443
|
435 export PATH=$PATH:$tools/bin
|
pankso@446
|
436 export PKG_CONFIG_PATH=$sysroot/usr/lib/pkgconfig
|
pankso@421
|
437 export CROSS_COMPILE=${HOST_SYSTEM}-
|
pankso@426
|
438 echo "Using cross-tools: $CROSS_COMPILE"
|
pankso@438
|
439 if [ "$ARCH" == "x86_64" ]; then
|
pankso@438
|
440 export CC="${HOST_SYSTEM}-gcc -m64"
|
pankso@438
|
441 export CXX="${HOST_SYSTEM}-g++ -m64"
|
pankso@438
|
442 else
|
pankso@438
|
443 export CC=${HOST_SYSTEM}-gcc
|
pankso@438
|
444 export CXX=${HOST_SYSTEM}-g++
|
pankso@438
|
445 fi
|
pankso@377
|
446 export AR=${HOST_SYSTEM}-ar
|
pankso@377
|
447 export AS=${HOST_SYSTEM}-as
|
pankso@377
|
448 export RANLIB=${HOST_SYSTEM}-ranlib
|
pankso@377
|
449 export LD=${HOST_SYSTEM}-ld
|
pankso@443
|
450 export STRIP=${HOST_SYSTEM}-strip ;;
|
pankso@359
|
451 esac
|
pankso@359
|
452
|
pankso@9
|
453 [ "$QA" ] && receipt_quality
|
pankso@44
|
454 cd $pkgdir
|
pankso@33
|
455 rm -rf install taz source
|
pankso@1
|
456
|
pankso@1
|
457 # Disable -pipe if less than 512Mb free RAM.
|
pankso@1
|
458 free=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
|
pankso@1
|
459 if [ "$free" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
|
pankso@1
|
460 gettext -e "Disabling -pipe compile flag: $free RAM\n"
|
pankso@1
|
461 CFLAGS="${CFLAGS/-pipe}" && CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
|
pankso@47
|
462 CXXFLAGS="${CXXFLAGS/-pipe}" && \
|
pankso@47
|
463 CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
|
pankso@1
|
464 fi
|
pankso@1
|
465 unset free
|
pankso@1
|
466
|
pankso@232
|
467 # Export flags and path to be used by make and receipt.
|
pankso@44
|
468 DESTDIR=$pkgdir/install
|
pankso@232
|
469 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS CONFIG_SITE LC_ALL=C LANG=C
|
pankso@358
|
470 #LDFLAGS
|
pankso@1
|
471
|
pankso@126
|
472 # Check for build deps and handle implicit depends of *-dev packages
|
pankso@126
|
473 # (ex: libusb-dev :: libusb).
|
pankso@215
|
474 rm -f $CACHE/installed.local $CACHE/installed.web $CACHE/missing.dep
|
pankso@215
|
475 touch $CACHE/installed.local $CACHE/installed.web
|
pankso@215
|
476 [ "$BUILD_DEPENDS" ] && gettext -e "Checking build dependencies...\n"
|
pankso@426
|
477 [ "$root" ] && echo "Using packages DB: ${root}$DB"
|
pankso@1
|
478 for dep in $BUILD_DEPENDS
|
pankso@1
|
479 do
|
pankso@126
|
480 implicit=${dep%-dev}
|
pankso@131
|
481 for i in $dep $implicit
|
pankso@126
|
482 do
|
pankso@426
|
483 if [ ! -f "${root}$INSTALLED/$i/receipt" ]; then
|
paul@174
|
484 # Try local package first. In some cases implicit doesn't exist, ex:
|
paul@174
|
485 # libboost-dev exists but not libboost, so check if we got vers.
|
pankso@173
|
486 unset vers
|
pascal@343
|
487 vers=$(. $WOK/$i/receipt 2>/dev/null ; echo $VERSION)
|
pankso@435
|
488 # We may have a local package.
|
pankso@435
|
489 if [ ! "$vers" ]; then
|
pankso@435
|
490 vers=$(grep "^$i |" $PKGS/packages.desc | awk '{print $3}')
|
pankso@435
|
491 fi
|
pankso@435
|
492 debug "bdep: $i version: $vers"
|
pankso@426
|
493 if [ -f "$PKGS/$i-${vers}${arch}.tazpkg" ]; then
|
pankso@426
|
494 echo $i-${vers}${arch}.tazpkg >> $CACHE/installed.local
|
pankso@126
|
495 else
|
paul@227
|
496 # Priority to package version in wok (maybe more up-to-date)
|
paul@227
|
497 # than the mirrored one.
|
pankso@173
|
498 if [ "$vers" ]; then
|
pankso@426
|
499 if fgrep -q $i-${vers}${arch} ${root}$DB/packages.list; then
|
pankso@215
|
500 echo $i >> $CACHE/installed.web
|
pankso@198
|
501 else
|
paul@211
|
502 # So package exists in wok but not available.
|
pankso@215
|
503 gettext "Missing dep (wok/pkg):"; echo " $i $vers"
|
pankso@215
|
504 echo $i >> $CACHE/missing.dep
|
pankso@198
|
505 fi
|
pankso@225
|
506 else
|
pankso@435
|
507 # Package is not in wok but may be in online repo.
|
pankso@426
|
508 if fgrep -q $i-${vers}${arch} ${root}$DB/packages.list; then
|
pankso@225
|
509 echo $i >> $CACHE/installed.web
|
pankso@225
|
510 else
|
paul@227
|
511 echo "ERROR: unknown dep $i" && exit 1
|
pankso@225
|
512 fi
|
pankso@173
|
513 fi
|
pankso@126
|
514 fi
|
pankso@1
|
515 fi
|
pankso@126
|
516 done
|
pankso@1
|
517 done
|
pankso@225
|
518
|
pankso@215
|
519 # Get the list of installed packages
|
pankso@426
|
520 cd ${root}$INSTALLED && ls -1 > $CACHE/installed.list
|
pankso@358
|
521
|
paul@211
|
522 # Have we a missing build dep to cook ?
|
pankso@215
|
523 if [ -s "$CACHE/missing.dep" ] && [ "$AUTO_COOK" ]; then
|
pankso@205
|
524 gettext -e "Auto cook config is set : AUTO_COOK\n"
|
pankso@204
|
525 cp -f $LOGS/$PACKAGE.log $LOGS/$PACKAGE.log.$$
|
pankso@224
|
526 for i in $(uniq $CACHE/missing.dep)
|
pankso@204
|
527 do
|
pankso@205
|
528 (gettext "Building dep (wok/pkg) :"; echo " $i $vers") | \
|
pankso@204
|
529 tee -a $LOGS/$PACKAGE.log.$$
|
pankso@205
|
530 cook $i || (echo -e "ERROR: can't cook dep '$i'\n" && \
|
pankso@205
|
531 fgrep "remove: " $LOGS/$i.log && \
|
pankso@427
|
532 fgrep "Removing: " $LOGS/$i.log && newline) | \
|
pankso@204
|
533 tee -a $LOGS/$PACKAGE.log.$$ && break
|
pankso@204
|
534 done
|
pankso@215
|
535 rm -f $CACHE/missing.dep
|
pankso@204
|
536 mv $LOGS/$PACKAGE.log.$$ $LOGS/$PACKAGE.log
|
pankso@204
|
537 fi
|
pankso@358
|
538
|
paul@211
|
539 # QA: Exit on missing dep errors. We exit in both cases, if AUTO_COOK
|
paul@211
|
540 # is enabled and cook fails we have ERROR in log, if no auto cook we have
|
pankso@204
|
541 # missing dep in cached file.
|
pankso@215
|
542 if fgrep -q "ERROR:" $LOGS/$pkg.log || [ -s "$CACHE/missing.dep" ]; then
|
pankso@215
|
543 [ -s "$CACHE/missing.dep" ] && nb=$(cat $CACHE/missing.dep | wc -l)
|
pankso@215
|
544 echo "ERROR: missing dep $nb" && exit 1
|
pankso@202
|
545 fi
|
pankso@358
|
546
|
pankso@426
|
547 # Install local packages: package-version${arch}
|
pankso@215
|
548 cd $PKGS
|
pankso@224
|
549 for i in $(uniq $CACHE/installed.local)
|
pankso@215
|
550 do
|
pankso@224
|
551 gettext "Installing dep (pkg/local):"; echo " $i"
|
pankso@423
|
552 tazpkg install $i --root=$root >/dev/null
|
pankso@215
|
553 done
|
pankso@358
|
554
|
pankso@215
|
555 # Install web or cached packages (if mirror is set to $PKGS we only
|
pankso@215
|
556 # use local packages).
|
pankso@224
|
557 for i in $(uniq $CACHE/installed.web)
|
pankso@215
|
558 do
|
pankso@228
|
559 gettext "Installing dep (web/cache):"; echo " $i"
|
pankso@423
|
560 tazpkg get-install $i --root=$root >/dev/null
|
pankso@215
|
561 done
|
pankso@358
|
562
|
pankso@215
|
563 # If a cook failed deps are removed.
|
pankso@426
|
564 cd ${root}$INSTALLED && ls -1 > $CACHE/installed.cook && cd $CACHE
|
pankso@215
|
565 [ ! -s "installed.cook.diff" ] && \
|
pankso@215
|
566 busybox diff installed.list installed.cook > installed.cook.diff
|
pankso@215
|
567 deps=$(cat installed.cook.diff | grep ^+[a-zA-Z0-9] | wc -l)
|
pankso@202
|
568
|
pankso@1
|
569 # Get source tarball and make sure we have source dir named:
|
paul@62
|
570 # $PACKAGE-$VERSION to be standard in receipts. Here we use tar.lzma
|
paul@62
|
571 # tarball if it exists.
|
pankso@1
|
572 if [ "$WGET_URL" ] && [ ! -f "$SRC/$TARBALL" ]; then
|
pankso@1
|
573 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
|
pankso@10
|
574 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
|
pankso@190
|
575 LZMA_SRC=""
|
pankso@1
|
576 else
|
pankso@1
|
577 get_source || exit 1
|
pankso@1
|
578 fi
|
pankso@1
|
579 fi
|
pankso@242
|
580 if [ ! "$WANTED" ] && [ "$TARBALL" ] && [ ! -d "$src" ]; then
|
pankso@1
|
581 mkdir -p $pkgdir/source/tmp && cd $pkgdir/source/tmp
|
pascal@268
|
582 if ! extract_source ; then
|
pascal@268
|
583 get_source
|
pascal@268
|
584 extract_source || exit 1
|
pascal@268
|
585 fi
|
pankso@190
|
586 if [ "$LZMA_SRC" ]; then
|
pankso@190
|
587 cd $pkgdir/source
|
pankso@190
|
588 if [ "$(ls -A tmp | wc -l)" -gl 1 ] || [ -f "$(echo tmp/*)" ]; then
|
pankso@190
|
589 mv tmp tmp-1 && mkdir tmp
|
pankso@190
|
590 mv tmp-1 tmp/${SOURCE:-$PACKAGE}-$VERSION
|
pankso@190
|
591 fi
|
pankso@190
|
592 if [ -d "tmp/${SOURCE:-$PACKAGE}-$VERSION" ]; then
|
pankso@358
|
593 cd tmp && tar -c * | lzma e $SRC/$TARBALL -si
|
pankso@190
|
594 fi
|
pankso@190
|
595 fi
|
pankso@190
|
596 cd $pkgdir/source/tmp
|
paul@62
|
597 # Some archives are not well done and don't extract to one dir (ex lzma).
|
pankso@57
|
598 files=$(ls | wc -l)
|
pankso@244
|
599 [ "$files" == 1 ] && [ -d "$(ls)" ] && mv * ../$PACKAGE-$VERSION
|
pankso@244
|
600 [ "$files" == 1 ] && [ -f "$(ls)" ] && mkdir -p ../$PACKAGE-$VERSION && \
|
pankso@244
|
601 mv * ../$PACKAGE-$VERSION/$TARBALL
|
pankso@57
|
602 [ "$files" -gt 1 ] && mkdir -p ../$PACKAGE-$VERSION && \
|
pankso@57
|
603 mv * ../$PACKAGE-$VERSION
|
pankso@1
|
604 cd .. && rm -rf tmp
|
pankso@1
|
605 fi
|
pankso@1
|
606
|
pankso@9
|
607 # Execute receipt rules.
|
pankso@44
|
608 if grep -q ^compile_rules $receipt; then
|
pankso@352
|
609 echo "Executing: compile_rules"
|
pankso@352
|
610 echo "CFLAGS : $CFLAGS"
|
pankso@358
|
611 #echo "LDFLAGS : $LDFLAGS"
|
pankso@55
|
612 [ -d "$src" ] && cd $src
|
pankso@97
|
613 compile_rules $@ || exit 1
|
pankso@10
|
614 # Stay compatible with _pkg
|
pankso@55
|
615 [ -d "$src/_pkg" ] && mv $src/_pkg $install
|
pankso@9
|
616 # QA: compile_rules success so valid.
|
pankso@9
|
617 mkdir -p $install
|
pankso@9
|
618 else
|
pankso@9
|
619 # QA: No compile_rules so no error, valid.
|
pankso@9
|
620 mkdir -p $install
|
pankso@1
|
621 fi
|
pankso@427
|
622 separator && newline
|
pankso@360
|
623
|
pankso@360
|
624 # Execute testsuite.
|
pankso@360
|
625 if grep -q ^testsuite $receipt; then
|
pankso@360
|
626 echo "Running testsuite"
|
pankso@360
|
627 separator
|
pankso@360
|
628 testsuite $@ || exit 1
|
pankso@427
|
629 separator && newline
|
pankso@360
|
630 fi
|
pankso@1
|
631 }
|
pankso@1
|
632
|
pankso@1
|
633 # Cook quality assurance.
|
pankso@1
|
634 cookit_quality() {
|
pankso@9
|
635 if [ ! -d "$WOK/$pkg/install" ] && [ ! "$WANTED" ]; then
|
pankso@15
|
636 echo -e "ERROR: cook failed" | tee -a $LOGS/$pkg.log
|
pankso@9
|
637 fi
|
pankso@9
|
638 # ERROR can be echoed any time in cookit()
|
pankso@33
|
639 if fgrep -q ERROR: $LOGS/$pkg.log; then
|
pankso@17
|
640 debug_info | tee -a $LOGS/$pkg.log
|
pankso@33
|
641 rm -f $command && exit 1
|
pankso@1
|
642 fi
|
pankso@1
|
643 }
|
pankso@1
|
644
|
pankso@16
|
645 # Create the package. Wanted to use Tazpkg to create a tazpkg package at first,
|
paul@62
|
646 # but it doesn't handle EXTRAVERSION.
|
pankso@1
|
647 packit() {
|
pankso@1
|
648 set_paths
|
pankso@359
|
649
|
pankso@359
|
650 # Handle cross compilation
|
pankso@359
|
651 case "$ARCH" in
|
pankso@428
|
652 arm|x86_64) arch="-$ARCH" ;;
|
pankso@359
|
653 esac
|
pankso@359
|
654
|
pankso@428
|
655 echo "Pack: $PACKAGE ${VERSION}${arch}"
|
pankso@1
|
656 separator
|
pankso@359
|
657
|
pankso@44
|
658 if grep -q ^genpkg_rules $receipt; then
|
pankso@16
|
659 gettext -e "Executing: genpkg_rules\n"
|
pankso@259
|
660 set -e && cd $pkgdir && mkdir -p $fs
|
pankso@232
|
661 genpkg_rules || echo -e "\nERROR: genpkg_rules failed\n" >> \
|
pankso@234
|
662 $LOGS/$pkg.log
|
pankso@241
|
663 else
|
pankso@241
|
664 gettext "No packages rules: meta package"; echo
|
pankso@241
|
665 mkdir -p $fs
|
pankso@16
|
666 fi
|
pankso@98
|
667
|
pankso@98
|
668 # First QA check to stop now if genpkg_rules failed.
|
pankso@98
|
669 if fgrep -q ERROR: $LOGS/$pkg.log; then
|
pankso@98
|
670 exit 1
|
pankso@98
|
671 fi
|
pankso@358
|
672
|
pankso@44
|
673 cd $taz
|
pankso@1
|
674 for file in receipt description.txt
|
pankso@1
|
675 do
|
pankso@1
|
676 [ ! -f "../$file" ] && continue
|
pankso@1
|
677 gettext "Copying"; echo -n " $file..."
|
pankso@1
|
678 cp -f ../$file $pack && chown 0.0 $pack/$file && status
|
pankso@1
|
679 done
|
pankso@119
|
680 copy_generic_files
|
pankso@358
|
681
|
paul@62
|
682 # Create files.list with redirecting find output.
|
pankso@16
|
683 gettext "Creating the list of files..." && cd $fs
|
pankso@16
|
684 find . -type f -print > ../files.list
|
pankso@16
|
685 find . -type l -print >> ../files.list
|
pankso@16
|
686 cd .. && sed -i s/'^.'/''/ files.list
|
pankso@16
|
687 status
|
pankso@43
|
688
|
pankso@119
|
689 # Strip and stuff files.
|
pankso@43
|
690 strip_package
|
pankso@43
|
691
|
pankso@43
|
692 # Md5sum of files.
|
pankso@16
|
693 gettext "Creating md5sum of files..."
|
pankso@16
|
694 while read file; do
|
pankso@16
|
695 [ -L "fs$file" ] && continue
|
pankso@16
|
696 [ -f "fs$file" ] || continue
|
pankso@16
|
697 case "$file" in
|
pankso@232
|
698 /lib/modules/*/modules.*|*.pyc) continue ;;
|
pankso@16
|
699 esac
|
pankso@16
|
700 md5sum "fs$file" | sed 's/ fs/ /'
|
pankso@16
|
701 done < files.list > md5sum
|
pankso@16
|
702 status
|
pankso@16
|
703 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum \
|
pankso@16
|
704 description.txt 2> /dev/null | awk \
|
pankso@16
|
705 '{ sz=$1 } END { print sz }')
|
pankso@358
|
706
|
pankso@16
|
707 # Build cpio archives.
|
pankso@16
|
708 gettext "Compressing the fs... "
|
pankso@16
|
709 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si
|
pankso@16
|
710 rm -rf fs
|
pankso@16
|
711 status
|
pankso@16
|
712 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
|
pankso@16
|
713 md5sum description.txt 2> /dev/null | awk \
|
pankso@16
|
714 '{ sz=$1 } END { print sz }')
|
pankso@16
|
715 gettext "Updating receipt sizes..."
|
pankso@16
|
716 sed -i s/^PACKED_SIZE.*$// receipt
|
pankso@16
|
717 sed -i s/^UNPACKED_SIZE.*$// receipt
|
pankso@16
|
718 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
|
pankso@16
|
719 status
|
pankso@16
|
720
|
pankso@16
|
721 # Set extra version.
|
pankso@16
|
722 if [ "$EXTRAVERSION" ]; then
|
pankso@16
|
723 gettext "Updating receipt EXTRAVERSION: "; echo -n "$EXTRAVERSION"
|
pankso@16
|
724 sed -i s/^EXTRAVERSION.*$// receipt
|
pankso@16
|
725 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
|
pankso@16
|
726 status
|
pankso@16
|
727 fi
|
pankso@16
|
728
|
pankso@16
|
729 # Compress.
|
pankso@16
|
730 gettext "Creating full cpio archive... "
|
pankso@16
|
731 find . -print | cpio -o -H newc --quiet > \
|
pankso@428
|
732 ../$PACKAGE-${VERSION}${EXTRAVERSION}${arch}.tazpkg
|
pankso@16
|
733 status
|
pankso@16
|
734 gettext "Restoring original package tree... "
|
pankso@16
|
735 unlzma -c fs.cpio.lzma | cpio -idm --quiet
|
pankso@16
|
736 status
|
pankso@16
|
737 rm fs.cpio.lzma && cd ..
|
pankso@43
|
738
|
pankso@43
|
739 # QA and give info.
|
pankso@43
|
740 tazpkg=$(ls *.tazpkg)
|
pankso@43
|
741 packit_quality
|
pankso@43
|
742 separator && gettext "Package:"; echo -e " $tazpkg\n"
|
pankso@1
|
743 }
|
pankso@1
|
744
|
paul@62
|
745 # Verify package quality and consistency.
|
pankso@8
|
746 packit_quality() {
|
pankso@157
|
747 #gettext "QA: Checking for broken link..."
|
pankso@157
|
748 #link=$(find $fs/usr -type l -follow)
|
pankso@157
|
749 #[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
|
pankso@157
|
750 #status
|
pankso@358
|
751
|
pankso@142
|
752 # Exit if any error found in log file.
|
pankso@33
|
753 if fgrep -q ERROR: $LOGS/$pkg.log; then
|
pankso@32
|
754 rm -f $command && exit 1
|
pankso@8
|
755 fi
|
pankso@358
|
756
|
pankso@44
|
757 gettext "QA: Checking for empty package..."
|
pankso@45
|
758 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
|
pankso@259
|
759 if [ "$files" == 0 ] && [ "$CATEGORY" != "meta" ]; then
|
pankso@44
|
760 echo -e "\nERROR: empty package"
|
pankso@32
|
761 rm -f $command && exit 1
|
pankso@8
|
762 else
|
pankso@134
|
763 # Ls sort by name so the first file is the one we want.
|
pankso@136
|
764 old=$(ls $PKGS/$pkg-*.tazpkg 2>/dev/null | head -n 1)
|
pankso@134
|
765 status
|
pankso@154
|
766 if [ -f "$old" ]; then
|
pankso@265
|
767 gettext "Removing old: $(basename $old)"
|
pankso@135
|
768 rm -f $old && status
|
pankso@154
|
769 fi
|
pankso@134
|
770 mv -f $pkgdir/taz/$pkg-*.tazpkg $PKGS
|
pankso@11
|
771 sed -i /^${pkg}$/d $broken
|
pankso@265
|
772 #gettext "Removing source tree..."
|
pankso@265
|
773 #rm -f $WOK/$pkg/source && status
|
pankso@8
|
774 fi
|
pankso@8
|
775 }
|
pankso@8
|
776
|
pankso@427
|
777 # Tic tac, tic tac...
|
pankso@421
|
778 tac() {
|
pascal@285
|
779 sed '1!G;h;$!d' $1
|
pascal@285
|
780 }
|
pascal@285
|
781
|
pankso@428
|
782 # Install package on --install or update the chroot.
|
pankso@428
|
783 install_package() {
|
pankso@428
|
784 case "$ARCH" in
|
pankso@428
|
785 arm|x86_64)
|
pankso@428
|
786 arch="-${ARCH}"
|
pankso@443
|
787 root=$CROSS_TREE/sysroot ;;
|
pankso@428
|
788 esac
|
pankso@428
|
789 # Install package if requested but skip install if target host doesn't
|
pankso@428
|
790 # match build system or it will break the build chroot.
|
pankso@428
|
791 build=$(echo $BUILD_SYSTEM | cut -d "-" -f 1)
|
pankso@428
|
792 if [ "$inst" ] && [ "$build" == "$ARCH" ]; then
|
pankso@428
|
793 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
|
pankso@428
|
794 cd $PKGS && tazpkg install \
|
pankso@428
|
795 $PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg --forced
|
pankso@428
|
796 else
|
pankso@428
|
797 gettext -e "Unable to install package, build has failed.\n\n"
|
pankso@428
|
798 exit 1
|
pankso@428
|
799 fi
|
pankso@428
|
800 fi
|
pankso@428
|
801
|
pankso@428
|
802 # Install package if part of the chroot to keep env up-to-date.
|
pankso@428
|
803 if [ -d "${root}$INSTALLED/$pkg" ]; then
|
pankso@428
|
804 . /etc/slitaz/cook.conf
|
pankso@428
|
805 . $WOK/$pkg/taz/$pkg-*/receipt
|
pankso@428
|
806 echo "Updating $ARCH chroot environment..."
|
pankso@428
|
807 echo "Updating chroot: $pkg (${VERSION}${EXTRAVERSION}${arch})" | log
|
pankso@428
|
808 cd $PKGS && tazpkg install \
|
pankso@428
|
809 $pkg-${VERSION}${EXTRAVERSION}${arch}.tazpkg \
|
pankso@428
|
810 --forced --root=$root
|
pankso@428
|
811 fi
|
pankso@428
|
812 }
|
pankso@428
|
813
|
pascal@285
|
814 # Launch the cook command into a chroot jail protected by aufs.
|
pascal@285
|
815 # The current filesystems are used read-only and updates are
|
pascal@285
|
816 # stored in a separate branch.
|
pascal@285
|
817 try_aufs_chroot() {
|
pascal@285
|
818
|
pascal@286
|
819 base=/dev/shm/aufsmnt$$
|
pascal@286
|
820
|
pascal@285
|
821 # Can we setup the chroot ? Is it already done ?
|
pascal@292
|
822 grep -q ^AUFS_NOT_SUPPORTED $receipt && return
|
pascal@285
|
823 [ -n "$AUFS_MOUNTS" -a ! -f /aufs-umount.sh ] || return
|
pascal@285
|
824 lsmod | grep -q aufs || modprobe aufs 2> /dev/null || return
|
pascal@286
|
825 mkdir ${base}root ${base}rw || return
|
pascal@285
|
826
|
pascal@285
|
827 echo "Setup aufs chroot..."
|
pascal@285
|
828
|
pascal@285
|
829 # Sanity check
|
pascal@286
|
830 for i in / /proc /sys /dev/shm /home ; do
|
pascal@285
|
831 case " $AUFS_MOUNTS " in
|
pascal@285
|
832 *\ $i\ *) ;;
|
pascal@285
|
833 *) AUFS_MOUNTS="$AUFS_MOUNTS $i" ;;
|
pascal@285
|
834 esac
|
pascal@285
|
835 done
|
pascal@285
|
836 for mnt in $(echo $AUFS_MOUNTS | sort | uniq); do
|
pascal@285
|
837 mount --bind $mnt ${base}root$mnt
|
pascal@285
|
838 if [ $mnt == / ] && ! mount -t aufs -o br=${base}rw:/ none ${base}root; then
|
pascal@285
|
839 echo "Aufs mountage failure"
|
pascal@285
|
840 umount ${base}root
|
pascal@285
|
841 rmdir ${base}*
|
pascal@285
|
842 return
|
pascal@285
|
843 fi
|
pascal@285
|
844 echo "umount ${base}root$mnt" >> ${base}rw/aufs-umount.sh
|
pascal@285
|
845 done
|
pascal@285
|
846
|
pascal@285
|
847 chroot ${base}root $(cd $(dirname $0); pwd)/$(basename $0) "$@"
|
pascal@285
|
848 status=$?
|
pascal@285
|
849
|
paul@342
|
850 echo "Leaving aufs chroot..."
|
pascal@285
|
851 tac ${base}rw/aufs-umount.sh | sh
|
pascal@285
|
852 rm -rf ${base}rw
|
pascal@285
|
853 umount ${base}root
|
pascal@285
|
854 rmdir $base*
|
pankso@428
|
855 # Dont install pkg twice... it's done after
|
pankso@428
|
856 #install_package
|
pankso@358
|
857 exit $status
|
pascal@285
|
858 }
|
pascal@285
|
859
|
paul@387
|
860 # Create a XML feed for freshly built packages.
|
pankso@310
|
861 gen_rss() {
|
pankso@310
|
862 pubdate=$(date "+%a, %d %b %Y %X")
|
pankso@310
|
863 cat > $FEEDS/$pkg.xml << EOT
|
pankso@310
|
864 <item>
|
pankso@310
|
865 <title>$PACKAGE $VERSION${EXTRAVERSION}</title>
|
pankso@310
|
866 <link>${COOKER_URL}?pkg=$PACKAGE</link>
|
pankso@310
|
867 <guid>$PACKAGE-$VERSION${EXTRAVERSION}</guid>
|
pankso@310
|
868 <pubDate>$pubdate</pubDate>
|
pankso@310
|
869 <description>$SHORT_DESC</description>
|
pankso@310
|
870 </item>
|
pankso@310
|
871 EOT
|
pankso@310
|
872 }
|
pankso@310
|
873
|
pankso@1
|
874 #
|
pankso@1
|
875 # Commands
|
pankso@1
|
876 #
|
pankso@1
|
877
|
pankso@1
|
878 case "$1" in
|
pankso@32
|
879 usage|help|-u|-h)
|
pankso@1
|
880 usage ;;
|
pankso@1
|
881 list-wok)
|
pankso@52
|
882 gettext -e "\nList of packages in:"; echo " $WOK"
|
pankso@1
|
883 separator
|
pankso@1
|
884 cd $WOK && ls -1
|
pankso@1
|
885 separator
|
pankso@1
|
886 echo -n "Packages: " && ls | wc -l
|
pankso@427
|
887 newline ;;
|
pankso@378
|
888 activity)
|
pankso@378
|
889 cat $activity ;;
|
pankso@69
|
890 search)
|
pankso@69
|
891 # Just a simple search function, we dont need more actually.
|
pankso@69
|
892 query="$2"
|
pankso@427
|
893 newline
|
pankso@427
|
894 gettext "Search results for:"; echo " $query"
|
pankso@69
|
895 separator
|
pankso@69
|
896 cd $WOK && ls -1 | grep "$query"
|
pankso@427
|
897 separator && newline ;;
|
pankso@1
|
898 setup)
|
pankso@1
|
899 # Setup a build environment
|
pankso@1
|
900 check_root
|
pankso@427
|
901 echo "Cook: setup environment" | log
|
pankso@427
|
902 newline
|
pankso@427
|
903 gettext "Setting up your environment"; newline
|
pankso@1
|
904 separator && cd $SLITAZ
|
pankso@52
|
905 init_db_files
|
pankso@397
|
906 gettext "Checking for packages to install..."; echo
|
pankso@397
|
907 # Use setup pkgs from cross.conf or cook.conf. When cross compiling
|
pankso@397
|
908 # ARCH-setup or 'cross check-env' should be used before: cook setup
|
pankso@397
|
909 case "$ARCH" in
|
pankso@421
|
910 arm|x86_64)
|
pankso@397
|
911 if [ ! -x "/usr/bin/cross" ]; then
|
pankso@397
|
912 gettext "ERROR: cross is not installed"; echo
|
pankso@397
|
913 exit 1
|
pankso@397
|
914 fi
|
pankso@397
|
915 gettext "Using config file: /etc/slitaz/cross.conf"; echo
|
pankso@397
|
916 . /etc/slitaz/cross.conf ;;
|
pankso@397
|
917 esac
|
pankso@397
|
918 for pkg in $SETUP_PKGS; do
|
pankso@397
|
919 if [ "$forced" ]; then
|
pankso@421
|
920 tazpkg -gi $pkg --forced
|
pankso@397
|
921 else
|
pankso@407
|
922 [ -d "$INSTALLED/$pkg" ] || tazpkg get-install $pkg
|
pankso@397
|
923 fi
|
pankso@397
|
924 done
|
pankso@1
|
925
|
pankso@1
|
926 # Handle --options
|
pankso@1
|
927 case "$2" in
|
pankso@397
|
928 --wok)
|
pankso@230
|
929 hg clone $WOK_URL wok || exit 1 ;;
|
pankso@230
|
930 --stable)
|
pankso@230
|
931 hg clone $WOK_URL-stable wok || exit 1 ;;
|
pankso@230
|
932 --undigest)
|
pankso@230
|
933 hg clone $WOK_URL-undigest wok || exit 1 ;;
|
pankso@397
|
934 --tiny)
|
pankso@397
|
935 hg clone $WOK_URL-tiny wok || exit 1 ;;
|
pankso@1
|
936 esac
|
pankso@1
|
937
|
pankso@1
|
938 # SliTaz group and permissions
|
pankso@1
|
939 if ! grep -q ^slitaz /etc/group; then
|
pankso@1
|
940 gettext -e "Adding group: slitaz\n"
|
pankso@1
|
941 addgroup slitaz
|
pankso@1
|
942 fi
|
pankso@1
|
943 gettext -e "Setting permissions for slitaz group...\n"
|
pascal@277
|
944 find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
|
pascal@277
|
945 find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
|
pankso@1
|
946 separator
|
pankso@1
|
947 gettext -e "All done, ready to cook packages :-)\n\n" ;;
|
pankso@395
|
948 *-setup)
|
pankso@395
|
949 # Setup for cross compiling.
|
pankso@395
|
950 arch=${1%-setup}
|
pankso@397
|
951 check_root
|
pankso@430
|
952 echo "Cook: setup $arch cross environment" | log
|
pankso@427
|
953 newline
|
pankso@443
|
954 boldify $(gettext "Setting up your $arch cross environment")
|
pankso@397
|
955 separator
|
pankso@397
|
956 init_db_files
|
pankso@359
|
957 sed -i \
|
pankso@396
|
958 -e s"/ARCH=.*/ARCH=\"$arch\"/" \
|
pankso@443
|
959 -e s"/CROSS_TREE=.*/CROSS_TREE=\"\/cross\/$arch\"/" \
|
pankso@359
|
960 -e s'/BUILD_SYSTEM=.*/BUILD_SYSTEM=i486-slitaz-linux/' \
|
pankso@395
|
961 /etc/slitaz/cook.conf
|
pankso@395
|
962 case "$arch" in
|
pankso@395
|
963 arm)
|
pankso@395
|
964 sed -i \
|
pankso@443
|
965 -e s'/CFLAGS=.*/CFLAGS="-march=armv6 -O2"/' \
|
pankso@395
|
966 -e s'/HOST_SYSTEM=.*/HOST_SYSTEM=$ARCH-slitaz-linux-gnueabi/' \
|
pankso@397
|
967 -e s'/xorg-dev/""/' \
|
pankso@395
|
968 /etc/slitaz/cook.conf ;;
|
pankso@395
|
969 x86_64)
|
pankso@395
|
970 sed -i \
|
pankso@395
|
971 -e s'/CFLAGS=.*/CFLAGS=""/' \
|
pankso@395
|
972 -e s'/HOST_SYSTEM=.*/HOST_SYSTEM=$ARCH-slitaz-linux/' \
|
pankso@395
|
973 /etc/slitaz/cook.conf ;;
|
pankso@395
|
974 esac
|
pankso@359
|
975 . /etc/slitaz/cook.conf
|
pankso@443
|
976 sysroot=$CROSS_TREE/sysroot
|
pankso@443
|
977 tools=/cross/$arch/tools
|
pankso@443
|
978 root=$sysroot
|
pankso@443
|
979 CC=$tools/bin/${HOST_SYSTEM}-gcc
|
pankso@421
|
980 echo "Target arch : $ARCH"
|
pankso@421
|
981 echo "Configure args : $CONFIGURE_ARGS"
|
pankso@443
|
982 echo "Arch sysroot : $sysroot"
|
pankso@443
|
983 echo "Tools prefix : $tools/bin"
|
paul@455
|
984 # Tell the packages manager where to find packages.
|
pankso@426
|
985 echo "Packages DB : ${root}$DB"
|
pankso@429
|
986 mkdir -p ${root}$INSTALLED
|
pankso@426
|
987 cd ${root}$DB && rm -f *.bak
|
pankso@426
|
988 for list in packages.list packages.desc packages.equiv packages.md5
|
pankso@426
|
989 do
|
pankso@426
|
990 rm -f $list && ln -s $SLITAZ/packages/$list $list
|
pankso@426
|
991 done
|
pankso@429
|
992 # We must have the cross compiled glibc-base installed or default
|
pankso@429
|
993 # i486 package will be used as dep by tazpkg and then break the
|
pankso@429
|
994 # cross environment
|
pankso@429
|
995 if [ ! -f "${root}$INSTALLED/glibc-base/receipt" ]; then
|
pankso@443
|
996 colorize 36 "WARNING: (e)glibc-base is not installed in sysroot"
|
pankso@429
|
997 fi
|
pankso@426
|
998 # Show GCC version or warn if not yet compiled.
|
pankso@406
|
999 if [ -x $CC ]; then
|
pankso@421
|
1000 echo "Cross compiler : ${HOST_SYSTEM}-gcc"
|
pankso@359
|
1001 else
|
pankso@437
|
1002 colorize 36 "C compiler is missing: ${HOST_SYSTEM}-gcc"
|
paul@387
|
1003 echo "Run 'cross compile' to cook a toolchain"
|
pankso@397
|
1004 fi
|
pankso@427
|
1005 separator && newline ;;
|
pankso@9
|
1006 test)
|
pankso@9
|
1007 # Test a cook environment.
|
pankso@13
|
1008 echo "Cook test: testing the cook environment" | log
|
pankso@9
|
1009 [ ! -d "$WOK" ] && exit 1
|
pankso@9
|
1010 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
|
pankso@9
|
1011 cook cooktest ;;
|
pankso@1
|
1012 new)
|
pankso@1
|
1013 # Create the package folder and an empty receipt.
|
pankso@1
|
1014 pkg="$2"
|
pankso@1
|
1015 [ "$pkg" ] || usage
|
pankso@427
|
1016 newline
|
pankso@1
|
1017 if [ -d "$WOK/$pkg" ]; then
|
paul@62
|
1018 echo -n "$pkg " && gettext "package already exists."
|
pankso@1
|
1019 echo -e "\n" && exit 1
|
pankso@1
|
1020 fi
|
pankso@1
|
1021 gettext "Creating"; echo -n " $WOK/$pkg"
|
pankso@1
|
1022 mkdir $WOK/$pkg && cd $WOK/$pkg && status
|
pankso@1
|
1023 gettext "Preparing the package receipt..."
|
pankso@1
|
1024 cp $DATA/receipt .
|
pankso@1
|
1025 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
|
pankso@427
|
1026 status && newline
|
pankso@358
|
1027
|
pankso@196
|
1028 # Interactive mode, asking and seding.
|
pankso@196
|
1029 case "$3" in
|
paul@214
|
1030 --interactive|-x)
|
pankso@358
|
1031 gettext -e "Entering interactive mode...\n"
|
paul@211
|
1032 separator
|
pankso@196
|
1033 echo "Package : $pkg"
|
pankso@196
|
1034 # Version.
|
pankso@196
|
1035 echo -n "Version : " ; read anser
|
pankso@196
|
1036 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
|
pankso@196
|
1037 # Category.
|
pankso@196
|
1038 echo -n "Category : " ; read anser
|
pankso@196
|
1039 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
|
pankso@196
|
1040 # Short description.
|
pankso@196
|
1041 echo -n "Short desc : " ; read anser
|
pankso@196
|
1042 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
|
pankso@196
|
1043 # Maintainer.
|
pankso@196
|
1044 echo -n "Maintainer : " ; read anser
|
pankso@196
|
1045 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
|
slaxemulator@471
|
1046 # License.
|
slaxemulator@471
|
1047 echo -n "License : " ; read anser
|
slaxemulator@471
|
1048 sed -i s/'LICENSE=\"\"'/"LICENSE=\"$anser\""/ receipt
|
pankso@196
|
1049 # Web site.
|
pankso@196
|
1050 echo -n "Web site : " ; read anser
|
pankso@196
|
1051 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
|
pankso@427
|
1052 newline
|
pankso@196
|
1053 # Wget URL.
|
pankso@196
|
1054 echo "Wget URL to download source tarball."
|
pankso@196
|
1055 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
|
pankso@196
|
1056 echo -n "Wget url : " ; read anser
|
paul@211
|
1057 sed -i s#'WGET_URL=\"$TARBALL\"'#"WGET_URL=\"$anser\""# receipt
|
pankso@196
|
1058 # Ask for a stuff dir.
|
pankso@196
|
1059 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
|
pankso@196
|
1060 if [ "$anser" = "y" ]; then
|
pankso@196
|
1061 echo -n "Creating the stuff directory..."
|
pankso@196
|
1062 mkdir $WOK/$pkg/stuff && status
|
pankso@196
|
1063 fi
|
pankso@196
|
1064 # Ask for a description file.
|
pankso@196
|
1065 echo -n "Are you going to write a description ? (y/N) : " ; read anser
|
pankso@196
|
1066 if [ "$anser" = "y" ]; then
|
pankso@196
|
1067 echo -n "Creating the description.txt file..."
|
pankso@427
|
1068 newline > $WOK/$pkg/description.txt && status
|
pankso@196
|
1069 fi
|
paul@211
|
1070 separator
|
paul@211
|
1071 gettext -e "Receipt is ready to use.\n"
|
pankso@427
|
1072 newline ;;
|
pankso@196
|
1073 esac ;;
|
pankso@1
|
1074 list)
|
pankso@1
|
1075 # Cook a list of packages (better use the Cooker since it will order
|
pankso@1
|
1076 # packages before executing cook).
|
pankso@1
|
1077 check_root
|
pankso@1
|
1078 [ -z "$2" ] && gettext -e "\nNo list in argument.\n\n" && exit 1
|
pankso@1
|
1079 [ ! -f "$2" ] && gettext -e "\nNo list found:" && \
|
pankso@1
|
1080 echo -e " $2\n" && exit 1
|
pankso@13
|
1081 echo "Cook list starting: $2" | log
|
pankso@1
|
1082 for pkg in $(cat $2)
|
pankso@1
|
1083 do
|
pankso@1
|
1084 cook $pkg || broken
|
pankso@1
|
1085 done ;;
|
pankso@1
|
1086 clean-wok)
|
pankso@1
|
1087 check_root
|
pankso@1
|
1088 gettext -e "\nCleaning all packages files..."
|
pankso@1
|
1089 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
|
pankso@427
|
1090 status && newline ;;
|
pankso@1
|
1091 clean-src)
|
pankso@1
|
1092 check_root
|
paul@62
|
1093 gettext -e "\nCleaning all packages sources..."
|
pankso@1
|
1094 rm -rf $WOK/*/source
|
pankso@427
|
1095 status && newline ;;
|
pankso@235
|
1096 pkgdb)
|
pankso@235
|
1097 # Create suitable packages list for TazPKG and only for built packages
|
pankso@235
|
1098 # as well as flavors files for TazLiTo. We dont need logs since we do it
|
paul@243
|
1099 # manually to ensure everything is fine before syncing the mirror.
|
pankso@239
|
1100 case "$2" in
|
pankso@239
|
1101 --flavors)
|
pankso@239
|
1102 continue ;;
|
pankso@239
|
1103 *)
|
pankso@240
|
1104 [ "$2" ] && PKGS="$2"
|
pankso@239
|
1105 [ ! -d "$PKGS" ] && \
|
pankso@240
|
1106 gettext -e "\nPackages directory doesn't exist\n\n" && exit 1 ;;
|
pankso@239
|
1107 esac
|
pankso@226
|
1108 time=$(date +%s)
|
pankso@239
|
1109 flavors=$SLITAZ/flavors
|
pankso@239
|
1110 live=$SLITAZ/live
|
pankso@235
|
1111 echo "cook:pkgdb" > $command
|
pankso@235
|
1112 echo "Cook pkgdb: Creating all packages lists" | log
|
pankso@427
|
1113 newline
|
pankso@239
|
1114 gettext "Creating lists for: "; echo "$PKGS"
|
pankso@1
|
1115 separator
|
pankso@235
|
1116 gettext "Cook pkgdb started: "; date "+%Y-%m-%d %H:%M"
|
pankso@133
|
1117 cd $PKGS
|
pankso@192
|
1118 rm -f packages.*
|
pankso@235
|
1119 gettext -e "Creating: packages.list\n"
|
pankso@85
|
1120 ls -1 *.tazpkg | sed s'/.tazpkg//' > $PKGS/packages.list
|
pankso@235
|
1121 gettext -e "Creating: packages.md5\n"
|
pankso@1
|
1122 md5sum *.tazpkg > $PKGS/packages.md5
|
gokhlayeh@297
|
1123 md5sum packages.md5 | cut -f1 -d' ' > ID
|
pankso@235
|
1124 gettext -e "Creating lists from: "; echo "$WOK"
|
pankso@1
|
1125 cd $WOK
|
pankso@1
|
1126 for pkg in *
|
pankso@1
|
1127 do
|
pankso@1
|
1128 unset_receipt
|
pankso@1
|
1129 . $pkg/receipt
|
pankso@1
|
1130 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg" ]; then
|
pascal@267
|
1131 # PACKED_SIZE and UNPACKED_SIZE are only in built receipt
|
pascal@274
|
1132 if [ -s $pkg/taz/*/receipt ]; then
|
pascal@274
|
1133 . $pkg/taz/*/receipt
|
pascal@274
|
1134 fi
|
pankso@192
|
1135 # packages.desc lets us search easily in DB
|
pankso@1
|
1136 cat >> $PKGS/packages.desc << EOT
|
pankso@235
|
1137 $PACKAGE | ${VERSION}$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE
|
pankso@1
|
1138 EOT
|
pankso@192
|
1139 # packages.txt used by tazpkg and tazpkg-web also to provide
|
pankso@192
|
1140 # a human readable package list with version and description.
|
pankso@192
|
1141 cat >> $PKGS/packages.txt << EOT
|
pankso@192
|
1142 $PACKAGE
|
pankso@235
|
1143 ${VERSION}$EXTRAVERSION
|
pankso@235
|
1144 $SHORT_DESC
|
pankso@235
|
1145 $PACKED_SIZE ($UNPACKED_SIZE installed)
|
pankso@358
|
1146
|
pankso@192
|
1147 EOT
|
pankso@192
|
1148 # packages.equiv is used by tazpkg install to check depends.
|
pankso@1
|
1149 for i in $PROVIDE; do
|
pankso@1
|
1150 DEST=""
|
pankso@1
|
1151 echo $i | fgrep -q : && DEST="${i#*:}:"
|
pankso@1
|
1152 if grep -qs ^${i%:*}= $PKGS/packages.equiv; then
|
pankso@1
|
1153 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" \
|
pankso@1
|
1154 $PKGS/packages.equiv
|
pankso@1
|
1155 else
|
pankso@1
|
1156 echo "${i%:*}=$DEST$PACKAGE" >> $PKGS/packages.equiv
|
pankso@1
|
1157 fi
|
pankso@1
|
1158 done
|
paul@197
|
1159 # files.list provides a list of all packages files.
|
pankso@194
|
1160 cat $pkg/taz/*/files.list | sed s/^/"$pkg: \0"/ >> \
|
pankso@194
|
1161 $PKGS/files.list
|
pankso@1
|
1162 fi
|
pankso@1
|
1163 done
|
pankso@358
|
1164
|
pankso@213
|
1165 # Display list size.
|
pankso@235
|
1166 gettext -e "Done: packages.desc\n"
|
pankso@235
|
1167 gettext -e "Done: packages.txt\n"
|
pankso@235
|
1168 gettext -e "Done: packages.equiv\n"
|
pankso@358
|
1169
|
pankso@194
|
1170 # files.list.lzma
|
pankso@235
|
1171 gettext -e "Creating: files.list.lzma\n"
|
pankso@235
|
1172 cd $PKGS && lzma e files.list files.list.lzma
|
pankso@194
|
1173 rm -f files.list
|
pankso@358
|
1174
|
pankso@235
|
1175 # Display some info.
|
pankso@1
|
1176 separator
|
pankso@1
|
1177 nb=$(ls $PKGS/*.tazpkg | wc -l)
|
pankso@226
|
1178 time=$(($(date +%s) - $time))
|
pankso@235
|
1179 echo -e "Packages: $nb - Time: ${time}s\n"
|
pankso@358
|
1180
|
paul@243
|
1181 # Create all flavors files at once. Do we really need code to monitor
|
paul@243
|
1182 # flavors changes ? Lets just build them with packages lists before
|
pankso@235
|
1183 # syncing the mirror.
|
pankso@239
|
1184 [ "$2" == "--flavors" ] || exit 1
|
pankso@239
|
1185 [ ! -d "$flavors" ] && echo -e "Missing flavors: $flavors\n" && exit 1
|
pankso@239
|
1186 [ -d "$live" ] || mkdir -p $live
|
pankso@236
|
1187 gettext "Creating flavors files in:"; echo " $live"
|
pankso@239
|
1188 echo "Cook pkgdb: Creating all flavors" | log
|
pankso@235
|
1189 separator
|
pankso@236
|
1190 gettext -e "Recharging lists to use latest packages...\n"
|
pankso@329
|
1191 tazpkg recharge >/dev/null 2>/dev/null
|
pankso@358
|
1192
|
pankso@235
|
1193 # We need a custom tazlito config to set working dir to /home/slitaz.
|
pankso@235
|
1194 if [ ! -f "$live/tazlito.conf" ]; then
|
pankso@235
|
1195 echo "Creating configuration file: tazlito.conf"
|
pankso@235
|
1196 cp /etc/tazlito/tazlito.conf $live
|
pankso@235
|
1197 sed -i s@WORK_DIR=.*@WORK_DIR=\"/home/slitaz\"@ \
|
pankso@235
|
1198 $live/tazlito.conf
|
pankso@235
|
1199 fi
|
pankso@235
|
1200
|
pankso@239
|
1201 # Update Hg flavors repo and pack.
|
pankso@239
|
1202 [ -d "$flavors/.hg" ] && cd $flavors && hg pull -u
|
pankso@358
|
1203
|
pankso@239
|
1204 cd $live
|
pankso@235
|
1205 echo "Starting to generate flavors..."
|
pankso@235
|
1206 rm -f flavors.list *.flavor
|
pankso@235
|
1207 for i in $flavors/*
|
pankso@235
|
1208 do
|
pankso@235
|
1209 fl=$(basename $i)
|
pankso@235
|
1210 echo "Packing flavor: $(basename $i)"
|
pankso@235
|
1211 tazlito pack-flavor $fl >/dev/null || exit 1
|
pankso@235
|
1212 tazlito show-flavor $fl --brief --noheader 2> \
|
pankso@235
|
1213 /dev/null >> flavors.list
|
pankso@235
|
1214 done
|
pankso@237
|
1215 cp -f $live/*.flavor $live/flavors.list $PKGS
|
pankso@235
|
1216 separator && gettext "Flavors size: "; du -sh $live | awk '{print $1}'
|
pankso@427
|
1217 newline && rm -f $command ;;
|
pankso@1
|
1218 *)
|
pankso@1
|
1219 # Just cook and generate a package.
|
pankso@1
|
1220 check_root
|
pankso@1
|
1221 time=$(date +%s)
|
pankso@1
|
1222 pkg="$1"
|
pankso@1
|
1223 [ -z "$pkg" ] && usage
|
pankso@44
|
1224 receipt="$WOK/$pkg/receipt"
|
pankso@427
|
1225 check_pkg_in_wok && newline
|
pankso@47
|
1226
|
pankso@377
|
1227 unset inst
|
pankso@377
|
1228 unset_receipt
|
pankso@377
|
1229 . $receipt
|
pankso@377
|
1230
|
pankso@377
|
1231 # Handle cross compilation.
|
pankso@377
|
1232 #
|
pankso@377
|
1233 # CROSS_NOTE: Actually we are running an ARM cooker but running
|
pankso@377
|
1234 # the cooker and build each commit in wok is not possible since
|
pankso@377
|
1235 # we dont cook the full wok for this arch. For ARM we need a set
|
paul@387
|
1236 # of packages to handle a touch screen desktop, servers but not
|
pankso@377
|
1237 # erland.
|
pankso@377
|
1238 #
|
pankso@377
|
1239 # The temporary solution is to build only reviewed and tested
|
pankso@377
|
1240 # packages with HOST_ARCH set in receipt.
|
pankso@377
|
1241 case "$ARCH" in
|
pankso@377
|
1242 arm)
|
pankso@377
|
1243 if [ ! "$HOST_ARCH" ]; then
|
pankso@379
|
1244 echo "cook: HOST_ARCH is not set in $pkg receipt"
|
paul@387
|
1245 echo "cook: This package is not included in: $ARCH"
|
pankso@377
|
1246 [ "$CROSS_BUGS" ] && echo "bugs: $CROSS_BUGS"
|
paul@387
|
1247 echo "Cook skip: $pkg is not included in: $ARCH" | log
|
pankso@427
|
1248 newline && exit 1
|
pankso@377
|
1249 fi ;;
|
pankso@377
|
1250 esac
|
pankso@377
|
1251
|
paul@387
|
1252 # Some packages are not included in some arch or fail to cross compile.
|
pankso@398
|
1253 : ${HOST_ARCH=i486}
|
pankso@381
|
1254 if ! $(echo "$HOST_ARCH" | fgrep -q $ARCH); then
|
pankso@381
|
1255 echo "cook: HOST_ARCH=$HOST_ARCH"
|
paul@387
|
1256 echo "cook: $pkg doesn't cook or is not included in: $ARCH"
|
pankso@381
|
1257 [ "$CROSS_BUGS" ] && echo "bugs: $CROSS_BUGS"
|
paul@387
|
1258 echo "Cook skip: $pkg doesn't cook or is not included in: $ARCH" | log
|
pankso@427
|
1259 newline && exit 1
|
pankso@377
|
1260 fi
|
pankso@377
|
1261
|
pankso@47
|
1262 # Skip blocked, 3 lines also for the Cooker.
|
pankso@151
|
1263 if grep -q "^$pkg$" $blocked && [ "$2" != "--unblock" ]; then
|
pankso@47
|
1264 gettext -e "Blocked package:"; echo -e " $pkg\n" && exit 0
|
pankso@47
|
1265 fi
|
pankso@47
|
1266
|
pascal@289
|
1267 try_aufs_chroot "$@"
|
pascal@289
|
1268
|
pankso@47
|
1269 # Log and source receipt.
|
pankso@56
|
1270 echo "Cook started for: <a href='cooker.cgi?pkg=$pkg'>$pkg</a>" | log
|
pankso@16
|
1271 echo "cook:$pkg" > $command
|
pascal@285
|
1272
|
pascal@285
|
1273 # Display and log info if cook process stopped.
|
pascal@285
|
1274 trap 'gettext -e "\n\nCook stopped: control-C\n\n" | \
|
pascal@285
|
1275 tee -a $LOGS/$pkg.log' INT
|
pascal@285
|
1276
|
pankso@1
|
1277 # Handle --options
|
pankso@1
|
1278 case "$2" in
|
pankso@1
|
1279 --clean|-c)
|
pankso@49
|
1280 gettext -e "Cleaning:"; echo -n " $pkg"
|
pankso@1
|
1281 cd $WOK/$pkg && rm -rf install taz source
|
pankso@427
|
1282 status && newline && exit 0 ;;
|
pankso@1
|
1283 --install|-i)
|
pankso@1
|
1284 inst='yes' ;;
|
pankso@49
|
1285 --getsrc|-gs)
|
pankso@49
|
1286 gettext "Getting source for:"; echo " $pkg"
|
pankso@45
|
1287 separator && get_source
|
pankso@39
|
1288 echo -e "Tarball: $SRC/$TARBALL\n" && exit 0 ;;
|
pankso@49
|
1289 --block|-b)
|
pankso@49
|
1290 gettext "Blocking:"; echo -n " $pkg"
|
pankso@49
|
1291 [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked
|
pankso@427
|
1292 status && newline && exit 0 ;;
|
pankso@49
|
1293 --unblock|-ub)
|
pankso@49
|
1294 gettext "Unblocking:"; echo -n " $pkg"
|
pankso@49
|
1295 sed -i "/^${pkg}$/"d $blocked
|
pankso@427
|
1296 status && newline && exit 0 ;;
|
pankso@358
|
1297
|
pankso@1
|
1298 esac
|
pankso@1
|
1299
|
paul@62
|
1300 # Check if wanted is built now so we have separate log files.
|
pankso@295
|
1301 for wanted in $WANTED ; do
|
pascal@291
|
1302 if grep -q "^$wanted$" $blocked; then
|
pascal@291
|
1303 echo "WANTED package is blocked: $wanted" | tee $LOGS/$pkg.log
|
pankso@427
|
1304 newline && rm -f $command && exit 1
|
pankso@217
|
1305 fi
|
pascal@291
|
1306 if grep -q "^$wanted$" $broken; then
|
pascal@291
|
1307 echo "WANTED package is broken: $wanted" | tee $LOGS/$pkg.log
|
pankso@427
|
1308 newline && rm -f $command && exit 1
|
pankso@218
|
1309 fi
|
pascal@291
|
1310 if [ ! -d "$WOK/$wanted/install" ]; then
|
pascal@291
|
1311 cook "$wanted" || exit 1
|
pankso@137
|
1312 fi
|
pascal@291
|
1313 done
|
pankso@1
|
1314
|
pankso@1
|
1315 # Cook and pack or exit on error and log everything.
|
pankso@97
|
1316 cookit $@ 2>&1 | tee $LOGS/$pkg.log
|
pankso@15
|
1317 remove_deps | tee -a $LOGS/$pkg.log
|
pankso@1
|
1318 cookit_quality
|
pankso@26
|
1319 packit 2>&1 | tee -a $LOGS/$pkg.log
|
pankso@1
|
1320 clean_log
|
pankso@33
|
1321
|
pankso@33
|
1322 # Exit if any error in packing.
|
pankso@33
|
1323 if grep -q ^ERROR $LOGS/$pkg.log; then
|
pankso@33
|
1324 debug_info | tee -a $LOGS/$pkg.log
|
pankso@33
|
1325 rm -f $command && exit 1
|
pankso@33
|
1326 fi
|
pankso@358
|
1327
|
pankso@310
|
1328 # Create an XML feed
|
pankso@310
|
1329 gen_rss
|
pankso@358
|
1330
|
pankso@1
|
1331 # Time and summary
|
pankso@1
|
1332 time=$(($(date +%s) - $time))
|
pankso@1
|
1333 summary | tee -a $LOGS/$pkg.log
|
pankso@427
|
1334 newline
|
pankso@1
|
1335
|
pankso@428
|
1336 # We may want to install/update.
|
pankso@428
|
1337 install_package
|
pankso@358
|
1338
|
pankso@9
|
1339 # Finally we DONT WANT to build the *-dev or packages with WANTED="$pkg"
|
pankso@17
|
1340 # You want automation: use the Cooker Build Bot.
|
pankso@18
|
1341 rm -f $command ;;
|
pankso@1
|
1342 esac
|
pankso@1
|
1343
|
pankso@1
|
1344 exit 0
|