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
|
paul@647
|
4 # before adding or modifying any code in cook!
|
pankso@1
|
5 #
|
al@899
|
6 # Copyright (C) SliTaz GNU/Linux - GNU GPL v3
|
pankso@1
|
7 # Author: Christophe Lincoln <pankso@slitaz.org>
|
pankso@1
|
8 #
|
al@728
|
9
|
pankso@422
|
10 . /usr/lib/slitaz/libcook.sh
|
pankso@1
|
11
|
pankso@633
|
12 VERSION="3.2"
|
al@779
|
13 export output=raw
|
al@596
|
14
|
al@728
|
15
|
al@596
|
16 # Internationalization.
|
al@596
|
17
|
al@728
|
18 export TEXTDOMAIN='cook'
|
al@596
|
19
|
al@596
|
20
|
pankso@1
|
21 #
|
pankso@1
|
22 # Functions
|
pankso@1
|
23 #
|
pankso@1
|
24
|
pankso@1
|
25 usage() {
|
al@728
|
26 cat <<EOT
|
pankso@1
|
27
|
al@728
|
28 $(boldify "$(_ 'Usage:')") $(_ 'cook [package|command] [list|--option]')
|
pankso@1
|
29
|
al@728
|
30 $(boldify "$(_ 'Commands:')")
|
al@728
|
31 usage|help $(_ 'Display this short usage.')
|
al@728
|
32 setup $(_ 'Setup your build environment.')
|
al@728
|
33 *-setup $(_ 'Setup a cross environment.')
|
al@728
|
34 * = {arm|armv6hf|armv7|x86_64}
|
al@728
|
35 test $(_ 'Test environment and cook a package.')
|
al@728
|
36 list-wok $(_ 'List packages in the wok.')
|
al@728
|
37 search $(_ 'Simple packages search function.')
|
al@728
|
38 new $(_ 'Create a new package with a receipt.')
|
al@728
|
39 list $(_ 'Cook a list of packages.')
|
al@728
|
40 clean-wok $(_ 'Clean-up all packages files.')
|
al@728
|
41 clean-src $(_ 'Clean-up all packages sources.')
|
al@728
|
42 uncook $(_ 'Check for uncooked packages')
|
al@728
|
43 pkgdb $(_ 'Create packages DB lists and flavors.')
|
pankso@1
|
44
|
al@728
|
45 $(boldify "$(_ 'Options:')")
|
al@728
|
46 cook <pkg>
|
al@728
|
47 --clean -c $(_ 'clean the package in the wok.')
|
al@728
|
48 --install -i $(_ 'cook and install the package.')
|
al@728
|
49 --getsrc -gs $(_ 'get the package source tarball.')
|
al@728
|
50 --block -b $(_ 'block a package so cook will skip it.')
|
al@728
|
51 --unblock -ub $(_ 'unblock a blocked package.')
|
al@728
|
52 --cdeps $(_ 'check dependencies of cooked package.')
|
al@728
|
53 --pack $(_ 'repack an already built package.')
|
al@728
|
54 --debug $(_ 'display debugging messages.')
|
al@728
|
55 --continue $(_ 'continue running compile_rules.')
|
al@728
|
56 cook new <pkg>
|
al@728
|
57 --interactive -x $(_ 'create a receipt interactively.')
|
al@728
|
58 cook setup
|
al@728
|
59 --wok $(_ 'clone the cooking wok from Hg repo.')
|
al@728
|
60 --stable $(_ 'clone the stable wok from Hg repo.')
|
al@728
|
61 --undigest $(_ 'clone the undigest wok from Hg repo.')
|
al@728
|
62 --tiny $(_ 'clone the tiny SliTaz wok from Hg repo.')
|
al@728
|
63 --forced $(_ 'force reinstall of chroot packages.')
|
al@728
|
64 cook pkgdb
|
al@728
|
65 --flavors $(_ 'create up-to-date flavors files.')
|
al@932
|
66 cook splitdb $(_ 'create up-to-date split.db file.')
|
pankso@1
|
67
|
pankso@1
|
68 EOT
|
pankso@1
|
69 exit 0
|
pankso@1
|
70 }
|
pankso@1
|
71
|
al@728
|
72
|
paul@62
|
73 # We don't want these escapes in web interface.
|
al@728
|
74
|
pankso@1
|
75 clean_log() {
|
al@931
|
76 sed -i -e 's|\[70G\[ \[1;32m| |' \
|
al@931
|
77 -e 's|\[0;39m \]||' $LOGS/${1:-$pkg}.log
|
pankso@1
|
78 }
|
pankso@1
|
79
|
al@728
|
80
|
paul@62
|
81 # Be sure package exists in wok.
|
al@728
|
82
|
pankso@1
|
83 check_pkg_in_wok() {
|
al@890
|
84 [ -d "$WOK/$pkg" ] || die 'Unable to find package "%s" in the wok' "$pkg"
|
pankso@1
|
85 }
|
pankso@1
|
86
|
al@728
|
87
|
paul@62
|
88 # Initialize files used in $CACHE
|
al@728
|
89
|
pankso@52
|
90 init_db_files() {
|
al@728
|
91 _ 'Creating directories structure in "%s"' "$SLITAZ"
|
xfred222@559
|
92 mkdir -p $WOK $PKGS $SRC $CACHE $LOGS $FEEDS
|
al@728
|
93 _ 'Creating DB files in "%s"' "$CACHE"
|
al@933
|
94 touch $activity $command $broken $blocked $CACHE/webstat
|
al@933
|
95 chown www:www $cache/webstat
|
pankso@52
|
96 }
|
pankso@52
|
97
|
al@728
|
98
|
paul@62
|
99 # Paths used in receipt and by cook itself.
|
al@728
|
100
|
pankso@1
|
101 set_paths() {
|
al@1003
|
102 # Kernel version is set from wok/linux or installed/linux-api-headers(wok-undigest)
|
al@1003
|
103 if [ -f "$WOK/linux/receipt" ]; then
|
al@1003
|
104 kvers=$(. $WOK/linux/receipt; echo $VERSION)
|
al@1003
|
105 kbasevers=$(echo $kvers | cut -d. -f1,2)
|
al@1003
|
106 elif [ -f "$INSTALLED/linux-api-headers/receipt" ]; then
|
al@1003
|
107 kvers=$(. $INSTALLED/linux-api-headers/receipt; echo $VERSION)
|
al@1003
|
108 kbasevers=$(echo $kvers | cut -d. -f1,2)
|
al@1003
|
109 fi
|
al@1003
|
110
|
al@1003
|
111 # Python version
|
al@1003
|
112 [ -f "$WOK/python/receipt" ] && pyvers=$(. $WOK/python/receipt; echo $VERSION)
|
al@1003
|
113 # Perl version for some packages needed it
|
al@1003
|
114 [ -f "$WOK/perl/receipt" ] && perlvers=$(. $WOK/perl/receipt; echo $VERSION)
|
al@1003
|
115
|
al@904
|
116 pkgdir="$WOK/$pkg"
|
al@841
|
117 . "$pkgdir/receipt"
|
al@728
|
118 basesrc="$pkgdir/source"
|
al@728
|
119 tmpsrc="$basesrc/tmp"
|
al@728
|
120 src="$basesrc/$PACKAGE-$VERSION"
|
al@728
|
121 taz="$pkgdir/taz"
|
al@904
|
122 pack="$taz/${1:-$PACKAGE}-$VERSION$EXTRAVERSION" # v2: multiple taz/* folders
|
al@728
|
123 fs="$pack/fs"
|
al@728
|
124 stuff="$pkgdir/stuff"
|
al@728
|
125 install="$pkgdir/install"
|
al@904
|
126
|
slaxemulator@492
|
127 pkgsrc="${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}"
|
slaxemulator@492
|
128 lzma_tarball="$pkgsrc.tar.lzma"
|
al@904
|
129
|
al@904
|
130 [ -n "$PATCH" -a -z "$PTARBALL" ] && PTARBALL="$(basename $PATCH)"
|
al@904
|
131
|
al@728
|
132 if [ -n "$WANTED" ]; then
|
al@728
|
133 basesrc="$WOK/$WANTED/source"
|
al@728
|
134 src="$basesrc/$WANTED-$VERSION"
|
al@728
|
135 install="$WOK/$WANTED/install"
|
al@728
|
136 wanted_stuff="$WOK/$WANTED/stuff"
|
pankso@1
|
137 fi
|
al@904
|
138
|
al@904
|
139 [ -n "$SOURCE" ] && source_stuff="$WOK/$SOURCE/stuff"
|
al@904
|
140
|
pankso@9
|
141 # Old way compatibility.
|
al@728
|
142 _pkg="$install"
|
pankso@1
|
143 }
|
pankso@1
|
144
|
al@728
|
145
|
pankso@144
|
146 # Create source tarball when URL is a SCM.
|
al@728
|
147
|
pankso@144
|
148 create_tarball() {
|
slaxemulator@498
|
149 local tarball
|
al@728
|
150 tarball="$pkgsrc.tar.bz2"
|
al@728
|
151 [ -n "$LZMA_SRC" ] && tarball="$lzma_tarball"
|
al@728
|
152 _ 'Creating tarball "%s"' "$tarball"
|
al@728
|
153 if [ -n "$LZMA_SRC" ]; then
|
slaxemulator@498
|
154 tar -c $pkgsrc | lzma e $SRC/$tarball -si $LZMA_SET_DIR || exit 1
|
al@728
|
155 LZMA_SRC=''
|
pankso@162
|
156 else
|
al@728
|
157 tar -cjf $tarball $pkgsrc || exit 1
|
al@728
|
158 mv $tarball $SRC; rm -rf $pkgsrc
|
pankso@162
|
159 fi
|
al@728
|
160 TARBALL="$tarball"
|
pankso@144
|
161 }
|
pankso@144
|
162
|
al@728
|
163
|
pankso@145
|
164 # Get package source. For SCM we are in cache so clone here and create a
|
pankso@145
|
165 # tarball here.
|
al@728
|
166
|
pankso@1
|
167 get_source() {
|
pascal@610
|
168 local url
|
al@890
|
169 url=${WGET_URL#*|}
|
ernia@571
|
170 set_paths
|
pankso@115
|
171 pwd=$(pwd)
|
pankso@9
|
172 case "$WGET_URL" in
|
al@890
|
173 http://*|ftp://*|https://*)
|
al@890
|
174 url="$MIRROR_URL/sources/packages/${TARBALL:0:1}/$TARBALL"
|
al@890
|
175 wget -T 60 -c -O $SRC/$TARBALL $WGET_URL ||
|
al@890
|
176 wget -T 60 -c -O $SRC/$TARBALL $url ||
|
al@890
|
177 die 'ERROR: %s' "wget $WGET_URL"
|
al@890
|
178 ;;
|
al@728
|
179
|
pankso@9
|
180 hg*|mercurial*)
|
al@728
|
181 _ 'Getting source from %s...' 'Hg'
|
al@728
|
182 _ 'URL: %s' "$url"
|
al@728
|
183 _ 'Cloning to "%s"' "$pwd/$pkgsrc"
|
al@728
|
184 if [ -n "$BRANCH" ]; then
|
al@728
|
185 _ 'Hg branch: %s' "$BRANCH"
|
al@890
|
186 hg clone $url --rev $BRANCH $pkgsrc ||
|
al@890
|
187 die 'ERROR: %s' "hg clone $url --rev $BRANCH"
|
pankso@246
|
188 else
|
al@890
|
189 hg clone $url $pkgsrc || die 'ERROR: %s' "hg clone $url"
|
pankso@246
|
190 fi
|
pankso@255
|
191 rm -rf $pkgsrc/.hg
|
al@890
|
192 create_tarball
|
al@890
|
193 ;;
|
al@728
|
194
|
pankso@9
|
195 git*)
|
al@728
|
196 _ 'Getting source from %s...' 'Git'
|
al@728
|
197 _ 'URL: %s' "$url"
|
al@688
|
198 cd $SRC
|
al@890
|
199 git clone $url $pkgsrc || die 'ERROR: %s' "git clone $url"
|
al@728
|
200 if [ -n "$BRANCH" ]; then
|
al@728
|
201 _ 'Git branch: %s' "$BRANCH"
|
al@728
|
202 cd $pkgsrc; git checkout $BRANCH; cd ..
|
pankso@63
|
203 fi
|
al@688
|
204 cd $SRC
|
al@890
|
205 create_tarball
|
al@890
|
206 ;;
|
al@728
|
207
|
pankso@144
|
208 cvs*)
|
pankso@144
|
209 mod=$PACKAGE
|
al@728
|
210 [ -n "$CVS_MODULE" ] && mod=$CVS_MODULE
|
al@728
|
211 _ 'Getting source from %s...' 'CVS'
|
al@728
|
212 _ 'URL: %s' "$url"
|
al@728
|
213 [ -n "$CVS_MODULE" ] && _ 'CVS module: %s' "$mod"
|
al@728
|
214 _ 'Cloning to "%s"' "$pwd/$mod"
|
pankso@144
|
215 cvs -d:$url co $mod && mv $mod $pkgsrc
|
al@890
|
216 create_tarball
|
al@890
|
217 ;;
|
al@728
|
218
|
pankso@69
|
219 svn*|subversion*)
|
al@728
|
220 _ 'Getting source from %s...' 'SVN'
|
al@728
|
221 _ 'URL: %s' "$url"
|
al@728
|
222 if [ -n "$BRANCH" ]; then
|
pankso@161
|
223 echo t | svn co $url -r $BRANCH $pkgsrc
|
pankso@161
|
224 else
|
pankso@161
|
225 echo t | svn co $url $pkgsrc
|
pankso@161
|
226 fi
|
al@890
|
227 create_tarball
|
al@890
|
228 ;;
|
al@728
|
229
|
al@590
|
230 bzr*)
|
al@728
|
231 _ 'Getting source from %s...' 'bazaar'
|
al@590
|
232 cd $SRC
|
al@590
|
233 pkgsrc=${url#*:}
|
al@728
|
234 if [ -n "$BRANCH" ]; then
|
al@590
|
235 echo "bzr -Ossl.cert_reqs=none branch $url -r $BRANCH"
|
al@590
|
236 bzr -Ossl.cert_reqs=none branch $url -r $BRANCH
|
al@590
|
237 else
|
al@590
|
238 echo "bzr -Ossl.cert_reqs=none branch $url"
|
al@590
|
239 bzr -Ossl.cert_reqs=none branch $url
|
al@728
|
240 cd $pkgsrc; BRANCH=$(bzr revno); cd ..
|
al@596
|
241 _ "Don't forget to add to receipt:"
|
al@728
|
242 echo -e "BRANCH=\"$BRANCH\"\n"
|
al@590
|
243 fi
|
al@590
|
244 mv $pkgsrc $pkgsrc-$BRANCH
|
al@728
|
245 pkgsrc="$pkgsrc-$BRANCH"
|
al@899
|
246 create_tarball
|
al@899
|
247 ;;
|
al@728
|
248
|
pankso@9
|
249 *)
|
al@899
|
250 broken; die 'ERROR: Unable to handle "%s"' "$WGET_URL"
|
al@899
|
251 ;;
|
pankso@9
|
252 esac
|
pankso@1
|
253 }
|
pankso@1
|
254
|
al@728
|
255
|
pankso@9
|
256 # Extract source package.
|
al@728
|
257
|
pankso@1
|
258 extract_source() {
|
pankso@177
|
259 if [ ! -s "$SRC/$TARBALL" ]; then
|
pankso@177
|
260 local url
|
slaxemulator@458
|
261 url="$MIRROR_URL/sources/packages"
|
al@728
|
262 url="$url/${TARBALL:0:1}/$TARBALL"
|
al@728
|
263 _ 'Getting source from %s...' 'mirror'
|
al@728
|
264 _ 'URL: %s' "$url"
|
al@728
|
265 busybox wget -c -P $SRC $url || _ 'ERROR: %s' "wget $url"
|
pankso@177
|
266 fi
|
al@728
|
267 _ 'Extracting source archive "%s"' "$TARBALL"
|
pankso@1
|
268 case "$TARBALL" in
|
al@728
|
269 *.tar.gz|*.tgz) tar -xzf $SRC/$TARBALL 2>/dev/null ;;
|
al@728
|
270 *.tar.bz2|*.tbz|*.tbz2) tar -xjf $SRC/$TARBALL 2>/dev/null ;;
|
al@728
|
271 *.tar.lzma) tar -xaf $SRC/$TARBALL ;;
|
al@728
|
272 *.tar.lz|*.tlz) lzip -d < $SRC/$TARBALL | tar -xf - 2>/dev/null ;;
|
al@728
|
273 *.tar) tar -xf $SRC/$TARBALL ;;
|
al@912
|
274 *.zip|*.xpi) unzip -o $SRC/$TARBALL 2>/dev/null >&2;;
|
al@728
|
275 *.xz) unxz -c $SRC/$TARBALL | tar -xf - || \
|
al@728
|
276 tar -xf $SRC/$TARBALL 2>/dev/null;;
|
psychomaniak@827
|
277 *.7z) 7zr x $SRC/$TARBALL 2>/dev/null >&2 ;;
|
al@728
|
278 *.Z|*.z) uncompress -c $SRC/$TARBALL | tar -xf - ;;
|
al@728
|
279 *.rpm) rpm2cpio $SRC/$TARBALL | cpio -idm --quiet ;;
|
al@728
|
280 *.run) /bin/sh $SRC/$TARBALL $RUN_OPTS ;;
|
al@728
|
281 *) cp $SRC/$TARBALL $(pwd) ;;
|
pankso@1
|
282 esac
|
pankso@1
|
283 }
|
pankso@1
|
284
|
al@728
|
285
|
al@834
|
286 # Display time.
|
al@834
|
287
|
al@834
|
288 disp_time() {
|
al@834
|
289 local sec div min
|
al@834
|
290 sec="$1"
|
al@834
|
291 div=$(( ($1 + 30) / 60))
|
al@834
|
292 case $div in
|
al@834
|
293 0) min='';;
|
al@834
|
294 # L10n: 'm' is for minutes (approximate cooking time)
|
al@834
|
295 *) min=$(_n ' ~ %dm' "$div");;
|
al@834
|
296 esac
|
al@834
|
297
|
al@834
|
298 # L10n: 's' is for seconds (cooking time)
|
al@834
|
299 _ '%ds%s' "$sec" "$min"
|
al@834
|
300 }
|
al@834
|
301
|
al@834
|
302
|
pankso@9
|
303 # Display cooked package summary.
|
al@728
|
304
|
pankso@1
|
305 summary() {
|
al@841
|
306 set_paths
|
pankso@1
|
307 cd $WOK/$pkg
|
slaxemulator@499
|
308 [ -d $WOK/$pkg/install ] && prod=$(du -sh $WOK/$pkg/install | awk '{print $1}' 2>/dev/null)
|
slaxemulator@499
|
309 [ -d $WOK/$pkg/source ] && srcdir=$(du -sh $WOK/$pkg/source | awk '{print $1}' 2>/dev/null)
|
al@728
|
310 [ -n "$TARBALL" ] && srcsize=$(du -sh $SRC/$TARBALL | awk '{print $1}')
|
al@728
|
311
|
al@1003
|
312 _ 'Summary for: %s' "$PACKAGE $VERSION$EXTRAVERSION"
|
pankso@1
|
313 separator
|
al@728
|
314
|
al@596
|
315 # L10n: keep the same width of translations to get a consistent view
|
al@728
|
316 [ -n "$TARBALL" ] && _ 'Src file : %s' "$TARBALL"
|
al@728
|
317 [ -n "$srcsize" ] && _ 'Src size : %s' "$srcsize"
|
al@904
|
318 [ -n "$srcdir" ] && _ 'Source dir : %s' "$srcdir"
|
al@728
|
319 [ -n "$prod" ] && _ 'Produced : %s' "$prod"
|
al@834
|
320 _ 'Cook time : %s' "$(disp_time "$time")"
|
al@728
|
321 _ 'Cook date : %s' "$(date "$(_ '+%%F %%R')")"
|
al@728
|
322 _ 'Host arch : %s' "$ARCH"
|
al@904
|
323
|
al@904
|
324 separator -
|
al@912
|
325 _ ' # : Packed : Compressed : Files : Package name'
|
al@904
|
326 separator -
|
al@904
|
327 pkgi=1
|
al@916
|
328 for i in $(all_names); do
|
al@1003
|
329 fs=$(du -sh $WOK/$pkg/taz/$i-$VERSION$EXTRAVERSION | awk '{print $1}')
|
al@1003
|
330 pkgname="$i-$VERSION$EXTRAVERSION.tazpkg"
|
al@904
|
331 size=$(ls -lh $PKGS/$pkgname | awk '{print $5}')
|
al@1003
|
332 files=$(wc -l < $WOK/$pkg/taz/$i-$VERSION$EXTRAVERSION/files.list)
|
al@912
|
333 printf "%2d : %7s : %10s : %5s : %s\n" "$pkgi" "$fs" "$size" "$files" "$pkgname"
|
al@904
|
334 pkgi=$((pkgi + 1))
|
al@904
|
335 done
|
al@596
|
336 separator
|
pankso@1
|
337 }
|
pankso@1
|
338
|
al@728
|
339
|
paul@62
|
340 # Display debugging error info.
|
al@728
|
341
|
pankso@15
|
342 debug_info() {
|
al@779
|
343 title 'Debug information'
|
al@596
|
344 # L10n: specify your format of date and time (to help: man date)
|
al@596
|
345 # L10n: not bad one is '+%x %R'
|
al@728
|
346 _ 'Cook date: %s' "$(date "$(_ '+%%F %%R')")"
|
al@890
|
347 if [ -n "$time" ]; then
|
al@890
|
348 times="$(($(date +%s) - $time))"
|
al@904
|
349 _ 'Wasted time : %s' "$(disp_time "$times")"
|
al@890
|
350 fi
|
pankso@76
|
351 for error in \
|
al@890
|
352 ERROR 'No package' "cp: can't" "can't open" "can't cd" \
|
al@728
|
353 'error:' 'fatal error:' 'undefined reference to' \
|
al@728
|
354 'Unable to connect to' 'link: cannot find the library' \
|
pascal@797
|
355 'CMake Error' ': No such file or directory' \
|
paul@798
|
356 'Could not read symbols: File in wrong format'
|
pankso@34
|
357 do
|
al@890
|
358 # format "line number:line content"
|
al@890
|
359 fgrep -n "$error" $LOGS/$pkg.log
|
pascal@625
|
360 done > $LOGS/$pkg.log.debug_info 2>&1
|
al@890
|
361 # sort by line number, remove duplicates
|
al@890
|
362 sort -gk1,1 -t: -u $LOGS/$pkg.log.debug_info
|
pascal@625
|
363 rm -f $LOGS/$pkg.log.debug_info
|
al@779
|
364 footer
|
pankso@15
|
365 }
|
pankso@15
|
366
|
al@728
|
367
|
al@887
|
368 # A bit smarter function than the classic `cp` command
|
al@887
|
369
|
al@899
|
370 scopy() {
|
al@899
|
371 if [ "$(stat -c %h -- "$1")" -eq 1 ]; then
|
al@899
|
372 cp -a "$1" "$2" # copy generic files
|
al@894
|
373 else
|
al@887
|
374 cp -al "$1" "$2" # copy hardlinks
|
al@887
|
375 fi
|
al@887
|
376 }
|
al@887
|
377
|
al@887
|
378
|
al@912
|
379 # Copy all generic files (locale, pixmaps, .desktop) from $install to $fs.
|
al@912
|
380 # We use standard paths, so some packages need to copy these files with the
|
al@912
|
381 # receipt and genpkg_rules.
|
al@912
|
382 # This function executes inside the packaging process, before compressor call.
|
al@728
|
383
|
al@728
|
384 copy_generic_files() {
|
al@912
|
385 # Proceed only for "main" package (for v2), and for any packages (v1)
|
al@912
|
386 [ "$pkg" == "$PACKAGE" ] || return 0
|
al@912
|
387
|
pankso@1
|
388 # $LOCALE is set in cook.conf
|
al@728
|
389 if [ -n "$LOCALE" -a -z "$WANTED" ]; then
|
pankso@260
|
390 if [ -d "$install/usr/share/locale" ]; then
|
al@912
|
391 mkdir -p "$fs/usr/share/locale"
|
al@728
|
392 for i in $LOCALE; do
|
al@899
|
393 if [ -d "$install/usr/share/locale/$i" ]; then
|
al@973
|
394 cp -r $install/usr/share/locale/$i $fs/usr/share/locale
|
pankso@1
|
395 fi
|
pankso@1
|
396 done
|
pankso@1
|
397 fi
|
pankso@1
|
398 fi
|
pankso@1
|
399
|
al@834
|
400 # Generic pixmaps copy can be disabled with COOKOPTS="!pixmaps" (or GENERIC_PIXMAPS="no")
|
al@834
|
401 if [ "${COOKOPTS/!pixmaps/}" == "$COOKOPTS" -a "$GENERIC_PIXMAPS" != 'no' ]; then
|
pankso@260
|
402 if [ -d "$install/usr/share/pixmaps" ]; then
|
al@912
|
403 mkdir -p "$fs/usr/share/pixmaps"
|
al@890
|
404 for i in png xpm; do
|
al@913
|
405 [ -f "$install/usr/share/pixmaps/$PACKAGE.$i" -a ! -f "$fs/usr/share/pixmaps/$PACKAGE.$i" ] &&
|
al@973
|
406 cp -r $install/usr/share/pixmaps/$PACKAGE.$i $fs/usr/share/pixmaps
|
al@890
|
407 done
|
pankso@1
|
408 fi
|
pankso@1
|
409 fi
|
pankso@1
|
410
|
pankso@1
|
411 # Desktop entry (.desktop).
|
al@834
|
412 # Generic desktop entry copy can be disabled with COOKOPTS="!menus" (or GENERIC_MENUS="no")
|
al@834
|
413 if [ "${COOKOPTS/!menus/}" == "$COOKOPTS" -a "$GENERIC_MENUS" != 'no' ]; then
|
al@912
|
414 if [ -d "$install/usr/share/applications" -a -z "$WANTED" ]; then
|
al@912
|
415 mkdir -p "$fs/usr/share"
|
al@973
|
416 cp -r $install/usr/share/applications $fs/usr/share
|
erjo@284
|
417 fi
|
pankso@1
|
418 fi
|
al@912
|
419 }
|
al@912
|
420
|
al@912
|
421
|
al@912
|
422 # Copy pixmaps, desktop files and licenses from $stuff to $install.
|
al@912
|
423 # This function executes after the main compile_rules() is done.
|
al@912
|
424
|
al@912
|
425 copy_generic_stuff() {
|
al@912
|
426 # Custom or homemade PNG pixmap can be in stuff.
|
al@912
|
427 if [ -f "$stuff/$PACKAGE.png" ]; then
|
al@912
|
428 mkdir -p $install/usr/share/pixmaps
|
al@912
|
429 cp $stuff/$PACKAGE.png $install/usr/share/pixmaps
|
al@912
|
430 fi
|
pankso@1
|
431
|
pankso@1
|
432 # Homemade desktop file(s) can be in stuff.
|
pankso@1
|
433 if [ -d "$stuff/applications" ]; then
|
al@912
|
434 mkdir -p $install/usr/share
|
al@973
|
435 cp -r $stuff/applications $install/usr/share
|
pankso@1
|
436 fi
|
pankso@1
|
437 if [ -f "$stuff/$PACKAGE.desktop" ]; then
|
al@912
|
438 mkdir -p $install/usr/share/applications
|
al@912
|
439 cp $stuff/$PACKAGE.desktop $install/usr/share/applications
|
pankso@1
|
440 fi
|
pankso@662
|
441
|
slaxemulator@500
|
442 # Add custom licenses
|
slaxemulator@500
|
443 if [ -d "$stuff/licenses" ]; then
|
al@912
|
444 mkdir -p $install/usr/share/licenses
|
al@973
|
445 cp -r $stuff/licenses $install/usr/share/licenses/$PACKAGE
|
slaxemulator@500
|
446 fi
|
pankso@1
|
447 }
|
pankso@1
|
448
|
al@728
|
449
|
al@769
|
450 # Update installed.cook.diff
|
al@769
|
451
|
al@769
|
452 update_installed_cook_diff() {
|
al@769
|
453 # If a cook failed deps are removed.
|
al@769
|
454 cd $root$INSTALLED; ls -1 > $CACHE/installed.cook
|
al@769
|
455 cd $CACHE
|
al@769
|
456 [ "$1" == 'force' -o ! -s '/tmp/installed.cook.diff' ] && \
|
al@769
|
457 busybox diff installed.list installed.cook > /tmp/installed.cook.diff
|
al@931
|
458 deps=$(grep ^+[a-zA-Z0-9] /tmp/installed.cook.diff | wc -l)
|
al@769
|
459 }
|
al@769
|
460
|
al@769
|
461
|
pankso@8
|
462 # Remove installed deps.
|
al@728
|
463
|
pankso@8
|
464 remove_deps() {
|
pankso@8
|
465 # Now remove installed build deps.
|
al@728
|
466 diff='/tmp/installed.cook.diff'
|
al@899
|
467 [ -s "$diff" ] || return
|
al@899
|
468
|
al@931
|
469 deps=$(grep ^+[a-zA-Z0-9] $diff | sed 's|^+||')
|
al@931
|
470 nb=$(grep ^+[a-zA-Z0-9] $diff | wc -l)
|
al@899
|
471 newline
|
al@899
|
472 _n 'Build dependencies to remove:'; echo " $nb"
|
al@899
|
473 [ -n "$root" ] && echo "root=\"$root\""
|
al@899
|
474 {
|
al@728
|
475 _n 'Removing:'
|
al@728
|
476 for dep in $deps; do
|
pankso@8
|
477 echo -n " $dep"
|
al@982
|
478 # Do not waste time uninstalling the packages if we are inside
|
al@982
|
479 # aufs chroot - unmounting chroot will "uninstall" all packages.
|
al@982
|
480 [ -s /aufs-umount.sh ] ||
|
pankso@426
|
481 echo 'y' | tazpkg remove $dep --root=$root >/dev/null
|
pankso@8
|
482 done
|
al@949
|
483 } | busybox fold -sw80
|
al@982
|
484 newline; newline
|
al@982
|
485 # Keep the last diff for debug and info.
|
al@982
|
486 mv -f $diff $CACHE/installed.diff
|
al@899
|
487 }
|
al@899
|
488
|
al@899
|
489
|
paul@900
|
490 # Automatically patch the sources.
|
al@899
|
491
|
al@899
|
492 patchit() {
|
al@899
|
493 [ -f "$stuff/patches/series" ] || return
|
al@899
|
494
|
al@938
|
495 IFS=$'\n'
|
al@899
|
496 while read i; do
|
al@940
|
497 patchname=$(echo ${i%%#*} | cut -d' ' -f1) # allow comments (anything after the # or space)
|
al@984
|
498 case $patchname in # allow patch options in form <options_no_spaces>|<file_name>
|
al@984
|
499 *\|*) patchopts="${patchname%|*}"; patchname="${patchname#*|}";;
|
al@984
|
500 *) patchopts='-Np1';;
|
al@984
|
501 esac
|
al@938
|
502 [ -n "$patchname" ] || continue # allow empty lines
|
al@938
|
503 [ -f "$src/done.$patchname" ] && continue # already applied (useful with `cook --continue`)
|
al@912
|
504 newline
|
al@938
|
505 _ 'Applying patch %s' "$patchname"
|
al@984
|
506 patch $patchopts -i $stuff/patches/$patchname | sed 's|^| |'
|
al@938
|
507 touch $src/done.$patchname
|
al@899
|
508 done < $stuff/patches/series
|
al@912
|
509 newline
|
al@938
|
510 unset IFS
|
pankso@1
|
511 }
|
pankso@1
|
512
|
al@834
|
513
|
al@907
|
514 # Check source tarball integrity.
|
al@907
|
515
|
al@907
|
516 check_integrity() {
|
al@909
|
517 for i in sha1 sha3 sha256 sha512 md5; do
|
al@909
|
518 I=$(echo $i | tr 'a-z' 'A-Z')
|
al@909
|
519 eval sum=\$TARBALL_$I
|
al@909
|
520 if [ -n "$sum" ]; then
|
al@909
|
521 newline
|
al@909
|
522 _ 'Checking %ssum of source tarball...' "$i"
|
al@909
|
523 echo "$sum $SRC/$TARBALL" | ${i}sum -c || exit 1
|
al@909
|
524 fi
|
al@909
|
525 done
|
al@909
|
526 newline
|
al@907
|
527 }
|
al@907
|
528
|
al@907
|
529
|
pankso@1
|
530 # The main cook function.
|
al@728
|
531
|
pankso@1
|
532 cookit() {
|
al@899
|
533 if [ -n "$SETUP_MD5" -a "$SETUP_MD5" != "$(ls $root$INSTALLED | md5sum | cut -c1-32)" ]; then
|
pascal@883
|
534 _ 'ERROR: Broken setup. Abort.'
|
pascal@883
|
535 return
|
pascal@882
|
536 fi
|
pascal@882
|
537
|
al@779
|
538 title 'Cook: %s' "$PACKAGE $VERSION"
|
pankso@1
|
539 set_paths
|
pankso@359
|
540
|
pankso@377
|
541 # Handle cross-tools.
|
pankso@359
|
542 case "$ARCH" in
|
pankso@675
|
543 arm*|x86_64)
|
paul@387
|
544 # CROSS_COMPILE is used by at least Busybox and the kernel to set
|
al@596
|
545 # the cross-tools prefix. Sysroot is the root of our target arch
|
al@728
|
546 sysroot="$CROSS_TREE/sysroot"
|
al@728
|
547 tools="$CROSS_TREE/tools"
|
pankso@443
|
548 # Set root path when cross compiling. ARM tested but not x86_64
|
pankso@443
|
549 # When cross compiling we must install build deps in $sysroot.
|
al@737
|
550 arch="-$ARCH"
|
al@728
|
551 root="$sysroot"
|
al@728
|
552 _ '%s sysroot: %s' "$ARCH" "$sysroot"
|
al@728
|
553 _ 'Adding "%s" to PATH' "$tools/bin"
|
al@728
|
554 export PATH="$PATH:$tools/bin"
|
al@728
|
555 export PKG_CONFIG_PATH="$sysroot/usr/lib/pkgconfig"
|
al@737
|
556 export CROSS_COMPILE="$HOST_SYSTEM-"
|
al@728
|
557 _ 'Using cross-tools: %s' "$CROSS_COMPILE"
|
al@728
|
558 if [ "$ARCH" == 'x86_64' ]; then
|
al@737
|
559 export CC="$HOST_SYSTEM-gcc -m64"
|
al@737
|
560 export CXX="$HOST_SYSTEM-g++ -m64"
|
pankso@438
|
561 else
|
al@737
|
562 export CC="$HOST_SYSTEM-gcc"
|
al@737
|
563 export CXX="$HOST_SYSTEM-g++"
|
pankso@438
|
564 fi
|
al@737
|
565 export AR="$HOST_SYSTEM-ar"
|
al@737
|
566 export AS="$HOST_SYSTEM-as"
|
al@737
|
567 export RANLIB="$HOST_SYSTEM-ranlib"
|
al@737
|
568 export LD="$HOST_SYSTEM-ld"
|
al@737
|
569 export STRIP="$HOST_SYSTEM-strip"
|
al@899
|
570 export LIBTOOL="$HOST_SYSTEM-libtool"
|
al@899
|
571 ;;
|
pankso@359
|
572 esac
|
pankso@359
|
573
|
al@1012
|
574 [ -n "$QA" ] && @@PREFIX@@/libexec/cookutils/precheck $receipt # former receipt_quality()
|
al@904
|
575
|
pankso@44
|
576 cd $pkgdir
|
al@728
|
577 [ -z "$continue" ] && rm -rf source 2>/dev/null
|
al@728
|
578 rm -rf install taz 2>/dev/null
|
pankso@1
|
579
|
al@860
|
580 # Disable -pipe if less than 512 MB free RAM.
|
al@860
|
581 free=$(awk '/^MemFree|^Buffers|^Cached/{s+=$2}END{print int(s/1024)}' /proc/meminfo)
|
al@860
|
582 if [ "$free" -lt 512 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
|
al@860
|
583 _ 'Disabling -pipe compile flag: %d MB RAM free' "$free"
|
al@728
|
584 CFLAGS="${CFLAGS/-pipe}"; CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
|
al@728
|
585 CXXFLAGS="${CXXFLAGS/-pipe}"; CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
|
pankso@1
|
586 fi
|
pankso@1
|
587 unset free
|
pankso@1
|
588
|
pankso@232
|
589 # Export flags and path to be used by make and receipt.
|
al@728
|
590 DESTDIR="$pkgdir/install"
|
al@596
|
591 # FIXME: L10n: Is this the right time for 'LC_ALL=C LANG=C'?
|
pankso@232
|
592 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS CONFIG_SITE LC_ALL=C LANG=C
|
pankso@358
|
593 #LDFLAGS
|
pankso@1
|
594
|
al@904
|
595 # BUILD_DEPENDS may vary depending on the ARCH
|
al@904
|
596 case "$ARCH" in
|
al@904
|
597 arm*) [ -n "$BUILD_DEPENDS_arm" ] && BUILD_DEPENDS=$BUILD_DEPENDS_arm ;;
|
al@904
|
598 x86_64) [ -n "$BUILD_DEPENDS_x86_64" ] && BUILD_DEPENDS=$BUILD_DEPENDS_x86_64 ;;
|
al@904
|
599 esac
|
al@904
|
600
|
pankso@126
|
601 # Check for build deps and handle implicit depends of *-dev packages
|
pankso@126
|
602 # (ex: libusb-dev :: libusb).
|
al@912
|
603 # rm -f $CACHE/installed.local $CACHE/installed.web $CACHE/missing.dep
|
al@912
|
604 # touch $CACHE/installed.local $CACHE/installed.web
|
al@728
|
605 [ -n "$BUILD_DEPENDS" ] && _ 'Checking build dependencies...'
|
al@728
|
606 [ -n "$root" ] && _ 'Using packages DB: %s' "$root$DB"
|
al@899
|
607
|
al@935
|
608 # Get the list of installed packages
|
al@935
|
609 cd $root$INSTALLED; ls > $CACHE/installed.list
|
al@935
|
610
|
al@912
|
611 for action in check install; do
|
al@912
|
612 for dep in $BUILD_DEPENDS; do
|
al@912
|
613 implicit="${dep%-dev}"; [ "$implicit" == "$dep" ] && implicit=''
|
al@912
|
614 for i in $dep $implicit; do
|
al@912
|
615 # Skip if package already installed
|
al@912
|
616 [ -f "$root$INSTALLED/$i/receipt" ] && continue
|
al@899
|
617
|
al@912
|
618 case $action in
|
al@912
|
619 check)
|
al@912
|
620 # Search for local package or local provided-package
|
al@912
|
621 name=$(awk -F$'\t' -vpkg="$i" '{
|
al@912
|
622 if (index(" " $1 " " $10 " ", " " pkg " ")) {print $1; exit}
|
al@912
|
623 }' "$PKGS/packages.info")
|
al@912
|
624 if [ -z "$name" ]; then
|
al@912
|
625 # Search for package in mirror
|
al@912
|
626 name="$(awk -F$'\t' -vi="$i" '$1==i{print $1; exit}' "$root$DB/packages.info")"
|
al@912
|
627 [ -z "$name" -a "$i" == "$dep" ] && die 'ERROR: unknown dep "%s"' "$i"
|
al@912
|
628 fi
|
al@912
|
629 ;;
|
al@912
|
630 install)
|
al@912
|
631 tazpkg get-install $i --root=$root --local --quiet --cookmode || { broken; exit 1; }
|
al@912
|
632 ;;
|
al@912
|
633 esac
|
al@912
|
634 done
|
pankso@126
|
635 done
|
pankso@1
|
636 done
|
pankso@225
|
637
|
al@912
|
638 # # Have we a missing build dep to cook?
|
al@912
|
639 # if [ -s "$CACHE/missing.dep" ] && [ -n "$AUTO_COOK" ]; then
|
al@912
|
640 # _ 'Auto cook config is set: %s' "$AUTO_COOK"
|
al@912
|
641 # cp -f $LOGS/$PACKAGE.log $LOGS/$PACKAGE.log.$$
|
al@912
|
642 # for i in $(uniq $CACHE/missing.dep); do
|
al@912
|
643 # (_ 'Building dep (wok/pkg) : %s' "$i $vers") | \
|
al@912
|
644 # tee -a $LOGS/$PACKAGE.log.$$
|
al@912
|
645 # # programmers: next two messages are exact copy from remove_deps()
|
al@912
|
646 # togrep1=$(_n 'Build dependencies to remove:')
|
al@912
|
647 # togrep2=$(_n 'Removing:')
|
al@912
|
648 # cook $i || (_ "ERROR: can't cook dep \"%s\"" "$i" && newline && \
|
al@912
|
649 # fgrep $togrep1 $LOGS/$i.log && \
|
al@912
|
650 # fgrep $togrep2 $LOGS/$i.log && newline) | \
|
al@912
|
651 # tee -a $LOGS/$PACKAGE.log.$$ && break
|
al@912
|
652 # done
|
al@912
|
653 # rm -f $CACHE/missing.dep
|
al@912
|
654 # mv $LOGS/$PACKAGE.log.$$ $LOGS/$PACKAGE.log
|
al@912
|
655 # fi
|
al@912
|
656 #
|
al@912
|
657 # # QA: Exit on missing dep errors. We exit in both cases, if AUTO_COOK
|
al@912
|
658 # # is enabled and cook fails we have ERROR in log, if no auto cook we have
|
al@912
|
659 # # missing dep in cached file.
|
al@912
|
660 # lerror=$(_n 'ERROR')
|
al@912
|
661 # if fgrep -q ^$lerror $LOGS/$pkg.log || [ -s "$CACHE/missing.dep" ]; then
|
al@912
|
662 # [ -s "$CACHE/missing.dep" ] && nb=$(wc -l < $CACHE/missing.dep)
|
al@912
|
663 # _p 'ERROR: missing %d dependency' 'ERROR: missing %d dependencies' "$nb" "$nb"
|
al@912
|
664 # broken; exit 1
|
al@912
|
665 # fi
|
al@912
|
666 #
|
al@912
|
667 # # Install local packages: package-version$arch
|
al@912
|
668 # cd $PKGS
|
al@912
|
669 # for i in $(uniq $CACHE/installed.local); do
|
al@912
|
670 # # _ 'Installing dep (pkg/local): %s' "$i"
|
al@912
|
671 # tazpkg install $i --root=$root --local --quiet --cookmode
|
al@912
|
672 # done
|
al@912
|
673 #
|
al@912
|
674 # # Install web or cached packages (if mirror is set to $PKGS we only
|
al@912
|
675 # # use local packages).
|
al@912
|
676 # for i in $(uniq $CACHE/installed.web); do
|
al@912
|
677 # # _ 'Installing dep (web/cache): %s' "$i"
|
al@912
|
678 # tazpkg get-install $i --root=$root --local --quiet --cookmode
|
al@912
|
679 # done
|
pankso@358
|
680
|
al@769
|
681 update_installed_cook_diff
|
pankso@202
|
682
|
pankso@1
|
683 # Get source tarball and make sure we have source dir named:
|
paul@62
|
684 # $PACKAGE-$VERSION to be standard in receipts. Here we use tar.lzma
|
paul@62
|
685 # tarball if it exists.
|
al@909
|
686 if [ -n "$WGET_URL" -a ! -f "$SRC/$TARBALL" ]; then
|
pankso@1
|
687 if [ -f "$SRC/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
|
al@728
|
688 TARBALL="${SOURCE:-$PACKAGE}-$VERSION.tar.lzma"
|
al@728
|
689 LZMA_SRC=''
|
pankso@1
|
690 else
|
al@899
|
691 get_source || { broken; exit 1; }
|
pankso@1
|
692 fi
|
pankso@1
|
693 fi
|
al@909
|
694 if [ -z "$WANTED" -a -n "$TARBALL" -a ! -d "$src" ]; then
|
al@728
|
695 mkdir -p $pkgdir/source/tmp; cd $pkgdir/source/tmp
|
pascal@268
|
696 if ! extract_source ; then
|
pascal@268
|
697 get_source
|
al@899
|
698 extract_source || { broken; exit 1; }
|
pascal@268
|
699 fi
|
al@728
|
700 if [ -n "$LZMA_SRC" ]; then
|
pankso@190
|
701 cd $pkgdir/source
|
al@909
|
702 if [ "$(ls -A tmp | wc -l)" -gl 1 -o -f "$(echo tmp/*)" ]; then
|
al@728
|
703 mv tmp tmp-1; mkdir tmp
|
pankso@190
|
704 mv tmp-1 tmp/${SOURCE:-$PACKAGE}-$VERSION
|
pankso@190
|
705 fi
|
pankso@190
|
706 if [ -d "tmp/${SOURCE:-$PACKAGE}-$VERSION" ]; then
|
al@728
|
707 cd tmp; tar -c * | lzma e $SRC/$TARBALL -si
|
pankso@190
|
708 fi
|
pankso@190
|
709 fi
|
al@1008
|
710
|
pankso@190
|
711 cd $pkgdir/source/tmp
|
paul@62
|
712 # Some archives are not well done and don't extract to one dir (ex lzma).
|
pankso@57
|
713 files=$(ls | wc -l)
|
al@1008
|
714 [ "$files" -eq 1 -a -d "$(ls)" ] &&
|
al@1008
|
715 mv * ../$PACKAGE-$VERSION
|
al@1008
|
716 [ "$files" -eq 1 -a -f "$(ls)" ] &&
|
al@1008
|
717 mkdir -p ../$PACKAGE-$VERSION &&
|
al@1008
|
718 mv * ../$PACKAGE-$VERSION/$TARBALL
|
al@1008
|
719 [ "$files" -gt 1 ] &&
|
al@1008
|
720 mkdir -p ../$PACKAGE-$VERSION &&
|
al@1008
|
721 mv * ../$PACKAGE-$VERSION
|
al@728
|
722 cd ..; rm -rf tmp
|
pankso@1
|
723 fi
|
pankso@662
|
724
|
al@1008
|
725 # Check md5sum (or similar) for sources tarball
|
al@909
|
726 check_integrity
|
al@909
|
727
|
pankso@658
|
728 # Libtool shared libs path hack.
|
pankso@658
|
729 case "$ARCH" in
|
pankso@658
|
730 arm*) cross libhack ;;
|
pankso@658
|
731 esac
|
pankso@1
|
732
|
al@1008
|
733 # Compiling all the sets
|
pankso@44
|
734 if grep -q ^compile_rules $receipt; then
|
al@728
|
735 _ 'Executing: %s' 'compile_rules'
|
pankso@352
|
736 echo "CFLAGS : $CFLAGS"
|
pankso@358
|
737 #echo "LDFLAGS : $LDFLAGS"
|
pankso@55
|
738 [ -d "$src" ] && cd $src
|
al@899
|
739 patchit
|
al@809
|
740
|
al@1008
|
741 # Get set names from $SPLIT variable, format ex. 'pkg1 pkg2:set1 pkg3:set2'
|
al@1008
|
742 SETS=$(echo $SPLIT \
|
al@1008
|
743 | awk '
|
al@1008
|
744 BEGIN { RS = " "; FS = ":"; }
|
al@1008
|
745 { print $2; }' \
|
al@1008
|
746 | sort -u \
|
al@1008
|
747 | tr '\n' ' ')
|
al@1008
|
748 SETS=${SETS% } # normalize space
|
al@1008
|
749 # Prepare specified source sets using patched sources
|
al@1008
|
750 [ -n "$SETS" ] &&
|
al@1008
|
751 for set in $SETS; do
|
al@1008
|
752 echo "Preparing set $set" # debug
|
al@1008
|
753 cp -a $src $src-$set
|
al@1008
|
754 done
|
al@912
|
755
|
al@1008
|
756 for SET in '' $SETS; do
|
al@1008
|
757 # Switch to the specified source set
|
al@1008
|
758 set_paths
|
al@1008
|
759 local suffix=''
|
al@1008
|
760 [ -n "$SET" ] && suffix="-$SET"
|
al@1008
|
761 export src="$WOK/$pkg/source/$PACKAGE-$VERSION$suffix"
|
al@1008
|
762 export install="$WOK/$pkg/install$suffix"
|
al@1008
|
763 export DESTDIR="$install"
|
al@1008
|
764
|
al@1008
|
765 if [ -n "$SETS" ]; then
|
al@1008
|
766 if [ -n "$SET" ]; then
|
al@1008
|
767 title "Switching to the set '$SET'"
|
al@1008
|
768 else
|
al@1008
|
769 title "Switching to the default set"
|
al@1008
|
770 fi
|
al@1008
|
771 echo "src : $src"
|
al@1008
|
772 echo "install: $install"
|
al@1008
|
773 fi
|
al@1015
|
774 [ -d "$src" ] && cd $src # packages without sources exists
|
al@1008
|
775 echo
|
al@1008
|
776
|
al@1008
|
777 [ -d "$install" ] && rm -r $install
|
al@1008
|
778 mkdir -p $install
|
al@1008
|
779
|
al@1008
|
780 compile_rules $@ || { broken; exit 1; }
|
al@1008
|
781
|
al@1008
|
782 # Stay compatible with _pkg
|
al@1008
|
783 [ -d "$src/_pkg" ] && mv $src/_pkg $install
|
al@1008
|
784
|
al@1008
|
785 copy_generic_stuff
|
al@1008
|
786
|
al@1008
|
787 # Actions to do after compiling the package
|
al@1008
|
788 # Skip all for split packages (already done in main package)
|
al@1008
|
789 if [ -z "$WANTED" ]; then
|
al@1008
|
790 footer
|
al@1008
|
791 export COOKOPTS ARCH install
|
al@1008
|
792 @@PREFIX@@/libexec/cookutils/compressor install
|
al@1008
|
793 fi
|
al@1008
|
794 done
|
al@1013
|
795 else
|
al@1013
|
796 mkdir -p $install # allow receipts without `compile_rules()`
|
al@837
|
797 fi
|
al@779
|
798 footer
|
pankso@360
|
799
|
pankso@360
|
800 # Execute testsuite.
|
pankso@360
|
801 if grep -q ^testsuite $receipt; then
|
al@779
|
802 title 'Running testsuite'
|
al@899
|
803 testsuite $@ || { broken; exit 1; }
|
al@779
|
804 footer
|
pankso@360
|
805 fi
|
al@769
|
806
|
al@769
|
807 update_installed_cook_diff force
|
pankso@1
|
808 }
|
pankso@1
|
809
|
al@728
|
810
|
pankso@1
|
811 # Cook quality assurance.
|
al@728
|
812
|
pankso@1
|
813 cookit_quality() {
|
al@989
|
814 while true; do
|
al@989
|
815 [ ! -d "$WOK/$pkg/install" -a -z "$WANTED" ] || break
|
al@728
|
816 _ 'ERROR: cook failed' | tee -a $LOGS/$pkg.log
|
al@989
|
817 [ "$trials" == 'yes' ] || break
|
al@989
|
818 title "Interactive mode"
|
al@989
|
819 # TODO: allow commands:
|
al@989
|
820 # q - quit; v - edit receipt here using vi;
|
al@989
|
821 # s - search for package containing package;
|
al@989
|
822 # <package name> - install package; [Enter] - retry
|
al@989
|
823 _ 'You may install the packages here and/or edit the receipt there.'
|
al@989
|
824 newline
|
al@989
|
825 while true; do
|
al@989
|
826 _n 'Install the package? [name/N] '; read answer
|
al@989
|
827 [ -n "$answer" ] || break
|
al@989
|
828 tazpkg -gi $answer --root=$root --local --quiet --cookmode
|
al@989
|
829 done
|
al@989
|
830 newline
|
al@989
|
831 _n 'Try again? [Y/n] '; read answer
|
al@989
|
832 [ "$answer" == 'n' ] && break
|
paul@993
|
833 # here you may append log if you want (">>" instead of last ">")
|
al@989
|
834 cookit $@ 2>&1 | loglimit 50 > $LOGS/$pkg.log
|
al@989
|
835 done
|
al@962
|
836
|
al@962
|
837 [ "${COOKOPTS/skip-log-errors/}" != "$COOKOPTS" ] && return 0
|
al@962
|
838
|
pankso@9
|
839 # ERROR can be echoed any time in cookit()
|
pascal@618
|
840 if grep -Ev "(conftest|configtest)" $LOGS/$pkg.log | \
|
al@962
|
841 grep -Eq "(^ERROR|undefined reference to)" ; then
|
pankso@17
|
842 debug_info | tee -a $LOGS/$pkg.log
|
al@992
|
843 put_status $pkg Failed
|
al@728
|
844 rm -f $command
|
al@899
|
845 broken; exit 1
|
pankso@1
|
846 fi
|
pankso@1
|
847 }
|
pankso@1
|
848
|
al@728
|
849
|
al@728
|
850 # Create the package. Wanted to use TazPkg to create a tazpkg package at first,
|
paul@62
|
851 # but it doesn't handle EXTRAVERSION.
|
al@728
|
852
|
pankso@1
|
853 packit() {
|
al@904
|
854 set_paths "$1"
|
al@904
|
855 PACKAGE="${1:-$PACKAGE}"
|
pankso@359
|
856
|
pankso@359
|
857 # Handle cross compilation
|
pankso@359
|
858 case "$ARCH" in
|
pankso@676
|
859 arm*|x86_64) arch="-$ARCH" ;;
|
pankso@359
|
860 esac
|
pankso@359
|
861
|
al@779
|
862 title 'Pack: %s' "$PACKAGE $VERSION$arch"
|
pankso@359
|
863
|
pankso@44
|
864 if grep -q ^genpkg_rules $receipt; then
|
al@728
|
865 _ 'Executing: %s' 'genpkg_rules'
|
al@728
|
866 set -e; cd $pkgdir; mkdir -p $fs
|
al@728
|
867 genpkg_rules || (newline; _ 'ERROR: genpkg_rules failed'; newline) >> \
|
pankso@234
|
868 $LOGS/$pkg.log
|
pankso@241
|
869 else
|
al@728
|
870 _ 'No packages rules: meta package'
|
pankso@241
|
871 mkdir -p $fs
|
pankso@16
|
872 fi
|
pankso@98
|
873
|
al@859
|
874 # Check CONFIG_FILES
|
al@859
|
875 if [ -n "$CONFIG_FILES" ]; then
|
al@912
|
876 unset IFS
|
al@859
|
877 for i in $CONFIG_FILES; do
|
al@859
|
878 if [ ! -e $fs$i ]; then
|
al@859
|
879 case $i in
|
al@859
|
880 */) mkdir -p $fs$i ;;
|
al@859
|
881 *) mkdir -p $fs$(dirname $i); touch $fs$i ;;
|
al@859
|
882 esac
|
al@859
|
883 fi
|
al@859
|
884 done
|
al@859
|
885 fi
|
al@859
|
886
|
pankso@98
|
887 # First QA check to stop now if genpkg_rules failed.
|
al@728
|
888 lerror=$(_n 'ERROR')
|
pascal@613
|
889 if fgrep -q ^$lerror $LOGS/$pkg.log; then
|
al@899
|
890 broken; exit 1
|
pankso@98
|
891 fi
|
pankso@358
|
892
|
pankso@44
|
893 cd $taz
|
al@904
|
894 action 'Copying "%s"...' 'receipt'
|
al@1002
|
895 export PACKAGE DEPENDS PROVIDE SUGGESTED TAZPANEL_DAEMON TAGS CAT
|
al@1001
|
896 @@PREFIX@@/libexec/cookutils/mk_pkg_receipt "$(realpath ../receipt)" > $pack/receipt
|
al@904
|
897 chown 0.0 $pack/receipt; status
|
al@904
|
898
|
al@904
|
899 unset desc
|
al@904
|
900 [ "$pkg" == "$PACKAGE" -a -f "../description.txt" ] && desc="../description.txt"
|
al@904
|
901 [ -f "../description.$PACKAGE.txt" ] && desc="../description.$PACKAGE.txt"
|
al@904
|
902 if [ -n "$desc" ]; then
|
al@904
|
903 action 'Copying "%s"...' "$(basename "$desc")"
|
al@904
|
904 cp -f $desc $pack/description.txt; chown 0.0 $pack/description.txt; status
|
al@904
|
905 fi
|
al@904
|
906
|
pankso@119
|
907 copy_generic_files
|
pankso@358
|
908
|
pankso@119
|
909 # Strip and stuff files.
|
al@865
|
910 export COOKOPTS ARCH HOST_SYSTEM LOCALE fs; @@PREFIX@@/libexec/cookutils/compressor fs
|
pankso@43
|
911
|
al@728
|
912 # Create files.list with redirecting find output.
|
al@779
|
913 action 'Creating the list of files...'
|
al@728
|
914 cd $fs
|
al@951
|
915 find . -type f -print > ../files.list
|
al@728
|
916 find . -type l -print >> ../files.list
|
al@931
|
917 cd ..; sed -i 's|^.||' files.list
|
al@728
|
918 status
|
al@728
|
919
|
pankso@43
|
920 # Md5sum of files.
|
al@779
|
921 action 'Creating md5sum of files...'
|
pankso@16
|
922 while read file; do
|
pankso@16
|
923 [ -L "fs$file" ] && continue
|
pankso@16
|
924 [ -f "fs$file" ] || continue
|
pankso@16
|
925 case "$file" in
|
pankso@232
|
926 /lib/modules/*/modules.*|*.pyc) continue ;;
|
pankso@16
|
927 esac
|
al@931
|
928 md5sum "fs$file" | sed 's| fs| |'
|
al@953
|
929 done < files.list | sort -k2 > md5sum
|
pankso@16
|
930 status
|
al@728
|
931
|
al@728
|
932 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
|
al@728
|
933 2>/dev/null | awk 'END{ print $1 }')
|
pankso@358
|
934
|
al@904
|
935 # Build cpio archive.
|
al@779
|
936 action 'Compressing the FS...'
|
al@904
|
937 find fs -newer $receipt -exec touch -hr $receipt '{}' \;
|
al@969
|
938 find fs | cpio -o -H newc --quiet | lzma-alone e fs.cpio.lzma -si
|
al@969
|
939 # find fs | cpio -o -H newc --quiet | /bin/lzma -zeT0 -vv >fs.cpio.lzma
|
al@904
|
940 mv fs ../
|
pankso@16
|
941 status
|
al@728
|
942
|
al@728
|
943 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list md5sum description.txt \
|
al@728
|
944 2>/dev/null | awk 'END{ print $1 }')
|
al@728
|
945
|
al@779
|
946 action 'Updating receipt sizes...'
|
al@931
|
947 sed -i '/^PACKED_SIZE=/d; /^UNPACKED_SIZE=/d' receipt
|
al@931
|
948 sed -i "s|^PACKAGE=|PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=|" receipt
|
pankso@16
|
949 status
|
pankso@16
|
950
|
pankso@16
|
951 # Set extra version.
|
al@728
|
952 if [ -n "$EXTRAVERSION" ]; then
|
al@779
|
953 action 'Updating receipt EXTRAVERSION: %s' "$EXTRAVERSION"
|
al@931
|
954 sed -i '/^EXTRAVERSION=/d' receipt
|
al@931
|
955 sed -i "s|^VERSION=|EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=|" receipt
|
pankso@16
|
956 status
|
pankso@16
|
957 fi
|
pankso@16
|
958
|
pankso@16
|
959 # Compress.
|
al@779
|
960 action 'Creating full cpio archive...'
|
al@904
|
961 find . -newer $receipt -exec touch -hr $receipt '{}' \;
|
al@904
|
962 find . | cpio -o -H newc --quiet > ../$PACKAGE-$VERSION$EXTRAVERSION$arch.tazpkg
|
pankso@16
|
963 status
|
al@728
|
964
|
al@1010
|
965 # Restoring original package tree.
|
al@904
|
966 mv ../fs .
|
al@728
|
967
|
al@728
|
968 rm fs.cpio.lzma; cd ..
|
pankso@43
|
969
|
pankso@43
|
970 # QA and give info.
|
pankso@43
|
971 tazpkg=$(ls *.tazpkg)
|
pankso@43
|
972 packit_quality
|
al@779
|
973 footer "$(_ 'Package "%s" created' "$tazpkg")"
|
al@932
|
974 update_packages_db
|
pankso@1
|
975 }
|
pankso@1
|
976
|
al@728
|
977
|
al@952
|
978 # Calculate release checksum: usually it does not change on "just recook".
|
al@952
|
979 # Release checksum is md5sum of file containing md5sums of:
|
al@952
|
980 # a) all files, b) receipt, and c) description.txt.
|
al@952
|
981 # Md5sum of the package file will change every time because of embedded timestamps;
|
al@952
|
982 # release checksum based only on files content, and will change only when files change.
|
al@952
|
983 # (Pitfall: ownership and permissions...)
|
al@952
|
984
|
al@952
|
985 release_checksum() {
|
al@952
|
986 local pack=$1
|
al@952
|
987 local rsum_file=$(mktemp)
|
al@952
|
988
|
al@952
|
989 cp $pack/md5sum $rsum_file
|
al@952
|
990 md5sum $pack/receipt | sed 's| [^ ]*/| |' >> $rsum_file
|
al@952
|
991 [ -e "$pack/description.txt" ] &&
|
al@952
|
992 md5sum $pack/description.txt | sed 's| [^ ]*/| |' >> $rsum_file
|
al@952
|
993
|
al@952
|
994 local rsum=$(md5sum $rsum_file | awk '{print $1}')
|
al@952
|
995 rm $rsum_file
|
al@952
|
996 local rsumold=$(awk -F$'\t' -vpkg="$PACKAGE" '
|
al@952
|
997 {if ($1 == pkg) { print $9; exit; }}' $PKGS/packages.info)
|
al@952
|
998
|
al@952
|
999 [ "$rsum" == "$rsumold" ] && rsum=''
|
al@952
|
1000
|
al@952
|
1001 echo $rsum
|
al@952
|
1002 }
|
al@952
|
1003
|
al@952
|
1004
|
paul@62
|
1005 # Verify package quality and consistency.
|
al@728
|
1006
|
pankso@8
|
1007 packit_quality() {
|
al@779
|
1008 #action 'QA: checking for broken link...'
|
pankso@157
|
1009 #link=$(find $fs/usr -type l -follow)
|
pankso@157
|
1010 #[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
|
pankso@157
|
1011 #status
|
pankso@358
|
1012
|
al@969
|
1013 if [ "${COOKOPTS/skip-log-errors/}" == "$COOKOPTS" ]; then
|
al@969
|
1014 # Exit if any error found in log file.
|
al@969
|
1015 if fgrep -q ^ERROR $LOGS/$pkg.log; then
|
al@969
|
1016 rm -f $command
|
al@969
|
1017 broken; exit 1
|
al@969
|
1018 fi
|
pankso@8
|
1019 fi
|
pankso@358
|
1020
|
al@1012
|
1021 [ -n "$CAT" ] && CATEGORY="${CAT%|*}" # allow meta-packages in v2 receipts
|
al@1012
|
1022
|
al@969
|
1023 if [ "${COOKOPTS/empty-pkg/}" == "$COOKOPTS" ]; then
|
al@969
|
1024 action 'QA: checking for empty package...'
|
al@969
|
1025 if [ ! -s "$pack/files.list" -a "$CATEGORY" != 'meta' ]; then
|
al@969
|
1026 broken
|
al@969
|
1027 rm -f $command
|
al@969
|
1028 false; status
|
al@969
|
1029 die 'ERROR: empty package'
|
al@969
|
1030 fi
|
al@969
|
1031 :; status
|
pankso@8
|
1032 fi
|
al@899
|
1033
|
al@952
|
1034
|
al@952
|
1035 # Find and remove old package(s) only if "release checksum" has changed
|
al@952
|
1036 rsum=$(release_checksum $pack)
|
al@952
|
1037 if [ -n "$rsum" ]; then
|
al@952
|
1038 old_file=$(awk -F$'\t' -vname="$PACKAGE" '{
|
al@952
|
1039 if ($1 == name) printf("%s-%s.tazpkg", $1, $2);
|
al@952
|
1040 }' $PKGS/packages.info)
|
al@952
|
1041 if [ -f "$PKGS/$old_file" ]; then
|
al@952
|
1042 action 'Removing old package "%s"' "$old_file"
|
al@952
|
1043 rm -f "$PKGS/$old_file"
|
al@899
|
1044 status
|
al@899
|
1045 fi
|
al@954
|
1046 # package changed, substitute old package by new
|
al@952
|
1047 mv -f $pkgdir/taz/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg $PKGS
|
al@954
|
1048 else
|
al@954
|
1049 # package not changed, remove new package
|
al@954
|
1050 rm -f $pkgdir/taz/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
|
al@952
|
1051 fi
|
al@952
|
1052
|
al@931
|
1053 sed -i "/^${pkg}$/d" $broken
|
al@899
|
1054 #action 'Removing source tree...'
|
al@899
|
1055 #rm -f $WOK/$pkg/source; status
|
pankso@8
|
1056 }
|
pankso@8
|
1057
|
al@728
|
1058
|
al@916
|
1059 # Return all the names of packages bundled in this receipt
|
al@916
|
1060
|
al@916
|
1061 all_names() {
|
al@1008
|
1062 # Get package names from $SPLIT variable
|
al@1008
|
1063 local split=$(echo $SPLIT \
|
al@1008
|
1064 | awk '
|
al@1008
|
1065 BEGIN { RS = " "; FS = ":"; }
|
al@1008
|
1066 { print $1; }' \
|
al@1008
|
1067 | tr '\n' ' ')
|
al@1008
|
1068 local split_space=" $split "
|
al@940
|
1069 if ! head -n1 $WOK/$pkg/receipt | fgrep -q 'v2'; then
|
al@940
|
1070 # For receipts v1: $SPLIT may present in the $WANTED package,
|
al@940
|
1071 # but split packages have their own receipts
|
al@940
|
1072 echo $PACKAGE
|
al@1008
|
1073 elif [ "${split_space/ $PACKAGE /}" != "$split_space" ]; then
|
al@916
|
1074 # $PACKAGE included somewhere in $SPLIT (probably in the end).
|
al@916
|
1075 # We should build packages in the order defined in the $SPLIT.
|
al@1008
|
1076 echo $split
|
al@916
|
1077 else
|
al@916
|
1078 # We'll build the $PACKAGE, then all defined in the $SPLIT.
|
al@1008
|
1079 echo $PACKAGE $split
|
al@916
|
1080 fi
|
al@916
|
1081 }
|
al@916
|
1082
|
al@916
|
1083
|
al@904
|
1084 # v2: pack all packages using compiled files
|
al@904
|
1085
|
al@904
|
1086 packall() {
|
al@904
|
1087 set_paths
|
al@904
|
1088 if head -n1 "$pkgdir/receipt" | fgrep -q 'v2'; then
|
al@916
|
1089 for i in $(all_names); do
|
al@913
|
1090 unset TAGS DEPENDS CAT CONFIG_FILES PROVIDE SUGGESTED DATABASE_FILES TAZPANEL_DAEMON
|
al@904
|
1091 packit $i
|
al@904
|
1092 done
|
al@904
|
1093 else
|
al@904
|
1094 packit
|
al@904
|
1095 fi
|
al@904
|
1096 }
|
al@904
|
1097
|
al@904
|
1098
|
al@728
|
1099 # Reverse "cat" command: prints input lines in the reverse order
|
al@728
|
1100
|
pankso@421
|
1101 tac() {
|
pascal@285
|
1102 sed '1!G;h;$!d' $1
|
pascal@285
|
1103 }
|
pascal@285
|
1104
|
al@728
|
1105
|
al@907
|
1106 # Update chroot with freshly rebuilt package: keep env up-to-date.
|
al@907
|
1107
|
al@907
|
1108 update_chroot() {
|
al@923
|
1109 local PACKAGE="$pkg"
|
al@923
|
1110 for i in $(all_names); do
|
al@907
|
1111 if [ -d "$root$INSTALLED/$i" ]; then
|
al@907
|
1112 . /etc/slitaz/cook.conf
|
al@1004
|
1113 . $WOK/$pkg/taz/$i-$VERSION$EXTRAVERSION/receipt
|
al@907
|
1114 _ 'Updating %s chroot environment...' "$ARCH"
|
al@907
|
1115 _ 'Updating chroot: %s' "$i ($VERSION$EXTRAVERSION$arch)" | log
|
al@907
|
1116 cd $PKGS
|
al@907
|
1117 tazpkg install $i-$VERSION$EXTRAVERSION$arch.tazpkg --forced --root=$root
|
al@907
|
1118 fi
|
al@907
|
1119 done
|
al@907
|
1120 }
|
al@907
|
1121
|
al@907
|
1122
|
al@907
|
1123 # Install package on --inst or update the chroot.
|
al@728
|
1124
|
pankso@428
|
1125 install_package() {
|
al@953
|
1126 set_paths
|
pankso@428
|
1127 case "$ARCH" in
|
pankso@676
|
1128 arm*|x86_64)
|
al@737
|
1129 arch="-$ARCH"
|
al@728
|
1130 root="$CROSS_TREE/sysroot" ;;
|
pankso@428
|
1131 esac
|
pankso@428
|
1132 # Install package if requested but skip install if target host doesn't
|
pankso@428
|
1133 # match build system or it will break the build chroot.
|
al@728
|
1134 build=$(echo $BUILD_SYSTEM | cut -d- -f1)
|
al@907
|
1135 if [ -n "$inst" -a "$build" == "$ARCH" ]; then
|
al@737
|
1136 if [ -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
|
al@728
|
1137 cd $PKGS
|
al@728
|
1138 tazpkg install $PACKAGE-$VERSION$EXTRAVERSION.tazpkg --forced
|
pankso@428
|
1139 else
|
al@899
|
1140 broken
|
al@899
|
1141 die 'Unable to install package, build has failed.'
|
pankso@428
|
1142 fi
|
pankso@428
|
1143 fi
|
pankso@428
|
1144
|
al@907
|
1145 update_chroot
|
pankso@428
|
1146 }
|
pankso@428
|
1147
|
al@728
|
1148
|
pascal@696
|
1149 # remove chroot jail
|
al@728
|
1150
|
pascal@696
|
1151 umount_aufs() {
|
pascal@696
|
1152 tac ${1}rw/aufs-umount.sh | sh
|
pascal@696
|
1153 rm -rf ${1}rw
|
pascal@696
|
1154 umount ${1}root
|
pascal@697
|
1155 rmdir ${1}r*
|
pascal@696
|
1156 }
|
pascal@696
|
1157
|
al@728
|
1158
|
pascal@285
|
1159 # Launch the cook command into a chroot jail protected by aufs.
|
pascal@285
|
1160 # The current filesystems are used read-only and updates are
|
pascal@285
|
1161 # stored in a separate branch.
|
al@728
|
1162
|
pascal@285
|
1163 try_aufs_chroot() {
|
pascal@285
|
1164
|
al@728
|
1165 base="/dev/shm/aufsmnt$$"
|
pascal@286
|
1166
|
al@596
|
1167 # Can we setup the chroot? Is it already done?
|
pascal@292
|
1168 grep -q ^AUFS_NOT_SUPPORTED $receipt && return
|
al@728
|
1169 grep -q ^AUFS_NOT_RAMFS $receipt && base="/mnt/aufsmnt$$"
|
pascal@285
|
1170 [ -n "$AUFS_MOUNTS" -a ! -f /aufs-umount.sh ] || return
|
pascal@875
|
1171 grep -q ^aufs /proc/modules || modprobe aufs 2> /dev/null || return
|
pascal@286
|
1172 mkdir ${base}root ${base}rw || return
|
pascal@285
|
1173
|
al@728
|
1174 _ 'Setup aufs chroot...'
|
pascal@285
|
1175
|
pascal@285
|
1176 # Sanity check
|
pascal@286
|
1177 for i in / /proc /sys /dev/shm /home ; do
|
pascal@285
|
1178 case " $AUFS_MOUNTS " in
|
pascal@285
|
1179 *\ $i\ *) ;;
|
pascal@285
|
1180 *) AUFS_MOUNTS="$AUFS_MOUNTS $i" ;;
|
pascal@285
|
1181 esac
|
pascal@285
|
1182 done
|
pascal@691
|
1183 for mnt in $(ls -d $AUFS_MOUNTS | sort | uniq); do
|
pascal@285
|
1184 mount --bind $mnt ${base}root$mnt
|
pascal@285
|
1185 if [ $mnt == / ] && ! mount -t aufs -o br=${base}rw:/ none ${base}root; then
|
al@728
|
1186 _ 'Aufs mount failure'
|
slaxemulator@519
|
1187 umount ${base}root
|
pascal@628
|
1188 rm -rf ${base}r*
|
slaxemulator@519
|
1189 return
|
pascal@285
|
1190 fi
|
pascal@285
|
1191 echo "umount ${base}root$mnt" >> ${base}rw/aufs-umount.sh
|
pascal@285
|
1192 done
|
pascal@696
|
1193 trap "umount_aufs ${base}" INT
|
pascal@285
|
1194
|
pascal@285
|
1195 chroot ${base}root $(cd $(dirname $0); pwd)/$(basename $0) "$@"
|
pascal@285
|
1196 status=$?
|
pascal@285
|
1197
|
al@728
|
1198 _ 'Leaving aufs chroot...'
|
al@737
|
1199 umount_aufs $base
|
pascal@683
|
1200 # Install package outside the aufs jail
|
pascal@683
|
1201 install_package
|
pankso@358
|
1202 exit $status
|
pascal@285
|
1203 }
|
pascal@285
|
1204
|
al@728
|
1205
|
al@705
|
1206 # Encode predefined XML entities
|
al@728
|
1207
|
al@705
|
1208 xml_ent() {
|
al@705
|
1209 sed -e 's|&|\&|g; s|<|\<|g; s|>|\>|g; s|"|\"|g' -e "s|'|\'|g"
|
al@705
|
1210 }
|
al@705
|
1211
|
al@728
|
1212
|
paul@387
|
1213 # Create a XML feed for freshly built packages.
|
al@728
|
1214
|
pankso@310
|
1215 gen_rss() {
|
al@728
|
1216 pubdate=$(date '+%a, %d %b %Y %X')
|
al@728
|
1217 cat > $FEEDS/$pkg.xml <<EOT
|
pankso@310
|
1218 <item>
|
al@737
|
1219 <title>$PACKAGE $VERSION$EXTRAVERSION</title>
|
al@899
|
1220 <link>${COOKER_URL}?pkg=${PACKAGE//+/%2B}</link>
|
al@737
|
1221 <guid>$PACKAGE-$VERSION$EXTRAVERSION</guid>
|
pankso@310
|
1222 <pubDate>$pubdate</pubDate>
|
al@705
|
1223 <description>$(echo -n "$SHORT_DESC" | xml_ent)</description>
|
pankso@310
|
1224 </item>
|
pankso@310
|
1225 EOT
|
pankso@310
|
1226 }
|
pankso@310
|
1227
|
al@728
|
1228
|
pankso@662
|
1229 # Truncate stdout log file to $1 Mb.
|
al@728
|
1230
|
al@728
|
1231 loglimit() {
|
pascal@593
|
1232 if [ -n "$DEFAULT_LOG_LIMIT" ]; then
|
pascal@621
|
1233 tee /dev/stderr | head -qc ${1:-$DEFAULT_LOG_LIMIT}m
|
pascal@593
|
1234 else
|
pascal@593
|
1235 tee /dev/stderr
|
pascal@593
|
1236 fi
|
pascal@576
|
1237 }
|
pascal@576
|
1238
|
al@728
|
1239
|
pankso@1
|
1240 #
|
pankso@671
|
1241 # Receipt functions to ease packaging
|
pankso@671
|
1242 #
|
pankso@671
|
1243
|
pankso@671
|
1244 get_dev_files() {
|
al@779
|
1245 action 'Getting standard devel files...'
|
pankso@671
|
1246 mkdir -p $fs/usr/lib
|
pankso@671
|
1247 cp -a $install/usr/lib/pkgconfig $fs/usr/lib
|
pascal@750
|
1248 cp -a $install/usr/lib/*a $fs/usr/lib
|
pankso@671
|
1249 cp -a $install/usr/include $fs/usr
|
pankso@671
|
1250 status
|
pankso@671
|
1251 }
|
pankso@671
|
1252
|
al@807
|
1253
|
al@809
|
1254 # Function to use in compile_rules() to copy man page from $src to $install
|
al@807
|
1255
|
al@809
|
1256 cook_pick_manpages() {
|
al@809
|
1257 local name section
|
al@809
|
1258 action 'Copying man pages...'
|
al@802
|
1259
|
al@809
|
1260 for i in $@; do
|
al@809
|
1261 name=$(echo $i | sed 's|\.[gbx]z2*$||')
|
al@809
|
1262 section=${name##*/}; section=${section##*.}
|
al@809
|
1263 mkdir -p $install/usr/share/man/man$section
|
al@899
|
1264 scopy $i $install/usr/share/man/man$section
|
al@802
|
1265 done
|
al@802
|
1266 status
|
al@802
|
1267 }
|
al@802
|
1268
|
al@807
|
1269
|
al@962
|
1270 # Function to use in compile_rules() to copy documentation from $src to $install
|
al@962
|
1271
|
al@962
|
1272 cook_pick_docs() {
|
al@962
|
1273 local docdir="$install/usr/share/doc/$PACKAGE-$VERSION"
|
al@962
|
1274 action 'Copying documentation...'
|
al@962
|
1275 mkdir -p $docdir
|
al@962
|
1276 cp -r $@ $docdir
|
al@962
|
1277 chmod -R a+r $docdir
|
al@962
|
1278 status
|
al@962
|
1279 }
|
al@962
|
1280
|
al@962
|
1281
|
al@807
|
1282 # Function to use in genpkg_rules() to copy specified files from $install to $fs
|
al@807
|
1283
|
al@802
|
1284 cook_copy_files() {
|
al@802
|
1285 action 'Copying files...'
|
al@802
|
1286 cd $install
|
al@802
|
1287 local i j
|
al@880
|
1288 IFS=$'\n'
|
al@802
|
1289 for i in $@; do
|
al@802
|
1290 for j in $(find . -name $i ! -type d); do
|
al@899
|
1291 mkdir -p $fs$(dirname ${j#.})
|
al@899
|
1292 scopy $j $fs$(dirname ${j#.})
|
al@802
|
1293 done
|
al@802
|
1294 done
|
al@802
|
1295 cd - >/dev/null
|
al@802
|
1296 status
|
al@802
|
1297 }
|
al@802
|
1298
|
al@807
|
1299
|
al@834
|
1300 # Function to use in genpkg_rules() to copy specified folders from $install to $fs
|
al@834
|
1301
|
al@834
|
1302 cook_copy_folders() {
|
al@834
|
1303 action 'Copying folders...'
|
al@834
|
1304 cd $install
|
al@834
|
1305 local i j
|
al@880
|
1306 IFS=$'\n'
|
al@834
|
1307 for i in $@; do
|
al@834
|
1308 for j in $(find . -name $i -type d); do
|
al@899
|
1309 mkdir -p $fs$(dirname ${j#.})
|
al@899
|
1310 cp -a $j $fs$(dirname ${j#.})
|
al@834
|
1311 done
|
al@834
|
1312 done
|
al@834
|
1313 cd - >/dev/null
|
al@834
|
1314 status
|
al@834
|
1315 }
|
al@834
|
1316
|
al@834
|
1317
|
paul@993
|
1318 # Remove from current $fs files that are already packed (for receipts v2).
|
al@989
|
1319 # Note: the order in $SPLIT is very important.
|
al@1010
|
1320 # Note 2: working in the current set.
|
al@989
|
1321
|
al@989
|
1322 remove_already_packed() {
|
al@989
|
1323 local i j
|
al@1010
|
1324 neighbors=$(
|
al@1010
|
1325 echo $SPLIT" " \
|
al@1010
|
1326 | awk -F$'\t' -vpkg="$PACKAGE" '
|
al@1010
|
1327 BEGIN { RS = " "; FS = ":"; }
|
al@1010
|
1328 { set[$1] = $2; }
|
al@1010
|
1329 END {
|
al@1010
|
1330 current_set = set[pkg];
|
al@1010
|
1331 for (i in set)
|
al@1010
|
1332 { if (i != pkg && set[i] == current_set) print i; }
|
al@1010
|
1333 }
|
al@1010
|
1334 ')
|
al@989
|
1335 IFS=$'\n'
|
al@1010
|
1336 for neighbor in $neighbors; do
|
al@1010
|
1337 i="$taz/$neighbor-$VERSION$EXTRAVERSION/files.list"
|
al@989
|
1338 [ -e "$i" ] || continue
|
al@989
|
1339 while read j; do
|
al@989
|
1340 [ -f $fs$j -o -h $fs$j ] || continue
|
al@989
|
1341 rm $fs$j
|
al@989
|
1342 rmdir --parents --ignore-fail-on-non-empty $fs$(dirname $j)
|
al@989
|
1343 done < $i
|
al@989
|
1344 done
|
al@989
|
1345 unset IFS
|
al@989
|
1346 }
|
al@989
|
1347
|
al@989
|
1348
|
al@1008
|
1349 # Function to use in genpkg_rules() to copy hicolor icons in specified sizes
|
al@1008
|
1350 # (default: 16 and 48) from $install to $fs
|
al@1008
|
1351
|
al@1008
|
1352 cook_copy_icons() {
|
al@1008
|
1353 local sizes=$@ i j
|
al@1008
|
1354 action 'Copying hicolor icons...'
|
al@1008
|
1355 [ -d "$fs/usr/share/icons/hicolor" ] && rm -rf "$fs/usr/share/icons/hicolor"
|
al@1008
|
1356 mkdir -p $fs/usr/share/icons/hicolor
|
al@1008
|
1357 for i in ${sizes:-16 48}; do
|
al@1008
|
1358 j="${i}x$i"; [ "$i" == 'scalable' ] && j="$i"
|
al@1008
|
1359 [ ! -e "$install/usr/share/icons/hicolor/$j" ] ||
|
al@1008
|
1360 scopy $install/usr/share/icons/hicolor/$j \
|
al@1008
|
1361 $fs/usr/share/icons/hicolor
|
al@1008
|
1362 done
|
al@1008
|
1363 status
|
al@1008
|
1364 }
|
al@1008
|
1365
|
al@1008
|
1366
|
al@899
|
1367 # Common function to copy files, folders and patterns
|
al@899
|
1368
|
al@899
|
1369 copy() {
|
al@899
|
1370 action 'Copying folders and files...'
|
al@963
|
1371 local i j k filelist=$(mktemp) folderlist=$(mktemp)
|
al@1008
|
1372
|
al@1008
|
1373 # Get set name for specified package from $SPLIT variable
|
al@1008
|
1374 local set=$(echo $SPLIT \
|
al@1008
|
1375 | awk -vpkg="$PACKAGE" '
|
al@1008
|
1376 BEGIN { RS = " "; FS = ":"; }
|
al@1009
|
1377 { if ($1 == pkg && $2) { print "-" $2; exit; } }')
|
al@1008
|
1378 # Change set, make filelist and folderlist for new set
|
al@1008
|
1379 export src="$WOK/$pkg/source/$PACKAGE-$VERSION$set"
|
al@1008
|
1380 export install="$WOK/$pkg/install$set"
|
al@1008
|
1381 export DESTDIR="$install"
|
al@899
|
1382 IFS=$'\n'
|
al@963
|
1383 cd $install
|
al@963
|
1384 find ! -type d | sed 's|\.||' > $filelist
|
al@963
|
1385 find -type d | sed 's|\.||' > $folderlist
|
al@1008
|
1386
|
al@899
|
1387 for i in $@; do
|
al@899
|
1388 case $i in
|
al@899
|
1389 @std)
|
al@899
|
1390 # Copy "standard" files (all but "developer files", man pages, documentation, translations)
|
al@980
|
1391 sed '/\.h$/d; /\.hxx$/d; /\.a$/d; /\.la$/d; /\.pc$/d; /\.pri$/d; /bin\/.*-config$/d;
|
al@905
|
1392 /\.m4$/d; /\.gir$/d; /\.typelib$/d; /\.vapi$/d; /\.deps$/d; /\.cmake$/d;
|
al@924
|
1393 /\/Makefile.*/d; /\.inc$/d; /\/include\//d;
|
al@904
|
1394 /\/share\/man\//d; /\/share\/doc\//d; /\/share\/gtk-doc\//d; /\/share\/info\//d;
|
al@904
|
1395 /\/share\/devhelp\//d; /\/share\/locale\//d;
|
al@904
|
1396 /\/share\/bash-completion\//d; /\/lib\/systemd\//d;
|
al@945
|
1397 /\/fonts\.scale$/d; /\/fonts\.dir$/d;
|
al@989
|
1398 /\/share\/appdata\//d; /\/share\/help\//d;
|
al@1003
|
1399 /\/share\/icons\/hicolor\/[12356][1245][268]*x[12356][1245][268]*\//d; # 22, 24, 32, 64, 128, 256, 512
|
al@912
|
1400 ' $filelist
|
al@899
|
1401 ;;
|
al@899
|
1402 @dev)
|
al@899
|
1403 # Copy "developer files"
|
al@980
|
1404 sed -n '/\.h$/p; /\.hxx$/p; /\.a$/p; /\.la$/p; /\.pc$/p; /\.pri$/p; /bin\/.*-config$/p;
|
al@905
|
1405 /\.m4$/p; /\.gir$/p; /\.typelib$/p; /\.vapi$/p; /\.deps$/p; /\.cmake$/p;
|
al@924
|
1406 /\/Makefile.*/p; /\.inc$/p; /\/include\//p;
|
al@912
|
1407 ' $filelist
|
al@899
|
1408 ;;
|
al@989
|
1409 @rm)
|
al@1008
|
1410 # Quick alias
|
al@989
|
1411 remove_already_packed
|
al@989
|
1412 ;;
|
al@1008
|
1413 @ico)
|
al@1008
|
1414 # Quick alias
|
al@1008
|
1415 cook_copy_icons >/dev/null
|
al@1008
|
1416 ;;
|
al@899
|
1417 */)
|
al@912
|
1418 # Copy specified folders.
|
al@912
|
1419 i="${i%/}"
|
al@912
|
1420 find -type d -path "*/${i#/}" | sed 's|^.||'
|
al@899
|
1421 ;;
|
al@899
|
1422 *)
|
al@912
|
1423 # Copy specified files.
|
al@912
|
1424 find ! -type d -path "*/${i#/}" | sed 's|^.||'
|
al@899
|
1425 ;;
|
al@1008
|
1426 esac \
|
al@1008
|
1427 | sort -u \
|
al@1008
|
1428 | while read j; do
|
al@912
|
1429 mkdir -p $fs$(dirname "$j")
|
al@912
|
1430 if [ -d "$install$j" ]; then
|
al@912
|
1431 cp -a "$install$j" $fs$(dirname "$j")
|
al@912
|
1432 else
|
al@912
|
1433 scopy "$install$j" $fs$(dirname "$j")
|
al@912
|
1434 fi
|
al@912
|
1435 done
|
al@963
|
1436 # Copy empty directories
|
al@963
|
1437 case $i in
|
al@963
|
1438 @std)
|
al@963
|
1439 while read j; do
|
al@966
|
1440 case $j in
|
al@1003
|
1441 # always skip empty man & doc folders, because this will end up
|
al@1003
|
1442 # copying all the man pages and docs to the package
|
al@1003
|
1443 */man/*|*/doc/*) continue;;
|
al@966
|
1444 esac
|
al@966
|
1445 [ -z "$(ls -A "$install$j")" ] || continue
|
al@963
|
1446 # directory $j is empty
|
al@963
|
1447 k="$j"
|
al@963
|
1448 # make 'ladder' from directories, from root dir to $j
|
al@963
|
1449 # /a /a/b /a/b/c etc.
|
al@963
|
1450 while :; do
|
al@963
|
1451 [ -z "$k" ] && break
|
al@963
|
1452 echo "$k"
|
al@963
|
1453 k="${k%/*}"
|
al@1008
|
1454 done \
|
al@1008
|
1455 | tac \
|
al@1008
|
1456 | while read k; do
|
al@1008
|
1457 # copy dir with its original ownership/permissions if it does not exist
|
al@963
|
1458 [ -d "$fs$k" ] || cp -a "$install$k" "$fs$k"
|
al@963
|
1459 done
|
al@963
|
1460 done < $folderlist
|
al@963
|
1461 ;;
|
al@963
|
1462 esac
|
al@899
|
1463 done
|
al@899
|
1464 cd - >/dev/null
|
al@912
|
1465 unset IFS
|
al@963
|
1466 rm $filelist $folderlist
|
al@899
|
1467 status
|
al@899
|
1468 }
|
al@899
|
1469
|
al@899
|
1470
|
al@932
|
1471 # Update packages database every time after successful build
|
al@899
|
1472
|
al@932
|
1473 update_packages_db() {
|
al@932
|
1474 # packages.info (unsorted, located near to packages)
|
al@932
|
1475 local pi="$PKGS/packages.info"
|
al@899
|
1476 unset_receipt; . $pack/receipt
|
al@899
|
1477 SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
|
al@945
|
1478
|
al@904
|
1479 DEPENDS=$(echo $DEPENDS) # remove newlines, tabs and multiple spaces from variable
|
al@945
|
1480
|
al@952
|
1481 rsum=$(release_checksum $pack)
|
al@952
|
1482 if [ -n "$rsum" ]; then
|
al@952
|
1483 _ 'The release checksum has changed.\n'
|
al@945
|
1484
|
al@952
|
1485 sed -i "/^$PACKAGE\t/d" $pi # remove old entry
|
al@952
|
1486 cat >> $pi <<EOT
|
al@945
|
1487 $PACKAGE $VERSION$EXTRAVERSION $CATEGORY $SHORT_DESC $WEB_SITE $TAGS $SIZES $DEPENDS $rsum $PROVIDE
|
al@899
|
1488 EOT
|
al@899
|
1489
|
al@952
|
1490 # files.list (uncompressed, unsorted, located in $cache)
|
al@952
|
1491 local fl="$cache/files.list"
|
al@952
|
1492 touch $fl
|
al@952
|
1493 sed -i "/^$PACKAGE: /d" $fl
|
al@952
|
1494 sed "s/^/$PACKAGE: \0/" $pack/files.list >> $fl
|
al@952
|
1495 else
|
al@952
|
1496 _ 'The release checksum has not changed.\n'
|
al@952
|
1497 fi
|
al@932
|
1498 }
|
al@932
|
1499
|
al@932
|
1500
|
al@932
|
1501 # Update split.db once for receipt
|
al@932
|
1502
|
al@932
|
1503 update_split_db() {
|
al@932
|
1504 local db="$cache/split.db"
|
al@932
|
1505 touch $db
|
al@932
|
1506 sed -i "/^$pkg\t/d" $db
|
al@932
|
1507 echo -e "$pkg\t$(all_names)" >> $db
|
al@932
|
1508 }
|
al@932
|
1509
|
al@932
|
1510
|
al@932
|
1511 # Recreate whole split.db from scratch
|
al@932
|
1512
|
al@932
|
1513 recreate_split_db() {
|
al@932
|
1514 # Clean
|
al@932
|
1515 local db="$cache/split.db"
|
al@932
|
1516 touch $db
|
al@932
|
1517 > $db
|
al@932
|
1518
|
al@932
|
1519 cd $WOK
|
al@940
|
1520 for pkg in *; do
|
al@940
|
1521 [ -f "$WOK/$pkg/receipt" ] || continue
|
al@932
|
1522 unset PACKAGE SPLIT
|
al@940
|
1523 . $WOK/$pkg/receipt
|
al@932
|
1524 echo -e "$PACKAGE\t$(all_names)" >> $db
|
al@932
|
1525 done
|
al@899
|
1526 }
|
al@899
|
1527
|
al@899
|
1528
|
al@992
|
1529 # Put the status to the activity log
|
al@992
|
1530
|
al@992
|
1531 put_status() {
|
al@992
|
1532 # $1: package, $2: status, one of 'Done', 'Failed'
|
al@992
|
1533 sed -i "s|>$1</a>$|& [ $2 ]|" $activity
|
al@992
|
1534 }
|
al@992
|
1535
|
al@992
|
1536
|
al@742
|
1537
|
al@728
|
1538
|
pankso@671
|
1539 #
|
pankso@1
|
1540 # Commands
|
pankso@1
|
1541 #
|
pankso@1
|
1542
|
al@932
|
1543 # cook <package> --deps
|
al@933
|
1544 [ -n "$deps" ] && {
|
al@933
|
1545 @@PREFIX@@/libexec/cookutils/deps $1
|
al@933
|
1546 exit 0
|
al@933
|
1547 }
|
al@933
|
1548
|
al@933
|
1549 # cook <package> --clean
|
al@933
|
1550 # cook <package> -c
|
al@933
|
1551 [ -n "$clean" -o "$2" == '-c' ] && {
|
al@933
|
1552 action 'Cleaning "%s"' "$1"
|
al@933
|
1553 cd $WOK/$1; rm -rf install taz source
|
al@933
|
1554 status; newline
|
al@933
|
1555 touch $activity # update $activity -> something changed -> update webstat
|
al@933
|
1556 exit 0
|
al@933
|
1557 }
|
al@933
|
1558
|
al@933
|
1559 # cook <package> --getsrc
|
al@933
|
1560 # cook <package> -gs
|
al@933
|
1561 [ -n "$getsrc" -o "$2" == '-gs' ] && {
|
al@933
|
1562 title 'Getting source for "%s"' "$1"
|
al@933
|
1563 receipt="$WOK/$pkg/receipt"
|
al@933
|
1564 check_pkg_in_wok
|
al@933
|
1565 unset_receipt
|
al@933
|
1566 . $receipt
|
al@933
|
1567 get_source
|
al@933
|
1568 _ 'Tarball: %s' "$SRC/$TARBALL"; newline
|
al@933
|
1569 exit 0
|
al@933
|
1570 }
|
al@933
|
1571
|
al@933
|
1572 # cook <package> --block
|
al@933
|
1573 # cook <package> -b
|
al@933
|
1574 [ -n "$block" -o "$2" == '-b' ] && {
|
al@933
|
1575 action 'Blocking package "%s"' "$1"
|
al@933
|
1576 [ $(grep "^$1$" $blocked) ] || echo "$1" >> $blocked
|
al@933
|
1577 status; newline
|
al@933
|
1578 touch $activity
|
al@933
|
1579 exit 0
|
al@933
|
1580 }
|
al@933
|
1581
|
al@933
|
1582 # cook <package> --unblock
|
al@933
|
1583 # cook <package> -ub
|
al@933
|
1584 [ -n "$unblock" -o "$2" == '-ub' ] && {
|
al@933
|
1585 action 'Unblocking package "%s"' "$1"
|
al@933
|
1586 sed -i "/^$1$/d" $blocked
|
al@933
|
1587 status; newline
|
al@933
|
1588 touch $activity
|
al@933
|
1589 exit 0
|
al@933
|
1590 }
|
al@933
|
1591
|
al@933
|
1592
|
al@932
|
1593
|
al@932
|
1594
|
pankso@1
|
1595 case "$1" in
|
pankso@32
|
1596 usage|help|-u|-h)
|
pankso@1
|
1597 usage ;;
|
al@728
|
1598
|
pankso@1
|
1599 list-wok)
|
al@779
|
1600 title 'List of %s packages in "%s"' "$ARCH" "$WOK"
|
pankso@642
|
1601 cd $WOK
|
al@728
|
1602 if [ "$ARCH" != 'i486' ]; then
|
pankso@643
|
1603 count=0
|
al@728
|
1604 for pkg in $(fgrep 'HOST_ARCH=' */receipt | egrep "$ARCH|any" | cut -d: -f1)
|
pankso@643
|
1605 do
|
pankso@643
|
1606 unset HOST_ARCH
|
al@951
|
1607 . ./$pkg
|
pankso@643
|
1608 count=$(($count + 1))
|
pankso@643
|
1609 colorize 34 "$PACKAGE"
|
pankso@643
|
1610 done
|
pankso@642
|
1611 else
|
pankso@643
|
1612 count=$(ls | wc -l)
|
pankso@643
|
1613 ls -1
|
pankso@642
|
1614 fi
|
al@779
|
1615 footer "$(_p '%s package' '%s packages' "$count" "$(colorize 32 "$count")")"
|
al@779
|
1616 ;;
|
al@728
|
1617
|
pankso@378
|
1618 activity)
|
pankso@378
|
1619 cat $activity ;;
|
al@728
|
1620
|
pankso@69
|
1621 search)
|
al@931
|
1622 # Just a simple search function, we don't need more actually.
|
pankso@69
|
1623 query="$2"
|
al@779
|
1624 title 'Search results for "%s"' "$query"
|
al@728
|
1625 cd $WOK; ls -1 | grep "$query"
|
al@779
|
1626 footer ;;
|
al@728
|
1627
|
pankso@1
|
1628 setup)
|
pankso@1
|
1629 # Setup a build environment
|
pankso@1
|
1630 check_root
|
al@728
|
1631 _ 'Cook: setup environment' | log
|
al@779
|
1632 title 'Setting up your environment'
|
psychomaniak@821
|
1633 [ -d $SLITAZ ] || mkdir -p $SLITAZ
|
al@596
|
1634 cd $SLITAZ
|
pankso@52
|
1635 init_db_files
|
al@728
|
1636 _ 'Checking for packages to install...'
|
pankso@397
|
1637 # Use setup pkgs from cross.conf or cook.conf. When cross compiling
|
pankso@645
|
1638 # ARCH-setup or 'cross check' should be used before: cook setup
|
pankso@397
|
1639 case "$ARCH" in
|
pankso@676
|
1640 arm*|x86_64)
|
al@899
|
1641 [ -x '/usr/bin/cross' ] || die 'ERROR: %s is not installed' 'cross'
|
al@728
|
1642 _ 'Using config file: %s' '/etc/slitaz/cross.conf'
|
pankso@397
|
1643 . /etc/slitaz/cross.conf ;;
|
pankso@397
|
1644 esac
|
pankso@397
|
1645 for pkg in $SETUP_PKGS; do
|
al@728
|
1646 if [ -n "$forced" ]; then
|
pankso@421
|
1647 tazpkg -gi $pkg --forced
|
pankso@397
|
1648 else
|
al@728
|
1649 [ ! -d "$INSTALLED/$pkg" ] && tazpkg get-install $pkg
|
pankso@397
|
1650 fi
|
pankso@397
|
1651 done
|
pankso@1
|
1652
|
pankso@1
|
1653 # Handle --options
|
pankso@1
|
1654 case "$2" in
|
al@728
|
1655 --wok) hg clone $WOK_URL wok || exit 1 ;;
|
al@728
|
1656 --stable) hg clone $WOK_URL-stable wok || exit 1 ;;
|
al@728
|
1657 --undigest) hg clone $WOK_URL-undigest wok || exit 1 ;;
|
al@728
|
1658 --tiny) hg clone $WOK_URL-tiny wok || exit 1 ;;
|
pankso@1
|
1659 esac
|
pankso@1
|
1660
|
pankso@1
|
1661 # SliTaz group and permissions
|
pankso@1
|
1662 if ! grep -q ^slitaz /etc/group; then
|
al@728
|
1663 _ 'Adding group "%s"' 'slitaz'
|
pankso@1
|
1664 addgroup slitaz
|
pankso@1
|
1665 fi
|
al@728
|
1666 _ 'Setting permissions for group "%s"...' 'slitaz'
|
pascal@277
|
1667 find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
|
pascal@277
|
1668 find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
|
al@779
|
1669 footer "$(_ 'All done, ready to cook packages :-)')" ;;
|
al@728
|
1670
|
pankso@395
|
1671 *-setup)
|
pankso@395
|
1672 # Setup for cross compiling.
|
al@728
|
1673 arch="${1%-setup}"
|
pankso@397
|
1674 check_root
|
pankso@644
|
1675 . /etc/slitaz/cook.conf
|
pankso@644
|
1676 for pkg in $CROSS_SETUP; do
|
al@728
|
1677 if [ -n "$forced" ]; then
|
pankso@644
|
1678 tazpkg -gi $pkg --forced
|
pankso@644
|
1679 else
|
al@728
|
1680 [ ! -d "$INSTALLED/$pkg" ] && tazpkg -gi $pkg
|
pankso@644
|
1681 fi
|
pankso@644
|
1682 done
|
al@728
|
1683
|
al@728
|
1684 _ 'Cook: setup %s cross environment' "$arch" | log
|
al@779
|
1685 title 'Setting up your %s cross environment' "$arch"
|
pankso@397
|
1686 init_db_files
|
pankso@359
|
1687 sed -i \
|
al@931
|
1688 -e "s|ARCH=.*|ARCH=\"$arch\"|" \
|
al@931
|
1689 -e "s|CROSS_TREE=.*|CROSS_TREE=\"/cross/$arch\"|" \
|
al@931
|
1690 -e 's|BUILD_SYSTEM=.*|BUILD_SYSTEM=i486-slitaz-linux|' \
|
pankso@395
|
1691 /etc/slitaz/cook.conf
|
pankso@395
|
1692 case "$arch" in
|
pankso@395
|
1693 arm)
|
al@728
|
1694 flags='-O2 -march=armv6'
|
pankso@650
|
1695 host="$ARCH-slitaz-linux-gnueabi" ;;
|
pankso@650
|
1696 armv6hf)
|
al@728
|
1697 flags='-O2 -march=armv6j -mfpu=vfp -mfloat-abi=hard'
|
pankso@650
|
1698 host="$ARCH-slitaz-linux-gnueabi" ;;
|
pankso@650
|
1699 armv7)
|
al@728
|
1700 flags='-Os -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -pipe'
|
pankso@650
|
1701 host="$ARCH-slitaz-linux-gnueabi" ;;
|
pankso@395
|
1702 x86_64)
|
al@728
|
1703 flags='-O2 -mtune=generic -pipe'
|
pankso@650
|
1704 host="$ARCH-slitaz-linux" ;;
|
pankso@395
|
1705 esac
|
pankso@650
|
1706 sed -i \
|
al@931
|
1707 -e "s|CFLAGS=.*|CFLAGS=\"$flags\"|" \
|
al@931
|
1708 -e "s|HOST_SYSTEM=.*|HOST_SYSTEM=$host|" /etc/slitaz/cook.conf
|
pankso@359
|
1709 . /etc/slitaz/cook.conf
|
al@728
|
1710 sysroot="$CROSS_TREE/sysroot"
|
al@728
|
1711 tools="/cross/$arch/tools"
|
al@728
|
1712 root="$sysroot"
|
al@596
|
1713 # L10n: keep the same width of translations to get a consistent view
|
al@728
|
1714 _ 'Target arch : %s' "$ARCH"
|
al@728
|
1715 _ 'Configure args : %s' "$CONFIGURE_ARGS"
|
al@728
|
1716 _ 'Build flags : %s' "$flags"
|
al@728
|
1717 _ 'Arch sysroot : %s' "$sysroot"
|
al@728
|
1718 _ 'Tools prefix : %s' "$tools/bin"
|
paul@455
|
1719 # Tell the packages manager where to find packages.
|
al@728
|
1720 _ 'Packages DB : %s' "$root$DB"
|
al@728
|
1721 mkdir -p $root$INSTALLED
|
al@728
|
1722 cd $root$DB; rm -f *.bak
|
al@728
|
1723 for list in packages.list packages.desc packages.equiv packages.md5; do
|
al@728
|
1724 rm -f $list
|
al@728
|
1725 ln -s $SLITAZ/packages/$list $list
|
pankso@426
|
1726 done
|
pankso@429
|
1727 # We must have the cross compiled glibc-base installed or default
|
pankso@429
|
1728 # i486 package will be used as dep by tazpkg and then break the
|
pankso@429
|
1729 # cross environment
|
al@728
|
1730 if [ ! -f "$root$INSTALLED/glibc-base/receipt" ]; then
|
al@728
|
1731 colorize 36 $(_ 'WARNING: %s is not installed in sysroot' '(e)glibc-base')
|
pankso@429
|
1732 fi
|
pankso@426
|
1733 # Show GCC version or warn if not yet compiled.
|
al@737
|
1734 if [ -x "$tools/bin/$HOST_SYSTEM-gcc" ]; then
|
al@728
|
1735 _ 'Cross compiler : %s' "$HOST_SYSTEM-gcc"
|
pankso@359
|
1736 else
|
al@728
|
1737 colorize 36 $(_ 'C compiler "%s" is missing' "$HOST_SYSTEM-gcc")
|
al@728
|
1738 _ 'Run "%s" to cook a toolchain' 'cross compile'
|
pankso@397
|
1739 fi
|
al@779
|
1740 footer ;;
|
al@728
|
1741
|
pankso@9
|
1742 test)
|
pankso@9
|
1743 # Test a cook environment.
|
al@728
|
1744 _ 'Cook test: testing the cook environment' | log
|
pankso@9
|
1745 [ ! -d "$WOK" ] && exit 1
|
pankso@9
|
1746 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
|
pankso@9
|
1747 cook cooktest ;;
|
al@728
|
1748
|
pankso@1
|
1749 new)
|
pankso@1
|
1750 # Create the package folder and an empty receipt.
|
pankso@1
|
1751 pkg="$2"
|
al@728
|
1752 [ -z "$pkg" ] && usage
|
pankso@427
|
1753 newline
|
al@899
|
1754 [ -d "$WOK/$pkg" ] && die 'Package "%s" already exists.' "$pkg"
|
al@728
|
1755
|
al@779
|
1756 action 'Creating folder "%s"' "$WOK/$pkg"
|
al@728
|
1757 mkdir $WOK/$pkg; cd $WOK/$pkg; status
|
al@728
|
1758
|
al@779
|
1759 action 'Preparing the package receipt...'
|
pankso@1
|
1760 cp $DATA/receipt .
|
al@931
|
1761 sed -i "s|^PACKAGE=.*|PACKAGE=\"$pkg\"|" receipt
|
al@728
|
1762 status; newline
|
pankso@358
|
1763
|
pankso@196
|
1764 # Interactive mode, asking and seding.
|
pankso@196
|
1765 case "$3" in
|
paul@214
|
1766 --interactive|-x)
|
al@728
|
1767 _ 'Entering interactive mode...'
|
paul@211
|
1768 separator
|
al@728
|
1769 _ 'Package : %s' "$pkg"
|
al@728
|
1770
|
al@728
|
1771 _n 'Version : ' ; read answer
|
al@931
|
1772 sed -i "s|^VERSION=.*|VERSION=\"$answer\"|" receipt
|
al@728
|
1773
|
al@728
|
1774 _n 'Category : ' ; read answer
|
al@931
|
1775 sed -i "s|^CATEGORY=.*|CATEGORY=\"$answer\"|" receipt
|
al@728
|
1776
|
al@596
|
1777 # L10n: Short description
|
al@728
|
1778 _n 'Short desc : ' ; read answer
|
al@931
|
1779 sed -i "s|^SHORT_DESC=.*|SHORT_DESC=\"$answer\"|" receipt
|
al@728
|
1780
|
al@728
|
1781 _n 'Maintainer : ' ; read answer
|
al@931
|
1782 sed -i "s|^MAINTAINER=.*|MAINTAINER=\"$answer\"|" receipt
|
al@728
|
1783
|
al@728
|
1784 _n 'License : ' ; read answer
|
al@931
|
1785 sed -i "s|^LICENSE=.*|LICENSE=\"$answer\"|" receipt
|
al@728
|
1786
|
al@728
|
1787 _n 'Web site : ' ; read answer
|
al@931
|
1788 sed -i "s|^WEB_SITE=.*|WEB_SITE=\"$answer\"|" receipt
|
pankso@427
|
1789 newline
|
al@728
|
1790
|
pankso@196
|
1791 # Wget URL.
|
al@728
|
1792 _ 'Wget URL to download source tarball.'
|
al@728
|
1793 _n 'Example : ' ; echo '$GNU_MIRROR/$PACKAGE/$TARBALL'
|
al@728
|
1794 _n 'Wget url : ' ; read answer
|
al@931
|
1795 sed -i "s|^WGET_URL=.*|WGET_URL=\"$answer\"|" receipt
|
al@728
|
1796
|
pankso@196
|
1797 # Ask for a stuff dir.
|
al@728
|
1798 confirm "$(_n 'Do you need a stuff directory? (y/N)')"
|
al@779
|
1799 if [ "$?" -eq 0 ]; then
|
al@779
|
1800 action 'Creating the stuff directory...'
|
al@728
|
1801 mkdir $WOK/$pkg/stuff; status
|
pankso@196
|
1802 fi
|
al@728
|
1803
|
pankso@196
|
1804 # Ask for a description file.
|
al@728
|
1805 confirm "$(_n 'Are you going to write a description? (y/N)')"
|
al@779
|
1806 if [ "$?" -eq 0 ]; then
|
al@779
|
1807 action 'Creating the "%s" file...' 'description.txt'
|
al@728
|
1808 touch $WOK/$pkg/description.txt; status
|
pankso@196
|
1809 fi
|
al@728
|
1810
|
al@779
|
1811 footer "$(_ 'Receipt is ready to use.')" ;;
|
pankso@196
|
1812 esac ;;
|
al@728
|
1813
|
pankso@1
|
1814 list)
|
pankso@1
|
1815 # Cook a list of packages (better use the Cooker since it will order
|
pankso@1
|
1816 # packages before executing cook).
|
pankso@1
|
1817 check_root
|
al@899
|
1818 [ -z "$2" ] && die 'No list in argument.'
|
al@899
|
1819 [ -f "$2" ] || die 'List "%s" not found.' "$2"
|
al@728
|
1820
|
al@728
|
1821 _ 'Starting cooking the list "%s"' "$2" | log
|
al@728
|
1822
|
al@931
|
1823 while read pkg; do
|
pankso@1
|
1824 cook $pkg || broken
|
al@931
|
1825 done < $2
|
al@931
|
1826 ;;
|
al@728
|
1827
|
pankso@1
|
1828 clean-wok)
|
pankso@1
|
1829 check_root
|
al@779
|
1830 newline; action 'Cleaning all packages files...'
|
pankso@1
|
1831 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
|
al@596
|
1832 status; newline ;;
|
al@728
|
1833
|
pankso@1
|
1834 clean-src)
|
pankso@1
|
1835 check_root
|
al@779
|
1836 newline; action 'Cleaning all packages sources...'
|
pankso@1
|
1837 rm -rf $WOK/*/source
|
al@596
|
1838 status; newline ;;
|
al@728
|
1839
|
pankso@662
|
1840 uncook)
|
pankso@662
|
1841 cd $WOK
|
pankso@662
|
1842 count=0
|
al@779
|
1843 title 'Checking for uncooked packages'
|
al@728
|
1844
|
al@951
|
1845 for i in *; do
|
pankso@664
|
1846 unset HOST_ARCH EXTRAVERSION
|
al@951
|
1847 [ ! -e $i/receipt ] && continue
|
al@951
|
1848 . ./$i/receipt
|
pankso@662
|
1849 # Source cooked pkg receipt to get EXTRAVERSION
|
al@951
|
1850 if [ -d "$WOK/$i/taz" ]; then
|
al@951
|
1851 cd $WOK/$i/taz/$(ls $WOK/$i/taz/ | head -n1)
|
pascal@950
|
1852 . ./receipt; cd $WOK
|
pankso@662
|
1853 fi
|
pankso@662
|
1854 case "$ARCH" in
|
pankso@662
|
1855 i486)
|
al@728
|
1856 debug "$(_ 'Package "%s"' "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg")"
|
al@728
|
1857 if [ ! -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg" ]; then
|
pankso@662
|
1858 count=$(($count + 1))
|
al@951
|
1859 colorize 34 "$i"
|
pankso@662
|
1860 fi ;;
|
pankso@676
|
1861 arm*)
|
paul@665
|
1862 # Check only packages included in arch
|
pascal@669
|
1863 if echo "$HOST_ARCH" | egrep -q "$ARCH|any"; then
|
pankso@662
|
1864 # *.tazpkg
|
al@728
|
1865 if [ ! -f "$PKGS/$PACKAGE-$VERSION$EXTRAVERSION-$ARCH.tazpkg" ]; then
|
pankso@662
|
1866 count=$(($count + 1))
|
al@951
|
1867 colorize 34 "$i"
|
pankso@662
|
1868 fi
|
pankso@662
|
1869 fi ;;
|
pankso@662
|
1870 esac
|
pankso@662
|
1871 done
|
al@728
|
1872
|
al@899
|
1873 if [ "$count" -gt 0 ]; then
|
al@779
|
1874 footer "$(_p '%s uncooked package' '%s uncooked packages' "$count" "$(colorize 31 "$count")")"
|
pankso@662
|
1875 else
|
al@728
|
1876 _ 'All packages are cooked :-)'
|
al@779
|
1877 newline
|
pankso@662
|
1878 fi
|
al@779
|
1879 ;;
|
al@728
|
1880
|
pankso@235
|
1881 pkgdb)
|
al@857
|
1882 # Create suitable packages list for TazPkg and only for built packages
|
al@857
|
1883 # as well as flavors files for TazLiTo. We don't need logs since we do it
|
paul@243
|
1884 # manually to ensure everything is fine before syncing the mirror.
|
al@987
|
1885 recreate_split_db
|
al@857
|
1886 @@PREFIX@@/libexec/cookutils/pkgdb "$2"
|
al@742
|
1887 ;;
|
al@728
|
1888
|
al@932
|
1889 splitdb)
|
al@932
|
1890 # File split.db is useful for searching for split packages.
|
al@932
|
1891 recreate_split_db
|
al@932
|
1892 ;;
|
al@932
|
1893
|
pankso@1
|
1894 *)
|
pankso@1
|
1895 # Just cook and generate a package.
|
pankso@1
|
1896 check_root
|
pankso@1
|
1897 time=$(date +%s)
|
pankso@1
|
1898 pkg="$1"
|
pankso@1
|
1899 [ -z "$pkg" ] && usage
|
al@899
|
1900
|
al@924
|
1901 # Search last successful cook time in all logs from newer to older
|
al@924
|
1902 for i in '' $(seq 0 9 | sed 's|^|.|'); do
|
al@924
|
1903 [ -f "$LOGS/$pkg.log$i" ] || break
|
al@924
|
1904 lastcooktime=$(sed '/^Cook time/!d; s|.*: *\([0-9]*\)s.*|\1|' \
|
al@924
|
1905 $LOGS/$pkg.log$i 2>/dev/null | sed '$!d')
|
al@924
|
1906 [ -n "$lastcooktime" ] && break
|
al@924
|
1907 done
|
al@924
|
1908
|
pankso@44
|
1909 receipt="$WOK/$pkg/receipt"
|
al@728
|
1910 check_pkg_in_wok
|
al@728
|
1911 newline
|
pankso@47
|
1912
|
pankso@377
|
1913 unset inst
|
pankso@377
|
1914 unset_receipt
|
pankso@377
|
1915 . $receipt
|
al@728
|
1916
|
pankso@377
|
1917 # Handle cross compilation.
|
pankso@377
|
1918 case "$ARCH" in
|
pankso@676
|
1919 arm*)
|
al@728
|
1920 if [ -z "$HOST_ARCH" ]; then
|
al@728
|
1921 _ 'cook: HOST_ARCH is not set in "%s" receipt' "$pkg"
|
al@728
|
1922 error="$(_ 'package "%s" is not included in %s' "$pkg" "$ARCH")"
|
al@728
|
1923 _ 'cook: %s' "$error"
|
al@728
|
1924 [ -n "$CROSS_BUGS" ] && _ 'bugs: %s' "$CROSS_BUGS"
|
al@728
|
1925 _ 'Cook skip: %s' "$error" | log
|
al@728
|
1926 newline
|
al@899
|
1927 broken; exit 1
|
pankso@377
|
1928 fi ;;
|
pankso@377
|
1929 esac
|
pankso@377
|
1930
|
paul@387
|
1931 # Some packages are not included in some arch or fail to cross compile.
|
pankso@398
|
1932 : ${HOST_ARCH=i486}
|
al@728
|
1933 debug "$(_ 'Host arch %s' "$HOST_ARCH")"
|
pankso@675
|
1934 # Handle arm{v6hf,v7,..}
|
pankso@675
|
1935 if ! $(echo "$HOST_ARCH" | egrep -q "${ARCH%v[0-9]*}|any"); then
|
al@728
|
1936 _ 'cook: %s' "HOST_ARCH=$HOST_ARCH"
|
al@728
|
1937 error="$(_ "package \"%s\" doesn't cook or is not included in %s" "$pkg" "$ARCH")"
|
al@728
|
1938 _ 'cook: %s' "error"
|
al@728
|
1939 [ -n "$CROSS_BUGS" ] && _ 'bugs: %s' "$CROSS_BUGS"
|
al@728
|
1940 _ 'Cook skip: %s' "$error" | log
|
al@931
|
1941 sed -i "/^${pkg}$/d" $broken
|
al@728
|
1942 newline
|
al@728
|
1943 exit 0
|
pankso@377
|
1944 fi
|
pankso@377
|
1945
|
pankso@47
|
1946 # Skip blocked, 3 lines also for the Cooker.
|
al@899
|
1947 grep -q "^$pkg$" $blocked && [ "$2" != '--unblock' ] &&
|
al@899
|
1948 die 'Package "%s" is blocked' "$pkg"
|
pankso@47
|
1949
|
pascal@289
|
1950 try_aufs_chroot "$@"
|
pascal@289
|
1951
|
pankso@47
|
1952 # Log and source receipt.
|
al@899
|
1953 _ 'Cook started for: %s' "<a href='cooker.cgi?pkg=${pkg//+/%2B}'>$pkg</a>" | log
|
pankso@16
|
1954 echo "cook:$pkg" > $command
|
al@899
|
1955
|
al@899
|
1956 [ -n "$lastcooktime" ] && echo "cook:$pkg $lastcooktime $(date +%s)" >> $cooktime
|
al@899
|
1957
|
pascal@824
|
1958 while read cmd duration start; do
|
pascal@824
|
1959 [ $(($start + $duration)) -lt $(date +%s) ] &&
|
pascal@824
|
1960 echo "sed -i '/^$cmd $duration/d' $cooktime"
|
pascal@824
|
1961 done < $cooktime | sh
|
pascal@285
|
1962
|
pascal@285
|
1963 # Display and log info if cook process stopped.
|
paul@647
|
1964 # FIXME: gettext not working (in single quotes) here!
|
al@596
|
1965 trap '_ "\n\nCook stopped: control-C\n\n" | \
|
pascal@285
|
1966 tee -a $LOGS/$pkg.log' INT
|
pascal@285
|
1967
|
al@932
|
1968 update_split_db
|
al@932
|
1969
|
pankso@1
|
1970 # Handle --options
|
pankso@1
|
1971 case "$2" in
|
pankso@1
|
1972 --install|-i)
|
pankso@1
|
1973 inst='yes' ;;
|
al@728
|
1974
|
slaxemulator@501
|
1975 --pack)
|
al@924
|
1976 [ -d "$WOK/$pkg/install" ] || die 'Need to build "%s"' "$pkg"
|
al@924
|
1977 [ ! -d "$WOK/$pkg/taz" ] || rm -rf "$WOK/$pkg/taz"
|
al@924
|
1978 [ ! -f "$LOGS/$pkg-pack.log" ] || rm -rf $LOGS/$pkg-pack.log
|
al@926
|
1979 sed -i '$ s|$| (packing)|' $activity
|
al@912
|
1980 packall 2>&1 | tee -a $LOGS/$pkg-pack.log
|
al@924
|
1981 clean_log "$pkg-pack"
|
al@924
|
1982 time=$(($(date +%s) - $time))
|
al@924
|
1983 summary | sed 's|^Cook |Pack |' | tee -a $LOGS/$pkg-pack.log
|
al@992
|
1984 put_status $pkg Done
|
al@899
|
1985 rm -f $command
|
slaxemulator@501
|
1986 exit 0 ;;
|
al@989
|
1987
|
al@989
|
1988 --trials|-t)
|
al@989
|
1989 trials='yes' ;;
|
pankso@1
|
1990 esac
|
pankso@1
|
1991
|
pascal@793
|
1992 # Rotate log
|
pascal@793
|
1993 for i in $(seq 9 -1 1); do
|
pascal@793
|
1994 j=$(($i - 1))
|
al@837
|
1995 [ -e $LOGS/$pkg.log.$j ] && mv -f $LOGS/$pkg.log.$j $LOGS/$pkg.log.$i
|
pascal@793
|
1996 done
|
al@837
|
1997 [ -e $LOGS/$pkg.log ] && mv $LOGS/$pkg.log $LOGS/$pkg.log.0
|
al@837
|
1998
|
paul@62
|
1999 # Check if wanted is built now so we have separate log files.
|
pankso@295
|
2000 for wanted in $WANTED ; do
|
pascal@291
|
2001 if grep -q "^$wanted$" $blocked; then
|
al@899
|
2002 broken
|
al@728
|
2003 rm -f $command
|
al@899
|
2004 die 'WANTED package "%s" is blocked' "$wanted"
|
pankso@217
|
2005 fi
|
pascal@291
|
2006 if grep -q "^$wanted$" $broken; then
|
al@899
|
2007 broken
|
al@728
|
2008 rm -f $command
|
al@899
|
2009 die 'WANTED package "%s" is broken' "$wanted"
|
pankso@218
|
2010 fi
|
pascal@291
|
2011 if [ ! -d "$WOK/$wanted/install" ]; then
|
al@899
|
2012 cook "$wanted" || { broken; exit 1; }
|
pankso@137
|
2013 fi
|
pascal@291
|
2014 done
|
pankso@1
|
2015
|
pankso@1
|
2016 # Cook and pack or exit on error and log everything.
|
al@1010
|
2017 ((((cookit $@ 2>&1; echo $? >&3) | loglimit 50 > $LOGS/$pkg.log) 3>&1) | (read rq; exit $rq))
|
al@1010
|
2018 rq=$? # the return code of `cookit $@` above command
|
al@1010
|
2019
|
al@1010
|
2020 # Remove build dependencies both when `cookit` done or fail
|
pankso@15
|
2021 remove_deps | tee -a $LOGS/$pkg.log
|
pankso@1
|
2022 cookit_quality
|
al@1010
|
2023
|
al@1010
|
2024 # Log and stop if `cookit` fails
|
al@1010
|
2025 if [ $rq -eq 1 ]; then
|
al@1010
|
2026 debug_info | tee -a $LOGS/$pkg.log
|
al@1010
|
2027 put_status $pkg Failed
|
al@1010
|
2028 rm -f $command
|
al@1010
|
2029 broken; exit 1
|
al@1010
|
2030 fi
|
al@1010
|
2031
|
al@1010
|
2032 # Proceed only if `cookit` return code is zero-OK
|
al@904
|
2033 packall 2>&1 | loglimit 5 >> $LOGS/$pkg.log
|
al@1010
|
2034
|
pankso@1
|
2035 clean_log
|
pankso@33
|
2036
|
pankso@33
|
2037 # Exit if any error in packing.
|
al@962
|
2038 if [ "${COOKOPTS/skip-log-errors/}" == "$COOKOPTS" ] &&
|
al@962
|
2039 grep -Ev "(/root/.cvspass|conftest|df: /|rm: can't remove)" $LOGS/$pkg.log | \
|
al@962
|
2040 grep -Eq "(^ERROR|: No such file or directory|not remade because of errors|ake: \*\*\* .* Error)"; then
|
pankso@33
|
2041 debug_info | tee -a $LOGS/$pkg.log
|
al@992
|
2042 put_status $pkg Failed
|
al@728
|
2043 rm -f $command
|
al@899
|
2044 broken; exit 1
|
pankso@33
|
2045 fi
|
pankso@358
|
2046
|
pankso@310
|
2047 # Create an XML feed
|
pankso@310
|
2048 gen_rss
|
pankso@358
|
2049
|
pankso@1
|
2050 # Time and summary
|
pankso@1
|
2051 time=$(($(date +%s) - $time))
|
pankso@1
|
2052 summary | tee -a $LOGS/$pkg.log
|
pankso@427
|
2053 newline
|
pankso@1
|
2054
|
al@899
|
2055 # We may want to install/update (outside aufs jail!).
|
al@899
|
2056 [ -s /aufs-umount.sh ] || install_package
|
al@899
|
2057
|
al@992
|
2058 put_status $pkg Done
|
pankso@358
|
2059
|
al@850
|
2060 # Finally we DON'T WANT to build the *-dev or packages with WANTED="$pkg"
|
al@899
|
2061 # If you want automation, use the Cooker Build Bot.
|
al@899
|
2062 rm -f $command
|
al@899
|
2063 ;;
|
pankso@1
|
2064 esac
|
pankso@1
|
2065
|
pankso@1
|
2066 exit 0
|