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