rev |
line source |
pankso@1
|
1 #!/bin/sh
|
pankso@1
|
2 #
|
pankso@1
|
3 # Cook - A tool to cook and generate SliTaz packages. Read the README
|
pankso@1
|
4 # before adding or modifing any code in cook!
|
pankso@1
|
5 #
|
pankso@1
|
6 # Copyright (C) SliTaz GNU/Linux - GNU gpl v3
|
pankso@1
|
7 # Author: Christophe Lincoln <pankso@slitaz.org>
|
pankso@1
|
8 #
|
pankso@422
|
9 . /usr/lib/slitaz/libcook.sh
|
slaxemulator@480
|
10 . /usr/lib/slitaz/libcookorder.sh
|
slaxemulator@528
|
11 . /usr/lib/slitaz/libcookiso.sh
|
slaxemulator@479
|
12
|
slaxemulator@479
|
13 COMMAND="$1"
|
pankso@1
|
14
|
pankso@1
|
15 #
|
pankso@1
|
16 # Functions
|
pankso@1
|
17 #
|
pankso@1
|
18
|
pankso@1
|
19 usage() {
|
pankso@1
|
20 cat << EOT
|
pankso@1
|
21
|
pankso@147
|
22 $(echo -e "\033[1m$(gettext "Usage:")\033[0m") cook [package|command] [list|--option]
|
pankso@1
|
23
|
pankso@1
|
24 $(echo -e "\033[1m$(gettext "Commands:")\033[0m")
|
paul@214
|
25 usage|help $(gettext "Display this short usage.")
|
paul@214
|
26 setup $(gettext "Setup your build environment.")
|
pankso@424
|
27 *-setup $(gettext "Setup a cross environment.")
|
paul@214
|
28 test $(gettext "Test environment and cook a package.")
|
paul@214
|
29 list-wok $(gettext "List packages in the wok.")
|
paul@214
|
30 search $(gettext "Simple packages search function.")
|
paul@214
|
31 new $(gettext "Create a new package with a receipt".)
|
pankso@358
|
32 list $(gettext "Cook a list of packages.")
|
paul@214
|
33 clean-wok $(gettext "Clean-up all packages files.")
|
paul@214
|
34 clean-src $(gettext "Clean-up all packages sources.")
|
slaxemulator@479
|
35 upwok $(gettext "Update wok.")
|
slaxemulator@479
|
36 gen-wok-db $(gettext "Build cook order files.")
|
slaxemulator@479
|
37 gen-src $(gettext "Build source list.")
|
slaxemulator@479
|
38 check-incoming $(gettext "Move incoming packages to packages folder.")
|
slaxemulator@479
|
39 gen-cooklist $(gettext "Make cook order list.")
|
slaxemulator@479
|
40 check-src $(gettext "Check upstream tarball for package in the wok.")
|
slaxemulator@479
|
41 maintainers $(gettext "List all maintainers in the wok.")
|
slaxemulator@479
|
42 maintained-by $(gettext "List packages maintained by a contributor.")
|
slaxemulator@479
|
43 tags $(gettext "List all tags used in wok receipts.")
|
pankso@239
|
44 pkgdb $(gettext "Create packages DB lists and flavors.")
|
slaxemulator@479
|
45 unbuild $(gettext "List all unbuild packages.")
|
pankso@1
|
46
|
pankso@1
|
47 $(echo -e "\033[1m$(gettext "Options:")\033[0m")
|
slaxemulator@479
|
48 --clean|-c Cook : $(gettext "clean the package in the wok.")
|
slaxemulator@479
|
49 --install|-i Cook : $(gettext "cook and install the package.")
|
slaxemulator@479
|
50 --getsrc|-gs Cook : $(gettext "get the package source tarball.")
|
slaxemulator@479
|
51 --block|-b Cook : $(gettext "Block a package so cook will skip it.")
|
slaxemulator@479
|
52 --unblock|-ub Cook : $(gettext "Unblock a blocked package.")
|
slaxemulator@479
|
53 --interactive|-x New : $(gettext "create a receipt interactively.")
|
slaxemulator@479
|
54 --local Upwok : $(gettext "update wok local changes in wok-hg.")
|
slaxemulator@479
|
55 --wok|-w Setup : $(gettext "clone the cooking wok from Hg repo.")
|
slaxemulator@479
|
56 --stable Setup : $(gettext "clone the stable wok from Hg repo.")
|
slaxemulator@479
|
57 --undigest Setup : $(gettext "clone the undigest wok from Hg repo.")
|
pankso@397
|
58 --tiny Setup: $(gettext "clone the tiny SliTaz wok from Hg repo.")
|
pankso@397
|
59 --forced Setup: $(gettext "force reinstall of chroot packages.")
|
slaxemulator@479
|
60 --flavors Pkgdb : $(gettext "create up-to-date flavors files.")
|
slaxemulator@479
|
61 --full Unbuild : $(gettext "create a full unbuild list.")
|
slaxemulator@479
|
62 --list Unbuild : $(gettext "Copy unbuild list into your cooklist.")
|
pankso@1
|
63
|
pankso@1
|
64 EOT
|
pankso@1
|
65 exit 0
|
pankso@1
|
66 }
|
pankso@1
|
67
|
paul@62
|
68 # We don't want these escapes in web interface.
|
pankso@1
|
69 clean_log() {
|
pankso@1
|
70 sed -i -e s'|\[70G\[ \[1;32m| |' \
|
pankso@1
|
71 -e s'|\[0;39m \]||' $LOGS/$pkg.log
|
pankso@1
|
72 }
|
pankso@1
|
73
|
slaxemulator@549
|
74 # check if $value is empty
|
pankso@9
|
75 if_empty_value() {
|
pankso@9
|
76 if [ -z "$value" ]; then
|
pankso@9
|
77 gettext "QA: empty variable:"; echo -e " ${var}=\"\"\n"
|
pankso@9
|
78 exit 1
|
pankso@9
|
79 fi
|
pankso@9
|
80 }
|
pankso@9
|
81
|
paul@62
|
82 # QA: check a receipt consistency before building.
|
pankso@9
|
83 receipt_quality() {
|
pankso@9
|
84 gettext -e "QA: checking package receipt...\n"
|
pankso@9
|
85 unset online
|
pankso@9
|
86 if ifconfig | grep -q -A 1 "^[a-z]*[0-9]" | fgrep 'addr:'; then
|
pankso@9
|
87 online="online"
|
pankso@9
|
88 fi
|
pankso@9
|
89 for var in PACKAGE VERSION CATEGORY SHORT_DESC MAINTAINER WEB_SITE
|
pankso@9
|
90 do
|
pankso@9
|
91 unset value
|
pascal@279
|
92 value="$(. $receipt ; eval echo \$$var)"
|
pankso@9
|
93 case "$var" in
|
pankso@9
|
94 PACKAGE|VERSION|SHORT_DESC)
|
pankso@9
|
95 if_empty_value ;;
|
pankso@9
|
96 CATEGORY)
|
pankso@9
|
97 [ -z "$value" ] && value="empty"
|
slaxemulator@497
|
98 valid="$PKGS_CATEGORIES"
|
pankso@9
|
99 if ! echo "$valid" | grep -q -w "$value"; then
|
paul@62
|
100 gettext "QA: unknown category:"; echo -e " $value\n"
|
pankso@9
|
101 exit 1
|
pankso@9
|
102 fi ;;
|
pankso@9
|
103 WEB_SITE)
|
paul@62
|
104 # We don't check WGET_URL since if dl is needed it will fail.
|
paul@62
|
105 # Break also if we're not online. Here error is not fatal.
|
pankso@9
|
106 if_empty_value
|
pankso@9
|
107 [ -z "$online" ] || break
|
slaxemulator@463
|
108 case $value in
|
slaxemulator@463
|
109 https://*)
|
slaxemulator@479
|
110 if ! wget -T $TIMEOUT --spider --no-check-certificate $value 2>/dev/null; then
|
slaxemulator@479
|
111 gettext "QA: Unable to reach:"; echo -e " $value"
|
slaxemulator@479
|
112 fi ;;
|
slaxemulator@463
|
113 http://*|ftp://*)
|
slaxemulator@479
|
114 if ! busybox wget -T $TIMEOUT -s $value 2>/dev/null; then
|
slaxemulator@479
|
115 gettext "QA: Unable to reach:"; echo -e " $value"
|
slaxemulator@479
|
116 fi ;;
|
slaxemulator@463
|
117 esac
|
pankso@9
|
118 esac
|
pankso@9
|
119 done
|
pankso@9
|
120 }
|
pankso@9
|
121
|
paul@62
|
122 # Paths used in receipt and by cook itself.
|
pankso@1
|
123 set_paths() {
|
pankso@1
|
124 pkgdir=$WOK/$PACKAGE
|
slaxemulator@492
|
125 basesrc=$pkgdir/source
|
slaxemulator@492
|
126 tmpsrc=$basesrc/tmp
|
slaxemulator@492
|
127 src=$basesrc/$PACKAGE-$VERSION
|
pankso@44
|
128 taz=$pkgdir/taz
|
pankso@44
|
129 pack=$taz/$PACKAGE-${VERSION}${EXTRAVERSION}
|
pankso@1
|
130 fs=$pack/fs
|
pankso@1
|
131 stuff=$pkgdir/stuff
|
pankso@1
|
132 install=$pkgdir/install
|
slaxemulator@492
|
133 pkgsrc="${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}"
|
slaxemulator@492
|
134 lzma_tarball="$pkgsrc.tar.lzma"
|
slaxemulator@506
|
135 orig_tarball="$TARBALL"
|
slaxemulator@492
|
136 if [ "$PATCH" ]; then
|
slaxemulator@492
|
137 [ "${PTARBALL}" ] || PTARBALL="$(basename $PATCH)"
|
slaxemulator@492
|
138 fi
|
pankso@1
|
139 if [ "$WANTED" ]; then
|
slaxemulator@492
|
140 basesrc=$WOK/$WANTED/source
|
slaxemulator@492
|
141 src=$basesrc/$WANTED-$VERSION
|
slaxemulator@492
|
142 install=$WOK/$WANTED/install
|
slaxemulator@492
|
143 wanted_stuff=$WOK/$WANTED/stuff
|
pankso@1
|
144 fi
|
slaxemulator@456
|
145 if [ "$SOURCE" ]; then
|
slaxemulator@456
|
146 source_stuff=$WOK/$SOURCE/stuff
|
slaxemulator@456
|
147 fi
|
slaxemulator@492
|
148 # Kernel version is set from linux
|
slaxemulator@492
|
149 if [ -f "$WOK/linux/receipt" ]; then
|
slaxemulator@492
|
150 kvers=$(grep ^VERSION= $WOK/linux/receipt | cut -d '"' -f 2)
|
slaxemulator@492
|
151 kbasevers=${kvers:0:3}
|
slaxemulator@492
|
152 fi
|
slaxemulator@492
|
153 # Python version
|
slaxemulator@492
|
154 if [ -f "$WOK/python/receipt" ]; then
|
slaxemulator@492
|
155 pyvers=$(grep ^VERSION= $WOK/python/receipt | cut -d '"' -f 2)
|
slaxemulator@492
|
156 fi
|
slaxemulator@492
|
157 # perl version for some packages needed it
|
slaxemulator@492
|
158 if [ -f "$WOK/perl/receipt" ]; then
|
slaxemulator@492
|
159 perlvers=$(grep ^VERSION= $WOK/perl/receipt | cut -d '"' -f 2)
|
pankso@232
|
160 fi
|
pankso@9
|
161 # Old way compatibility.
|
pankso@1
|
162 _pkg=$install
|
pankso@1
|
163 }
|
pankso@1
|
164
|
pankso@144
|
165 # Create source tarball when URL is a SCM.
|
pankso@144
|
166 create_tarball() {
|
slaxemulator@498
|
167 local tarball
|
slaxemulator@498
|
168 tarball=$pkgsrc.tar.bz2
|
slaxemulator@498
|
169 [ "$LZMA_SRC" ] && tarball=$lzma_tarball
|
pankso@144
|
170 gettext "Creating tarball: "; echo "$tarball"
|
pankso@162
|
171 if [ "$LZMA_SRC" ]; then
|
slaxemulator@498
|
172 tar -c $pkgsrc | lzma e $SRC/$tarball -si $LZMA_SET_DIR || exit 1
|
slaxemulator@498
|
173 LZMA_SRC=""
|
pankso@162
|
174 else
|
pankso@162
|
175 tar cjf $tarball $pkgsrc || exit 1
|
pankso@162
|
176 mv $tarball $SRC && rm -rf $pkgsrc
|
pankso@162
|
177 fi
|
slaxemulator@498
|
178 TARBALL=$tarball
|
pankso@144
|
179 }
|
pankso@144
|
180
|
pankso@145
|
181 # Get package source. For SCM we are in cache so clone here and create a
|
pankso@145
|
182 # tarball here.
|
pankso@1
|
183 get_source() {
|
pankso@115
|
184 pwd=$(pwd)
|
slaxemulator@467
|
185 for file in $@; do
|
slaxemulator@467
|
186 gettext "Getting source from url:"; echo " ${file#*|}"
|
slaxemulator@467
|
187 if [ "$file" = "$PATCH" -o "$file" = "$orig_url_patch" ]; then
|
slaxemulator@467
|
188 SAVE_FILE="$SRC/$PTARBALL"
|
slaxemulator@467
|
189 else
|
slaxemulator@467
|
190 SAVE_FILE="$SRC/$TARBALL"
|
slaxemulator@467
|
191 fi
|
slaxemulator@467
|
192 case "$file" in
|
slaxemulator@467
|
193 http://*|ftp://*)
|
slaxemulator@467
|
194 # Busybox Wget is better!
|
slaxemulator@467
|
195 busybox wget $WGET_OPTIONS -T $TIMEOUT -c -O $SAVE_FILE $file || \
|
slaxemulator@467
|
196 (echo -e "ERROR: wget $file" && exit 1) ;;
|
slaxemulator@467
|
197 https://*)
|
slaxemulator@467
|
198 wget $WGET_OPTIONS -T $TIMEOUT -c --no-check-certificate -O $SAVE_FILE $file || \
|
slaxemulator@467
|
199 (echo -e "ERROR: wget $file" && exit 1) ;;
|
slaxemulator@467
|
200 hg*|mercurial*)
|
slaxemulator@467
|
201 if $(echo "$file" | fgrep -q "hg|"); then
|
slaxemulator@467
|
202 url=${file#hg|}
|
slaxemulator@467
|
203 else
|
slaxemulator@467
|
204 url=${file#mercurial|}
|
slaxemulator@467
|
205 fi
|
slaxemulator@467
|
206 gettext -e "Getting source from Hg...\n"
|
slaxemulator@467
|
207 echo "URL: $url"
|
slaxemulator@467
|
208 gettext "Cloning to: "; echo "$pwd/$pkgsrc"
|
slaxemulator@467
|
209 if [ "$BRANCH" ]; then
|
slaxemulator@467
|
210 echo "Hg branch: $BRANCH"
|
slaxemulator@467
|
211 hg clone $url --rev $BRANCH $pkgsrc || \
|
slaxemulator@467
|
212 (echo "ERROR: hg clone $url --rev $BRANCH" && exit 1)
|
slaxemulator@467
|
213 else
|
slaxemulator@467
|
214 hg clone $url $pkgsrc || (echo "ERROR: hg clone $url" && exit 1)
|
slaxemulator@467
|
215 fi
|
slaxemulator@467
|
216 create_tarball ;;
|
slaxemulator@467
|
217 git*)
|
slaxemulator@467
|
218 url=${file#git|}
|
slaxemulator@467
|
219 gettext -e "Getting source from Git...\n"
|
slaxemulator@467
|
220 echo "URL: $url"
|
slaxemulator@467
|
221 git clone $url $pkgsrc || (echo "ERROR: git clone $url" && exit 1)
|
slaxemulator@467
|
222 if [ "$BRANCH" ]; then
|
slaxemulator@467
|
223 echo "Git branch: $BRANCH"
|
slaxemulator@467
|
224 cd $pkgsrc && git checkout $BRANCH && cd ..
|
slaxemulator@467
|
225 fi
|
slaxemulator@467
|
226 create_tarball ;;
|
slaxemulator@516
|
227 bzr*|bazaar*)
|
slaxemulator@516
|
228 if $(echo "$file" | fgrep -q "bzr|"); then
|
slaxemulator@516
|
229 url=${file#bzr|}
|
slaxemulator@516
|
230 else
|
slaxemulator@516
|
231 url=${file#bazaar|}
|
slaxemulator@516
|
232 fi
|
slaxemulator@516
|
233 gettext -e "Getting source from BZR...\n"
|
slaxemulator@516
|
234 echo "URL: $url"
|
slaxemulator@516
|
235 bzr branch $url $pkgsrc
|
slaxemulator@516
|
236 create_tarball ;;
|
slaxemulator@467
|
237 cvs*)
|
slaxemulator@467
|
238 url=${file#cvs|}
|
slaxemulator@467
|
239 mod=$PACKAGE
|
slaxemulator@467
|
240 [ "$CVS_MODULE" ] && mod=$CVS_MODULE
|
slaxemulator@467
|
241 gettext -e "Getting source from CVS...\n"
|
slaxemulator@467
|
242 echo "URL: $url"
|
slaxemulator@467
|
243 [ "$CVS_MODULE" ] && echo "CVS module: $mod"
|
slaxemulator@467
|
244 gettext "Cloning to: "; echo "$pwd/$mod"
|
slaxemulator@467
|
245 cvs -d:$url co $mod && mv $mod $pkgsrc
|
slaxemulator@467
|
246 create_tarball ;;
|
slaxemulator@467
|
247 svn*|subversion*)
|
slaxemulator@468
|
248 if $(echo "$file" | fgrep -q "svn|"); then
|
slaxemulator@467
|
249 url=${file#svn|}
|
slaxemulator@467
|
250 else
|
slaxemulator@467
|
251 url=${file#subversion|}
|
slaxemulator@467
|
252 fi
|
slaxemulator@467
|
253 gettext -e "Getting source from SVN...\n"
|
slaxemulator@467
|
254 echo "URL: $url"
|
slaxemulator@467
|
255 if [ "$BRANCH" ]; then
|
slaxemulator@467
|
256 echo t | svn co $url -r $BRANCH $pkgsrc
|
slaxemulator@467
|
257 else
|
slaxemulator@467
|
258 echo t | svn co $url $pkgsrc
|
slaxemulator@467
|
259 fi
|
slaxemulator@467
|
260 create_tarball ;;
|
slaxemulator@467
|
261 *)
|
slaxemulator@467
|
262 gettext -e "\nERROR: Unable to handle:"; echo -e " $file \n" | \
|
slaxemulator@467
|
263 tee -a $LOGS/$PACKAGE.log
|
slaxemulator@467
|
264 exit 1 ;;
|
slaxemulator@467
|
265 esac
|
slaxemulator@467
|
266 done
|
slaxemulator@471
|
267 }
|
slaxemulator@471
|
268
|
slaxemulator@545
|
269 # get source tarball
|
slaxemulator@545
|
270 # $1 = --extract
|
slaxemulator@474
|
271 getsrc() {
|
slaxemulator@474
|
272 gettext "Getting source for:"; echo " $pkg"
|
slaxemulator@474
|
273 set_paths
|
slaxemulator@474
|
274 [ -f "$SRC/$lzma_tarball" ] && \
|
slaxemulator@474
|
275 TARBALL="$lzma_tarball"
|
slaxemulator@474
|
276
|
slaxemulator@474
|
277 # Get source tarball and make sure we have source dir named:
|
slaxemulator@474
|
278 # $PACKAGE-$VERSION to be standard in receipts. Here we use tar.lzma
|
slaxemulator@474
|
279 # tarball if it exists.
|
slaxemulator@506
|
280 look_for_cookopt !unpack && unpack="no"
|
slaxemulator@506
|
281 look_for_cookopt !repack_src && LZMA_SRC=""
|
slaxemulator@506
|
282 if [ ! "$WANTED" ] && [ "$TARBALL" ] && [ ! "$unpack" ] && [ ! "$cook_code" ]; then
|
slaxemulator@474
|
283 [ -d $tmpsrc ] && rm -rf $tmpsrc
|
slaxemulator@474
|
284 mkdir -p $tmpsrc && cd $tmpsrc
|
slaxemulator@474
|
285 fi
|
slaxemulator@474
|
286
|
slaxemulator@506
|
287 if [ "$WGET_URL" ] && [ ! -f "$SRC/$TARBALL" ]; then
|
slaxemulator@506
|
288 separator && download
|
slaxemulator@506
|
289 fi
|
slaxemulator@506
|
290
|
slaxemulator@506
|
291 if [ "$WGET_URL" ] && [ -f "$SRC/$TARBALL" ] && [ ! "$unpack" ] && [ ! "$cook_code" ]; then
|
slaxemulator@506
|
292 [ "$TARBALL" = "$lzma_tarball" ] && LZMA_SRC=""
|
slaxemulator@474
|
293 if [ "$1" = "--extract" ]; then
|
slaxemulator@506
|
294 extract_source || exit 1
|
slaxemulator@506
|
295 if [ ! -f "$SRC/$lzma_tarball" ] && [ "$LZMA_SRC" ]; then
|
slaxemulator@506
|
296 echo -e "Repacking source."
|
slaxemulator@506
|
297 repack_source || exit 1
|
slaxemulator@506
|
298 fi
|
slaxemulator@506
|
299 extract_path || exit 1
|
slaxemulator@506
|
300 if [ -f $SRC/$TARBALL ]; then
|
slaxemulator@506
|
301 [ -d $tmpsrc ] && rm -rf $tmpsrc
|
slaxemulator@506
|
302 fi
|
slaxemulator@506
|
303 fi
|
slaxemulator@474
|
304 fi
|
slaxemulator@474
|
305
|
slaxemulator@474
|
306 # This is to make sure if PATCH equals something it will be downloaded
|
slaxemulator@474
|
307 # checks are done in download functions
|
slaxemulator@506
|
308 if [ "$PATCH" ] && [ ! "$cook_code" ]; then
|
slaxemulator@474
|
309 if [ ! -f "$SRC/$PTARBALL" ]; then
|
slaxemulator@474
|
310 separator && download
|
slaxemulator@474
|
311 fi
|
slaxemulator@474
|
312 fi
|
slaxemulator@474
|
313
|
slaxemulator@474
|
314 echo -e "Tarball: $SRC/$TARBALL"
|
slaxemulator@474
|
315 [ "$PATCH" ] && echo -e "Patch: $SRC/$PTARBALL"
|
slaxemulator@474
|
316 }
|
slaxemulator@474
|
317
|
slaxemulator@545
|
318 # the base function to download sources when offline
|
slaxemulator@545
|
319 # This is to make sure source can be download when local-mirror
|
slaxemulator@545
|
320 # script is in use.
|
slaxemulator@474
|
321 download_base() {
|
slaxemulator@474
|
322 local URLS url alt_url orig_url orig_url_patch
|
slaxemulator@474
|
323 url="$ONLINE_SRC_REPOSITORY"
|
slaxemulator@474
|
324 if [ "$SOURCE" ]; then
|
slaxemulator@474
|
325 alt_url="${url}${SOURCE:0:1}/$SOURCE-${KBASEVER:-$VERSION}.tar.lzma"
|
slaxemulator@474
|
326 else
|
slaxemulator@474
|
327 alt_url="${url}${PACKAGE:0:1}/$PACKAGE-${KBASEVER:-$VERSION}.tar.lzma"
|
slaxemulator@474
|
328 fi
|
slaxemulator@474
|
329 orig_url="${url}${TARBALL:0:1}/$TARBALL"
|
slaxemulator@474
|
330 [ "$PATCH" ] && orig_url_patch="${url}${PTARBALL:0:1}/$PTARBALL"
|
slaxemulator@474
|
331 URLS="$@ $alt_url $orig_url $orig_url_patch"
|
slaxemulator@474
|
332 [ "$LAN_MIRROR" ] && URLS="$alt_url $orig_url $orig_url_patch $@"
|
slaxemulator@474
|
333 if [ "$WGET_URL" = "$orig_url" ]; then
|
slaxemulator@474
|
334 [ "$TARBALL" = "$lzma_tarball" ] && LZMA_SRC=""
|
slaxemulator@474
|
335 get_source $@
|
slaxemulator@474
|
336 elif [ "$WGET_URL" = "$alt_url" ]; then
|
slaxemulator@474
|
337 LZMA_SRC=""
|
slaxemulator@474
|
338 get_source $@
|
slaxemulator@474
|
339 else
|
slaxemulator@474
|
340 for i in $URLS; do
|
slaxemulator@474
|
341 if [ "$1" = "$PATCH" ]; then
|
slaxemulator@474
|
342 [ ! -f "$SRC/$PTARBALL" ] || continue
|
pankso@9
|
343 else
|
slaxemulator@474
|
344 [ ! -f "$SRC/$TARBALL" ] || continue
|
pankso@9
|
345 fi
|
slaxemulator@474
|
346 case $i in
|
slaxemulator@474
|
347 ${url}*)
|
slaxemulator@474
|
348 [ "$i" = "$alt_url" ] && TARBALL="$(basename $alt_url)"
|
slaxemulator@474
|
349 [ "$i" = "$alt_url" ] && LZMA_SRC=""
|
slaxemulator@474
|
350 get_source $i
|
slaxemulator@474
|
351 ;;
|
slaxemulator@474
|
352 *)
|
slaxemulator@474
|
353 get_source $i ;;
|
slaxemulator@474
|
354 esac
|
slaxemulator@474
|
355 done
|
slaxemulator@474
|
356 fi
|
slaxemulator@474
|
357 }
|
slaxemulator@474
|
358
|
slaxemulator@474
|
359 # Get source from multible urls
|
slaxemulator@474
|
360 download() {
|
slaxemulator@474
|
361 if [ ! -s "$SRC/$TARBALL" ]; then
|
slaxemulator@474
|
362 download_base $WGET_URL
|
slaxemulator@474
|
363 [ -f "$SRC/$TARBALL" ] || broken
|
slaxemulator@474
|
364 fi
|
slaxemulator@474
|
365
|
slaxemulator@474
|
366 if [ "$PATCH" ]; then
|
slaxemulator@474
|
367 if [ ! -s "$SRC/$PTARBALL" ]; then
|
slaxemulator@474
|
368 download_base $PATCH
|
slaxemulator@474
|
369 [ -f "$SRC/$PTARBALL" ] || broken
|
slaxemulator@474
|
370 fi
|
slaxemulator@474
|
371 fi
|
pankso@1
|
372 }
|
pankso@1
|
373
|
pankso@9
|
374 # Extract source package.
|
pankso@1
|
375 extract_source() {
|
pankso@1
|
376 gettext "Extracting:"; echo " $TARBALL"
|
pankso@1
|
377 case "$TARBALL" in
|
pankso@120
|
378 *.tar.gz|*.tgz) tar xzf $SRC/$TARBALL 2>/dev/null ;;
|
pankso@178
|
379 *.tar.bz2|*.tbz|*.tbz2) tar xjf $SRC/$TARBALL 2>/dev/null ;;
|
pankso@1
|
380 *.tar.lzma) tar xaf $SRC/$TARBALL ;;
|
pankso@42
|
381 *.tar) tar xf $SRC/$TARBALL ;;
|
pankso@42
|
382 *.zip|*.xpi) unzip -o $SRC/$TARBALL ;;
|
pankso@42
|
383 *.xz) unxz -c $SRC/$TARBALL | tar xf - ;;
|
pankso@42
|
384 *.Z) uncompress -c $SRC/$TARBALL | tar xf - ;;
|
pankso@42
|
385 *.rpm) rpm2cpio $SRC/$TARBALL | cpio -idm --quiet ;;
|
slaxemulator@474
|
386 *.deb) ar vx $SRC/$TARBALL
|
slaxemulator@474
|
387 [ ! -d $tmpsrc/$PACKAGE-$VERSION ] && mkdir -p $tmpsrc/$PACKAGE-$VERSION
|
slaxemulator@474
|
388 cd $tmpsrc/$PACKAGE-$VERSION
|
slaxemulator@474
|
389 tar -xvzf $tmpsrc/data.tar.gz
|
slaxemulator@474
|
390 [ -f $tmpsrc/data.tar.gz ] && rm -f $tmpsrc/data.tar.gz
|
slaxemulator@474
|
391 [ -f $tmpsrc/control.tar.gz ] && rm -f $tmpsrc/control.tar.gz
|
slaxemulator@474
|
392 [ -f $tmpsrc/debian-binary ] && rm -f $tmpsrc/debian-binary ;;
|
pankso@238
|
393 *.run) /bin/sh $SRC/$TARBALL $RUN_OPTS ;;
|
slaxemulator@474
|
394 *.7z) 7zr x $SRC/$TARBALL ;;
|
pankso@191
|
395 *) cp $SRC/$TARBALL $(pwd) ;;
|
pankso@1
|
396 esac
|
slaxemulator@468
|
397 chown -R 0.0 $(pwd)
|
slaxemulator@471
|
398 }
|
slaxemulator@471
|
399
|
slaxemulator@545
|
400 # Repack source tarball as .tar.lzma
|
slaxemulator@545
|
401 # The source tarball is extracted as $tmpsrc/$pkgsrc path
|
slaxemulator@545
|
402 # This way the source has a clean path when building
|
slaxemulator@474
|
403 repack_source() {
|
slaxemulator@474
|
404
|
slaxemulator@474
|
405 # Some archives are not well done and don't extract to one dir (ex lzma).
|
slaxemulator@474
|
406 files=$(ls | wc -l)
|
slaxemulator@474
|
407 [ "$files" == 1 ] && [ -d "$(ls)" ] && [ ! -d "$pkgsrc" ] && mv * $tmpsrc/$pkgsrc
|
slaxemulator@474
|
408 if [ ! -d "$tmpsrc/$pkgsrc" ]; then
|
slaxemulator@474
|
409 cd $basesrc
|
slaxemulator@474
|
410 if [ "$(ls -A tmp | wc -l)" -gt 1 ] || [ -f "$(echo tmp/*)" ]; then
|
slaxemulator@474
|
411 mv tmp tmp-1 && mkdir tmp
|
slaxemulator@474
|
412 mv tmp-1 tmp/$pkgsrc
|
slaxemulator@474
|
413 fi
|
slaxemulator@474
|
414 fi
|
slaxemulator@474
|
415 if [ -d "$tmpsrc/$pkgsrc" ]; then
|
slaxemulator@474
|
416 gettext "Repacking source is enabled:"; echo " LZMA_SRC"
|
slaxemulator@474
|
417 TARBALL=$lzma_tarball
|
slaxemulator@474
|
418 cd $tmpsrc
|
slaxemulator@474
|
419 if [ -x /usr/bin/optipng ]; then
|
slaxemulator@474
|
420 [ "$SHRINKPNG" ] && find -name "*.png" -type f | xargs -i optipng "{}"
|
slaxemulator@474
|
421 fi
|
slaxemulator@474
|
422 tar -c * | lzma e $SRC/$TARBALL -si $LZMA_SET_DIR
|
slaxemulator@474
|
423 if [ $REMOVE_ORIG_TARBALL ]; then
|
slaxemulator@474
|
424 if [ -f $SRC/$TARBALL ]; then
|
slaxemulator@506
|
425 [ -f $SRC/$orig_tarball ] && rm -f $SRC/$orig_tarball
|
slaxemulator@474
|
426 fi
|
slaxemulator@474
|
427 fi
|
slaxemulator@474
|
428 fi
|
pankso@1
|
429 }
|
pankso@1
|
430
|
pankso@9
|
431 # Display cooked package summary.
|
pankso@1
|
432 summary() {
|
slaxemulator@499
|
433 [ -d $WOK/$pkg/install ] && prod=$(du -sh $WOK/$pkg/install | awk '{print $1}' 2>/dev/null)
|
slaxemulator@499
|
434 [ -d $WOK/$pkg/source ] && srcdir=$(du -sh $WOK/$pkg/source | awk '{print $1}' 2>/dev/null)
|
slaxemulator@499
|
435 fs=$(du -sh $WOK/$pkg/taz/* | awk '{print $1}')
|
slaxemulator@474
|
436 size=$(du -sh $INCOMING/$pkg-${VERSION}*.tazpkg | awk '{print $1}')
|
slaxemulator@499
|
437 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
|
slaxemulator@499
|
438 [ "$TARBALL" ] && srcsize=$(du -sh $SRC/$TARBALL | awk '{print $1}')
|
pankso@18
|
439 cookdate=$(date "+%Y-%m-%d %H:%M")
|
pankso@101
|
440 sec=$time
|
pascal@280
|
441 div=$(( ($time + 30) / 60))
|
pankso@112
|
442 [ "$div" != 0 ] && min="~ ${div}m"
|
pankso@1
|
443 gettext "Summary for:"; echo " $PACKAGE $VERSION"
|
pankso@1
|
444 separator
|
slaxemulator@499
|
445 [ "$srcdir" ] && echo "Source dir : $srcdir"
|
slaxemulator@499
|
446 [ "$TARBALL" ] && echo "Src file : $TARBALL"
|
slaxemulator@499
|
447 [ "$srcsize" ] && echo "Src size : $srcsize"
|
slaxemulator@499
|
448 [ "$prod" ] && echo "Produced : $prod"
|
pankso@1
|
449 cat << EOT
|
slaxemulator@499
|
450 Packed : $fs
|
slaxemulator@499
|
451 Compressed : $size
|
slaxemulator@499
|
452 Files : $files
|
slaxemulator@499
|
453 Cook time : ${sec}s $min
|
slaxemulator@499
|
454 Cook date : $cookdate
|
slaxemulator@499
|
455 Host arch : $ARCH
|
pankso@1
|
456 $(separator)
|
pankso@1
|
457 EOT
|
pankso@1
|
458 }
|
pankso@1
|
459
|
paul@62
|
460 # Display debugging error info.
|
pankso@15
|
461 debug_info() {
|
pankso@17
|
462 echo -e "\nDebug information"
|
pankso@15
|
463 separator
|
pankso@48
|
464 echo "Cook date: $(date '+%Y-%m-%d %H:%M')"
|
pankso@76
|
465 for error in \
|
pankso@77
|
466 ERROR "No package" "cp: can't" "can't open" "can't cd" \
|
slaxemulator@512
|
467 "error:" "fatal error:" "rm: can't remove" "cp: can't stat" \
|
slaxemulator@502
|
468 "undefined reference to" "Unable to connect to" \
|
slaxemulator@512
|
469 "link: cannot find the library" "CMake Error"
|
pankso@34
|
470 do
|
pankso@34
|
471 fgrep "$error" $LOGS/$pkg.log
|
pankso@34
|
472 done
|
pankso@427
|
473 separator && newline
|
pankso@15
|
474 }
|
pankso@15
|
475
|
pankso@1
|
476 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
|
pankso@1
|
477 # so some packages need to copy these files with the receipt and genpkg_rules.
|
slaxemulator@500
|
478 copy_generic_files()
|
slaxemulator@500
|
479 {
|
pankso@1
|
480 # $LOCALE is set in cook.conf
|
slaxemulator@500
|
481 if [ "$LOCALE" -a "$WANTED" = "" ]; then
|
pankso@260
|
482 if [ -d "$install/usr/share/locale" ]; then
|
pankso@1
|
483 mkdir -p $fs/usr/share/locale
|
pankso@1
|
484 for i in $LOCALE
|
pankso@1
|
485 do
|
pankso@260
|
486 if [ -d "$install/usr/share/locale/$i" ]; then
|
pankso@260
|
487 cp -a $install/usr/share/locale/$i $fs/usr/share/locale
|
pankso@1
|
488 fi
|
pankso@1
|
489 done
|
pankso@1
|
490 fi
|
pankso@1
|
491 fi
|
pankso@1
|
492
|
pankso@1
|
493 # Generic pixmaps copy can be disabled with GENERIC_PIXMAPS="no"
|
pankso@1
|
494 if [ "$GENERIC_PIXMAPS" != "no" ]; then
|
pankso@260
|
495 if [ -d "$install/usr/share/pixmaps" ]; then
|
pankso@1
|
496 mkdir -p $fs/usr/share/pixmaps
|
slaxemulator@500
|
497 if [ -f "$install/usr/share/pixmaps/$PACKAGE.png" ]; then
|
slaxemulator@500
|
498 cp -a $install/usr/share/pixmaps/$PACKAGE.png \
|
slaxemulator@500
|
499 $fs/usr/share/pixmaps
|
slaxemulator@500
|
500 elif [ -f "$install/usr/share/pixmaps/$PACKAGE.xpm" ]; then
|
slaxemulator@500
|
501 cp -a $install/usr/share/pixmaps/$PACKAGE.xpm \
|
slaxemulator@500
|
502 $fs/usr/share/pixmaps
|
slaxemulator@500
|
503 fi
|
pankso@1
|
504 fi
|
pankso@1
|
505
|
pankso@1
|
506 # Custom or homemade PNG pixmap can be in stuff.
|
pankso@1
|
507 if [ -f "$stuff/$PACKAGE.png" ]; then
|
pankso@1
|
508 mkdir -p $fs/usr/share/pixmaps
|
pankso@1
|
509 cp -a $stuff/$PACKAGE.png $fs/usr/share/pixmaps
|
pankso@1
|
510 fi
|
pankso@1
|
511 fi
|
pankso@1
|
512
|
pankso@1
|
513 # Desktop entry (.desktop).
|
erjo@284
|
514 # Generic desktop entry copy can be disabled with GENERIC_MENUS="no"
|
erjo@284
|
515 if [ "$GENERIC_MENUS" != "no" ]; then
|
erjo@284
|
516 if [ -d "$install/usr/share/applications" ] && [ "$WANTED" == "" ]; then
|
slaxemulator@500
|
517 mkdir -p $fs/usr/share
|
erjo@284
|
518 cp -a $install/usr/share/applications $fs/usr/share
|
erjo@284
|
519 fi
|
pankso@1
|
520 fi
|
pankso@1
|
521
|
pankso@1
|
522 # Homemade desktop file(s) can be in stuff.
|
pankso@1
|
523 if [ -d "$stuff/applications" ]; then
|
pankso@1
|
524 mkdir -p $fs/usr/share
|
pankso@1
|
525 cp -a $stuff/applications $fs/usr/share
|
pankso@1
|
526 fi
|
pankso@1
|
527 if [ -f "$stuff/$PACKAGE.desktop" ]; then
|
pankso@1
|
528 mkdir -p $fs/usr/share/applications
|
pankso@1
|
529 cp -a $stuff/$PACKAGE.desktop $fs/usr/share/applications
|
pankso@1
|
530 fi
|
slaxemulator@500
|
531
|
slaxemulator@500
|
532 # Add custom licenses
|
slaxemulator@500
|
533 if [ -d "$stuff/licenses" ]; then
|
slaxemulator@500
|
534 mkdir -p $fs/usr/share/licenses
|
slaxemulator@500
|
535 cp -a $stuff/licenses $fs/usr/share/licenses/$PACKAGE
|
slaxemulator@500
|
536 fi
|
pankso@1
|
537 }
|
pankso@1
|
538
|
pankso@67
|
539 # Find and strip : --strip-all (-s) or --strip-debug on static libs as well
|
pankso@415
|
540 # as removing uneeded files like in Python packages. Cross compiled binaries
|
pankso@415
|
541 # must be stripped with cross-tools aka $ARCH-slitaz-*-strip
|
slaxemulator@479
|
542 strip_package()
|
slaxemulator@479
|
543 {
|
pankso@415
|
544 case "$ARCH" in
|
pankso@415
|
545 arm|x86_64) export STRIP=${HOST_SYSTEM}-strip ;;
|
pankso@415
|
546 *) export STRIP=strip ;;
|
pankso@415
|
547 esac
|
pankso@67
|
548 gettext "Executing strip on all files..."
|
pankso@1
|
549 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
|
pankso@1
|
550 do
|
pankso@1
|
551 if [ -d "$dir" ]; then
|
pankso@414
|
552 find $dir -type f -exec $STRIP -s '{}' 2>/dev/null \;
|
pankso@1
|
553 fi
|
pankso@1
|
554 done
|
pankso@414
|
555 find $fs -name "*.so*" -exec $STRIP -s '{}' 2>/dev/null \;
|
pankso@414
|
556 find $fs -name "*.a" -exec $STRIP --strip-debug '{}' 2>/dev/null \;
|
pankso@1
|
557 status
|
pankso@67
|
558
|
pankso@117
|
559 # Remove Python .pyc and .pyo from packages.
|
pankso@150
|
560 if echo "$PACKAGE $DEPENDS" | fgrep -q "python"; then
|
pankso@68
|
561 gettext "Removing Python compiled files..."
|
pankso@67
|
562 find $fs -type f -name "*.pyc" -delete 2>/dev/null
|
pankso@67
|
563 find $fs -type f -name "*.pyo" -delete 2>/dev/null
|
pankso@117
|
564 status
|
pankso@117
|
565 fi
|
pankso@117
|
566
|
pankso@117
|
567 # Remove Perl perllocal.pod and .packlist from packages.
|
pankso@117
|
568 if echo "$DEPENDS" | fgrep -q "perl"; then
|
pankso@117
|
569 gettext "Removing Perl compiled files..."
|
pankso@67
|
570 find $fs -type f -name "perllocal.pod" -delete 2>/dev/null
|
pankso@67
|
571 find $fs -type f -name ".packlist" -delete 2>/dev/null
|
pankso@67
|
572 status
|
pankso@67
|
573 fi
|
pankso@1
|
574 }
|
pankso@1
|
575
|
pankso@8
|
576 # Remove installed deps.
|
pankso@8
|
577 remove_deps() {
|
pankso@8
|
578 # Now remove installed build deps.
|
pankso@113
|
579 diff="$CACHE/installed.cook.diff"
|
pankso@113
|
580 if [ -s "$CACHE/installed.cook.diff" ]; then
|
pankso@113
|
581 deps=$(cat $diff | grep ^+[a-zA-Z0-9] | sed s/^+//)
|
pankso@113
|
582 nb=$(cat $diff | grep ^+[a-zA-Z0-9] | wc -l)
|
slaxemulator@479
|
583 gettext "Build dependencies to remove:"; echo " $nb"
|
pankso@8
|
584 gettext "Removing:"
|
pankso@8
|
585 for dep in $deps
|
pankso@8
|
586 do
|
pankso@8
|
587 echo -n " $dep"
|
slaxemulator@479
|
588 tazpkg remove $dep --auto --root=/ >/dev/null
|
pankso@8
|
589 done
|
pankso@16
|
590 echo -e "\n"
|
pankso@113
|
591 # Keep the last diff for debug and info.
|
pankso@113
|
592 mv -f $CACHE/installed.cook.diff $CACHE/installed.diff
|
pankso@1
|
593 fi
|
pankso@1
|
594 }
|
pankso@1
|
595
|
slaxemulator@545
|
596 # extract path of source tarball
|
slaxemulator@545
|
597 # This is for the getsrc --extract option
|
slaxemulator@479
|
598 extract_path()
|
slaxemulator@479
|
599 {
|
slaxemulator@479
|
600 # Some archives are not well done and don't extract to one dir (ex lzma).
|
slaxemulator@479
|
601 files=$(ls | wc -l)
|
slaxemulator@479
|
602 [ "$files" == 1 ] && [ -d "$(ls)" ] && mv * ../$PACKAGE-$VERSION
|
slaxemulator@479
|
603 [ "$files" == 1 ] && [ -f "$(ls)" ] && mkdir -p ../$PACKAGE-$VERSION && \
|
slaxemulator@479
|
604 mv * ../$PACKAGE-$VERSION/$TARBALL
|
slaxemulator@479
|
605 [ "$files" -gt 1 ] && mkdir -p ../$PACKAGE-$VERSION && \
|
slaxemulator@479
|
606 mv * ../$PACKAGE-$VERSION
|
slaxemulator@479
|
607 cd .. && rm -rf tmp
|
slaxemulator@479
|
608 if [ "$TOUCH_FILES" ]; then
|
slaxemulator@479
|
609 echo "Touching source files to update timestamp"
|
slaxemulator@479
|
610 echo "May take a bit"
|
slaxemulator@479
|
611 find $src -type f -exec touch "{}" \;
|
slaxemulator@479
|
612 fi
|
slaxemulator@501
|
613 }
|
slaxemulator@501
|
614
|
pankso@1
|
615 # The main cook function.
|
pankso@1
|
616 cookit() {
|
pankso@11
|
617 echo "Cook: $PACKAGE $VERSION"
|
pankso@9
|
618 separator
|
pankso@1
|
619 set_paths
|
pankso@359
|
620
|
pankso@377
|
621 # Handle cross-tools.
|
pankso@359
|
622 case "$ARCH" in
|
pankso@359
|
623 arm|x86_64)
|
paul@387
|
624 # CROSS_COMPILE is used by at least Busybox and the kernel to set
|
slaxemulator@479
|
625 # the cross-tools prefix but first check if sysroot is used.
|
pankso@443
|
626 # the cross-tools prefix. Sysroot the the root of our target arch
|
pankso@443
|
627 sysroot=$CROSS_TREE/sysroot
|
pankso@443
|
628 tools=$CROSS_TREE/tools
|
pankso@443
|
629 # Set root path when cross compiling. ARM tested but not x86_64
|
pankso@443
|
630 # When cross compiling we must install build deps in $sysroot.
|
pankso@443
|
631 arch="-${ARCH}"
|
pankso@443
|
632 root=$sysroot
|
pankso@443
|
633 echo "$ARCH sysroot: $sysroot"
|
pankso@443
|
634 echo "Adding $tools/bin to PATH"
|
pankso@443
|
635 export PATH=$PATH:$tools/bin
|
pankso@446
|
636 export PKG_CONFIG_PATH=$sysroot/usr/lib/pkgconfig
|
pankso@421
|
637 export CROSS_COMPILE=${HOST_SYSTEM}-
|
pankso@426
|
638 echo "Using cross-tools: $CROSS_COMPILE"
|
pankso@438
|
639 if [ "$ARCH" == "x86_64" ]; then
|
pankso@438
|
640 export CC="${HOST_SYSTEM}-gcc -m64"
|
pankso@438
|
641 export CXX="${HOST_SYSTEM}-g++ -m64"
|
pankso@438
|
642 else
|
pankso@438
|
643 export CC=${HOST_SYSTEM}-gcc
|
pankso@438
|
644 export CXX=${HOST_SYSTEM}-g++
|
pankso@438
|
645 fi
|
pankso@377
|
646 export AR=${HOST_SYSTEM}-ar
|
pankso@377
|
647 export AS=${HOST_SYSTEM}-as
|
pankso@377
|
648 export RANLIB=${HOST_SYSTEM}-ranlib
|
pankso@377
|
649 export LD=${HOST_SYSTEM}-ld
|
pankso@443
|
650 export STRIP=${HOST_SYSTEM}-strip ;;
|
slaxemulator@479
|
651 *)
|
slaxemulator@479
|
652 root="/" ;;
|
pankso@359
|
653 esac
|
pankso@359
|
654
|
pankso@9
|
655 [ "$QA" ] && receipt_quality
|
pankso@44
|
656 cd $pkgdir
|
pankso@33
|
657 rm -rf install taz source
|
pankso@1
|
658
|
pankso@1
|
659 # Disable -pipe if less than 512Mb free RAM.
|
pankso@1
|
660 free=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
|
pankso@1
|
661 if [ "$free" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" ]; then
|
pankso@1
|
662 gettext -e "Disabling -pipe compile flag: $free RAM\n"
|
pankso@1
|
663 CFLAGS="${CFLAGS/-pipe}" && CFLAGS=$(echo "$CFLAGS" | tr -s ' ')
|
pankso@47
|
664 CXXFLAGS="${CXXFLAGS/-pipe}" && \
|
pankso@47
|
665 CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ')
|
pankso@1
|
666 fi
|
pankso@1
|
667 unset free
|
pankso@1
|
668
|
pankso@232
|
669 # Export flags and path to be used by make and receipt.
|
pankso@44
|
670 DESTDIR=$pkgdir/install
|
pankso@232
|
671 export DESTDIR MAKEFLAGS CFLAGS CXXFLAGS CONFIG_SITE LC_ALL=C LANG=C
|
slaxemulator@479
|
672 #export LDFLAGS
|
slaxemulator@479
|
673
|
slaxemulator@479
|
674 if [ ! "$WANTED" ] && [ "$TARBALL" ]; then
|
slaxemulator@479
|
675 getsrc --extract
|
slaxemulator@479
|
676 fi
|
pankso@1
|
677
|
pankso@126
|
678 # Check for build deps and handle implicit depends of *-dev packages
|
pankso@126
|
679 # (ex: libusb-dev :: libusb).
|
pankso@215
|
680 rm -f $CACHE/installed.local $CACHE/installed.web $CACHE/missing.dep
|
pankso@215
|
681 touch $CACHE/installed.local $CACHE/installed.web
|
slaxemulator@479
|
682 look_for_cookopt !auto_dep && AUTO_DEP=""
|
slaxemulator@479
|
683 if [ "$AUTO_DEP" -a ! "$WANTED" ]; then
|
slaxemulator@479
|
684 BDEPS=$(scan $PACKAGE --look_for=bdep --with_dev | \
|
slaxemulator@479
|
685 grep -v $(for i in $(look_for_rwanted) $PACKAGE; do echo " -e ^$i$"; done))
|
slaxemulator@479
|
686 else
|
slaxemulator@479
|
687 BDEPS="$BUILD_DEPENDS"
|
slaxemulator@479
|
688 fi
|
slaxemulator@479
|
689 [ "$BDEPS" ] && gettext -e "Checking build dependencies...\n"
|
slaxemulator@514
|
690 [ "$root" != "/" ] && echo "Using packages DB: ${root}$DB"
|
slaxemulator@479
|
691 for dep in $BDEPS
|
pankso@1
|
692 do
|
slaxemulator@479
|
693 for i in $dep
|
pankso@126
|
694 do
|
pankso@426
|
695 if [ ! -f "${root}$INSTALLED/$i/receipt" ]; then
|
paul@174
|
696 # Try local package first. In some cases implicit doesn't exist, ex:
|
paul@174
|
697 # libboost-dev exists but not libboost, so check if we got vers.
|
pankso@173
|
698 unset vers
|
slaxemulator@479
|
699 [ -f $WOK/$i/receipt ] || continue
|
pascal@343
|
700 vers=$(. $WOK/$i/receipt 2>/dev/null ; echo $VERSION)
|
slaxemulator@479
|
701 if [ -f "$INCOMING/$i-${vers}_${kbasevers}.tazpkg" ]; then
|
slaxemulator@479
|
702 echo $i-${vers}_${kbasevers}.tazpkg >> $CACHE/installed.local
|
slaxemulator@479
|
703 elif [ -f "$PKGS/$i-${vers}_${kbasevers}.tazpkg" ]; then
|
slaxemulator@479
|
704 echo $i-${vers}_${kbasevers}.tazpkg >> $CACHE/installed.local
|
slaxemulator@479
|
705 elif [ -f "$INCOMING/$i-$vers.tazpkg" ]; then
|
slaxemulator@479
|
706 echo $i-$vers.tazpkg >> $CACHE/installed.local
|
slaxemulator@479
|
707 elif [ -f "$PKGS/$i-$vers.tazpkg" ]; then
|
slaxemulator@479
|
708 echo $i-$vers.tazpkg >> $CACHE/installed.local
|
pankso@126
|
709 else
|
paul@227
|
710 # Priority to package version in wok (maybe more up-to-date)
|
paul@227
|
711 # than the mirrored one.
|
pankso@173
|
712 if [ "$vers" ]; then
|
pankso@426
|
713 if fgrep -q $i-${vers}${arch} ${root}$DB/packages.list; then
|
pankso@215
|
714 echo $i >> $CACHE/installed.web
|
pankso@198
|
715 else
|
paul@211
|
716 # So package exists in wok but not available.
|
pankso@215
|
717 gettext "Missing dep (wok/pkg):"; echo " $i $vers"
|
pankso@215
|
718 echo $i >> $CACHE/missing.dep
|
pankso@198
|
719 fi
|
pankso@225
|
720 else
|
pankso@435
|
721 # Package is not in wok but may be in online repo.
|
pankso@426
|
722 if fgrep -q $i-${vers}${arch} ${root}$DB/packages.list; then
|
pankso@225
|
723 echo $i >> $CACHE/installed.web
|
pankso@225
|
724 else
|
paul@227
|
725 echo "ERROR: unknown dep $i" && exit 1
|
pankso@225
|
726 fi
|
pankso@173
|
727 fi
|
pankso@126
|
728 fi
|
pankso@1
|
729 fi
|
pankso@126
|
730 done
|
pankso@1
|
731 done
|
pankso@225
|
732
|
pankso@215
|
733 # Get the list of installed packages
|
slaxemulator@514
|
734 ls -1 ${root}$INSTALLED > $CACHE/installed.list
|
pankso@358
|
735
|
paul@211
|
736 # Have we a missing build dep to cook ?
|
pankso@215
|
737 if [ -s "$CACHE/missing.dep" ] && [ "$AUTO_COOK" ]; then
|
pankso@205
|
738 gettext -e "Auto cook config is set : AUTO_COOK\n"
|
pankso@204
|
739 cp -f $LOGS/$PACKAGE.log $LOGS/$PACKAGE.log.$$
|
pankso@224
|
740 for i in $(uniq $CACHE/missing.dep)
|
pankso@204
|
741 do
|
pankso@205
|
742 (gettext "Building dep (wok/pkg) :"; echo " $i $vers") | \
|
pankso@204
|
743 tee -a $LOGS/$PACKAGE.log.$$
|
pankso@205
|
744 cook $i || (echo -e "ERROR: can't cook dep '$i'\n" && \
|
pankso@205
|
745 fgrep "remove: " $LOGS/$i.log && \
|
pankso@427
|
746 fgrep "Removing: " $LOGS/$i.log && newline) | \
|
pankso@204
|
747 tee -a $LOGS/$PACKAGE.log.$$ && break
|
pankso@204
|
748 done
|
pankso@215
|
749 rm -f $CACHE/missing.dep
|
pankso@204
|
750 mv $LOGS/$PACKAGE.log.$$ $LOGS/$PACKAGE.log
|
pankso@204
|
751 fi
|
pankso@358
|
752
|
paul@211
|
753 # QA: Exit on missing dep errors. We exit in both cases, if AUTO_COOK
|
paul@211
|
754 # is enabled and cook fails we have ERROR in log, if no auto cook we have
|
pankso@204
|
755 # missing dep in cached file.
|
pankso@215
|
756 if fgrep -q "ERROR:" $LOGS/$pkg.log || [ -s "$CACHE/missing.dep" ]; then
|
pankso@215
|
757 [ -s "$CACHE/missing.dep" ] && nb=$(cat $CACHE/missing.dep | wc -l)
|
pankso@215
|
758 echo "ERROR: missing dep $nb" && exit 1
|
pankso@202
|
759 fi
|
pankso@358
|
760
|
pankso@426
|
761 # Install local packages: package-version${arch}
|
pankso@224
|
762 for i in $(uniq $CACHE/installed.local)
|
pankso@215
|
763 do
|
slaxemulator@479
|
764 if [ -f "$INCOMING/$i" ]; then
|
slaxemulator@479
|
765 gettext "Installing dep (pkg/local):"; echo " $i"
|
slaxemulator@479
|
766 tazpkg install $INCOMING/$i --root=$root >/dev/null
|
slaxemulator@479
|
767 elif [ -f "$PKGS/$i" ]; then
|
slaxemulator@479
|
768 gettext "Installing dep (pkg/local):"; echo " $i"
|
slaxemulator@479
|
769 tazpkg install $PKGS/$i --root=$root >/dev/null
|
slaxemulator@479
|
770 fi
|
pankso@215
|
771 done
|
pankso@358
|
772
|
pankso@215
|
773 # Install web or cached packages (if mirror is set to $PKGS we only
|
pankso@215
|
774 # use local packages).
|
pankso@224
|
775 for i in $(uniq $CACHE/installed.web)
|
pankso@215
|
776 do
|
pankso@228
|
777 gettext "Installing dep (web/cache):"; echo " $i"
|
pankso@423
|
778 tazpkg get-install $i --root=$root >/dev/null
|
pankso@215
|
779 done
|
pankso@358
|
780
|
pankso@215
|
781 # If a cook failed deps are removed.
|
slaxemulator@479
|
782 ls -1 ${root}$INSTALLED > $CACHE/installed.cook
|
slaxemulator@479
|
783 [ ! -s "$CACHE/installed.cook.diff" ] && \
|
slaxemulator@479
|
784 busybox diff $CACHE/installed.list $CACHE/installed.cook > $CACHE/installed.cook.diff
|
slaxemulator@479
|
785 deps=$(cat $CACHE/installed.cook.diff | grep ^+[a-zA-Z0-9] | wc -l)
|
pankso@1
|
786
|
pankso@9
|
787 # Execute receipt rules.
|
slaxemulator@479
|
788 if [ $(grep ^compile_rules $receipt) ] && [ "$cook_code" = "" ]; then
|
pankso@352
|
789 echo "Executing: compile_rules"
|
pankso@352
|
790 echo "CFLAGS : $CFLAGS"
|
pankso@358
|
791 #echo "LDFLAGS : $LDFLAGS"
|
pankso@55
|
792 [ -d "$src" ] && cd $src
|
slaxemulator@479
|
793 compile_rules $@ || broken
|
slaxemulator@479
|
794 [ "$cook_code" ] && exit 1
|
pankso@10
|
795 # Stay compatible with _pkg
|
pankso@55
|
796 [ -d "$src/_pkg" ] && mv $src/_pkg $install
|
pankso@9
|
797 # QA: compile_rules success so valid.
|
pankso@9
|
798 mkdir -p $install
|
pankso@9
|
799 else
|
pankso@9
|
800 # QA: No compile_rules so no error, valid.
|
pankso@9
|
801 mkdir -p $install
|
pankso@1
|
802 fi
|
pankso@427
|
803 separator && newline
|
pankso@360
|
804
|
pankso@360
|
805 # Execute testsuite.
|
pankso@360
|
806 if grep -q ^testsuite $receipt; then
|
pankso@360
|
807 echo "Running testsuite"
|
pankso@360
|
808 separator
|
pankso@360
|
809 testsuite $@ || exit 1
|
pankso@427
|
810 separator && newline
|
pankso@360
|
811 fi
|
pankso@1
|
812 }
|
pankso@1
|
813
|
pankso@1
|
814 # Cook quality assurance.
|
pankso@1
|
815 cookit_quality() {
|
pankso@9
|
816 if [ ! -d "$WOK/$pkg/install" ] && [ ! "$WANTED" ]; then
|
pankso@15
|
817 echo -e "ERROR: cook failed" | tee -a $LOGS/$pkg.log
|
pankso@9
|
818 fi
|
pankso@9
|
819 # ERROR can be echoed any time in cookit()
|
pankso@33
|
820 if fgrep -q ERROR: $LOGS/$pkg.log; then
|
pankso@17
|
821 debug_info | tee -a $LOGS/$pkg.log
|
pankso@33
|
822 rm -f $command && exit 1
|
pankso@1
|
823 fi
|
pankso@1
|
824 }
|
pankso@1
|
825
|
pankso@16
|
826 # Create the package. Wanted to use Tazpkg to create a tazpkg package at first,
|
paul@62
|
827 # but it doesn't handle EXTRAVERSION.
|
pankso@1
|
828 packit() {
|
pankso@1
|
829 set_paths
|
pankso@359
|
830
|
pankso@359
|
831 # Handle cross compilation
|
pankso@359
|
832 case "$ARCH" in
|
pankso@428
|
833 arm|x86_64) arch="-$ARCH" ;;
|
pankso@359
|
834 esac
|
pankso@359
|
835
|
pankso@428
|
836 echo "Pack: $PACKAGE ${VERSION}${arch}"
|
pankso@1
|
837 separator
|
pankso@359
|
838
|
pankso@44
|
839 if grep -q ^genpkg_rules $receipt; then
|
pankso@16
|
840 gettext -e "Executing: genpkg_rules\n"
|
pankso@259
|
841 set -e && cd $pkgdir && mkdir -p $fs
|
slaxemulator@479
|
842 genpkg_rules || (broken && echo -e "\nERROR: genpkg_rules failed\n" >> \
|
slaxemulator@479
|
843 $LOGS/$pkg.log)
|
pankso@241
|
844 else
|
pankso@241
|
845 gettext "No packages rules: meta package"; echo
|
pankso@241
|
846 mkdir -p $fs
|
pankso@16
|
847 fi
|
pankso@98
|
848
|
pankso@98
|
849 # First QA check to stop now if genpkg_rules failed.
|
pankso@98
|
850 if fgrep -q ERROR: $LOGS/$pkg.log; then
|
slaxemulator@479
|
851 broken && exit 1
|
pankso@98
|
852 fi
|
pankso@358
|
853
|
pankso@44
|
854 cd $taz
|
pankso@1
|
855 for file in receipt description.txt
|
pankso@1
|
856 do
|
pankso@1
|
857 [ ! -f "../$file" ] && continue
|
pankso@1
|
858 gettext "Copying"; echo -n " $file..."
|
pankso@1
|
859 cp -f ../$file $pack && chown 0.0 $pack/$file && status
|
pankso@1
|
860 done
|
pankso@119
|
861 copy_generic_files
|
pankso@358
|
862
|
paul@62
|
863 # Create files.list with redirecting find output.
|
pankso@16
|
864 gettext "Creating the list of files..." && cd $fs
|
pankso@16
|
865 find . -type f -print > ../files.list
|
pankso@16
|
866 find . -type l -print >> ../files.list
|
pankso@16
|
867 cd .. && sed -i s/'^.'/''/ files.list
|
pankso@16
|
868 status
|
pankso@43
|
869
|
pankso@119
|
870 # Strip and stuff files.
|
slaxemulator@479
|
871 look_for_cookopt !strip && STRIP="n"
|
slaxemulator@479
|
872 [ "$STRIP" ] || strip_package
|
pankso@43
|
873
|
pankso@43
|
874 # Md5sum of files.
|
slaxemulator@479
|
875 gettext "Creating $CHECKSUM of files..."
|
pankso@16
|
876 while read file; do
|
pankso@16
|
877 [ -L "fs$file" ] && continue
|
pankso@16
|
878 [ -f "fs$file" ] || continue
|
pankso@16
|
879 case "$file" in
|
pankso@232
|
880 /lib/modules/*/modules.*|*.pyc) continue ;;
|
pankso@16
|
881 esac
|
slaxemulator@479
|
882 $CHECKSUM "fs$file" | sed 's/ fs/ /'
|
slaxemulator@479
|
883 done < files.list > "$CHECKSUM"
|
pankso@16
|
884 status
|
slaxemulator@479
|
885 UNPACKED_SIZE=$(du -chs fs receipt files.list $CHECKSUM \
|
pankso@16
|
886 description.txt 2> /dev/null | awk \
|
pankso@16
|
887 '{ sz=$1 } END { print sz }')
|
slaxemulator@479
|
888
|
slaxemulator@479
|
889 if [ "$UPCOOKLIST" ]; then
|
slaxemulator@479
|
890 check_so_files
|
slaxemulator@479
|
891 fi
|
slaxemulator@479
|
892
|
slaxemulator@479
|
893 # Generate md5 of cooking stuff to look for commit later.
|
slaxemulator@479
|
894 gen_cookmd5
|
slaxemulator@479
|
895 echo -e "\n# md5sum of cooking stuff :" >> receipt
|
slaxemulator@479
|
896 cat $WOK/$PACKAGE/md5 | sed 's/^/# /' >> receipt
|
slaxemulator@479
|
897
|
pankso@16
|
898 # Build cpio archives.
|
pankso@16
|
899 gettext "Compressing the fs... "
|
slaxemulator@479
|
900 find fs | cpio -o -H newc --quiet | lzma e fs.cpio.lzma -si $LZMA_SET_DIR
|
pankso@16
|
901 rm -rf fs
|
pankso@16
|
902 status
|
pankso@16
|
903 PACKED_SIZE=$(du -chs fs.cpio.lzma receipt files.list \
|
slaxemulator@479
|
904 $CHECKSUM description.txt 2> /dev/null | awk \
|
pankso@16
|
905 '{ sz=$1 } END { print sz }')
|
pankso@16
|
906 gettext "Updating receipt sizes..."
|
pankso@16
|
907 sed -i s/^PACKED_SIZE.*$// receipt
|
pankso@16
|
908 sed -i s/^UNPACKED_SIZE.*$// receipt
|
pankso@16
|
909 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
|
pankso@16
|
910 status
|
pankso@16
|
911
|
pankso@16
|
912 # Set extra version.
|
pankso@16
|
913 if [ "$EXTRAVERSION" ]; then
|
pankso@16
|
914 gettext "Updating receipt EXTRAVERSION: "; echo -n "$EXTRAVERSION"
|
pankso@16
|
915 sed -i s/^EXTRAVERSION.*$// receipt
|
pankso@16
|
916 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
|
pankso@16
|
917 status
|
pankso@16
|
918 fi
|
pankso@16
|
919
|
pankso@16
|
920 # Compress.
|
pankso@16
|
921 gettext "Creating full cpio archive... "
|
pankso@16
|
922 find . -print | cpio -o -H newc --quiet > \
|
pankso@428
|
923 ../$PACKAGE-${VERSION}${EXTRAVERSION}${arch}.tazpkg
|
pankso@16
|
924 status
|
pankso@16
|
925 gettext "Restoring original package tree... "
|
pankso@16
|
926 unlzma -c fs.cpio.lzma | cpio -idm --quiet
|
pankso@16
|
927 status
|
pankso@16
|
928 rm fs.cpio.lzma && cd ..
|
slaxemulator@479
|
929
|
slaxemulator@479
|
930 if [ "$UPCOOKLIST" ]; then
|
slaxemulator@479
|
931 check_recook_rdeps
|
slaxemulator@479
|
932 fi
|
slaxemulator@479
|
933
|
pankso@43
|
934 # QA and give info.
|
pankso@43
|
935 tazpkg=$(ls *.tazpkg)
|
pankso@43
|
936 packit_quality
|
pankso@43
|
937 separator && gettext "Package:"; echo -e " $tazpkg\n"
|
pankso@1
|
938 }
|
pankso@1
|
939
|
paul@62
|
940 # Verify package quality and consistency.
|
pankso@8
|
941 packit_quality() {
|
pankso@157
|
942 #gettext "QA: Checking for broken link..."
|
pankso@157
|
943 #link=$(find $fs/usr -type l -follow)
|
pankso@157
|
944 #[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
|
pankso@157
|
945 #status
|
pankso@358
|
946
|
pankso@142
|
947 # Exit if any error found in log file.
|
pankso@33
|
948 if fgrep -q ERROR: $LOGS/$pkg.log; then
|
pankso@32
|
949 rm -f $command && exit 1
|
pankso@8
|
950 fi
|
pankso@358
|
951
|
pankso@44
|
952 gettext "QA: Checking for empty package..."
|
pankso@45
|
953 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l)
|
pankso@259
|
954 if [ "$files" == 0 ] && [ "$CATEGORY" != "meta" ]; then
|
pankso@44
|
955 echo -e "\nERROR: empty package"
|
pankso@32
|
956 rm -f $command && exit 1
|
pankso@8
|
957 else
|
pankso@134
|
958 # Ls sort by name so the first file is the one we want.
|
slaxemulator@479
|
959 old=$(ls $INCOMING/$pkg-[0-9]*.tazpkg 2>/dev/null | head -n 1)
|
pankso@134
|
960 status
|
pankso@154
|
961 if [ -f "$old" ]; then
|
pankso@265
|
962 gettext "Removing old: $(basename $old)"
|
pankso@135
|
963 rm -f $old && status
|
pankso@154
|
964 fi
|
slaxemulator@479
|
965 mv -f $pkgdir/taz/$pkg-*.tazpkg $INCOMING
|
pankso@11
|
966 sed -i /^${pkg}$/d $broken
|
pankso@8
|
967 fi
|
pankso@8
|
968 }
|
pankso@8
|
969
|
pankso@428
|
970 # Install package on --install or update the chroot.
|
slaxemulator@479
|
971 install_package()
|
slaxemulator@479
|
972 {
|
slaxemulator@479
|
973 local pkg build
|
pankso@428
|
974 case "$ARCH" in
|
pankso@428
|
975 arm|x86_64)
|
pankso@428
|
976 arch="-${ARCH}"
|
pankso@443
|
977 root=$CROSS_TREE/sysroot ;;
|
slaxemulator@479
|
978 *)
|
slaxemulator@479
|
979 root="/" ;;
|
pankso@428
|
980 esac
|
pankso@428
|
981 # Install package if requested but skip install if target host doesn't
|
pankso@428
|
982 # match build system or it will break the build chroot.
|
pankso@428
|
983 build=$(echo $BUILD_SYSTEM | cut -d "-" -f 1)
|
slaxemulator@479
|
984 for pkg in $PACKAGE; do
|
slaxemulator@479
|
985 if [ -f "$inst" ] && [ "$build" == "$ARCH" ]; then
|
slaxemulator@479
|
986 if [ -f "$INCOMING/$pkg-${VERSION}${EXTRAVERSION}${arch}.tazpkg" ]; then
|
slaxemulator@479
|
987 echo "Updating $ARCH chroot environment..."
|
slaxemulator@479
|
988 echo "Updating chroot: $pkg (${VERSION}${EXTRAVERSION}${arch})" | log
|
slaxemulator@479
|
989 tazpkg install \
|
slaxemulator@479
|
990 $INCOMING/$pkg-${VERSION}${EXTRAVERSION}${arch}.tazpkg --root=$root --forced
|
slaxemulator@479
|
991 else
|
slaxemulator@479
|
992 gettext -e "Unable to install package, build has failed.\n\n"
|
slaxemulator@479
|
993 exit 1
|
slaxemulator@479
|
994 fi
|
pankso@428
|
995 fi
|
slaxemulator@479
|
996 done
|
slaxemulator@479
|
997
|
pankso@428
|
998 # Install package if part of the chroot to keep env up-to-date.
|
slaxemulator@479
|
999 if [ -f "${root}$INSTALLED/$pkg/receipt" ]; then
|
pankso@428
|
1000 . /etc/slitaz/cook.conf
|
pankso@428
|
1001 . $WOK/$pkg/taz/$pkg-*/receipt
|
pankso@428
|
1002 echo "Updating $ARCH chroot environment..."
|
pankso@428
|
1003 echo "Updating chroot: $pkg (${VERSION}${EXTRAVERSION}${arch})" | log
|
slaxemulator@479
|
1004 if [ -f "$PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}${arch}.tazpkg" ]; then
|
slaxemulator@479
|
1005 tazpkg install \
|
slaxemulator@479
|
1006 $PKGS/$pkg-${VERSION}${EXTRAVERSION}${arch}.tazpkg \
|
slaxemulator@479
|
1007 --forced --root=$root
|
slaxemulator@479
|
1008 elif [ -f "$INCOMING/$PACKAGE-${VERSION}${EXTRAVERSION}${arch}.tazpkg" ]; then
|
slaxemulator@479
|
1009 tazpkg install \
|
slaxemulator@479
|
1010 $INCOMING/$pkg-${VERSION}${EXTRAVERSION}${arch}.tazpkg \
|
slaxemulator@479
|
1011 --forced --root=$root
|
slaxemulator@479
|
1012 fi
|
pankso@428
|
1013 fi
|
pankso@428
|
1014 }
|
pankso@428
|
1015
|
slaxemulator@479
|
1016 tac()
|
slaxemulator@479
|
1017 {
|
slaxemulator@479
|
1018 sed '1!G;h;$!d' $1
|
slaxemulator@479
|
1019 }
|
slaxemulator@479
|
1020
|
slaxemulator@545
|
1021 # this function is to build the unbuild list
|
slaxemulator@479
|
1022 unbuild()
|
slaxemulator@479
|
1023 {
|
slaxemulator@479
|
1024 check_root
|
slaxemulator@479
|
1025 get_options_list="full list"
|
slaxemulator@479
|
1026 get_options
|
slaxemulator@479
|
1027 [ -f $unbuild ] && rm -rf $unbuild
|
slaxemulator@479
|
1028 LIST="$fullco"
|
slaxemulator@479
|
1029 [ -f "$1" ] && LIST="$1"
|
slaxemulator@479
|
1030 #[ "$full" ] && LIST=$(ls $WOK)
|
slaxemulator@479
|
1031 if [ -f "$1" -a "$full" ]; then
|
slaxemulator@479
|
1032 COMMAND=gen-cooklist
|
slaxemulator@479
|
1033 gen_cook_list
|
slaxemulator@479
|
1034 LIST="$tmp/cooklist"
|
slaxemulator@479
|
1035 fi
|
slaxemulator@479
|
1036 for pkg in $(cat $LIST | grep -v ^#); do
|
slaxemulator@479
|
1037 unset VERSION PACKAGE
|
slaxemulator@479
|
1038 [ -f $WOK/$pkg/receipt ] || continue
|
slaxemulator@479
|
1039 . $WOK/$pkg/receipt
|
slaxemulator@479
|
1040 if [ ! -f $INCOMING/$PACKAGE-${VERSION}*.tazpkg -a ! -f $PKGS/$PACKAGE-${VERSION}*.tazpkg ]; then
|
slaxemulator@479
|
1041 echo "$PACKAGE" && echo "$PACKAGE" >> $unbuild
|
slaxemulator@479
|
1042 fi
|
slaxemulator@479
|
1043 done
|
slaxemulator@479
|
1044 unset pkg
|
slaxemulator@479
|
1045 [ "$list" ] && cp -a $unbuild $cooklist
|
slaxemulator@479
|
1046 }
|
slaxemulator@479
|
1047
|
pascal@285
|
1048 # Launch the cook command into a chroot jail protected by aufs.
|
pascal@285
|
1049 # The current filesystems are used read-only and updates are
|
pascal@285
|
1050 # stored in a separate branch.
|
pascal@285
|
1051 try_aufs_chroot() {
|
pascal@285
|
1052
|
pascal@286
|
1053 base=/dev/shm/aufsmnt$$
|
pascal@286
|
1054
|
pascal@285
|
1055 # Can we setup the chroot ? Is it already done ?
|
pascal@292
|
1056 grep -q ^AUFS_NOT_SUPPORTED $receipt && return
|
pascal@285
|
1057 [ -n "$AUFS_MOUNTS" -a ! -f /aufs-umount.sh ] || return
|
pascal@285
|
1058 lsmod | grep -q aufs || modprobe aufs 2> /dev/null || return
|
pascal@286
|
1059 mkdir ${base}root ${base}rw || return
|
pascal@285
|
1060
|
pascal@285
|
1061 echo "Setup aufs chroot..."
|
pascal@285
|
1062
|
pascal@285
|
1063 # Sanity check
|
slaxemulator@479
|
1064 for i in / /proc /sys /dev/shm /dev/pts /home ; do
|
pascal@285
|
1065 case " $AUFS_MOUNTS " in
|
pascal@285
|
1066 *\ $i\ *) ;;
|
pascal@285
|
1067 *) AUFS_MOUNTS="$AUFS_MOUNTS $i" ;;
|
pascal@285
|
1068 esac
|
pascal@285
|
1069 done
|
pascal@285
|
1070 for mnt in $(echo $AUFS_MOUNTS | sort | uniq); do
|
pascal@285
|
1071 mount --bind $mnt ${base}root$mnt
|
pascal@285
|
1072 if [ $mnt == / ] && ! mount -t aufs -o br=${base}rw:/ none ${base}root; then
|
slaxemulator@518
|
1073 echo "Aufs mountage failure"
|
slaxemulator@518
|
1074 umount ${base}root
|
slaxemulator@518
|
1075 rmdir ${base}*
|
slaxemulator@518
|
1076 return
|
pascal@285
|
1077 fi
|
pascal@285
|
1078 echo "umount ${base}root$mnt" >> ${base}rw/aufs-umount.sh
|
pascal@285
|
1079 done
|
pascal@285
|
1080
|
pascal@285
|
1081 chroot ${base}root $(cd $(dirname $0); pwd)/$(basename $0) "$@"
|
pascal@285
|
1082 status=$?
|
pascal@285
|
1083
|
paul@342
|
1084 echo "Leaving aufs chroot..."
|
pascal@285
|
1085 tac ${base}rw/aufs-umount.sh | sh
|
pascal@285
|
1086 rm -rf ${base}rw
|
pascal@285
|
1087 umount ${base}root
|
pascal@285
|
1088 rmdir $base*
|
slaxemulator@479
|
1089
|
slaxemulator@479
|
1090 # Install package if requested
|
slaxemulator@479
|
1091 install_package
|
pankso@358
|
1092 exit $status
|
pascal@285
|
1093 }
|
pascal@285
|
1094
|
slaxemulator@479
|
1095 # Create a XML feed for freshly built package.
|
pankso@310
|
1096 gen_rss() {
|
pankso@310
|
1097 pubdate=$(date "+%a, %d %b %Y %X")
|
pankso@310
|
1098 cat > $FEEDS/$pkg.xml << EOT
|
pankso@310
|
1099 <item>
|
pankso@310
|
1100 <title>$PACKAGE $VERSION${EXTRAVERSION}</title>
|
pankso@310
|
1101 <link>${COOKER_URL}?pkg=$PACKAGE</link>
|
pankso@310
|
1102 <guid>$PACKAGE-$VERSION${EXTRAVERSION}</guid>
|
pankso@310
|
1103 <pubDate>$pubdate</pubDate>
|
pankso@310
|
1104 <description>$SHORT_DESC</description>
|
pankso@310
|
1105 </item>
|
pankso@310
|
1106 EOT
|
pankso@310
|
1107 }
|
pankso@310
|
1108
|
slaxemulator@479
|
1109
|
slaxemulator@479
|
1110
|
pankso@1
|
1111 #
|
pankso@1
|
1112 # Commands
|
pankso@1
|
1113 #
|
pankso@1
|
1114
|
slaxemulator@479
|
1115 case "$COMMAND" in
|
pankso@32
|
1116 usage|help|-u|-h)
|
pankso@1
|
1117 usage ;;
|
pankso@1
|
1118 list-wok)
|
pankso@52
|
1119 gettext -e "\nList of packages in:"; echo " $WOK"
|
pankso@1
|
1120 separator
|
pankso@1
|
1121 cd $WOK && ls -1
|
pankso@1
|
1122 separator
|
pankso@1
|
1123 echo -n "Packages: " && ls | wc -l
|
pankso@427
|
1124 newline ;;
|
pankso@378
|
1125 activity)
|
pankso@378
|
1126 cat $activity ;;
|
pankso@69
|
1127 search)
|
pankso@69
|
1128 # Just a simple search function, we dont need more actually.
|
pankso@69
|
1129 query="$2"
|
pankso@427
|
1130 newline
|
pankso@427
|
1131 gettext "Search results for:"; echo " $query"
|
pankso@69
|
1132 separator
|
pankso@69
|
1133 cd $WOK && ls -1 | grep "$query"
|
pankso@427
|
1134 separator && newline ;;
|
pankso@1
|
1135 setup)
|
pankso@1
|
1136 # Setup a build environment
|
pankso@1
|
1137 check_root
|
pankso@427
|
1138 echo "Cook: setup environment" | log
|
pankso@427
|
1139 newline
|
pankso@427
|
1140 gettext "Setting up your environment"; newline
|
pankso@1
|
1141 separator && cd $SLITAZ
|
pankso@52
|
1142 init_db_files
|
pankso@397
|
1143 gettext "Checking for packages to install..."; echo
|
pankso@397
|
1144 # Use setup pkgs from cross.conf or cook.conf. When cross compiling
|
pankso@397
|
1145 # ARCH-setup or 'cross check-env' should be used before: cook setup
|
pankso@397
|
1146 case "$ARCH" in
|
pankso@421
|
1147 arm|x86_64)
|
pankso@397
|
1148 if [ ! -x "/usr/bin/cross" ]; then
|
pankso@397
|
1149 gettext "ERROR: cross is not installed"; echo
|
pankso@397
|
1150 exit 1
|
pankso@397
|
1151 fi
|
pankso@397
|
1152 gettext "Using config file: /etc/slitaz/cross.conf"; echo
|
pankso@397
|
1153 . /etc/slitaz/cross.conf ;;
|
pankso@397
|
1154 esac
|
slaxemulator@468
|
1155 for pkg in $INSTALL_PKGS; do
|
pankso@397
|
1156 if [ "$forced" ]; then
|
pankso@421
|
1157 tazpkg -gi $pkg --forced
|
pankso@397
|
1158 else
|
slaxemulator@468
|
1159 [ -f "$INSTALLED/$pkg/receipt" ] || tazpkg get-install $pkg
|
pankso@397
|
1160 fi
|
pankso@397
|
1161 done
|
slaxemulator@468
|
1162 # chroot list
|
slaxemulator@468
|
1163 ls -1 "$INSTALLED" > $CACHE/chroot-pkgs
|
pankso@1
|
1164 # Handle --options
|
pankso@1
|
1165 case "$2" in
|
pankso@397
|
1166 --wok)
|
slaxemulator@479
|
1167 hg clone $WOK_URL $WOKHG || exit 1 ;;
|
pankso@230
|
1168 --stable)
|
slaxemulator@479
|
1169 hg clone $WOK_URL-stable $WOKHG || exit 1 ;;
|
pankso@230
|
1170 --undigest)
|
slaxemulator@479
|
1171 hg clone $WOK_URL-undigest $WOKHG || exit 1 ;;
|
pankso@397
|
1172 --tiny)
|
slaxemulator@479
|
1173 hg clone $WOK_URL-tiny $WOKHG || exit 1 ;;
|
pankso@1
|
1174 esac
|
pankso@1
|
1175
|
slaxemulator@479
|
1176 rsync_wok
|
slaxemulator@479
|
1177
|
pankso@1
|
1178 # SliTaz group and permissions
|
pankso@1
|
1179 if ! grep -q ^slitaz /etc/group; then
|
pankso@1
|
1180 gettext -e "Adding group: slitaz\n"
|
pankso@1
|
1181 addgroup slitaz
|
pankso@1
|
1182 fi
|
pankso@1
|
1183 gettext -e "Setting permissions for slitaz group...\n"
|
pascal@277
|
1184 find $SLITAZ -maxdepth 2 -exec chown root.slitaz {} \;
|
pascal@277
|
1185 find $SLITAZ -maxdepth 2 -exec chmod g+w {} \;
|
pankso@1
|
1186 separator
|
pankso@1
|
1187 gettext -e "All done, ready to cook packages :-)\n\n" ;;
|
pankso@395
|
1188 *-setup)
|
pankso@395
|
1189 # Setup for cross compiling.
|
pankso@395
|
1190 arch=${1%-setup}
|
pankso@397
|
1191 check_root
|
pankso@430
|
1192 echo "Cook: setup $arch cross environment" | log
|
pankso@427
|
1193 newline
|
pankso@443
|
1194 boldify $(gettext "Setting up your $arch cross environment")
|
pankso@397
|
1195 separator
|
pankso@397
|
1196 init_db_files
|
pankso@359
|
1197 sed -i \
|
pankso@396
|
1198 -e s"/ARCH=.*/ARCH=\"$arch\"/" \
|
pankso@443
|
1199 -e s"/CROSS_TREE=.*/CROSS_TREE=\"\/cross\/$arch\"/" \
|
pankso@359
|
1200 -e s'/BUILD_SYSTEM=.*/BUILD_SYSTEM=i486-slitaz-linux/' \
|
pankso@395
|
1201 /etc/slitaz/cook.conf
|
pankso@395
|
1202 case "$arch" in
|
pankso@395
|
1203 arm)
|
pankso@395
|
1204 sed -i \
|
pankso@443
|
1205 -e s'/CFLAGS=.*/CFLAGS="-march=armv6 -O2"/' \
|
pankso@395
|
1206 -e s'/HOST_SYSTEM=.*/HOST_SYSTEM=$ARCH-slitaz-linux-gnueabi/' \
|
pankso@397
|
1207 -e s'/xorg-dev/""/' \
|
pankso@395
|
1208 /etc/slitaz/cook.conf ;;
|
pankso@395
|
1209 x86_64)
|
pankso@395
|
1210 sed -i \
|
pankso@395
|
1211 -e s'/CFLAGS=.*/CFLAGS=""/' \
|
pankso@395
|
1212 -e s'/HOST_SYSTEM=.*/HOST_SYSTEM=$ARCH-slitaz-linux/' \
|
pankso@395
|
1213 /etc/slitaz/cook.conf ;;
|
pankso@395
|
1214 esac
|
pankso@359
|
1215 . /etc/slitaz/cook.conf
|
pankso@443
|
1216 sysroot=$CROSS_TREE/sysroot
|
pankso@443
|
1217 tools=/cross/$arch/tools
|
pankso@443
|
1218 root=$sysroot
|
pankso@443
|
1219 CC=$tools/bin/${HOST_SYSTEM}-gcc
|
pankso@421
|
1220 echo "Target arch : $ARCH"
|
pankso@421
|
1221 echo "Configure args : $CONFIGURE_ARGS"
|
pankso@443
|
1222 echo "Arch sysroot : $sysroot"
|
pankso@443
|
1223 echo "Tools prefix : $tools/bin"
|
paul@455
|
1224 # Tell the packages manager where to find packages.
|
pankso@426
|
1225 echo "Packages DB : ${root}$DB"
|
pankso@429
|
1226 mkdir -p ${root}$INSTALLED
|
pankso@426
|
1227 cd ${root}$DB && rm -f *.bak
|
pankso@426
|
1228 for list in packages.list packages.desc packages.equiv packages.md5
|
pankso@426
|
1229 do
|
pankso@426
|
1230 rm -f $list && ln -s $SLITAZ/packages/$list $list
|
pankso@426
|
1231 done
|
pankso@429
|
1232 # We must have the cross compiled glibc-base installed or default
|
pankso@429
|
1233 # i486 package will be used as dep by tazpkg and then break the
|
pankso@429
|
1234 # cross environment
|
pankso@429
|
1235 if [ ! -f "${root}$INSTALLED/glibc-base/receipt" ]; then
|
pankso@443
|
1236 colorize 36 "WARNING: (e)glibc-base is not installed in sysroot"
|
pankso@429
|
1237 fi
|
pankso@426
|
1238 # Show GCC version or warn if not yet compiled.
|
pankso@406
|
1239 if [ -x $CC ]; then
|
pankso@421
|
1240 echo "Cross compiler : ${HOST_SYSTEM}-gcc"
|
pankso@359
|
1241 else
|
pankso@437
|
1242 colorize 36 "C compiler is missing: ${HOST_SYSTEM}-gcc"
|
paul@387
|
1243 echo "Run 'cross compile' to cook a toolchain"
|
pankso@397
|
1244 fi
|
pankso@427
|
1245 separator && newline ;;
|
slaxemulator@479
|
1246 upwok)
|
slaxemulator@479
|
1247 case "$2" in
|
slaxemulator@479
|
1248 --local)
|
slaxemulator@479
|
1249 gettext -e "Updating local chanages in wok-hg to wok...\n"
|
slaxemulator@479
|
1250 rsync_wok || exit 1
|
slaxemulator@479
|
1251 exit 1 ;;
|
slaxemulator@479
|
1252 esac
|
slaxemulator@479
|
1253
|
slaxemulator@479
|
1254 gettext -e "Updating wok-hg...\n"
|
slaxemulator@479
|
1255 if [ -d $WOKHG/.hg ]; then
|
slaxemulator@479
|
1256 cd $WOKHG
|
slaxemulator@479
|
1257 hg pull -u || exit 1
|
slaxemulator@479
|
1258 fi
|
slaxemulator@479
|
1259 cd $SLITAZ
|
slaxemulator@479
|
1260 rsync_wok || exit 1 ;;
|
pankso@9
|
1261 test)
|
pankso@9
|
1262 # Test a cook environment.
|
pankso@13
|
1263 echo "Cook test: testing the cook environment" | log
|
pankso@9
|
1264 [ ! -d "$WOK" ] && exit 1
|
pankso@9
|
1265 [ ! -d "$WOK/cooktest" ] && cp -r $DATA/cooktest $WOK
|
pankso@9
|
1266 cook cooktest ;;
|
pankso@1
|
1267 new)
|
pankso@1
|
1268 # Create the package folder and an empty receipt.
|
pankso@1
|
1269 pkg="$2"
|
pankso@1
|
1270 [ "$pkg" ] || usage
|
pankso@427
|
1271 newline
|
slaxemulator@479
|
1272 if [ -d "$WOKHG/$pkg" ]; then
|
paul@62
|
1273 echo -n "$pkg " && gettext "package already exists."
|
pankso@1
|
1274 echo -e "\n" && exit 1
|
pankso@1
|
1275 fi
|
slaxemulator@479
|
1276 gettext "Creating"; echo -n " $WOKHG/$pkg"
|
slaxemulator@479
|
1277 mkdir $WOKHG/$pkg && cd $WOKHG/$pkg && status
|
pankso@1
|
1278 gettext "Preparing the package receipt..."
|
pankso@1
|
1279 cp $DATA/receipt .
|
pankso@1
|
1280 sed -i s"/^PACKAGE=.*/PACKAGE=\"$pkg\"/" receipt
|
pankso@427
|
1281 status && newline
|
pankso@358
|
1282
|
pankso@196
|
1283 # Interactive mode, asking and seding.
|
pankso@196
|
1284 case "$3" in
|
paul@214
|
1285 --interactive|-x)
|
pankso@358
|
1286 gettext -e "Entering interactive mode...\n"
|
paul@211
|
1287 separator
|
pankso@196
|
1288 echo "Package : $pkg"
|
pankso@196
|
1289 # Version.
|
pankso@196
|
1290 echo -n "Version : " ; read anser
|
pankso@196
|
1291 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
|
pankso@196
|
1292 # Category.
|
pankso@196
|
1293 echo -n "Category : " ; read anser
|
pankso@196
|
1294 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
|
pankso@196
|
1295 # Short description.
|
pankso@196
|
1296 echo -n "Short desc : " ; read anser
|
pankso@196
|
1297 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
|
pankso@196
|
1298 # Maintainer.
|
pankso@196
|
1299 echo -n "Maintainer : " ; read anser
|
pankso@196
|
1300 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
|
slaxemulator@471
|
1301 # License.
|
slaxemulator@471
|
1302 echo -n "License : " ; read anser
|
slaxemulator@471
|
1303 sed -i s/'LICENSE=\"\"'/"LICENSE=\"$anser\""/ receipt
|
pankso@196
|
1304 # Web site.
|
pankso@196
|
1305 echo -n "Web site : " ; read anser
|
pankso@196
|
1306 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
|
pankso@427
|
1307 newline
|
pankso@196
|
1308 # Wget URL.
|
pankso@196
|
1309 echo "Wget URL to download source tarball."
|
pankso@196
|
1310 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
|
pankso@196
|
1311 echo -n "Wget url : " ; read anser
|
paul@211
|
1312 sed -i s#'WGET_URL=\"$TARBALL\"'#"WGET_URL=\"$anser\""# receipt
|
pankso@196
|
1313 # Ask for a stuff dir.
|
pankso@196
|
1314 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
|
pankso@196
|
1315 if [ "$anser" = "y" ]; then
|
pankso@196
|
1316 echo -n "Creating the stuff directory..."
|
slaxemulator@479
|
1317 mkdir -p $WOKHG/$pkg/stuff && status
|
pankso@196
|
1318 fi
|
pankso@196
|
1319 # Ask for a description file.
|
pankso@196
|
1320 echo -n "Are you going to write a description ? (y/N) : " ; read anser
|
pankso@196
|
1321 if [ "$anser" = "y" ]; then
|
pankso@196
|
1322 echo -n "Creating the description.txt file..."
|
slaxemulator@479
|
1323 newline > $WOKHG/$pkg/description.txt && status
|
pankso@196
|
1324 fi
|
paul@211
|
1325 separator
|
paul@211
|
1326 gettext -e "Receipt is ready to use.\n"
|
pankso@427
|
1327 newline ;;
|
pankso@196
|
1328 esac ;;
|
pankso@1
|
1329 list)
|
pankso@1
|
1330 # Cook a list of packages (better use the Cooker since it will order
|
pankso@1
|
1331 # packages before executing cook).
|
pankso@1
|
1332 check_root
|
pankso@1
|
1333 [ -z "$2" ] && gettext -e "\nNo list in argument.\n\n" && exit 1
|
pankso@1
|
1334 [ ! -f "$2" ] && gettext -e "\nNo list found:" && \
|
pankso@1
|
1335 echo -e " $2\n" && exit 1
|
pankso@13
|
1336 echo "Cook list starting: $2" | log
|
pankso@1
|
1337 for pkg in $(cat $2)
|
pankso@1
|
1338 do
|
pankso@1
|
1339 cook $pkg || broken
|
pankso@1
|
1340 done ;;
|
pankso@1
|
1341 clean-wok)
|
pankso@1
|
1342 check_root
|
pankso@1
|
1343 gettext -e "\nCleaning all packages files..."
|
pankso@1
|
1344 rm -rf $WOK/*/taz $WOK/*/install $WOK/*/source
|
pankso@427
|
1345 status && newline ;;
|
pankso@1
|
1346 clean-src)
|
pankso@1
|
1347 check_root
|
paul@62
|
1348 gettext -e "\nCleaning all packages sources..."
|
pankso@1
|
1349 rm -rf $WOK/*/source
|
pankso@427
|
1350 status && newline ;;
|
slaxemulator@479
|
1351 gen-cooklist)
|
slaxemulator@479
|
1352 check_root
|
slaxemulator@479
|
1353 [ -f "$2" ] && LIST="$2"
|
slaxemulator@479
|
1354 get_options_list="pkg wok missing"
|
slaxemulator@479
|
1355 get_options
|
slaxemulator@479
|
1356 if ! [ "$pkg" ]; then
|
slaxemulator@479
|
1357 if [ ! "$LIST" ] || [ "$LIST" = "toolchain" ]; then
|
slaxemulator@479
|
1358 pkg="$TOOLCHAIN $TOOLCHAIN_EXTRA"
|
slaxemulator@479
|
1359 else
|
slaxemulator@479
|
1360 check_for_list
|
slaxemulator@479
|
1361 fi
|
slaxemulator@479
|
1362 fi
|
slaxemulator@479
|
1363 gen_cook_list
|
slaxemulator@479
|
1364 if [ "$missing" ]; then
|
slaxemulator@479
|
1365 cooklist=${LIST:-$cooklist}
|
slaxemulator@479
|
1366 for pkgname in $(cat $cooklist)
|
slaxemulator@479
|
1367 do
|
slaxemulator@479
|
1368 unset EXTRAVERSION
|
slaxemulator@479
|
1369 [ -f $wok/$pkgname/receipt ] || continue
|
slaxemulator@479
|
1370 . $wok/$pkgname/receipt
|
slaxemulator@479
|
1371 if [ -f $INCOMING/$PACKAGE-${VERSION}*.tazpkg -o -f $PKGS/$PACKAGE-${VERSION}*.tazpkg ]; then
|
slaxemulator@479
|
1372 if grep "^$pkgname" $cooklist; then
|
slaxemulator@479
|
1373 sed -i "s|^$pkgname$||g" $cooklist
|
slaxemulator@479
|
1374 sed -i /^$/d $cooklist
|
slaxemulator@479
|
1375 fi
|
slaxemulator@479
|
1376 fi
|
slaxemulator@479
|
1377 done
|
slaxemulator@479
|
1378 fi
|
slaxemulator@479
|
1379
|
slaxemulator@479
|
1380 #rm -f $command
|
slaxemulator@479
|
1381 ;;
|
slaxemulator@479
|
1382 gen-wok-db)
|
slaxemulator@479
|
1383 check_root
|
slaxemulator@479
|
1384 #echo "cook:gen-wok-db" > $command
|
slaxemulator@479
|
1385 [ -d "$WOKHG" ] && WOK="$WOKHG"
|
slaxemulator@479
|
1386 [ "$2" ] && WOK="$2"
|
slaxemulator@479
|
1387 gen_wok_db ;;
|
slaxemulator@479
|
1388 check-incoming)
|
slaxemulator@479
|
1389 check_root
|
slaxemulator@479
|
1390 get_options_list="forced"
|
slaxemulator@479
|
1391 get_options
|
slaxemulator@479
|
1392 echo "cook:check-incoming" > $command
|
slaxemulator@479
|
1393 check_for_incoming
|
slaxemulator@479
|
1394 rm -f $command ;;
|
slaxemulator@479
|
1395 gen-src)
|
slaxemulator@479
|
1396 check_root
|
slaxemulator@479
|
1397 [ "$2" ] && src_repository="$2"
|
slaxemulator@479
|
1398 [ -d "$src_repository" ] || src_repository="$SRC"
|
slaxemulator@479
|
1399 gettext -e "Rebulding sources.list file: $src_repository"
|
slaxemulator@479
|
1400 gen_sources_list $src_repository
|
slaxemulator@479
|
1401 status ;;
|
slaxemulator@479
|
1402 maintainers)
|
slaxemulator@479
|
1403 check_root
|
slaxemulator@479
|
1404 newline
|
slaxemulator@479
|
1405 echo "List of maintainers for: $WOK"
|
slaxemulator@479
|
1406 separator
|
slaxemulator@479
|
1407 tmp="/tmp/slitaz-maintainers"
|
slaxemulator@479
|
1408 touch $tmp
|
slaxemulator@479
|
1409 for pkg in $WOK/*
|
slaxemulator@479
|
1410 do
|
slaxemulator@479
|
1411 [ -f $pkg/receipt ] || continue
|
slaxemulator@479
|
1412 . $pkg/receipt
|
slaxemulator@479
|
1413 if ! fgrep -q "$MAINTAINER" $tmp; then
|
slaxemulator@479
|
1414 echo "$MAINTAINER" >> $tmp
|
slaxemulator@479
|
1415 echo "$MAINTAINER"
|
slaxemulator@479
|
1416 fi
|
slaxemulator@479
|
1417 done
|
slaxemulator@479
|
1418 separator
|
slaxemulator@479
|
1419 echo "Maintainers: `cat $tmp | wc -l`"
|
slaxemulator@479
|
1420 newline
|
slaxemulator@479
|
1421 # Remove tmp files
|
slaxemulator@479
|
1422 [ -f $tmp ] && rm -f $tmp
|
slaxemulator@479
|
1423 ;;
|
slaxemulator@479
|
1424 tags)
|
slaxemulator@479
|
1425 check_root
|
slaxemulator@479
|
1426 echo -e "\n\033[1mTags list :\033[0m"
|
slaxemulator@479
|
1427 separator
|
slaxemulator@479
|
1428 tmp="/tmp/tags"
|
slaxemulator@479
|
1429 touch $tmp
|
slaxemulator@479
|
1430 for pkg in $WOK/*; do
|
slaxemulator@479
|
1431 unset TAGS
|
slaxemulator@479
|
1432 [ -f $pkg/receipt ] || continue
|
slaxemulator@479
|
1433 source $pkg/receipt
|
slaxemulator@479
|
1434 for t in $TAGS; do
|
slaxemulator@479
|
1435 grep -q ^$t$ $tmp && continue
|
slaxemulator@479
|
1436 echo $t | tee -a $tmp
|
slaxemulator@479
|
1437 done
|
slaxemulator@479
|
1438 done
|
slaxemulator@479
|
1439 separator
|
slaxemulator@479
|
1440 echo "$(wc -l $tmp | cut -f1 -d ' ') tags listed."
|
slaxemulator@479
|
1441 [ -f $tmp ] && rm -rf $tmp
|
slaxemulator@479
|
1442 ;;
|
slaxemulator@479
|
1443 maintained-by)
|
slaxemulator@479
|
1444 # Search for packages maintained by a contributor.
|
slaxemulator@479
|
1445 check_root
|
slaxemulator@479
|
1446 if [ ! -n "$2" ]; then
|
slaxemulator@479
|
1447 echo "Specify a name or email of a maintainer." >&2
|
slaxemulator@479
|
1448 exit 1
|
slaxemulator@479
|
1449 fi
|
slaxemulator@479
|
1450 echo "Maintainer packages"
|
slaxemulator@479
|
1451 separator
|
slaxemulator@479
|
1452 for pkg in $WOK/*
|
slaxemulator@479
|
1453 do
|
slaxemulator@479
|
1454 [ -f $pkg/receipt ] || continue
|
slaxemulator@479
|
1455 . $pkg/receipt
|
slaxemulator@479
|
1456 if echo "$MAINTAINER" | fgrep -q "$2"; then
|
slaxemulator@479
|
1457 echo "$PACKAGE"
|
slaxemulator@479
|
1458 packages=$(($packages+1))
|
slaxemulator@479
|
1459 fi
|
slaxemulator@479
|
1460 done
|
slaxemulator@479
|
1461 separator
|
slaxemulator@479
|
1462 echo "Packages maintained by $2: $packages"
|
slaxemulator@479
|
1463 newline
|
slaxemulator@479
|
1464 ;;
|
slaxemulator@479
|
1465 check-src)
|
slaxemulator@479
|
1466 # Verify if upstream package is still available.
|
slaxemulator@479
|
1467 #
|
slaxemulator@479
|
1468 check_root
|
slaxemulator@479
|
1469 PACKAGE="$2"
|
slaxemulator@479
|
1470 receipt="$WOK/$PACKAGE/receipt"
|
slaxemulator@479
|
1471 if [ ! -f $receipt ]; then
|
slaxemulator@479
|
1472 gettext -e "\nUnable to find package in the wok:"
|
slaxemulator@479
|
1473 echo -e " $PACKAGE\n" && exit 1
|
slaxemulator@479
|
1474 fi
|
slaxemulator@479
|
1475 unset_receipt
|
slaxemulator@479
|
1476 source $receipt
|
slaxemulator@479
|
1477 check_src()
|
slaxemulator@479
|
1478 {
|
slaxemulator@479
|
1479 for url in $@; do
|
slaxemulator@479
|
1480 busybox wget -s $url 2>/dev/null && break
|
slaxemulator@479
|
1481 done
|
slaxemulator@479
|
1482 }
|
slaxemulator@479
|
1483 if [ "$WGET_URL" ];then
|
slaxemulator@479
|
1484 echo -n "$PACKAGE : "
|
slaxemulator@479
|
1485 check_src $WGET_URL
|
slaxemulator@479
|
1486 status
|
slaxemulator@479
|
1487 else
|
slaxemulator@479
|
1488 echo "No tarball to check for $PACKAGE"
|
slaxemulator@479
|
1489 fi
|
slaxemulator@479
|
1490 ;;
|
slaxemulator@479
|
1491 unbuild)
|
slaxemulator@479
|
1492 unbuild "$2" "$3" ;;
|
pankso@235
|
1493 pkgdb)
|
pankso@235
|
1494 # Create suitable packages list for TazPKG and only for built packages
|
pankso@235
|
1495 # as well as flavors files for TazLiTo. We dont need logs since we do it
|
paul@243
|
1496 # manually to ensure everything is fine before syncing the mirror.
|
slaxemulator@479
|
1497 pkgdb "$2"
|
slaxemulator@521
|
1498 if [ "$3" == "--flavors" ]; then
|
slaxemulator@521
|
1499 cook flavors
|
slaxemulator@521
|
1500 fi
|
slaxemulator@521
|
1501 exit 0 ;;
|
slaxemulator@521
|
1502 flavors)
|
slaxemulator@528
|
1503 [ -d "$flavors" ] || $(echo -e "Missing flavors: $flavors\n" && exit 1)
|
slaxemulator@528
|
1504 [ -d "$live" ] || mkdir -p $live
|
slaxemulator@521
|
1505 gettext "Creating flavors files in:"; echo " $live"
|
slaxemulator@521
|
1506 echo "Cook pkgdb: Creating all flavors" | log
|
slaxemulator@521
|
1507 separator
|
slaxemulator@521
|
1508 gettext -e "Recharging lists to use latest packages...\n"
|
slaxemulator@521
|
1509 tazpkg recharge >/dev/null 2>/dev/null
|
slaxemulator@521
|
1510
|
slaxemulator@528
|
1511 if [ ! -f "$live/cookiso.conf" ]; then
|
slaxemulator@521
|
1512 echo "Creating configuration file: tazlito.conf"
|
slaxemulator@528
|
1513 cp /etc/slitaz/cookiso.conf $live
|
slaxemulator@528
|
1514 sed -i "s|WORK_DIR=.*|WORK_DIR="$SLITAZ"|g" $live/cookiso.conf
|
slaxemulator@521
|
1515 fi
|
slaxemulator@521
|
1516
|
slaxemulator@521
|
1517 #[ -d "$flavors/.hg" ] && $flavors && hg pull -u
|
slaxemulator@521
|
1518
|
slaxemulator@521
|
1519 cd $live
|
slaxemulator@521
|
1520 echo "Starting to generate flavors..."
|
slaxemulator@521
|
1521 rm -f flavors.list *.flavor
|
slaxemulator@521
|
1522 for i in $flavors/*
|
slaxemulator@521
|
1523 do
|
slaxemulator@521
|
1524 fl=$(basename $i)
|
slaxemulator@521
|
1525 echo "Packing flavor: $(basename $i)"
|
slaxemulator@528
|
1526 pack_flavor $fl >/dev/null || exit 1
|
slaxemulator@528
|
1527 show_flavor $fl --brief --noheader 2> \
|
slaxemulator@521
|
1528 /dev/null >> flavors.list
|
slaxemulator@521
|
1529 done
|
slaxemulator@521
|
1530 cp -f $live/*.flavor $live/flavors.list $PKGS
|
slaxemulator@521
|
1531 separator && gettext "Flavors size: "; du -sh $live | awk '{print $1}'
|
slaxemulator@479
|
1532 exit 0 ;;
|
slaxemulator@479
|
1533 clean-chroot)
|
slaxemulator@479
|
1534 clean_chroot ;;
|
pankso@1
|
1535 *)
|
pankso@1
|
1536 # Just cook and generate a package.
|
pankso@1
|
1537 check_root
|
pankso@1
|
1538 time=$(date +%s)
|
pankso@1
|
1539 pkg="$1"
|
pankso@1
|
1540 [ -z "$pkg" ] && usage
|
pankso@44
|
1541 receipt="$WOK/$pkg/receipt"
|
pankso@427
|
1542 check_pkg_in_wok && newline
|
pankso@47
|
1543
|
pankso@377
|
1544 unset inst
|
pankso@377
|
1545 unset_receipt
|
pankso@377
|
1546 . $receipt
|
pankso@377
|
1547
|
pankso@377
|
1548 # Handle cross compilation.
|
pankso@377
|
1549 #
|
pankso@377
|
1550 # CROSS_NOTE: Actually we are running an ARM cooker but running
|
pankso@377
|
1551 # the cooker and build each commit in wok is not possible since
|
pankso@377
|
1552 # we dont cook the full wok for this arch. For ARM we need a set
|
paul@387
|
1553 # of packages to handle a touch screen desktop, servers but not
|
pankso@377
|
1554 # erland.
|
pankso@377
|
1555 #
|
pankso@377
|
1556 # The temporary solution is to build only reviewed and tested
|
pankso@377
|
1557 # packages with HOST_ARCH set in receipt.
|
pankso@377
|
1558 case "$ARCH" in
|
pankso@377
|
1559 arm)
|
pankso@377
|
1560 if [ ! "$HOST_ARCH" ]; then
|
pankso@379
|
1561 echo "cook: HOST_ARCH is not set in $pkg receipt"
|
paul@387
|
1562 echo "cook: This package is not included in: $ARCH"
|
pankso@377
|
1563 [ "$CROSS_BUGS" ] && echo "bugs: $CROSS_BUGS"
|
paul@387
|
1564 echo "Cook skip: $pkg is not included in: $ARCH" | log
|
pankso@427
|
1565 newline && exit 1
|
pankso@377
|
1566 fi ;;
|
pankso@377
|
1567 esac
|
pankso@377
|
1568
|
paul@387
|
1569 # Some packages are not included in some arch or fail to cross compile.
|
pankso@398
|
1570 : ${HOST_ARCH=i486}
|
pankso@381
|
1571 if ! $(echo "$HOST_ARCH" | fgrep -q $ARCH); then
|
pankso@381
|
1572 echo "cook: HOST_ARCH=$HOST_ARCH"
|
paul@387
|
1573 echo "cook: $pkg doesn't cook or is not included in: $ARCH"
|
pankso@381
|
1574 [ "$CROSS_BUGS" ] && echo "bugs: $CROSS_BUGS"
|
paul@387
|
1575 echo "Cook skip: $pkg doesn't cook or is not included in: $ARCH" | log
|
pankso@427
|
1576 newline && exit 1
|
pankso@377
|
1577 fi
|
pankso@377
|
1578
|
pankso@47
|
1579 # Skip blocked, 3 lines also for the Cooker.
|
pankso@151
|
1580 if grep -q "^$pkg$" $blocked && [ "$2" != "--unblock" ]; then
|
pankso@47
|
1581 gettext -e "Blocked package:"; echo -e " $pkg\n" && exit 0
|
pankso@47
|
1582 fi
|
pankso@47
|
1583
|
slaxemulator@468
|
1584 if [ "$AUFS_MODE" ]; then
|
slaxemulator@468
|
1585 try_aufs_chroot "$@"
|
slaxemulator@468
|
1586 fi
|
pascal@289
|
1587
|
pankso@47
|
1588 # Log and source receipt.
|
pankso@56
|
1589 echo "Cook started for: <a href='cooker.cgi?pkg=$pkg'>$pkg</a>" | log
|
pankso@16
|
1590 echo "cook:$pkg" > $command
|
pascal@285
|
1591
|
pascal@285
|
1592 # Display and log info if cook process stopped.
|
pascal@285
|
1593 trap 'gettext -e "\n\nCook stopped: control-C\n\n" | \
|
pascal@285
|
1594 tee -a $LOGS/$pkg.log' INT
|
pascal@285
|
1595
|
slaxemulator@479
|
1596 set_paths
|
slaxemulator@479
|
1597
|
pankso@1
|
1598 # Handle --options
|
pankso@1
|
1599 case "$2" in
|
pankso@1
|
1600 --clean|-c)
|
pankso@49
|
1601 gettext -e "Cleaning:"; echo -n " $pkg"
|
pankso@1
|
1602 cd $WOK/$pkg && rm -rf install taz source
|
pankso@427
|
1603 status && newline && exit 0 ;;
|
pankso@1
|
1604 --install|-i)
|
pankso@1
|
1605 inst='yes' ;;
|
slaxemulator@479
|
1606 --noupdate|-nu)
|
slaxemulator@479
|
1607 UPCHROOT="" ;;
|
slaxemulator@479
|
1608 --nocleanchroot|-ncc)
|
slaxemulator@479
|
1609 CLEAN_CHROOT="" ;;
|
pankso@49
|
1610 --getsrc|-gs)
|
slaxemulator@479
|
1611 getsrc "$3"
|
slaxemulator@479
|
1612 exit 0 ;;
|
pankso@49
|
1613 --block|-b)
|
pankso@49
|
1614 gettext "Blocking:"; echo -n " $pkg"
|
pankso@49
|
1615 [ $(grep "^$pkg$" $blocked) ] || echo "$pkg" >> $blocked
|
pankso@427
|
1616 status && newline && exit 0 ;;
|
pankso@49
|
1617 --unblock|-ub)
|
pankso@49
|
1618 gettext "Unblocking:"; echo -n " $pkg"
|
pankso@49
|
1619 sed -i "/^${pkg}$/"d $blocked
|
pankso@427
|
1620 status && newline && exit 0 ;;
|
slaxemulator@501
|
1621 --pack)
|
slaxemulator@501
|
1622 if [ -d $WOK/$pkg/taz ]; then
|
slaxemulator@501
|
1623 rm -rf $WOK/$pkg/taz
|
slaxemulator@501
|
1624 [ -f $LOGS/$pkg-pack.log ] && rm -rf $LOGS/$pkg-pack.log
|
slaxemulator@501
|
1625 packit 2>&1 | tee -a $LOGS/$pkg-pack.log
|
slaxemulator@501
|
1626 clean_log
|
slaxemulator@501
|
1627 else
|
slaxemulator@501
|
1628 gettext "Need to build $pkg." && exit 0
|
slaxemulator@501
|
1629 fi
|
slaxemulator@501
|
1630 exit 0 ;;
|
pankso@1
|
1631 esac
|
pankso@1
|
1632
|
paul@62
|
1633 # Check if wanted is built now so we have separate log files.
|
slaxemulator@479
|
1634 if [ "$WANTED" ]; then
|
slaxemulator@479
|
1635 if grep -q "^$WANTED$" $blocked; then
|
slaxemulator@479
|
1636 echo "WANTED package $PACKAGE is blocked: $WANTED" | tee $LOGS/$pkg.log
|
pankso@427
|
1637 newline && rm -f $command && exit 1
|
pankso@217
|
1638 fi
|
slaxemulator@479
|
1639 if grep -q "^$WANTED$" $broken; then
|
slaxemulator@479
|
1640 echo "WANTED package $PACKAGE is broken: $WANTED" | tee $LOGS/$pkg.log
|
pankso@427
|
1641 newline && rm -f $command && exit 1
|
pankso@218
|
1642 fi
|
slaxemulator@479
|
1643 if [ ! "$COOK_WANTED" ]; then
|
slaxemulator@479
|
1644 if [ ! -d "$WOK/$WANTED/install" ]; then
|
slaxemulator@479
|
1645 cook "$WANTED" || exit 1
|
slaxemulator@479
|
1646 fi
|
pankso@137
|
1647 fi
|
slaxemulator@479
|
1648 fi
|
slaxemulator@479
|
1649
|
slaxemulator@479
|
1650 if [ "$UPCOOKLIST" ]; then
|
slaxemulator@479
|
1651 db_md5=$(md5sum $dep_db $wan_db)
|
slaxemulator@479
|
1652 echo "update_wok_db"
|
slaxemulator@479
|
1653 update_wan_db
|
slaxemulator@479
|
1654 echo "check_for_commit"
|
slaxemulator@479
|
1655 check_for_commit
|
slaxemulator@479
|
1656 sort -o $dep_db $dep_db
|
slaxemulator@479
|
1657 sort -o $wan_db $wan_db
|
slaxemulator@479
|
1658 if [ "$db_md5" != "$(md5sum $dep_db $wan_db)" ]; then
|
slaxemulator@479
|
1659 grep -q "^#" $fullco || sed 1i"#PlanSort" -i $fullco
|
slaxemulator@479
|
1660 fi
|
slaxemulator@479
|
1661 fi
|
slaxemulator@479
|
1662
|
pankso@1
|
1663 # Cook and pack or exit on error and log everything.
|
pankso@97
|
1664 cookit $@ 2>&1 | tee $LOGS/$pkg.log
|
pankso@15
|
1665 remove_deps | tee -a $LOGS/$pkg.log
|
slaxemulator@479
|
1666 if [ "$CLEAN_CHROOT" ]; then
|
slaxemulator@479
|
1667 clean_chroot | tee -a $LOGS/$pkg.log
|
slaxemulator@479
|
1668 fi
|
pankso@1
|
1669 cookit_quality
|
pankso@26
|
1670 packit 2>&1 | tee -a $LOGS/$pkg.log
|
pankso@1
|
1671 clean_log
|
pankso@33
|
1672
|
pankso@33
|
1673 # Exit if any error in packing.
|
pankso@33
|
1674 if grep -q ^ERROR $LOGS/$pkg.log; then
|
pankso@33
|
1675 debug_info | tee -a $LOGS/$pkg.log
|
slaxemulator@479
|
1676 broken
|
pankso@33
|
1677 rm -f $command && exit 1
|
pankso@33
|
1678 fi
|
pankso@358
|
1679
|
slaxemulator@479
|
1680 # This is needed cause unset and source receipt again
|
slaxemulator@479
|
1681 if [ -f "$SRC/$lzma_tarball" ]; then
|
slaxemulator@479
|
1682 TARBALL="$lzma_tarball"
|
slaxemulator@479
|
1683 fi
|
slaxemulator@479
|
1684
|
pankso@310
|
1685 # Create an XML feed
|
pankso@310
|
1686 gen_rss
|
pankso@358
|
1687
|
pankso@1
|
1688 # Time and summary
|
pankso@1
|
1689 time=$(($(date +%s) - $time))
|
pankso@1
|
1690 summary | tee -a $LOGS/$pkg.log
|
pankso@427
|
1691 newline
|
pankso@1
|
1692
|
slaxemulator@479
|
1693 if [ "$AUTO_PURGE_SRC" ]; then
|
slaxemulator@479
|
1694 if [ -f "$SRC/$TARBALL" ]; then
|
slaxemulator@479
|
1695 previous_tarball=$(grep ^$PACKAGE:incoming $SRC/sources.list | cut -f2)
|
slaxemulator@479
|
1696 if [ -f "$SRC/$previous_tarball" ]; then
|
slaxemulator@479
|
1697 sed "/^$PACKAGE:incoming/ s/.*/$PACKAGE:incoming\t$TARBALL/" \
|
slaxemulator@479
|
1698 -i $SRC/sources.list
|
slaxemulator@479
|
1699 grep -q $'\t'$previous_tarball$ $SRC/sources.list || \
|
slaxemulator@479
|
1700 rm -f $SRC/$previous_tarball
|
slaxemulator@479
|
1701 else
|
slaxemulator@479
|
1702 echo -e "$PACKAGE:incoming\t$TARBALL" >> $SRC/sources.list
|
slaxemulator@479
|
1703 fi
|
slaxemulator@479
|
1704 fi
|
slaxemulator@479
|
1705 fi
|
slaxemulator@479
|
1706
|
slaxemulator@479
|
1707 # remove source folder if its not used in
|
slaxemulator@479
|
1708 # genpkg_rules in all wanted packages
|
slaxemulator@479
|
1709 remove_src
|
slaxemulator@479
|
1710
|
pankso@428
|
1711 install_package
|
slaxemulator@479
|
1712
|
slaxemulator@479
|
1713 # Regen the cooklist if it was planned and command is not cook.
|
slaxemulator@479
|
1714 [ "$regen_cooklist" -a "$UPCOOKLIST" ] && unset regen_cooklist && sort_cooklist
|
slaxemulator@479
|
1715
|
slaxemulator@479
|
1716 if [ $(grep -l "^$pkg$" $broken) ]; then
|
slaxemulator@479
|
1717 sed -i "^$pkg$" $broken
|
slaxemulator@479
|
1718 fi
|
pankso@9
|
1719 # Finally we DONT WANT to build the *-dev or packages with WANTED="$pkg"
|
pankso@17
|
1720 # You want automation: use the Cooker Build Bot.
|
pankso@18
|
1721 rm -f $command ;;
|
pankso@1
|
1722 esac
|
pankso@1
|
1723
|
pankso@1
|
1724 exit 0
|