tazwok view tazwok @ rev 553

Speed optimization of md5sum & build-depends scan core loops.
author Antoine Bodin <gokhlayeh@slitaz.org>
date Tue Jan 03 23:34:29 2012 +0100 (2012-01-03)
parents 176f3c91b68a
children 50581bf79fd4
line source
1 #!/bin/sh
2 # Tazwok - SliTaz source compiler and binary packages generator/cooker.
3 #
4 # Tazwok can compile source packages and create binary packages suitable for
5 # Tazpkg (Tiny Autonomous zone package manager). You can build individual
6 # packages or a list of packages with one command, rebuild the full distro,
7 # generate a packages repository and also list and get info about packages.
8 #
9 # (C) 2007-2009 SliTaz - GNU General Public License.
10 #
12 VERSION=4.3
13 . /usr/lib/slitaz/libtaz
14 source_lib commons
16 # Use text instead of numbers, don't get $2 here if it's an option.
17 [ "$2" = "${2#--}" ] && PACKAGE=$2 && LIST=$2 && ARG=$2
18 COMMAND=$1
20 ########################################################################
21 # TAZWOK USAGE
22 ########################
23 # Print the usage (English).
25 usage()
26 {
27 echo -e "\nSliTaz sources compiler and packages generator - Version: $VERSION\n
28 \033[1mUsage: \033[0m `basename $0` [command] [package|list|category|dir|id] [--option]
29 \033[1mCommands: \033[0m\n
30 usage Print this short usage.
31 stats Print Tazwok statistics from the config file and the wok.
32 edit Edit a package receipt in the current wok.
33 build-depends Generate a list of packages to build a wok.
34 list List all packages in the wok tree or by category.
35 info Get information about a package in the wok.
36 report Display commit/cooklist/broken/blocked.
37 check Check every receipt for common errors.
38 check-log Check the process log file of a package.
39 check-depends* Check every receipt for DEPENDS - doesn't scan ELF files.
40 check-src Check upstream tarball for package in the wok.
41 search Search for a package in the wok by pattern or name.
42 compile Configure and build a package using the receipt rules.
43 genpkg Generate a suitable package for Tazpkg with the rules.
44 cook Compile and generate a package directly.
45 cook-list Cook all packages specified in the list by order.
46 cook-commit Cook all modified receipts.
47 cook-all Cook all packages except toolchain.
48 cook-toolchain Cook the toolchain packages.
49 gen-cooklist Generate a sorted cooklist using packages or list.
50 sort-cooklist Sort the cooklist given in argument.
51 get-src Download the tarball of the package given in argument.
52 gen-src Rebuild sources.list in $SOURCES_REPOSITORY folder.
53 clean Clean all generated files in the package tree.
54 new-tree Prepare a new package tree and receipt (--interactive).
55 gen-list (Re-)Generate a packages list for a repository.
56 check-list Update packages lists for a repository.
57 gen-wok-db (Re-)Generate wok lists with depends and wanted data.
58 gen-clean-wok Generate a clean wok in a dir.
59 clean-wok Clean entirely the wok.
60 clean-src Remove old/unrelated-to-wok sources.
61 remove Remove a package from the wok.
62 webserver Enable/disable webserver on localhost.
63 update-wok Update the wok.
64 maintainers List all maintainers in the wok.
65 maintained-by List packages maintained by a contributor.
66 tags List all tags used in wok receipts.
67 block Add package from the blocked list to prevent cooking it.
68 unblock Remove package from the blocked list.\n
70 You can use `basename $0` command --help to list available options.
71 \033[1mImportant - *: \033[0m Commands which need a rewrite."
72 }
74 # This function displays an error message without returning any error code.
75 # It also logs the message in source package's warnings.txt; this file can be
76 # used on an eventual package page on website to display cooking warnings.
77 tazwok_warning()
78 {
79 echo -e "tazwok: $1" >&2
80 echo -e "$1" >> $WOK/${WANTED:-$PACKAGE}/warning.txt
81 return
82 }
84 ########################################################################
85 # TAZWOK VARIABLES & INITIAL CONFIGURATION
86 ########################
88 # Check if all packages are up to date into build environnement
89 check_env_status()
90 {
91 { [ "${COMMAND#cook}" = "$COMMAND" ] ||
92 [ "$COMMAND" = cook-toolchain ] ||
93 [ -f /etc/config.site.tmptoolchain ]; } && return
94 MIRROR_path=$(grep -l "^$1$" $LOCALSTATE/mirror $LOCALSTATE/undigest/*/mirror)
96 if [ ! "$MIRROR_path" ]; then
97 echo "You are trying to cook something but you don't use $1 repository, which is \
98 needed for this operation." | fold -s >&2
99 exit 1
100 fi
102 LOCALSTATE_path=${MIRROR_path%/mirror}
104 # Check is possible only if repository use ID.
105 if [ "${MIRROR_path:0:1}" = '/' ]; then
106 [ -f "$MIRROR_path/ID" ] || return
107 else
108 wget -a -s $MIRROR_path/ID 2>/dev/null || return
109 fi
111 [ -f $LOCALSTATE_path/ID ] && ID=$(cat $LOCALSATE_path/ID)
113 if [ "$LOCALSTATE_path" = "$LOCALSTATE" ]; then
114 tazpkg recharge main
115 else
116 tazpkg recharge ${LOCALSTATE_path##*/}
117 fi
119 [ "$(cat $LOCALSTATE_path/ID)" = "$ID" ] || env_status=1
120 }
122 get_tazwok_config()
123 {
124 # Get configuration file.
125 get_config
127 # Define & get options.
128 get_options_list="$get_options_list WOK SLITAZ_DIR SLITAZ_VERSION undigest"
129 get_options
131 LOCAL_REPOSITORY=$SLITAZ_DIR/${undigest:-$SLITAZ_VERSION}
133 if ! [ "$save_dir" ]; then
134 if [ -f $LOCAL_REPOSITORY/tazwok.conf ] || [ -f $LOCAL_REPOSITORY/slitaz.conf ]; then
135 save_dir=$LOCAL_REPOSITORY
136 [ -f $LOCAL_REPOSITORY/slitaz.conf ] && source $LOCAL_REPOSITORY/slitaz.conf
137 cd $save_dir
138 get_tazwok_config
139 unset save_dir
140 return
141 fi
142 fi
144 set_common_path
146 # Check that packages are up to date if user intend to cook.
147 check_env_status ${USE_ONLINE_PKG:-$PACKAGES_REPOSITORY}
148 check_env_status $INCOMING_REPOSITORY
150 # In case undigest is used, we need to upgrade system.
151 if [ "$undigest" ]; then
152 use_undigest_scan_core
153 ref_PACKAGES_REPOSITORY=$SLITAZ_DIR/$SLITAZ_VERSION/packages
154 if [ -f $SLITAZ_DIR/$SLITAZ_VERSION/tazwok.conf ] && \
155 grep -q ^USE_ONLINE_PKG $SLITAZ_DIR/$SLITAZ_VERSION/tazwok.conf; then
156 ref_USE_ONLINE_PKG=$(source $SLITAZ_DIR/$SLITAZ_VERSION/tazwok.conf && \
157 echo $USE_ONLINE_PKG)
158 fi
160 check_env_status ${ref_USE_ONLINE_PKG:-$ref_PACKAGES_REPOSITORY}
161 cd $ref_PACKAGES_REPOSITORY
162 if [ "$ref_USE_ONLINE_PKG" ]; then
163 ref_dep_db=$LOCALSTATE_path/wok-depends.txt
164 ref_wan_db=$LOCALSTATE_path/wok-wanted.txt
165 ref_lib_db=$LOCALSTATE_path/libraries.txt
166 else
167 ref_dep_db=$ref_PACKAGES_REPOSITORY/wok-depends.txt
168 ref_wan_db=$ref_PACKAGES_REPOSITORY/wok-wanted.txt
169 ref_lib_db=$ref_PACKAGES_REPOSITORY/libraries.txt
170 fi
172 for file in $ref_dep_db $ref_wan_db $ref_lib_db; do
173 [ -f "$file" ] && continue
174 missing_file=t
175 echo "$file is missing." >&2
176 done
177 if [ "$missing_file" ]; then
178 echo "
179 Theses files are needed to get datas about packages from the reference repository $SLITAZ_VERSION. \
180 If you don't intend to build this reference repository yourself, you should set USE_ONLINE_PKG variable \
181 into tazwok.conf of this reference repository. How-to:" | fold -s >&2
182 echo "echo 'USE_ONLINE_PKG=\"packages_repository_url\"' >> $SLITAZ_DIR/$SLITAZ_VERSION/tazwok.conf"
183 echo ""
184 exit 1
185 fi
186 fi
188 # If $env_status exists, it means an upgrade may be needed.
189 if [ "$env_status" ]; then
190 if [ -x /usr/bin/clean-chroot ]; then
191 echo y | tazpkg upgrade
192 else
193 echo "\e[0;31mWarning: \e[m"
194 echo "You're environnement may need a package upgrade."
195 echo "Upgrading is highly recommanded to ensure repository consistency."
196 echo "You can (E)xit, (U)pgrade, or (C)ontinue."
197 echo -n "What do you want to do ?"
198 read answer
199 case $answer in
200 [Cc]*) ;;
201 [Uu]*) echo y | tazpkg upgrade ;;
202 *) exit
203 esac
204 fi
205 fi
207 # Check commons directories, create them if user is root.
208 if test $(id -u) = 0 ; then
209 check_dir $WOK || chmod 777 $WOK
210 check_dir $LOCAL_REPOSITORY/clean-wok || chmod 777 $LOCAL_REPOSITORY/clean-wok
211 check_dir $PACKAGES_REPOSITORY
212 check_dir $SOURCES_REPOSITORY
213 check_dir $INCOMING_REPOSITORY
214 check_dir $LOCAL_REPOSITORY/log
215 check_dir $LOCAL_REPOSITORY/tmp
216 for file in $dep_db $wan_db $cookorder $commit $cooklist \
217 $broken $blocked $SOURCES_REPOSITORY/sources.list $lib_db
218 do
219 [ -f $file ] || touch $file
220 done
221 fi
223 # Limit memory usage.
224 ulimit -v $(awk '/MemTotal|SwapTotal/ { n+=$2 } END { print int((n*80)/100) }' < /proc/meminfo)
225 }
227 # The path to the most important files/dir used by Tazwok.
228 set_common_path()
229 {
230 PACKAGES_REPOSITORY=$LOCAL_REPOSITORY/packages
231 [ "$WOK" ] || WOK=$LOCAL_REPOSITORY/wok
232 INCOMING_REPOSITORY=$LOCAL_REPOSITORY/packages-incoming
233 SOURCES_REPOSITORY=$LOCAL_REPOSITORY/src
234 RECEIPT="$WOK/$PACKAGE/receipt"
235 LOG="$WOK/$PACKAGE/process.log"
236 dep_db=$INCOMING_REPOSITORY/wok-depends.txt
237 wan_db=$INCOMING_REPOSITORY/wok-wanted.txt
238 lib_db=$INCOMING_REPOSITORY/libraries.txt
239 cookorder=$PACKAGES_REPOSITORY/cookorder.txt
240 commit=$PACKAGES_REPOSITORY/commit
241 cooklist=$PACKAGES_REPOSITORY/cooklist
242 broken=$PACKAGES_REPOSITORY/broken
243 blocked=$PACKAGES_REPOSITORY/blocked
245 # log steps for webserver.
246 log_step="$LOCAL_REPOSITORY/log/step"
247 run_on_exit="$run_on_exit
248 rm -f $LOCAL_REPOSITORY/log/step
249 rm -f $LOCAL_REPOSITORY/log/package"
250 }
252 ########################################################################
253 # TAZWOK CHECK FUNCTIONS
254 ########################
256 # Check for a package name on cmdline.
257 check_for_package_on_cmdline()
258 {
259 if [ ! "$PACKAGE" ]; then
260 echo -e "\nYou must specify a package name on the command line." >&2
261 echo -e "Example : tazwok $COMMAND package\n" >&2
262 exit 1
263 fi
264 }
266 # Check for the receipt of a package used to cook.
267 check_for_receipt()
268 {
269 if [ ! -f "$RECEIPT" ]; then
270 echo -e "\nUnable to find the receipt : $RECEIPT\n" >&2
271 exit 1
272 fi
273 }
275 # Check for a specified file list on cmdline.
276 check_for_list()
277 {
278 if [ ! "$LIST" ]; then
279 echo -e "\nPlease specify the path to the list of packages to cook.\n" >&2
280 exit 1
281 elif ! [ -f "$LIST" ]; then
282 echo -e "\nUnable to find $LIST packages list.\n" >&2
283 exit 1
284 elif ! [ -s "$LIST" ]; then
285 echo -e "\nList is empty.\n" >&2
286 exit 1
287 fi
288 }
290 ########################################################################
291 # TAZWOK CORE FUNCTIONS
292 ########################
294 remove_src()
295 {
296 [ "$WANTED" ] && return
297 look_for_cookopt !remove_src && return
298 if [ ! -d $WOK/$PACKAGE/install ] && [ "$src" ] && [ -d "$src/_pkg" ]; then
299 check_for_var_modification _pkg src || return
300 mv "$src/_pkg" $WOK/$PACKAGE/install
301 fi
303 # Don't remove sources if a package uses src variable in its
304 # genpkg_rules: it maybe needs something inside.
305 for i in $PACKAGE $(look_for_rwanted); do
306 sed -n '/^genpkg_rules\(\)/','/^}/'p $WOK/$i/receipt | \
307 fgrep -q '$src' && tazwok_warning "Sources will not be removed \
308 because $i uses \$src in its receipt." && return
309 done
311 report step "Removing sources directory"
312 rm -fr "$src"
313 report end-step
314 }
316 # Check $COOK_OPT; usage : get_cookopt particular_opt
317 # Return error if not found
318 # Return args if the opt is in the format opt=arg1:arg2:etc
319 look_for_cookopt()
320 {
321 for arg in $COOK_OPT; do
322 case $arg in
323 $1=*)
324 arg=${arg#$1=}
325 while [ "$arg" ]; do
326 echo "${arg%%:*}"
327 [ "${arg/:}" = "$arg" ] && return
328 arg=${arg#*:}
329 done
330 ;;
331 $1)
332 return
333 ;;
334 esac
335 done
336 return 1
337 }
339 # Check for the wanted package if specified in WANTED
340 # receipt variable. Set the $src/$_pkg variable to help compile
341 # and generate packages.
342 check_for_wanted()
343 {
344 if [ "$WANTED" ]; then
345 report "Checking for the wanted package"
346 if [ ! -d "$WOK/$WANTED" ]; then
347 report exit "\nWanted package is missing in the work directory.\n"
348 fi
350 # Checking for buildtree of Wanted package
351 if [ ! -d "$WOK/$WANTED/taz" ]; then
352 echo -e "\n\nSource files of wanted package is missing in the work directory."
353 echo -n "Would you like to build the missing package (y/N) ? " ; read anser
354 if [ "$anser" == "y" ]; then
355 tazwok cook $WANTED
356 else
357 report exit "\nWanted package source tree is missing in the work directory.\n"
358 fi
359 fi
360 report end-step
362 # Set wanted src path.
363 set_src_path && set_pkg_path
365 fi
366 }
368 # Check for build dependencies, notify user and install if specified.
369 check_for_build_depends()
370 {
371 [ "$WANTED" ] && return
372 [ "$CATEGORY" = meta ] && ! fgrep -q compile_rules $RECEIPT && return
373 [ ! "$BUILD_DEPENDS" ] && ! fgrep -q compile_rules $RECEIPT && return
374 report step "Looking for build dependencies"
376 # Keep the list of previously installed build_depends then compare
377 # it with new build_depends to know what to install and what to
378 # what to remove.
379 plan_remove=" $MISSING_PACKAGE $remove_later "
380 [ ! "`echo "$plan_remove" | tr -d ' '`" ] && unset plan_remove
381 unset MISSING_PACKAGE remove_later
382 rwanted=$(look_for_rwanted)
384 for pkg in $(scan $PACKAGE --look_for=bdep --with_dev | \
385 grep -v $(for i in $(look_for_rwanted) $PACKAGE; do echo " -e ^$i$"; done))
386 do
388 # Delay the removing of previous cook depends if they are needed
389 # for next cook too.
390 if [ ! -d "$INSTALLED/$pkg" ] ; then
391 MISSING_PACKAGE="$MISSING_PACKAGE $pkg"
392 fi
393 if echo "$plan_remove" \
394 | fgrep -q " $pkg "
395 then
396 plan_remove="${plan_remove/ $pkg / }"
397 remove_later="$remove_later $pkg"
398 fi
399 grep -q ^$pkg$ $broken && broken_pkg="$broken_pkg$pkg "
400 done
402 # Don't cook if a depend is broken.
403 if [ "$broken_pkg" ]; then
404 MISSING_PACKAGE=$plan_remove
405 echo "Can't cook $PACKAGE because of broken depend(s) : $broken_pkg" >&2
406 unset plan_remove broken_pkg
408 # Set report step to failed.
409 report_return_code=1
410 report end-step
411 return 1
412 fi
413 if [ "$MISSING_PACKAGE" ]; then
414 install_missing()
415 {
416 echo "Installing missing packages : $MISSING_PACKAGE"
417 for pkg in $MISSING_PACKAGE; do
418 [ -d "$INSTALLED/$pkg" ] || tazpkg get-install $pkg
419 done
420 }
421 if [ "$auto_install" = yes ]; then
422 install_missing
423 else
424 horizontal_line
425 for pkg in $MISSING_PACKAGE
426 do
427 echo "Missing : $pkg"
428 done
429 horizontal_line
430 echo "You can continue, exit or install missing dependencies."
431 echo -n "Install, continue or exit (install/y/N) ? "; read answer
432 case $answer in
433 install)
434 install_missing ;;
435 y|yes)
436 unset MISSING_PACKAGE;;
437 *)
438 report stop
439 exit 0 ;;
440 esac
441 fi
442 fi
443 report end-step
444 remove_build_depends $plan_remove
445 unset plan_remove
446 }
448 remove_build_depends()
449 {
450 [ "$1" ] || return
451 report step "Removing previous build dependencies"
452 echo "Removing these packages : $@"
453 for pkg in $@; do
454 [ -f "$INSTALLED/$pkg/receipt" ] && tazpkg remove $pkg --auto
455 done
456 cd $PWD
457 report end-step
458 }
460 # Check if we can use the new way to handle tarball
461 # or if we keep the previous method by checking for
462 # _pkg=/src= in receipt and reverse-wanted.
463 check_for_var_modification()
464 {
465 for var in $@; do
466 for pkg in $PACKAGE $(look_for_wanted) $(look_for_rwanted); do
467 [ -f $WOK/$pkg/receipt ] || continue
468 fgrep -q "$var=" $WOK/$pkg/receipt && return 1
469 done
470 done
472 # Tweak to make if; then...; fi function working with this one.
473 echo -n ""
474 }
476 set_src_path()
477 {
478 if check_for_var_modification src _pkg; then
479 src=$WOK/${WANTED:-$PACKAGE}/${WANTED:-$PACKAGE}-$VERSION
480 else
481 tazwok_warning "Use original name or tarball root directory because src/_pkg is defined in the receipt (this is no longer needed!)."
482 src=$WOK/${WANTED:-$PACKAGE}/${SOURCE:-${WANTED:-$PACKAGE}}-$VERSION
483 fi
484 stuff=$WOK/$PACKAGE/stuff
485 [ "$WANTED" ] && wanted_stuff=$WOK/$WANTED/stuff
486 # Kernel version is set from linux-api-headers since it part of toolchain.
487 if [ -f "$LOCALSTATE/installed/linux-api-headers/receipt" ]; then
488 kvers=$(grep ^VERSION= $LOCALSTATE/installed/linux-api-headers/receipt | \
489 cut -d '"' -f 2)
490 fi
491 }
493 set_pkg_path()
494 {
495 if [ -d $WOK/${WANTED:-$PACKAGE}/install ] ; then
496 _pkg=$WOK/${WANTED:-$PACKAGE}/install
497 else
498 _pkg=$src/_pkg
499 fi
500 # compatibly with cookutils
501 install=$_pkg
502 }
504 # Output $VERSION-$EXTRAVERSION using packages.txt
505 get_pkg_version()
506 {
507 [ "$PACKAGE" ] || return
508 grep -m1 -A1 -sh ^$PACKAGE$ $1/packages.txt | tail -1 | sed 's/ *//'
509 }
511 remove_previous_package()
512 {
513 if [ "$prev_VERSION" ] && [ "$VERSION$EXTRAVERSION" != "$prev_VERSION" ]; then
514 rm -f $1/$PACKAGE-$prev_VERSION.tazpkg
515 fi
516 return 0
517 }
519 # Check for src tarball and wget if needed.
520 check_for_tarball()
521 {
522 [ "$WGET_URL" ] || return 0
523 [ "$WANTED" ] && return 0
524 report step "Checking for source tarball: $PACKAGE"
525 local repack_src=$repack_src TARBALL=$TARBALL nounpack=$nounpack
526 look_for_cookopt !unpack && nounpack=yes
527 if [ "$repack_src" = yes ] && look_for_cookopt !repack_src; then
528 repack_src=no
529 fi
530 if [ "$target" ]; then
531 src="$target"
532 else
533 set_src_path
534 fi
535 tmp_src=$LOCAL_REPOSITORY/tmp/tarball-$$
536 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
537 [ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}.tar.lzma" ] ; then
538 cd $SOURCES_REPOSITORY
539 if [ "$SOURCE" ]; then
540 alt_url="http://mirror.slitaz.org/sources/packages/${SOURCE:0:1}/$SOURCE-${KBASEVER:-$VERSION}.tar.lzma"
541 else
542 alt_url="http://mirror.slitaz.org/sources/packages/${PACKAGE:0:1}/$PACKAGE-${KBASEVER:-$VERSION}.tar.lzma"
543 fi
544 download $WGET_URL $alt_url http://mirror.slitaz.org/sources/packages/${TARBALL:0:1}/$TARBALL
545 unset alt_url
546 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
547 [ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}.tar.lzma" ] && \
548 [ ! -d $tmp_src ]; then
549 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n" >&2
550 report end-step
551 return 1
552 fi
553 fi
554 report end-step
555 if { [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}.tar.lzma" ] && [ "$nounpack" ] ; } || \
556 { [ -f "$SOURCES_REPOSITORY/$TARBALL" ] && [ "$repack_src" != yes ] && [ "$nounpack" ] ; }; then
557 [ -d "$tmp_src" ] && rm -r "$tmp_src"
558 return 0
559 fi
561 report step "Untaring source tarball"
563 # Log process.
564 echo "untaring source tarball" >> $LOG
566 # If $tmp_src exists, there's already a unpacked tarball in it.
567 if ! [ -d "$tmp_src" ]; then
568 mkdir "$tmp_src"
569 if [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}.tar.lzma" ] && [ "$repack_src" = yes ]; then
570 lzma d $SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}.tar.lzma -so | \
571 tar xf - -C "$tmp_src"
572 repack_src=no
573 TARBALL=${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}.tar.lzma
574 elif [ -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
575 case "$TARBALL" in
576 *zip|*xpi) cd $tmp_src && unzip -o $SOURCES_REPOSITORY/$TARBALL ;;
577 *bz2|*tbz|*gem) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
578 *tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
579 *lzma|*lz) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
580 *xz) unxz -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
581 *Z|*taz) uncompress -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
582 *gz) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
583 *rpm) cd $tmp_src && rpm2cpio $SOURCES_REPOSITORY/$TARBALL | cpio -idm --quiet;;
584 *.run) cd $tmp_src && sh $SOURCES_REPOSITORY/$TARBALL $RUN_OPTS;;
586 # It's a plain file or something receipt unpack itself.
587 *)
588 mkdir $tmp_src/${SOURCE:-$PACKAGE}-$VERSION
589 cp $SOURCES_REPOSITORY/$TARBALL $tmp_src/${src##*/}
590 ;;
592 esac || { report end-step
593 rm -f $SOURCES_REPOSITORY/$TARBALL
594 rm -r $tmp_src
595 return 1
596 }
597 fi
599 # Check if uncompressed tarball is in a root dir or not.
600 if [ "$(ls -A $tmp_src | wc -l)" -gt 1 ] || [ -f "$(echo $tmp_src/*)" ]; then
601 if check_for_var_modification src _pkg; then
602 mv "$tmp_src" "$tmp_src-1"
603 mkdir "$tmp_src"
604 mv "$tmp_src-1" "$tmp_src/${SOURCE:-$PACKAGE}-$VERSION"
605 else
606 mv "$tmp_src"/* "$WOK/$PACKAGE"
607 repack_src=no
608 rm -r "$tmp_src"
609 tazwok_warning "Putting all files in $WOK/$PACKAGE; not sure about how to handle this tarball (no root dir)... Please try to remove src/_pkg definition from the receipt if you encounter any problems."
610 fi
611 fi
612 fi
614 if [ "$repack_src" = yes ]; then
615 report step "Repacking sources in .tar.lzma format"
616 [ "$TARBALL" ] && rm -f $SOURCES_REPOSITORY/$TARBALL
617 TARBALL=${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}.tar.lzma
618 cd "$tmp_src"
619 tar -c * | lzma e $SOURCES_REPOSITORY/$TARBALL -si
620 fi
622 # Remove previous tarball if no other package needs it. We take care to
623 # keep tarball if the same package uses it in the main repository.
624 if [ "$TARBALL" ]; then
625 previous_tarball=$(grep ^$PACKAGE:incoming $SOURCES_REPOSITORY/sources.list | cut -f2)
626 if [ "$previous_tarball" ]; then
627 sed "/^$PACKAGE:incoming/ s/.*/$PACKAGE:incoming\t$TARBALL/" \
628 -i $SOURCES_REPOSITORY/sources.list
629 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
630 rm -f $SOURCES_REPOSITORY/$previous_tarball
631 else
632 echo -e "$PACKAGE:incoming\t$TARBALL" >> $SOURCES_REPOSITORY/sources.list
633 fi
634 fi
636 if [ "$nounpack" ]; then
637 [ -d "$tmp_src" ] && rm -r "$tmp_src"
638 report end-step
639 return
640 fi
641 if [ ! -d "$src" ]|| [ "$target" ]; then
642 # Permissions settings.
643 chown -R root.root "$tmp_src"
644 if [ -d "$src" ]; then
645 mkdir -p "$src"
646 for f in "$tmp_src"/*/*; do
647 cp -a "$f" "$src" || { report end-step; rm -r "$tmp_src"; return 1; }
648 done
649 else
650 if ! check_for_var_modification src _pkg && ! [ "$target" ]; then
651 src="${src%/*}/$(ls $tmp_src)"
652 fi
653 mv "$(echo $tmp_src/*)" "$src" || { report end-step; rm -r "$tmp_src"; return 1; }
654 fi
655 rm -r "$tmp_src"
656 else
657 [ -d "$tmp_src" ] && rm -r "$tmp_src"
658 echo "There's already something at $src. Abort." >&2
659 fi
660 report end-step
661 }
663 # help gen sources.list file from scranch
664 gen_sources_list()
665 {
666 local src_repository=$1
667 [ -f $src_repository/sources.list ] && rm -f $src_repository/sources.list
668 for i in $WOK/*; do
669 unset PACKAGE SOURCE VERSION WGET_URL TARBALL WANTED
670 [ -f $i/receipt ] && source $i/receipt
671 [ "$WGET_URL" ] || continue
672 if grep -q "^$PACKAGE | $VERSION" $PACKAGES_REPOSITORY/packages.desc; then
673 main_version="$VERSION"
674 if [ -f $src_repository/${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}.tar.lzma ]; then
675 echo -e "$PACKAGE:main\t${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}.tar.lzma" >> $src_repository/sources.list
676 elif [ -f "$src_repository/$TARBALL" ]; then
677 echo -e "$PACKAGE:main\t$TARBALL" >> $src_repository/sources.list
678 fi
679 else
680 # May not works if package use extraversion.
681 main_version=$(grep -m1 -A1 -sh ^$PACKAGE$ $PACKAGES_REPOSITORY/packages.txt | tail -1 | sed 's/ *//')
682 if [ -f $src_repository/${SOURCE:-$PACKAGE}-$main_version.tar.lzma ]; then
683 echo -e "$PACKAGE:main\t${SOURCE:-$PACKAGE}-$main_version.tar.lzma" >> $src_repository/sources.list
684 else
685 unset main_version
686 fi
687 fi
688 if [ ! "$main_version" ] || [ $(grep -q "^$PACKAGE | $VERSION" $INCOMING_REPOSITORY/packages.desc 2>/dev/null) ]; then
689 if [ -f $src_repository/${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}.tar.lzma ]; then
690 echo -e "$PACKAGE:incoming\t${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}.tar.lzma" >> $src_repository/sources.list
691 elif [ -f "$src_repository/$TARBALL" ]; then
692 echo -e "$PACKAGE:incoming\t$TARBALL" >> $src_repository/sources.list
693 fi
694 fi
695 done
696 }
698 # Log and execute compile_rules function if it exists, to configure and
699 # make the package if it exists.
700 check_for_compile_rules()
701 {
702 if grep -q ^compile_rules $RECEIPT; then
703 echo "executing compile_rules" >> $LOG
704 report step "Executing compile_rules"
705 if [ -d "$src" ]; then
706 cd "$src"
707 else
708 cd $WOK/$PACKAGE
709 fi
710 rm -f /tmp/config.site
711 ulimit -d unlimited
712 ulimit -m unlimited
714 freeram=$(free -m | fgrep 'Mem:' | tr -s ' ' | cut -f 4 -d ' ')
716 # Disable -pipe in CFLAGS/CXXFLAGS if less than 512MB of free
717 # RAM are available.
718 if [ "$freeram" -lt 512 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" -o \
719 "$CXXFLAGS" != "${CXXFLAGS/-pipe}" ]; then
720 tazwok_warning "Disabling -pipe compile flag because of low memory: $freeram MB available."
721 CFLAGS="${CFLAGS/-pipe}"
722 CXXFLAGS="${CXXFLAGS/-pipe}"
723 fi
724 unset freeram
726 # Set cook environement variables.
727 [ "$src" ] || set_src_path
728 [ "$DESTDIR" ] || DESTDIR="$WOK/$PACKAGE/install"
729 [ "$CONFIG_SITE" ] || CONFIG_SITE=/etc/config.site
730 export CFLAGS=$(echo "$CFLAGS" | tr -s ' ') \
731 CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ') \
732 MAKEFLAGS DESTDIR CONFIG_SITE default_prefix \
733 default_datarootdir default_datadir default_localedir \
734 default_infodir default_mandir default_build default_host \
735 BUILD_SYSTEM HOST_SYSTEM
736 local LC_ALL=POSIX LANG=POSIX
737 compile_rules
738 return_code=$?
740 if [ -f /tmp/config.site ]; then
741 rm /tmp/config.site
742 else
743 tazwok_warning "config.site hasn't been used during \
744 the configuration process."
745 fi
747 # Return the proper status to step.
748 (exit $return_code)
749 report end-step
750 fi
751 }
753 # Check for loop in deps tree. /!\ can be removed.
754 check_for_deps_loop()
755 {
756 local list
757 local pkg
758 local deps
759 pkg=$1
760 shift
761 [ -n "$1" ] || return
762 list=""
764 # Filter out already processed deps.
765 for i in $@; do
766 case " $ALL_DEPS" in
767 *\ $i\ *);;
768 *) list="$list $i";;
769 esac
770 done
771 ALL_DEPS="$ALL_DEPS$list "
772 for i in $list; do
773 [ -f $i/receipt ] || continue
774 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
775 case " $deps " in
776 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
777 *) check_for_deps_loop $pkg $deps;;
778 esac
779 done
780 }
782 # Function used by download().
783 revert_vcs_failure()
784 {
785 cd $SOURCES_REPOSITORY
786 rm -r $tmp_src
787 }
789 download()
790 {
791 if [ "$COMMAND" = get-src ]; then
792 if [ "${DEPENDS/tar}" != "$DEPENDS" ] || [ "${BUILD_DEPENDS/tar}" != "$BUILD_DEPENDS" ]; then
793 [ -f $INSTALLED/tar/receipt ] || tazpkg get-install tar --forced
794 fi
795 fi
796 for file in $@; do
797 echo "Downloading from ${file#*|}..."
798 case "$file" in
799 git\|*)
800 file=${file#git|}
801 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/git/receipt ] && tazpkg get-install git --forced
802 if [ -f $INSTALLED/git/receipt ]; then
803 mkdir $tmp_src
804 cd $tmp_src
805 if [ "$BRANCH" ]; then
806 git clone $file ${src##*/} && cd ${src##*/} && \
807 git checkout $BRANCH && rm -rf .git* && break
808 else
809 git clone $file ${src##*/} && rm -rf ${src##*/}/.git* && break
810 fi
811 revert_vcs_failure
812 else
813 tazwok_warning "Needs git to download the source tarball from $file, please add it as a build-depend."
814 continue
815 fi
816 ;;
817 bazaar\|*)
818 file=${file#bazaar|}
819 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/bazaar/receipt ] && tazpkg get-install bazaar --forced
820 if [ -f $INSTALLED/bazaar/receipt ]; then
821 mkdir $tmp_src
822 cd $tmp_src
823 if [ "$BRANCH" ]; then
824 bzr co $file -r $BRANCH ${src##*/} && rm -rf ${src##*/}/.bzr* && break
825 else
826 bzr co $file ${src##*/} && rm -rf ${src##*/}/.bzr* && break
827 fi
828 revert_vcs_failure
829 else
830 tazwok_warning "Needs bazaar to download the source tarball from $file, please add it as a build-depend."
831 continue
832 fi
833 ;;
834 svn*|subversion*)
835 if $(echo "$WGET_URL" | fgrep -q svn); then
836 file=${WGET_URL#svn|}
837 else
838 file=${WGET_URL#subversion|}
839 fi
840 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/subversion/receipt ] && tazpkg get-install subversion --forced
841 if [ -f $INSTALLED/subversion/receipt ]; then
842 mkdir $tmp_src
843 cd $tmp_src
844 if [ "$BRANCH" ]; then
845 echo t | svn co $file -r $BRANCH ${src##*/} && rm -rf ${src##*/}/.svn* && break
846 else
847 echo t | svn co $file ${src##*/} && rm -rf ${src##*/}/.svn* && break
848 fi
849 revert_vcs_failure
850 else
851 tazwok_warning "Needs subversion to download the source tarball from $file, please add it as a build-depend."
852 continue
853 fi
854 ;;
855 hg*|mercurial*)
856 if $(echo "$WGET_URL" | fgrep -q hg); then
857 file=${WGET_URL#hg|}
858 else
859 file=${WGET_URL#mercurial|}
860 fi
861 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/mercurial/receipt ] && tazpkg get-install mercurial --forced
862 if [ -f $INSTALLED/mercurial/receipt ]; then
863 mkdir $tmp_src
864 cd $tmp_src
865 if [ "$BRANCH" ]; then
866 hg clone $file --rev $BRANCH ${src##*/} && rm -rf ${src##*/}/.hg* && break
867 else
868 hg clone $file ${src##*/} && rm -rf ${src##*/}/.hg* && break
869 fi
870 revert_vcs_failure
871 else
872 tazwok_warning "Needs mercurial to download the source tarball from $file, please add it as a build-depend."
873 continue
874 fi
875 ;;
876 cvs*)
877 file=${WGET_URL#cvs|}
878 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/cvs/receipt ] && tazpkg get-install cvs --forced
879 if [ -f $INSTALLED/cvs/receipt ]; then
880 mkdir $tmp_src
881 cd $tmp_src
882 mod=${src##*/}
883 [ "$CVS_MODULE" ] && mod=$CVS_MODULE
884 cvs -z3 -d:$file co $mod && rm -rf $mod/CVS && break
885 else
886 tazwok_warning "Needs cvs to download the source tarball from $file, please add it as a build-depend."
887 continue
888 fi
889 ;;
890 https*)
891 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/wget/receipt ] && tazpkg get-install wget --forced
892 if [ -d $INSTALLED/wget ]; then
893 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
894 wget -q --no-check-certificate -O $TARBALL $file && break
895 else
896 wget -q --no-check-certificate $file && break
897 fi
898 else
899 tazwok_warning "Needs wget to download the source tarball from $file, please add it as a build-depend."
900 continue
901 fi
902 ;;
903 http*|ftp*)
904 # Handle crappy URL.
905 if [ "$COMMAND" = get-src ]; then
906 if [ "${DEPENDS/wget}" != "$DEPENDS" ] || [ "${BUILD_DEPENDS/wget}" != "$BUILD_DEPENDS" ]; then
907 [ -f $INSALLED/wget/receipt ] || tazpkg get-install wget --forced
908 fi
909 fi
910 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
911 wget -q -O $TARBALL $file && break
912 else
913 wget -q $file && break
914 fi
915 ;;
916 esac
917 done
918 }
920 # Regenerate every package that wants a PACKAGE compiled.
921 refresh_packages_from_compile()
922 {
923 # make tazwok genpkg happy.
924 mkdir $WOK/$PACKAGE/taz
926 # Cook rwanted in default or specied order.
927 genlist=" $(look_for_rwanted | tr '\n' ' ') "
928 for i in $(look_for_cookopt genpkg | tac); do
929 [ "${genlist/ $i }" = "$genlist" ] && continue
930 genlist=" $i${genlist/ $i / }"
931 done
932 if [ "$genlist" ]; then
933 local PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
934 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
935 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
936 src _pkg DESTDIR CONFIG_SITE RECEIPT LOG stuff wanted_stuff
937 for PACKAGE in $genlist; do
938 set_common_path
939 gen_package
940 done
941 fi
942 }
944 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
945 # so some packages need to copy these files with the receipt and genpkg_rules.
946 # This function is executed by gen_package when 'tazwok genpkg'.
947 copy_generic_files()
948 {
949 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
950 # using generic variables and $LOCALE from Tazwok config file.
951 if [ "$LOCALE" ]; then
952 if [ -d "$_pkg/usr/share/locale" ]; then
953 for i in $LOCALE
954 do
955 if [ -d "$_pkg/usr/share/locale/$i" ]; then
956 mkdir -p $fs/usr/share/locale
957 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
958 fi
959 done
960 fi
961 fi
963 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
964 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
965 # in pkg receipt.
966 if [ "$GENERIC_PIXMAPS" != "no" ]; then
967 if [ -d "$_pkg/usr/share/pixmaps" ]; then
968 mkdir -p $fs/usr/share/pixmaps
969 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
970 $fs/usr/share/pixmaps 2>/dev/null
971 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
972 $fs/usr/share/pixmaps 2>/dev/null
973 fi
975 # Custom or homemade PNG pixmap can be in stuff.
976 if [ -f "stuff/$PACKAGE.png" ]; then
977 mkdir -p $fs/usr/share/pixmaps
978 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
979 fi
980 fi
982 # Desktop entry (.desktop).
983 if [ -d "$_pkg/usr/share/applications" ]; then
984 cp -a $_pkg/usr/share/applications $fs/usr/share
985 fi
987 # Homemade desktop file(s) can be in stuff.
988 if [ -d "stuff/applications" ]; then
989 mkdir -p $fs/usr/share
990 cp -a stuff/applications $fs/usr/share
991 fi
992 if [ -f "stuff/$PACKAGE.desktop" ]; then
993 mkdir -p $fs/usr/share/applications
994 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
995 fi
996 }
998 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
999 strip_package()
1001 report step "Executing strip on all files"
1003 # Binaries.
1004 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
1005 do
1006 if [ -d "$dir" ]; then
1007 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
1008 fi
1009 done
1011 # Libraries.
1012 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
1013 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
1014 report end-step
1017 # Remove .pyc and .pyo files from packages.
1018 py_compiled_files_remove()
1020 report step "Removing all .pyc and .pyo files from package"
1021 find $fs -type f -name "*.pyc" -delete 2>/dev/null
1022 find $fs -type f -name "*.pyo" -delete 2>/dev/null
1023 report end-step
1026 # Removing all perllocal.pod and .packlist files from package
1027 perl_compiled_files_remove()
1029 report step "Removing all perllocal.pod and .packlist files from package"
1030 find $fs -type f -name "perllocal.pod" -delete 2>/dev/null
1031 find $fs -type f -name ".packlist" -delete 2>/dev/null
1032 report end-step
1035 # Check FSH in a slitaz package (Path: /:/usr)
1036 check_fsh()
1038 cd $WOK/$PACKAGE/taz/*/fs
1039 if [ -z "$(find * ! -type d)" ] && [ "$CATEGORY" != meta ]; then
1040 echo "$PACKAGE fs is empty." >&2
1041 cd $WOK/$PACKAGE && rm -rf taz
1042 return 1
1043 fi
1044 [ -n "$FSH" ] || FSH="bin boot dev etc home init lib media mnt proc \
1045 root sbin share sys tmp usr var vz usr/bin usr/games usr/include usr/lib \
1046 usr/local usr/sbin usr/share usr/src"
1047 error=0
1048 for i in `ls -d * usr/* 2>/dev/null`
1049 do
1050 if ! echo $FSH | fgrep -q $i; then
1051 echo "Wrong path: /$i" >&2
1052 error=1
1053 fi
1054 done
1055 if [ "$error" = "1" ]; then
1056 cat << _EOT_
1058 Package will install files in a non standard directory and won't be generated.
1059 You may have a wrong copy path in genpkg_rules or need to add some options to
1060 configure in compile_rules. Some valid options for SliTaz (Linux FSH):
1062 --prefix=/usr
1063 --sysconfdir=/etc
1064 --libexecdir=/usr/lib/(pkgname)
1065 --localstatedir=/var
1066 --mandir=/usr/share/man
1067 --infodir=/usr/share/info
1069 For more information please read SliTaz docs and run: ./configure --help
1070 ================================================================================
1071 $PACKAGE package generation aborted.
1073 _EOT_
1075 # Dont generate a corrupted package.
1076 cd $WOK/$PACKAGE && rm -rf taz
1077 return 1
1078 fi
1079 return 0
1082 get_cook_files()
1084 if [ -d stuff ]; then
1085 cook_files=`find receipt description.txt stuff 2>/dev/null`
1086 elif [ -f description.txt ]; then
1087 cook_files="receipt
1088 description.txt"
1089 else
1090 cook_files="receipt"
1091 fi
1094 gen_cookmd5()
1096 # md5sum of cooking stuff make tazwok able to check for changes
1097 # without hg.
1098 cd $WOK/$PACKAGE
1099 local IFS="
1102 if [ ! "$cook_files" ]; then
1103 get_cook_files
1104 fi
1106 md5sum $cook_files > md5
1108 unset cook_files
1111 set_pkg_broken()
1113 grep -q ^$PACKAGE$ $broken || echo $PACKAGE >> $broken
1115 # Remove pkg from cooklist to avoid re-cook it if no changes happen
1116 # in the cook stuff.
1117 sed "/^$PACKAGE$/d" -i $cooklist $commit
1119 gen_cookmd5
1121 # Return 1 to make report know that its mother-function failed.
1122 return 1
1125 update_lib_db()
1127 # Update lib_db
1128 libs=$(for file in $(find * -type f); do
1129 [ "$(dd if=$file bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ] || continue
1130 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $PWD/$file
1131 done | { cut -f 1 -d ' ' | tr -d '\t' | sort -u | \
1132 sed -e 's/^linux-gate.so.*$/SLIB/' -e 's~^/lib/ld-.*$~SLIB~' \
1133 -e '/^statically$/d' | tr '\n' ' '; })
1136 # Create a package tree and build the gziped cpio archive
1137 # to make a SliTaz (.tazpkg) package.
1138 gen_package()
1140 check_root
1141 check_for_package_on_cmdline
1142 check_for_receipt
1143 source_receipt
1145 # May compute VERSION
1146 if grep -q ^get_version $RECEIPT; then
1147 get_version
1148 fi
1149 check_for_wanted
1150 cd $WOK/$PACKAGE
1152 # Remove old Tazwok package files.
1153 [ -d "taz" ] && rm -rf taz
1155 # Create the package tree and set useful variables.
1156 fs=$WOK/$PACKAGE/taz/$PACKAGE-$VERSION/fs
1157 mkdir -p $fs
1159 # Set $src for standard package and $_pkg variables.
1160 set_src_path
1161 set_pkg_path
1163 # Execute genpkg_rules, check package and copy generic files to build
1164 # the package.
1165 report step "Building $PACKAGE with the receipt"
1166 report open-bloc
1167 if look_for_cookopt !fs; then
1169 elif grep -q ^genpkg_rules $RECEIPT; then
1171 # Log process.
1172 echo "executing genpkg_rules" >> $LOG
1173 report step "Executing genpkg_rules"
1174 ( set -e; genpkg_rules ) || { set_pkg_broken; report close-bloc; return 1; }
1175 check_fsh || { set_pkg_broken; report close-bloc; return 1; }
1176 cd $WOK/$PACKAGE
1177 report end-step
1179 # Skip generic files for packages with a WANTED variable
1180 # (dev and split pkgs).
1181 if [ ! "$WANTED" ]; then
1182 copy_generic_files
1183 fi
1184 look_for_cookopt !strip || strip_package
1185 perl_compiled_files_remove
1186 else
1187 echo "No package rules to gen $PACKAGE..." >&2
1188 set_pkg_broken
1189 report close-bloc
1190 return 1
1191 fi
1193 # Copy the receipt and description (if exists) into the binary package tree.
1194 cd $WOK/$PACKAGE
1195 report step "Copying the receipt"
1196 cp receipt taz/$PACKAGE-$VERSION
1197 report end-step
1198 if grep -q ^get_version $RECEIPT; then
1199 report step "Updating version in receipt"
1200 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
1201 taz/$PACKAGE-$VERSION/receipt
1202 report end-step
1203 fi
1204 if [ -f "description.txt" ]; then
1205 report step "Copying the description file"
1206 cp description.txt taz/$PACKAGE-$VERSION
1207 report end-step
1208 fi
1210 # Generate md5 of cooking stuff to look for commit later.
1211 gen_cookmd5
1212 echo -e "\n# md5sum of cooking stuff :" >> taz/$PACKAGE-$VERSION/receipt
1213 cat md5 | sed 's/^/# /' >> taz/$PACKAGE-$VERSION/receipt
1215 # Create the files.list by redirecting find output.
1216 report step "Creating the list of files"
1217 cd taz/$PACKAGE-$VERSION
1218 LAST_FILE=""
1219 { find fs -print; echo; } | while read file; do
1220 if [ "$LAST_FILE" ]; then
1221 case "$file" in
1222 $LAST_FILE/*)
1223 case "$(ls -ld "$LAST_FILE")" in
1224 drwxr-xr-x\ *\ root\ *\ root\ *);;
1225 *) echo ${LAST_FILE#fs};;
1226 esac;;
1227 *) echo ${LAST_FILE#fs};;
1228 esac
1229 fi
1230 LAST_FILE="$file"
1231 done > files.list
1233 py_compiled_files_remove
1235 # Next, check if something has changed in lib files.
1236 # Plan to recook each packages which depends on libs
1237 # which doesn't exists anymore.
1238 for rep in $INCOMING_REPOSITORY $PACKAGES_REPOSITORY; do
1239 prev_VERSION=$(get_pkg_version $rep)
1240 [ "$prev_VERSION" ] && pkg_file=$rep/$PACKAGE-$prev_VERSION.tazpkg && break
1241 done
1242 if [ "$pkg_file" ]; then
1243 report step "Looking if reverse depends needs to be refreshed"
1244 get_pkg_files $pkg_file
1245 cd $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
1247 pkg_to_check=$(diff files.list $pkg_files_dir/files.list | \
1248 grep '^-/.*\.so' | while read lib; do
1249 fgrep " ${lib##*/} " $libs_db | cut -f1
1250 done | sort -u)
1252 if [ "$pkg_to_check" ]; then
1253 for rdep in $(scan $PACKAGE --look_for=rdep | use_wanted); do
1254 echo "$pkg_to_check" | grep -q ^$PACKAGE$ || continue
1255 [ "$rdep" = "${WANTED:-$PACKAGE}" ] && continue
1256 grep -q ^$rdep$ $blocked $cooklist && continue
1257 echo "Plan to recook $rdep"
1258 echo $rdep >> $cooklist
1259 regen_cooklist=yes
1260 done
1261 fi
1263 rm -r $pkg_files_dir
1264 unset pkg_file pkg_file_dir pkg_to_check
1265 report end-step
1266 fi
1268 update_lib_db
1270 sed "/$PACKAGE\t/d" -i $lib_db
1271 if [ "$libs" ]; then
1272 libs=$(echo " $libs" | sed -r 's/( SLIB)+ / /g')
1273 echo -e "$PACKAGE\t$libs" >> $lib_db
1274 sort -o $lib_db $lib_db
1275 fi
1276 unset libs
1278 if [ ! "$EXTRAVERSION" ]; then
1279 case "$PACKAGE" in
1280 linux*);;
1281 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
1282 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
1283 esac
1284 fi
1285 rm -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
1287 report step "Creating md5sum of files"
1288 while read file; do
1289 [ -L "fs$file" ] && continue
1290 [ -f "fs$file" ] || continue
1291 md5sum "fs$file" | sed 's/ fs/ /'
1292 done < files.list > md5sum
1293 report end-step
1294 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
1295 2> /dev/null | awk '{ sz=$1 } END { print sz }')
1297 # Build cpio archives. Find, cpio and gzip the fs, finish by
1298 # removing the fs tree.
1299 # Don't log this because compression always outputs error messages.
1300 find fs -print | cpio -o -H newc | case "$PACKAGE-$COMPRESSION" in
1301 tazpkg-lzma) gzip > fs.cpio.gz;;
1302 *-lzma) lzma e fs.cpio.lzma -si;;
1303 *) gzip > fs.cpio.gz;;
1304 esac && rm -rf fs
1305 PACKED_SIZE=$(du -chs fs.cpio.* receipt files.list md5sum \
1306 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
1307 report step "Updating receipt sizes"
1308 sed -i '/^PACKED_SIZE/d' receipt
1309 sed -i '/^UNPACKED_SIZE/d' receipt
1310 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
1311 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
1312 report end-step
1313 if [ "$EXTRAVERSION" ]; then
1314 report step "Updating receipt EXTRAVERSION"
1315 sed -i s/^EXTRAVERSION.*$// receipt
1316 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
1317 fi
1318 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1319 remove_previous_package $INCOMING_REPOSITORY
1320 report step "Creating full cpio archive"
1321 find . -print | cpio -o -H newc > $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
1323 # Restore package tree in case we want to browse it.
1324 report step "Restoring original package tree"
1325 { zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma; } | cpio --quiet -id
1326 rm fs.cpio.* && cd ..
1328 # Save receipts if save_wok is enabled.
1329 [ "$save_wok" ] && copy_cooking_stuff $WOK $PACKAGE $INCOMING_REPOSITORY/wok
1331 # Recook of reverse-depends if package was broken.
1332 if grep -q "^$PACKAGE$" $broken; then
1333 report step "Planning a re-try cook of reverse depends"
1334 sed "/^$PACKAGE$/d" -i $broken
1335 for rdep in $(look_for_rdep); do
1336 grep -q "^$rdep$" $broken || continue
1337 grep -q "^$rdep$" $cooklist && continue
1338 echo "Adding $rdep to the cooklist"
1339 echo $rdep >> $cooklist
1340 regen_cooklist=t
1341 done
1342 report end-step
1343 fi
1344 sed "/^$PACKAGE$/d" -i $commit $cooklist
1346 # Log process.
1347 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
1348 report close-bloc
1349 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
1350 echo "Size : `du -sh $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
1351 echo ""
1354 ########################################################################
1355 # This section contains functions used by several other functions
1356 # below.
1357 ########################
1359 # Look for receipt/files.list in wok. If they can't be found, get them
1360 # from package. Accept one argument : absolute path to package.
1361 get_pkg_files()
1363 pkg_files_dir=$tmp/$(basename ${1%.tazpkg})
1364 mkdir -p $pkg_files_dir && \
1365 cd $pkg_files_dir && \
1366 cpio --quiet -idm receipt < $1 && \
1367 cpio --quiet -idm files.list < $1
1370 ########################################################################
1371 # This section contains functions to generate packages databases.
1372 ########################
1375 gen_packages_db()
1377 # pkg_repository can be $PACKAGES_REPOSITORY or $INCOMING_REPOSITORY.
1378 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1379 cd $pkg_repository
1380 report step "Generating packages lists: $pkg_repository"
1381 report open-bloc
1382 report step "Removing old files"
1383 for file in files.list.lzma packages.list packages.txt \
1384 packages.desc packages.equiv packages.md5; do
1385 rm -rf $file
1386 done
1387 touch files.list
1389 packages_db_start
1390 unset RECEIPT
1391 report step "Reading data from all packages"
1392 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1393 get_packages_info
1394 done
1395 report end-step
1396 packages_db_end
1397 report close-bloc
1400 update_packages_db()
1402 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1403 cd $pkg_repository
1404 for file in packages.list packages.equiv packages.md5 packages.desc \
1405 packages.txt; do
1406 if [ ! -f "$file" ]; then
1407 gen_packages_db
1408 return
1409 fi
1410 done
1411 if [ -f files.list.lzma ]; then
1412 lzma d files.list.lzma files.list
1413 else
1414 gen_packages_db
1415 return
1416 fi
1417 report step "Updating packages lists: $pkg_repository"
1418 packages_db_start
1420 # Look for removed/update packages.
1421 touch stamp -r packages.list
1422 for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
1423 pkg="$pkg_repository/$(grep -m1 ^$PACKAGE- packages.list).tazpkg"
1424 if ! [ -f "$pkg" ]; then
1425 erase_package_info
1426 else
1427 if [ "$pkg" -nt "stamp" ]; then
1428 updated_pkg="$updated_pkg
1429 $PACKAGE $pkg"
1430 elif [ ! -f $WOK/$PACKAGE/receipt ] && \
1431 [ "$COMMAND" = check-incoming -o "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
1432 erase_package_info
1433 echo "Removing $PACKAGE from $pkg_repository."
1434 rm $pkg
1435 [ "$save_wok" ] && rm -rf $pkg_repository/wok/$PACKAGE
1436 if [ "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
1437 rm -rf $WOK/$PACKAGE
1438 sed "/^$PACKAGE\t/d" -i $wan_db $dep_db $cookorder
1439 sed "/^$PACKAGE$/d" -i $cooklist $commit $blocked $broken
1440 rm -f $LOCAL_REPOSITORY/log/$PACKAGE.html
1441 if [ "$(sed 1!d $cookorder)" != "#PlanSort" ]; then
1442 sed 1i"#PlanSort" -i $cookorder
1443 regen_cooklist=yes
1444 fi
1445 else
1446 echo "$PACKAGE" >> removed
1447 sed -n '1,10p' -i removed
1448 fi
1449 fi
1450 fi
1451 done
1452 rm stamp
1453 echo "$updated_pkg" | sed 1d | while read PACKAGE pkg; do
1454 erase_package_info
1455 get_packages_info
1456 done
1457 unset updated_pkg
1459 # Look for new packages.
1460 for pkg in $pkg_repository/*.tazpkg; do
1461 fgrep -q " ${pkg##*/}" packages.md5 || get_packages_info
1462 done
1463 report end-step
1464 packages_db_end
1467 packages_db_start()
1469 if [ -s packages.txt ]; then
1470 sed -e 's/^# Packages :.*/# Packages : unknown/' \
1471 -e "s/# Date :.*/# Date : $(date +%Y-%m-%d\ \%H:%M:%S)/" \
1472 -i packages.txt
1473 else
1474 echo "# SliTaz GNU/Linux - Packages list
1476 # Packages : unknown
1477 # Date : $(date +%Y-%m-%d\ \%H:%M:%S)
1479 " > packages.txt
1480 fi
1482 # Needed in some cases as tazwok defines RECEIPT at configuration time
1483 # in this particular case it can break the script.
1484 unset RECEIPT
1486 # If $packages_repository is the main one, configure few functions
1487 # to act as they should, without having loop on them (speed-up)
1488 if [ "$pkg_repository" = "$PACKAGES_REPOSITORY" ]; then
1489 erase_package_info_extracmd="erase_package_info_main"
1490 get_packages_info_extracmd="get_packages_info_main"
1491 fi
1494 erase_package_info()
1496 cd $pkg_repository
1497 sed "/^$PACKAGE$/,/^$/d" -i packages.txt
1498 sed "/^$PACKAGE /d" -i packages.desc
1499 sed -e "s/=$PACKAGE /= /" -e "s/ $PACKAGE / /" -e "s/ $PACKAGE$//" \
1500 -e "/=$PACKAGE$/d" -e "s/=[0-9,a-z,A-Z]:$PACKAGE /= /" \
1501 -e "s/ [0-9,a-z,A-Z]:$PACKAGE / /" -e "s/ [0-9,a-z,A-Z]:$PACKAGE$/ /" \
1502 -e "/=[0-9,a-z,A-Z]:$PACKAGE$/d" \
1503 -i packages.equiv
1504 sed "/^$PACKAGE:/d" -i files.list
1505 sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
1506 sed "/ $(basename $pkg)$/d" -i packages.md5
1507 $erase_package_info_extracmd
1510 erase_package_info_main()
1512 for i in wanted.txt depends.txt libraries.txt; do
1513 [ -f $i ] || continue
1514 sed "/^$PACKAGE\t/d" -i $i
1515 done
1518 get_packages_info()
1520 # If there's no taz folder in the wok, extract info from the
1521 # package.
1522 get_pkg_files $pkg
1523 source_receipt
1524 echo "Getting data from $PACKAGE"
1526 cat >> $pkg_repository/packages.txt << _EOT_
1527 $PACKAGE
1528 $VERSION$EXTRAVERSION
1529 $SHORT_DESC
1530 _EOT_
1531 if [ "$PACKED_SIZE" ]; then
1532 cat >> $pkg_repository/packages.txt << _EOT_
1533 $PACKED_SIZE ($UNPACKED_SIZE installed)
1535 _EOT_
1536 else
1537 echo "" >> $pkg_repository/packages.txt
1538 fi
1540 # Packages.desc is used by Tazpkgbox <tree>.
1541 echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
1543 # Packages.equiv is used by tazpkg install to check depends.
1544 for i in $PROVIDE; do
1545 DEST=""
1546 echo $i | fgrep -q : && DEST="${i#*:}:"
1547 if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
1548 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
1549 else
1550 echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
1551 fi
1552 done
1554 if [ -f files.list ]; then
1555 { echo "$PACKAGE"; cat files.list; } | awk '
1556 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
1557 fi
1559 cd .. && rm -r "$pkg_files_dir"
1561 cd $pkg_repository
1562 echo $(basename ${pkg%.tazpkg}) >> packages.list
1563 md5sum $(basename $pkg) >> packages.md5
1564 $get_packages_info_extracmd
1567 get_packages_info_main()
1569 [ "$WANTED" ] && echo -e "$PACKAGE\t$WANTED" >> wanted.txt
1570 echo -e "$PACKAGE\t "$DEPENDS" \t "$BUILD_DEPENDS" " >> package.txt
1571 grep -m1 ^$PACKAGE$'\t' $lib_db >> libraries.txt
1574 source_receipt()
1576 unset PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
1577 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
1578 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
1579 src _pkg DESTDIR CONFIG_SITE BRANCH TARBALL KBASEVER \
1580 stuff wanted_stuff
1581 . ${RECEIPT:-$PWD/receipt}
1584 packages_db_end()
1586 cd $pkg_repository
1587 pkgs=$(wc -l packages.list | sed 's/ .*//')
1588 sed "s/# Packages : .*/# Packages : $pkgs/" -i packages.txt
1590 # If lists were updated it's generally needed to sort them well.
1591 if ! sort -c packages.list 2> /dev/null; then
1592 report step "Sorting packages lists"
1593 files_list="packages.list packages.desc packages.equiv"
1594 [ "${pkg_repository##*/}" = packages ] && \
1595 files_list="$files_list wanted.txt depends.txt libraries.txt"
1596 for file in $files_list; do
1597 [ -f $file ] || continue
1598 sort -o $file $file
1599 done
1600 report end-step
1601 fi
1603 md5sum packages.md5 | cut -f1 -d' ' > ID
1604 [ -s ID ] || echo null > ID
1606 # Dont log this because lzma always output errors.
1607 lzma e files.list files.list.lzma
1608 rm -f files.list
1609 [ -f packages.equiv ] || touch packages.equiv
1612 ########################################################################
1613 # This section contains functions to generate wok database.
1614 ########################
1616 gen_wok_db()
1618 report step "Generating wok database"
1619 report open-bloc
1620 report step "Removing old files"
1621 for file in $wan_db $dep_db $cookorder; do
1622 [ -f $file ] && rm $file
1623 done
1624 report step "Generating wok-wanted.txt"
1625 gen_wan_db
1626 report step "Generating wok-depends.txt"
1627 gen_dep_db
1628 sort_db
1629 report close-bloc
1632 gen_wan_db()
1634 [ -f $wan_db ] && rm -f $wan_db
1635 for RECEIPT in $(fgrep -l WANTED $WOK/*/receipt); do
1636 WANTED=
1637 source $RECEIPT
1638 [ "$WANTED" ] || continue
1639 echo -e $PACKAGE"\t"$WANTED >> $wan_db
1640 done
1643 gen_dep_db()
1645 [ -f $dep_db ] && rm -f $dep_db
1646 for PACKAGE in $(ls $WOK); do
1647 RECEIPT=$WOK/$PACKAGE/receipt
1648 if [ -s $RECEIPT ]; then
1649 source_receipt
1650 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
1651 fi
1652 done
1655 update_wan_db()
1657 local PACKAGE=$PACKAGE
1658 wanted_list=$(fgrep WANTED=\"$PACKAGE\" $WOK/*/receipt | cut -f1 -d ':')
1659 grep $'\t'$PACKAGE $wan_db | cut -f 1 | while read wan; do
1660 echo "$wanted_list" | fgrep -q /$wan/receipt && continue
1661 sed "/^$wan\t/d" -i $wan_db
1662 done
1663 for RECEIPT in $wanted_list; do
1664 unset WANTED PACKAGE
1665 source $RECEIPT
1666 [ "$WANTED" ] || continue
1667 sed "/^$PACKAGE\t/d" -i $wan_db
1668 echo -e $PACKAGE"\t"$WANTED >> $wan_db
1669 done
1670 unset wanted_list
1673 update_dep_db()
1675 sed "/^$PACKAGE\t/d" -i $dep_db
1676 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
1679 sort_db()
1681 report step "Generating cookorder.txt"
1682 sed 's/ \t / /' $dep_db | while read PACKAGE BUILD_DEPENDS; do
1683 grep -q ^$PACKAGE$'\t' $wan_db && continue
1685 # Replace each BUILD_DEPENDS with a WANTED package by it's
1686 # WANTED package.
1687 echo -e $PACKAGE"\t $(echo $BUILD_DEPENDS | use_wanted | \
1688 sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' ') "
1689 done > $tmp/db
1690 while [ -s "$tmp/db" ]; do
1691 status=start
1692 for pkg in $(cut -f 1 $tmp/db); do
1693 if ! fgrep -q ' '$pkg' ' $tmp/db; then
1694 echo $pkg >> $tmp/cookorder
1695 sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
1696 status=proceed
1697 fi
1698 done
1699 if [ "$status" = start ]; then
1700 cp -f $tmp/db /tmp/remain-depends.txt
1701 echo "Can't go further because of dependency loop(s). The remaining packages will be commented in the cookorder and will be unbuilt in case of major updates until the problem is solved." >&2
1702 for remaining in $(cut -f 1 $tmp/db); do
1703 if ! grep -q ^$remaining $PACKAGES_REPOSITORY/blocked; then
1704 echo "$remaining" >> $PACKAGES_REPOSITORY/blocked
1705 fi
1706 done
1707 break
1708 fi
1709 done
1710 [ -s $tmp/cookorder ] || touch $tmp/cookorder
1712 # The toolchain packages are moved in first position.
1713 grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1714 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
1715 $tmp/cookorder | tac > $cookorder
1716 for pkg in $(cat $cookorder); do
1717 sed "/^$pkg$/d" -i $tmp/cookorder
1718 done
1720 tac $tmp/cookorder >> $cookorder
1721 report end-step
1724 ########################################################################
1725 # SCAN CORE
1726 ########################
1727 # Includes various scan core-functions. It's not intended to be used
1728 # directly : prefer scan wrappers in next section.
1730 look_for_dep()
1732 grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2
1735 look_for_bdep()
1737 look_for_all
1740 look_for_all()
1742 grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2,3 | sed 's/ / /'
1745 look_for_rdep()
1747 fgrep ' '$PACKAGE' ' $dep_db | cut -f 1
1750 look_for_rbdep()
1752 fgrep ' '$PACKAGE' ' $dep_db | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
1755 # Return WANTED if it exists.
1756 look_for_wanted()
1758 grep -m1 ^$PACKAGE$'\t' $wan_db | cut -f 2
1761 # Return packages which wants PACKAGE.
1762 look_for_rwanted()
1764 grep $'\t'$PACKAGE$ $wan_db | cut -f 1
1767 look_for_dev()
1769 WANTED=$(look_for_wanted)
1770 if [ "$WANTED" ]; then
1771 [ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
1772 fi
1773 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1776 with_dev()
1778 for PACKAGE in $(cat); do
1779 echo $PACKAGE
1780 look_for_dev
1781 done
1784 with_wanted()
1786 for PACKAGE in $(cat); do
1787 echo $PACKAGE
1788 look_for_wanted
1789 done
1792 use_wanted()
1794 for input in $(cat); do
1795 { grep ^$input$'\t' $wan_db || echo $input
1797 done | sed 's/.*\t//'
1800 check_for_pkg_in_wok()
1802 [ -f $WOK/$PACKAGE/receipt ] && return
1803 echo "Can't find $PACKAGE in wok or mirror" >&2
1804 return 2
1807 # Define how theses functions should act when using --undigest.
1808 use_undigest_scan_core()
1810 look_for_dep()
1812 if [ -f "$WOK/$PACKAGE/receipt" ]; then
1813 grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2
1814 else
1815 grep -m1 ^$PACKAGE$'\t' $ref_dep_db | cut -f 2
1816 fi
1819 look_for_all()
1821 if [ -f "$WOK/$PACKAGE/receipt" ]; then
1822 grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2,3 | sed 's/ / /'
1823 else
1824 grep -m1 ^$PACKAGE$'\t' $ref_dep_db | cut -f 2,3 | sed 's/ / /'
1825 fi
1828 look_for_rdep()
1830 fgrep ' '$PACKAGE' ' $dep_db | cut -f 1
1831 for rdep in $(fgrep ' '$PACKAGE' ' $ref_dep_db | cut -f 1); do
1832 [ -f "WOK$/$rdep/receipt" ] || echo "$rdep"
1833 done
1836 look_for_rbdep()
1838 fgrep ' '$PACKAGE' ' $dep_db | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
1839 for rdep in $(fgrep ' '$PACKAGE' ' $ref_dep_db | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
1840 [ -f "WOK$/$rdep/receipt" ] || echo "$rdep"
1841 done
1844 look_for_wanted()
1846 if [ -f "$WOK/$PACKAGE/receipt" ]; then
1847 grep -m1 ^$PACKAGE$'\t' $wan_db | cut -f 2
1848 else
1849 grep -m1 ^$PACKAGE$'\t' $ref_wan_db | cut -f 2
1850 fi
1853 look_for_rwanted()
1855 if [ -f "$WOK/$PACKAGE/receipt" ]; then
1856 grep $'\t'$PACKAGE$ $wan_db | cut -f 1
1857 else
1858 grep $'\t'$PACKAGE$ $ref_wan_db | cut -f 1
1859 fi
1862 look_for_dev()
1864 WANTED=$(look_for_wanted)
1865 if [ "$WANTED" ]; then
1866 if [ -f "$WOK/$WANTED/receipt" ]; then
1867 [ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
1868 else
1869 grep -q ^$WANTED-dev$'\t' $ref_dep_db && echo $WANTED-dev
1870 fi
1871 fi
1872 if [ -f "$WOK/$PACKAGE/receipt" ]; then
1873 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1874 else
1875 grep -q ^$PACKAGE-dev$'\t' $ref_dep_db && echo $PACKAGE-dev
1876 fi
1879 check_for_pkg_in_wok()
1881 [ -f $WOK/$PACKAGE/receipt ] && return
1882 grep -q ^$PACKAGE'$\t' $ref_dep_db && return 1
1883 echo "Can't find $PACKAGE in wok or mirror" >&2
1884 return 2
1888 ########################################################################
1889 # SCAN
1890 ########################
1891 # Use wok-wanted.txt and wok-depeds.txt to scan depends.
1892 # Option in command line (must be first arg) :
1893 # --look_for=bdep/rbdep - Look for depends or reverse depends.
1894 # --with_dev - Add development packages (*-dev) in the result.
1895 # --with_wanted - Add package+reverse wanted in the result.
1896 # --with_args - Include packages in argument in the result.
1898 scan()
1900 # Get packages in argument.
1901 local PACKAGE=$PACKAGE WANTED=$WANTED pkg_list=
1902 for arg in $@; do
1903 [ "$arg" = "${arg#--}" ] || continue
1904 pkg_list="$pkg_list $arg"
1905 done
1907 # Get options.
1908 [ "$pkg_list" ] || return
1909 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
1910 get_options_list="look_for with_dev with_wanted with_args cooklist use_wanted"
1911 get_options
1913 # Get db md5 to be able to check for changes latter.
1914 db_md5=$(md5sum $dep_db $wan_db)
1916 # Cooklist is a special case where we need to modify a little
1917 # scan behavior
1918 if [ "$cooklist" ]; then
1919 gen_wan_db
1920 look_for=all && with_args=yes && with_dev= && with_wanted=
1921 filter=use_wanted
1922 if [ "$COMMAND" = gen-cooklist ]; then
1923 for PACKAGE in $pkg_list; do
1924 grep -q ^$PACKAGE$'\t' $dep_db && continue
1925 [ -d "$WOK/$p" ] || continue
1926 check_for_missing
1927 done
1928 append_to_dep()
1930 if grep -q ^$PACKAGE$'\t' $dep_db; then
1931 echo $PACKAGE >> $tmp/dep
1932 else
1933 check_for_missing && echo $PACKAGE >> $tmp/dep
1934 fi
1936 else
1937 append_to_dep()
1939 check_for_commit && echo $PACKAGE >> $tmp/dep
1941 fi
1942 else
1943 append_to_dep()
1945 echo $PACKAGE >> $tmp/dep
1947 # If requested packages are not in dep_db, partial generation of this db is needed.
1948 for PACKAGE in $pkg_list; do
1949 grep -q ^$PACKAGE$'\t' $dep_db && continue
1950 [ -d "$WOK/$p" ] || continue
1951 plan_check_for_missing=yes
1952 check_for_missing
1953 done
1954 if [ "$plan_check_for_missing" ]; then
1955 append_to_dep()
1957 if grep -q ^$PACKAGE$'\t' $dep_db; then
1958 echo $PACKAGE >> $tmp/dep
1959 else
1960 check_for_missing && echo $PACKAGE >> $tmp/dep
1961 fi
1963 unset plan_check_for_missing
1964 fi
1965 fi
1967 [ "$with_dev" ] && filter=with_dev
1968 [ "$with_wanted" ] && filter=with_wanted
1969 if [ "$filter" ]; then
1970 pkg_list=$(echo $pkg_list | $filter | sort -u)
1971 scan_pkg()
1973 look_for_$look_for | $filter
1975 else
1976 scan_pkg()
1978 look_for_$look_for
1980 fi
1981 touch $tmp/dep
1982 for PACKAGE in $pkg_list; do
1983 [ "$with_args" ] && append_to_dep
1984 scan_pkg
1985 done | tr ' ' '\n' | sort -u > $tmp/list
1986 [ "$look_for" = bdep ] && look_for=dep
1987 while [ -s $tmp/list ]; do
1988 PACKAGE=$(sed 1!d $tmp/list)
1989 sed 1d -i $tmp/list
1990 append_to_dep
1991 for pkg in $(scan_pkg); do
1992 grep -q ^$pkg$ $tmp/list $tmp/dep || echo $pkg >> $tmp/list
1993 done
1994 done
1995 if [ "$cooklist" ]; then
1996 mv $tmp/dep $tmp/cooklist
1997 else
1998 cat $tmp/dep | sort -u
1999 fi
2000 rm -f $tmp/dep $tmp/list
2001 sort -o $dep_db $dep_db
2002 sort -o $wan_db $wan_db
2003 if [ "$db_md5" != "$(md5sum $dep_db $wan_db)" ]; then
2004 grep -q "^#" $cookorder || sed 1i"#PlanSort" -i $cookorder
2005 fi
2008 ########################################################################
2009 # This section contains functions to check the package repository and
2010 # find which packages to cook.
2011 ########################
2013 check_for_missing()
2015 local PACKAGE=$PACKAGE
2016 if ! check_for_pkg_in_wok; then
2017 [ "$?" = 2 ] && return 1
2018 return
2019 fi
2020 RECEIPT=$WOK/$PACKAGE/receipt
2021 source_receipt
2022 PACKAGE=${WANTED:-$PACKAGE}
2023 update_wan_db
2024 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
2025 RECEIPT=$WOK/$PACKAGE/receipt
2026 source_receipt
2027 update_dep_db
2028 done
2031 # We use md5 of cooking stuff in the packaged receipt to check
2032 # commit. We look consecutively in 3 different locations :
2033 # - in the wok/PACKAGE/taz/* folder
2034 # - in the receipt in the package in incoming repository
2035 # - in the receipt in the package in packages repository
2036 # If md5sums match, there's no commit.
2037 check_for_commit_using_md5sum()
2039 if [ ! -f $WOK/$PACKAGE/md5 ]; then
2040 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
2041 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
2042 cd $WOK/$PACKAGE
2043 fi
2045 if [ "$1" ]; then
2046 check_for_commit_using_time && return
2047 fi
2049 if [ -s md5 ]; then
2050 if md5sum -cs md5; then
2052 # If md5sum check if ok, check for new/missing files in
2053 # cooking stuff.
2054 for file in $([ -f receipt ] && echo receipt; \
2055 [ -f description.txt ] && echo description.txt; \
2056 [ -d stuff ] && find stuff); do
2057 if ! fgrep -q " $file" md5; then
2058 set_commited
2059 fi
2060 done
2061 else
2062 set_commited
2063 fi
2064 else
2065 set_commited
2066 fi
2069 set_commited()
2071 ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/commit &&
2072 echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
2073 gen_cookmd5
2074 update_dep_db
2077 check_for_commit_using_time()
2079 local count=0 file cook_files
2081 get_cook_files
2083 for file in $cook_files; do
2084 if [ $file -nt md5 ]; then
2085 return 1
2086 else
2087 count=$((count+1))
2088 fi
2089 done
2091 if [ "$cook_files" ] \
2092 && [ ! "$count md5" = "`wc -l md5`" ]
2093 then
2094 return 1
2095 fi
2098 check_for_commit()
2100 if ! check_for_pkg_in_wok; then
2101 [ "$?" = 2 ] && return 1
2102 return
2103 fi
2104 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
2105 RECEIPT=$WOK/$PACKAGE/receipt
2106 source_receipt
2108 if [ -f $WOK/$PACKAGE/md5 ]; then
2109 cd $WOK/$PACKAGE
2110 check_for_commit_using_md5sum or time
2111 elif [ -d "$WOK/$PACKAGE/taz" ] \
2112 && taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*') \
2113 && [ -d "$taz_dir" ]
2114 then
2115 cd "$taz_dir"
2116 check_for_commit_using_md5sum or time
2117 else
2118 pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
2119 [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
2120 if [ "$pkg" ]; then
2121 get_pkg_files $pkg
2122 check_for_commit_using_md5sum
2123 rm -r $pkg_files_dir
2124 else
2125 set_commited
2126 fi
2127 fi
2128 [ "$forced" ] || echo $PACKAGE >> $tmp/checked
2129 done
2132 gen_cook_list()
2134 report step "Scanning wok"
2135 if [ "$pkg" ]; then
2136 scan $pkg --cooklist
2137 elif [ "$LIST" ]; then
2138 scan `cat $LIST` --cooklist
2139 else
2140 scan `cat $cooklist` --cooklist
2141 fi
2142 report end-step
2144 [ -s $tmp/checked ] || [ -s $tmp/cooklist ] || return
2146 # Core toolchain should not be cooked unless cook-toolchain is used.
2147 if ! [ -f /etc/config.site.tmptoolchain ] ; then
2148 for PACKAGE in $(scan gcc --look_for=all --with_args --with_wanted); do
2149 grep -q ^$PACKAGE$ $blocked || echo $PACKAGE >> $blocked
2150 done
2151 fi
2153 if [ -s $commit ] && [ "$COMMAND" != gen-cooklist ]; then
2154 for PACKAGE in $(cat $commit); do
2155 WANTED="$(look_for_wanted)"
2156 if [ "$WANTED" ]; then
2157 grep -q ^$WANTED$ $broken $cooklist $blocked $commit && continue
2158 fi
2159 grep -q ^$PACKAGE$ $blocked $cooklist && continue
2160 echo $PACKAGE >> $cooklist
2161 done
2162 fi
2163 sort_cooklist
2166 sort_cooklist()
2168 if [ "$(sed 1!d $cookorder)" = "#PlanSort" ]; then
2169 sed 1d -i $cookorder
2170 sort_db
2171 fi
2172 report step "Generating cooklist"
2173 if [ -f "$tmp/checked" ]; then
2174 rm -f $tmp/cooklist
2175 cat $tmp/checked | while read PACKAGE; do
2176 grep -q ^$PACKAGE$ $cooklist && echo $PACKAGE >> $tmp/cooklist
2177 done
2178 elif ! [ "$COMMAND" = gen-cooklist ]; then
2179 cat $blocked | while read PACKAGE; do
2180 sed "/^$PACKAGE/d" -i $tmp/cooklist
2181 done
2182 fi
2183 report end-step
2184 [ -s $tmp/cooklist ] || return
2186 report step "Sorting cooklist"
2187 for PACKAGE in $(cat $tmp/cooklist); do
2188 WANTED="$(look_for_wanted)"
2189 [ "$WANTED" ] || continue
2190 if grep -q ^$WANTED$ $broken $tmp/cooklist; then
2191 sed "/^$PACKAGE$/d" -i $tmp/cooklist
2192 elif [ ! -d $WOK/$WANTED/install ]; then
2193 sed "/^$PACKAGE$/d" -i $tmp/cooklist
2194 echo $WANTED >> $tmp/cooklist
2195 fi
2196 done
2198 # Use cookorder.txt to sort cooklist.
2199 if [ -s $tmp/cooklist ]; then
2200 cat $cookorder | while read PACKAGE; do
2201 if grep -q ^$PACKAGE$ $tmp/cooklist; then
2202 sed "/^$PACKAGE$/d" -i $tmp/cooklist
2203 echo $PACKAGE >> $tmp/cooklist.tmp
2204 fi
2205 done
2207 # Remaining packages in cooklist are those without compile_rules.
2208 # They can be cooked first in any order.
2209 if [ -f $tmp/cooklist.tmp ]; then
2210 cat $tmp/cooklist.tmp >> $tmp/cooklist
2211 rm $tmp/cooklist.tmp
2212 fi
2214 cat $tmp/cooklist
2215 [ "$LIST" ] || cat $tmp/cooklist > $cooklist
2216 fi
2218 report end-step
2221 look_for_missing_pkg()
2223 for pkg in $(cat $PACKAGES_REPOSITORY/$1); do
2224 grep -q ^$pkg$ $INCOMING_REPOSITORY/packages.txt \
2225 $PACKAGES_REPOSITORY/packages.txt || \
2226 continue
2227 echo $pkg
2228 done
2231 check_for_incoming()
2233 report step "Checking that all packages were cooked OK"
2234 [ -s $INCOMING_REPOSITORY/packages.desc ] || {
2235 echo "No packages in $INCOMING_REPOSITORY."
2236 report end-step; return; }
2237 if [ -s $broken ]; then
2238 missingpkg=$(look_for_missing_pkg broken)
2239 if [ "$missingpkg" ]; then
2240 echo "Don't move incoming packages to main repository because these ones are broken:" >&2
2241 echo "$missingpkg"
2242 report end-step
2243 return 1
2244 fi
2245 fi
2246 if [ -s $cooklist ]; then
2247 missingpkg=$(look_for_missing_pkg cooklist)
2248 if [ "$missingpkg" ]; then
2249 echo "Don't move incoming packages to main repository because these ones need to be cooked:" >&2
2250 echo "$missingpkg"
2251 report end-step
2252 return 1
2253 fi
2254 fi
2255 incoming_pkgs="$(cut -f 1 -d '|' $INCOMING_REPOSITORY/packages.desc)"
2256 if ! [ "$forced" ]; then
2257 cooklist=$PACKAGES_REPOSITORY/cooklist
2258 pkg="$incoming_pkgs"
2259 gen_cook_list
2260 if [ -s $cooklist ]; then
2261 missingpkg=$(look_for_missing_pkg cooklist)
2262 if [ "$missingpkg" ]; then
2263 echo "Don't move incoming packages to main repository because these ones need to be cooked:" >&2
2264 echo "$missingpkg"
2265 report end-step
2266 return 1
2267 fi
2268 fi
2269 fi
2271 report step "Moving incoming packages to main repository"
2272 [ "$save_wok" ] && mkdir -p $PACKAGES_REPOSITORY/wok
2273 unset EXTRAVERSION
2274 for PACKAGE in $incoming_pkgs; do
2275 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
2276 VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
2277 remove_previous_package $PACKAGES_REPOSITORY
2278 echo "Moving $PACKAGE..."
2279 mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
2280 touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
2281 previous_tarball=$(grep -m1 ^$PACKAGE:main $SOURCES_REPOSITORY/sources.list | cut -f2)
2282 sed -e "/^$PACKAGE:main/d" \
2283 -e "s/^$PACKAGE:incoming/$PACKAGE:main/" \
2284 -i $SOURCES_REPOSITORY/sources.list
2285 if [ "$previous_tarball" ]; then
2286 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
2287 rm -f $SOURCES_REPOSITORY/$previous_tarball
2288 fi
2289 [ "$save_wok" ] && mv $INCOMING_REPOSITORY/wok/$PACKAGE $PACKAGES_REPOSITORY/wok
2290 done
2292 if [ "$save_wok" = tarball ]; then
2293 rm -f $PACKAGES_REPOSITORY/wok.tar.lzma
2294 cd $PACKAGES_REPOSITORY/wok
2295 report step "Generating safe-wok tarball"
2296 tar -c * | lzma e -si $PACKAGES_REPOSITORY/wok.tar.lzma
2297 report end-step
2298 fi
2300 for file in packages.list packages.equiv packages.md5 packages.desc \
2301 packages.txt; do
2302 echo -n "" > $INCOMING_REPOSITORY/$file
2303 done
2304 rm -r $INCOMING_REPOSITORY/files.list.lzma
2305 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2307 report step "Updating flavors"
2308 if [ -x /usr/bin/tazlito ] || [ -x /usr/bin/clean-chroot ]; then
2309 if ! [ -x /usr/bin/tazlito ]; then
2310 tazpkg get-install tazlito
2311 fi
2313 # Handle cases where tazwok is used into main system;
2314 # Handle cases where SLITAZ_DIR is not /home/slitaz.
2315 [ -L /home/slitaz/flavors ] && rm /home/slitaz/flavors
2316 mkdir -p /home/slitaz
2317 ln -s $LOCAL_REPOSITORY/flavors /home/slitaz/flavors
2318 cd /home/slitaz/flavors
2319 [ -d .hg ] && hg pull -u
2321 cd $LOCAL_REPOSITORY/packages
2322 for i in $LOCAL_REPOSITORY/flavors/*; do
2323 [ -d "$i" ] || continue
2324 tazlito pack-flavor ${i##*/}
2325 done
2327 noheader=""
2328 for i in *.flavor; do
2329 tazlito show-flavor $i --brief $noheader
2330 noheader="--noheader"
2331 done > flavors.list
2332 [ -x /usr/bin/clean-chroot ] && clean-chroot
2333 else
2334 echo "Can't create up-to-date flavors because the tazlito package is missing." >&2
2335 fi
2336 report end-step
2339 # Usage: move_cooking_stuff source receipt destination
2340 # Make the argument check before calling it!
2341 copy_cooking_stuff()
2343 rm -rf $3/$2
2344 mkdir -p $3/$2
2345 cp -a $1/$2/receipt $3/$2
2346 [ -f $1/$2/description.txt ] && \
2347 cp -a $1/$2/description.txt $3/$2
2348 if [ -d "$1/$2/stuff" ]; then
2349 cp -a $1/$2/stuff $3/$2
2350 fi
2353 ########################################################################
2354 # TAZWOK MAIN FUNCTIONS
2355 ########################
2357 clean()
2359 cd $WOK/$PACKAGE
2360 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
2361 -e ^stuff$ || return
2363 [ "$COMMAND" = clean-wok ] || report step "Cleaning $PACKAGE"
2364 # Check for clean_wok function.
2365 if grep -q ^clean_wok $RECEIPT; then
2366 clean_wok
2367 fi
2368 # Clean should only have a receipt, stuff and optionals desc/md5.
2369 for f in `ls .`
2370 do
2371 case $f in
2372 receipt|stuff|description.txt|md5)
2373 continue ;;
2374 *)
2375 rm -rf $f ;;
2376 esac
2377 done
2378 [ "$COMMAND" != clean-wok ] && report end-step
2381 # Configure and make a package with the receipt.
2382 compile_package()
2384 check_for_package_on_cmdline
2386 # Include the receipt to get all needed variables and functions
2387 # and cd into the work directory to start the work.
2388 check_for_receipt
2389 source_receipt
2391 # Log the package name and date.
2392 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
2393 echo "package $PACKAGE (compile)" >> $LOG
2395 # Set wanted $src variable to help compiling.
2396 [ ! "$src" ] && set_src_path
2397 check_for_build_depends || return 1
2398 check_for_wanted
2399 unset target
2400 check_for_tarball && check_for_compile_rules
2403 # Cook command also include all features to manage lists which keep
2404 # track of wok/packages state.
2405 cook()
2407 cook_code=
2408 set_common_path
2409 check_for_receipt
2410 source_receipt
2412 # Define log path and start report.
2413 for i in $(look_for_rwanted) $PACKAGE; do
2414 rm -f $LOCAL_REPOSITORY/log/$i.html
2415 done
2416 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
2417 echo "$PACKAGE" > $LOCAL_REPOSITORY/log/package
2418 report step "Cooking $PACKAGE"
2419 report open-bloc
2421 clean $PACKAGE
2422 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
2424 if compile_package; then
2425 remove_src
2426 refresh_packages_from_compile
2427 gen_package
2429 # Update packages-incoming repository.
2430 store_pkgname=$PACKAGE
2431 pkg_repository=$INCOMING_REPOSITORY
2432 update_packages_db
2434 PACKAGE=$store_pkgname
2435 unset store_pkgname
2437 # Upgrade to cooked packages if it was previously installed.
2438 report step "Looking for package(s) to upgrade"
2439 for pkg in $(look_for_rwanted) $PACKAGE; do
2440 if [ -f $INSTALLED/$pkg/receipt ]; then
2441 tazpkg get-install $pkg --forced
2442 fi
2443 done
2444 report end-step
2445 else
2446 for PACKAGE in $(look_for_wanted) $PACKAGE; do
2447 set_pkg_broken
2448 done
2449 cook_code=1
2450 fi
2452 # Remove build_depends in cook mode (if in cooklist, it's done when
2453 # checking build_depends of next package and we remove only unneeded
2454 # packages to keep chroot minimal and gain some time).
2455 if [ "$COMMAND" = cook ]; then
2456 remove_build_depends $MISSING_PACKAGE
2457 [ -x /usr/bin/clean-chroot ] && clean-chroot
2458 fi
2460 # Regen the cooklist if it was planned and command is not cook.
2461 [ "$regen_cooklist" ] && unset regen_cooklist &&
2462 [ "$COMMAND" != cook ] && sort_cooklist
2464 # Some hacks to set the bloc & function status as failed if cook has
2465 # failed.
2466 report_return_code=$cook_code
2467 report close-bloc
2468 report end-sublog
2469 rm -f $LOCAL_REPOSITORY/log/package
2470 return $cook_code
2473 cook_list()
2475 if [ -s $tmp/cooklist ]; then
2476 if [ -f /usr/bin/tazchroot ]; then
2477 # Note : options -main variables- are automatically kept by
2478 # the sub-applications tazchroot/tazwok; as well as report data.
2479 cd $LOCAL_REPOSITORY
2480 [ ! -f tazchroot.conf ] && configure_tazchroot
2481 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
2482 return
2483 fi
2484 while [ -s $tmp/cooklist ]; do
2485 PACKAGE=$(sed 1!d $tmp/cooklist)
2486 cook
2487 done
2488 remove_build_depends $MISSING_PACKAGE $remove_later
2489 [ -x /usr/bin/clean-chroot ] && clean-chroot
2490 else
2491 echo "Nothing to cook."
2492 return
2493 fi
2496 configure_tazchroot()
2498 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
2499 # Tazchroot configuration file - created by tazwok.
2501 # Local repository definition.
2502 SLITAZ_DIR=$SLITAZ_DIR
2503 SLITAZ_VERSION=$SLITAZ_VERSION
2504 LOCAL_REPOSITORY=$SLITAZ_DIR/${undigest:-$SLITAZ_VERSION}
2505 ${USE_ONLINE_PKG:+USE_ONLINE_PKG=$USE_ONLINE_PKG}
2506 ${undigest:+undigest=$undigest}
2507 ${ref_USE_ONLINE_PKG:+ref_USE_ONLINE_PKG=$ref_USE_ONLINE_PKG}
2509 # Chroot path.
2510 # You can use a chroot into /tmp if it's mounted in RAM
2511 # to speed-up the process, be sure you have a free GB.
2512 # (minimal chroot is like 150~200MB, can be a lot more during cook)
2513 # chroot_dir=/tmp/chroot-${undigest:-$SLITAZ_VERSION}
2514 chroot_dir=\$LOCAL_REPOSITORY/chroot
2516 # Default scripts path (these scripts are added to the
2517 # $chroot_dir/usr/bin and can be called with tazchroot script).
2518 script_dir=/usr/lib/slitaz/chroot-scripts/tazwok
2520 # List of directories to mount.
2521 list_dir="$LOCAL_REPOSITORY
2522 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
2524 create_chroot()
2526 mkdir -p \$chroot_dir
2527 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
2528 tazpkg get-install \$pkg --root="\$chroot_dir"
2529 done
2531 # Store list of installed packages needed by cleanchroot.
2532 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
2534 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
2535 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
2536 -i \$chroot_dir/etc/slitaz/slitaz.conf
2537 echo \$SLITAZ_VERSION > \$chroot_dir/etc/slitaz-release
2538 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
2539 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
2541 # The build bot may run in a sandbox: link sandbox lockfile.
2542 [ -d \$LOCAL_REPOSITORY/sandbox ] && ln -s \$LOCAL_REPOSITORY/sandbox/proc/1 \$chroot_dir/proc/1
2545 mount_chroot()
2547 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
2548 $( if [ "$USE_ONLINE_PKG" ]; then
2549 echo ' echo "$USE_ONLINE_PKG" > $chroot_dir$LOCALSTATE/mirror'
2550 else
2551 echo ' echo "$LOCAL_REPOSITORY/packages" > $chroot_dir$LOCALSTATE/mirror'
2552 fi
2554 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
2555 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
2556 $( if [ "$undigest" ]; then
2557 echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION'
2558 if [ "$ref_USE_ONLINE_PKG" ]; then
2559 echo ' echo "$ref_USE_ONLINE_PKG" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror'
2560 else
2561 echo ' echo "$ref_LOCAL_REPOSITORY/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror'
2562 fi
2563 fi )
2564 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
2565 mount -o bind /proc \$chroot_dir/proc
2566 mount -o bind /sys \$chroot_dir/sys
2567 mount -o bind /dev/pts \$chroot_dir/dev/pts
2568 mount -o bind /dev/shm \$chroot_dir/dev/shm
2569 for dir in \$list_dir; do
2570 mkdir -p \$dir \$chroot_dir\$dir
2571 mount \$dir \$chroot_dir\$dir
2572 done
2575 umount_chroot()
2577 for dir in \$list_dir; do
2578 umount \$chroot_dir\$dir
2579 done
2580 umount \$chroot_dir/dev/shm
2581 umount \$chroot_dir/dev/pts
2582 umount \$chroot_dir/sys
2583 umount \$chroot_dir/proc
2585 EOF
2588 ########################################################################
2589 ######################### END OF NEW FUNCTIONS #########################
2590 ########################################################################
2592 # List packages providing a virtual package.
2593 whoprovide()
2595 local i;
2596 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
2597 . $i
2598 case " $PROVIDE " in
2599 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
2600 esac
2601 done
2604 ########################################################################
2605 # TAZWOK COMMANDS
2606 ########################
2608 case "$COMMAND" in
2609 stats)
2610 # Tazwok general statistics from the wok config file.
2612 get_tazwok_config
2613 echo -e "\n\033[1mTazwok configuration statistics\033[0m
2614 ================================================================================
2615 Wok directory : $WOK
2616 Packages repository : $PACKAGES_REPOSITORY
2617 Incoming repository : $INCOMING_REPOSITORY
2618 Sources repository : $SOURCES_REPOSITORY
2619 Log directory : $LOCAL_REPOSITORY/log
2620 Packages in the wok : `ls -1 $WOK | wc -l`
2621 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2622 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2623 ================================================================================\n"
2624 ;;
2625 edit)
2626 get_tazwok_config
2627 check_for_package_on_cmdline
2628 check_for_receipt
2629 $EDITOR $WOK/$PACKAGE/receipt
2630 ;;
2631 build-depends)
2632 # List dependencies to rebuild wok, or only a package.
2633 get_tazwok_config
2634 report(){ : ; }
2635 if [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
2636 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
2637 --look_for=dep --with_dev --with_args
2638 else
2639 check_for_package_on_cmdline
2640 scan $PACKAGE --look_for=bdep --with_dev
2641 fi
2642 ;;
2643 gen-cooklist)
2644 check_root
2645 get_options_list="pkg"
2646 get_tazwok_config
2647 report(){ : ; }
2648 if ! [ "$pkg" ]; then
2649 if [ ! "$LIST" ] || [ "$LIST" = toolchain ]; then
2650 pkg="$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA"
2651 else
2652 check_for_list
2653 fi
2654 fi
2655 gen_cook_list
2656 ;;
2657 check-depends)
2658 # Check package depends /!\.
2659 get_tazwok_config
2660 echo ""
2661 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
2662 ================================================================================"
2663 TMPDIR=/tmp/tazwok$$
2664 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
2666 # Build ALL_DEPENDS variable.
2667 scan_dep()
2669 local i
2670 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
2671 for i in $DEPENDS $SUGGESTED ; do
2672 case " $ALL_DEPENDS " in
2673 *\ $i\ *) continue;;
2674 esac
2675 [ -d $WOK/$i ] || {
2676 ALL_DEPENDS="$ALL_DEPENDS$i "
2677 continue
2679 DEPENDS=""
2680 SUGGESTED=""
2681 . $WOK/$i/receipt
2682 scan_dep
2683 done
2686 # Check for ELF file.
2687 is_elf()
2689 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ]
2692 # Print shared library dependencies.
2693 ldd()
2695 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2698 mkdir $TMPDIR
2699 cd $TMPDIR
2700 for i in $LOCALSTATE/files.list.lzma \
2701 $LOCALSTATE/undigest/*/files.list.lzma ; do
2702 [ -f $i ] && lzma d $i -so >> files.list
2703 done
2704 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2705 tazpkg extract $pkg > /dev/null 2>&1
2706 . */receipt
2707 ALL_DEPENDS="$DEFAULT_DEPENDS "
2708 scan_dep
2709 find */fs -type f | while read file ; do
2710 is_elf $file || continue
2711 case "$file" in
2712 *.o|*.ko|*.ko.gz) continue;;
2713 esac
2714 ldd $file | while read lib rem; do
2715 case "$lib" in
2716 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2717 continue;;
2718 esac
2719 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2720 case " $ALL_DEPENDS " in
2721 *\ $dep\ *) continue 2;;
2722 esac
2723 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2724 case " $ALL_DEPENDS " in
2725 *\ $vdep\ *) continue 3;;
2726 esac
2727 done
2728 done
2729 [ -n "$dep" ] || dep="UNKNOWN"
2730 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2731 done
2732 done
2733 rm -rf */
2734 done
2735 cd /tmp
2736 rm -rf $TMPDIR
2737 ;;
2738 check)
2739 # Check wok consistency.
2740 get_tazwok_config
2741 echo ""
2742 echo -e "\033[1mWok and packages checking\033[0m
2743 ================================================================================"
2744 cd $WOK
2745 for pkg in $(ls)
2746 do
2747 [ -f $pkg/receipt ] || continue
2748 RECEIPT= $pkg/receipt
2749 source_receipt
2750 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2751 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2752 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2753 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2754 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2755 if [ -n "$WANTED" ]; then
2756 if [ ! -f $WANTED/receipt ]; then
2757 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2758 else
2759 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2760 if [ "$VERSION" = "$WANTED" ]; then
2761 # BASEVERSION is computed in receipt
2762 fgrep -q '_pkg=' $pkg/receipt &&
2763 BASEVERSION=$VERSION
2764 fi
2765 if [ "$VERSION" != "$BASEVERSION" ]; then
2766 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2767 fi
2768 fi
2769 fi
2771 if [ -n "$CATEGORY" ]; then
2772 case " $(echo $CATEGORIES) " in
2773 *\ $CATEGORY\ *);;
2774 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2775 esac
2776 else
2777 echo"Package $PACKAGE has no CATEGORY" >&2
2778 fi
2779 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2780 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2781 case "$WGET_URL" in
2782 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2783 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2784 '') ;;
2785 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2786 esac
2787 case "$WEB_SITE" in
2788 ftp*|http*);;
2789 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2790 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2791 esac
2792 case "$MAINTAINER" in
2793 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2794 esac
2795 case "$MAINTAINER" in
2796 *@*);;
2797 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2798 esac
2799 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2800 for i in $DEPENDS; do
2801 [ -d $i ] && continue
2802 [ -n "$(whoprovide $i)" ] && continue
2803 echo -e "$MSG $i"
2804 MSG=""
2805 done
2806 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2807 for i in $BUILD_DEPENDS; do
2808 [ -d $i ] && continue
2809 [ -n "$(whoprovide $i)" ] && continue
2810 echo -e "$MSG $i"
2811 MSG=""
2812 done
2813 MSG="Dependency loop between $PACKAGE and :\n"
2814 ALL_DEPS=""
2815 check_for_deps_loop $PACKAGE $DEPENDS
2816 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2817 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2818 echo "$pkg should be rebuilt after $i installation"
2819 done
2820 done
2821 ;;
2822 list)
2823 # List packages in wok directory. User can specify a category.
2825 get_tazwok_config
2826 if [ "$2" = "category" ]; then
2827 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2828 exit 0
2829 fi
2830 # Check for an asked category.
2831 if [ -n "$2" ]; then
2832 ASKED_CATEGORY=$2
2833 echo ""
2834 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2835 horizontal_line
2836 for pkg in $WOK/*
2837 do
2838 [ ! -f $pkg/receipt ] && continue
2839 . $pkg/receipt
2840 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2841 echo -n "$PACKAGE"
2842 echo -e "\033[28G $VERSION"
2843 packages=$(($packages+1))
2844 fi
2845 done
2846 horizontal_line
2847 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
2848 else
2849 # By default list all packages and version.
2850 echo ""
2851 echo -e "\033[1mList of packages in the wok\033[0m"
2852 horizontal_line
2853 for pkg in $WOK/*
2854 do
2855 [ ! -f $pkg/receipt ] && continue
2856 . $pkg/receipt
2857 echo -n "$PACKAGE"
2858 echo -en "\033[28G $VERSION"
2859 echo -e "\033[42G $CATEGORY"
2860 packages=$(($packages+1))
2861 done
2862 horizontal_line
2863 echo -e "$packages packages available in the wok.\n"
2864 fi
2865 ;;
2866 info)
2867 # Information about a package.
2869 get_tazwok_config
2870 check_for_package_on_cmdline
2871 check_for_receipt
2872 . $WOK/$PACKAGE/receipt
2873 echo ""
2874 echo -e "\033[1mTazwok package information\033[0m
2875 ================================================================================
2876 Package : $PACKAGE
2877 Version : $VERSION
2878 Category : $CATEGORY
2879 Short desc : $SHORT_DESC
2880 Maintainer : $MAINTAINER"
2881 if [ ! "$WEB_SITE" = "" ]; then
2882 echo "Web site : $WEB_SITE"
2883 fi
2884 if [ ! "$DEPENDS" = "" ]; then
2885 echo "Depends : $DEPENDS"
2886 fi
2887 if [ ! "$WANTED" = "" ]; then
2888 echo "Wanted src : $WANTED"
2889 fi
2890 horizontal_line
2891 echo ""
2892 ;;
2893 check-log)
2894 # We just cat the file log to view process info.
2896 get_tazwok_config
2897 if [ ! -f "$LOG" ]; then
2898 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2899 exit 1
2900 else
2901 echo ""
2902 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2903 horizontal_line
2904 cat $LOG
2905 horizontal_line
2906 echo ""
2907 if [ -s "$WOK/$PACKAGE/warning.txt" ]; then
2908 echo -e "\033[1mCook warning(s) for :\033[0m $PACKAGE"
2909 horizontal_line
2910 cat "$WOK/$PACKAGE/warning.txt"
2911 horizontal_line
2912 echo ""
2913 fi
2914 fi
2915 ;;
2916 search)
2917 # Search for a package by pattern or name.
2919 get_tazwok_config
2920 if [ -z "$2" ]; then
2921 echo -e "\nPlease specify a pattern or a package name to search." >&2
2922 echo -e "Example : 'tazwok search gcc'.\n" >&2
2923 exit 1
2924 fi
2925 echo ""
2926 echo -e "\033[1mSearch result for :\033[0m $2"
2927 horizontal_line
2928 list=`ls -1 $WOK | fgrep $2`
2929 for pkg in $list
2930 do
2931 . $WOK/$pkg/receipt
2932 echo -n "$PACKAGE "
2933 echo -en "\033[24G $VERSION"
2934 echo -e "\033[42G $CATEGORY"
2935 packages=$(($PACKAGEs+1))
2936 done
2937 horizontal_line
2938 echo "$packages packages found for : $2"
2939 echo ""
2940 ;;
2941 compile)
2942 # Configure and make a package with the receipt.
2944 get_tazwok_config
2945 source_lib report
2946 report start
2947 compile_package
2948 ;;
2949 genpkg)
2950 # Generate a package.
2952 get_tazwok_config
2953 source_lib report
2954 report start
2955 gen_package
2956 ;;
2957 cook)
2958 # Compile and generate a package. Just execute tazwok with
2959 # the good commands.
2961 check_root
2962 get_tazwok_config
2963 source_lib report
2964 report start
2965 db_md5=$(md5sum $dep_db $wan_db)
2966 update_wan_db
2967 check_for_commit
2968 sort -o $dep_db $dep_db
2969 sort -o $wan_db $wan_db
2970 if [ "$db_md5" != "$(md5sum $dep_db $wan_db)" ]; then
2971 grep -q "^#" $cookorder || sed 1i"#PlanSort" -i $cookorder
2972 fi
2973 cook
2974 ;;
2975 sort-cooklist)
2976 check_root
2977 get_tazwok_config
2978 check_for_list
2979 report(){ : ; }
2980 # When using sort-cooklist, the script should behave as for gen-cooklist
2981 # The only difference between these two is where the output is sent.
2982 COMMAND=gen-cooklist
2983 gen_cook_list
2984 cp -af $tmp/cooklist $LIST
2985 ;;
2986 cook-list)
2987 # Cook all packages listed in a file or in default cooklist.
2988 check_root
2989 get_options_list="pkg forced"
2990 get_tazwok_config
2991 source_lib report
2992 report start
2993 if ! [ "$pkg" ]; then
2994 [ "$LIST" ] && check_for_list
2995 fi
2996 gen_cook_list
2997 cook_list
2998 ;;
2999 clean)
3000 # Clean up a package work directory + those which want it.
3002 get_tazwok_config
3003 check_for_package_on_cmdline
3004 check_for_receipt
3005 source_lib report
3006 report start
3007 . $RECEIPT
3008 clean
3009 ;;
3010 gen-clean-wok)
3011 # Generate a clean wok from the current wok by copying all receipts
3012 # and stuff directory.
3014 get_tazwok_config
3015 source_lib report
3016 report start
3017 if [ -z "$ARG" ]; then
3018 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
3019 exit 1
3020 else
3021 dest=$ARG
3022 mkdir -p $dest
3023 fi
3024 report step "Creating clean wok in : $dest"
3025 for pkg in `ls -1 $WOK`
3026 do
3027 copy_cooking_stuff $WOK $pkg $dest
3028 done
3029 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
3030 report end-step
3031 echo "Packages cleaned : `ls -1 $dest | wc -l`"
3032 echo ""
3033 ;;
3034 clean-wok)
3035 # Clean all packages in the work directory.
3037 get_tazwok_config
3038 source_lib report
3039 report start
3040 report step "Cleaning wok"
3041 for PACKAGE in `ls -1 $WOK`
3042 do
3043 set_common_path
3044 source_receipt
3045 clean
3046 done
3047 echo "`ls -1 $WOK | wc -l` packages cleaned."
3048 ;;
3049 clean-src)
3050 # Remove tarball unrelated to wok receipts from src repo.
3051 check_root
3052 get_options_list="forced"
3053 get_tazwok_config
3054 cd $SOURCES_REPOSITORY
3055 echo -n "Checking $SOURCES_REPOSITORY..."
3056 for TARBALL in *; do
3057 [ "$TARBALL" = sources.list ] && continue
3058 grep -q $'\t'$TARBALL$ $SOURCES_REPOSITORY/sources.list || \
3059 echo $TARBALL >> $tmp/obsolete
3060 done
3061 status
3062 if ! [ -f $tmp/obsolete ]; then
3063 echo "No sources need to be removed."
3064 exit 1
3065 fi
3066 echo ""
3067 echo -e "\033[1mObsolete/unrelated-to-wok sources :\033[0m"
3068 horizontal_line
3069 cat $tmp/obsolete
3070 horizontal_line
3071 echo "$(wc -l $tmp/obsolete | cut -f1 -d' ') tarballs to remove."
3072 echo ""
3073 echo -n "Please confirm before removing (type uppercase YES): "
3074 read answer
3075 if [ "$answer" = YES ]; then
3076 echo -n "Removing old sources..."
3077 cat $tmp/obsolete | while read i; do
3078 rm -f $SOURCES_REPOSITORY/$i
3079 done
3080 status
3081 fi
3082 ;;
3083 gen-list)
3084 get_tazwok_config
3085 if [ "$2" ]; then
3086 if [ -d "$2" ]; then
3087 pkg_repository=$2
3088 else
3089 echo -e "\nUnable to find directory : $2\n" >&2
3090 exit 1
3091 fi
3092 fi
3094 source_lib report
3095 report start
3096 if [ "$pkg_repository" ]; then
3097 gen_packages_db
3098 else
3099 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
3100 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
3101 fi
3102 ;;
3103 check-list)
3104 # The directory to move into by default is the repository,
3105 # if $2 is not empty cd into $2.
3107 get_tazwok_config
3108 if [ "$2" ]; then
3109 if [ -d "$2" ]; then
3110 pkg_repository=$2
3111 else
3112 echo -e "\nUnable to find directory : $2\n" >&2
3113 exit 1
3114 fi
3115 fi
3117 source_lib report
3118 report start
3119 if [ "$pkg_repository" ]; then
3120 update_packages_db
3121 else
3122 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
3123 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
3124 fi
3125 ;;
3126 new-tree)
3127 # Just create a few directories and generate an empty receipt to prepare
3128 # the creation of a new package.
3130 get_tazwok_config
3131 check_for_package_on_cmdline
3132 clean_wok=$LOCAL_REPOSITORY/clean-wok
3133 if [ -d $clean_wok/$PACKAGE ]; then
3134 echo -e "\n$PACKAGE package tree already exists.\n" >&2
3135 exit 1
3136 fi
3137 echo "Creating : $clean_wok/$PACKAGE"
3138 mkdir $clean_wok/$PACKAGE
3139 cd $clean_wok/$PACKAGE
3140 echo -n "Preparing the receipt..."
3142 # Default receipt begin.
3144 echo "# SliTaz package receipt." > receipt
3145 echo "" >> receipt
3146 echo "PACKAGE=\"$PACKAGE\"" >> receipt
3147 # Finish the empty receipt.
3148 cat >> receipt << "EOF"
3149 VERSION=""
3150 CATEGORY=""
3151 SHORT_DESC=""
3152 MAINTAINER=""
3153 DEPENDS=""
3154 TARBALL="$PACKAGE-$VERSION.tar.gz"
3155 WEB_SITE=""
3156 WGET_URL=""
3158 # Rules to configure and make the package.
3159 compile_rules()
3161 cd $src
3162 ./configure $CONFIGURE_ARGS && make && make install
3165 # Rules to gen a SliTaz package suitable for Tazpkg.
3166 genpkg_rules()
3168 mkdir -p $fs/usr
3169 cp -a $_pkg/usr/bin $fs/usr
3172 EOF
3174 # Default receipt end.
3176 status
3177 # Interactive mode, asking and seding.
3178 if [ "$3" = "--interactive" ]; then
3179 echo "Entering interactive mode..."
3180 horizontal_line
3181 echo "Package : $PACKAGE"
3182 # Version.
3183 echo -n "Version : " ; read anser
3184 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
3185 # Category.
3186 echo -n "Category : " ; read anser
3187 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
3188 # Short description.
3189 echo -n "Short desc : " ; read anser
3190 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
3191 # Maintainer.
3192 echo -n "Maintainer : " ; read anser
3193 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
3194 # Web site.
3195 echo -n "Web site : " ; read anser
3196 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
3197 echo ""
3198 # Wget URL.
3199 echo "Wget URL to download source tarball."
3200 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
3201 echo -n "Wget url : " ; read anser
3202 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
3203 # Ask for a stuff dir.
3204 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
3205 if [ "$anser" = "y" ]; then
3206 echo -n "Creating the stuff directory..."
3207 mkdir stuff && status
3208 fi
3209 # Ask for a description file.
3210 echo -n "Are you going to write a description ? (y/N) : " ; read anser
3211 if [ "$anser" = "y" ]; then
3212 echo -n "Creating the description.txt file..."
3213 echo "" > description.txt && status
3214 fi
3215 horizontal_line
3216 echo ""
3217 fi
3218 ;;
3219 remove)
3220 # Remove a package from the wok.
3222 get_tazwok_config
3223 check_for_package_on_cmdline
3224 echo ""
3225 echo -n "Please confirm deletion (y/N) : "; read anser
3226 if [ "$anser" = "y" ]; then
3227 echo -n "Removing $PACKAGE..."
3228 rm -rf $WOK/$PACKAGE && status
3229 echo ""
3230 fi
3231 ;;
3232 update-wok)
3233 # Pull and update a Hg wok.
3234 get_options_list="local"
3235 get_tazwok_config
3236 source_lib report
3237 report start
3238 clean_wok=$LOCAL_REPOSITORY/clean-wok
3239 cd $clean_wok
3240 if ! [ "$local" ]; then
3241 if [ "$WOK_UPDATE_METHOD" = hg ]; then
3242 if ! [ -f "$INSTALLED/mercurial/receipt" ]; then
3244 # Auto-install only if we are in a cook chroot.
3245 if [ -x /usr/bin/clean-chroot ]; then
3246 tazpkg get-install mercurial
3247 else
3248 echo "" >&2
3249 echo "You need to install mercurial to get wok from hg (recommended). Otherwise, you can switch wok get method to \"tarball\" into $LOCAL_REPOSITORY/tazwok.conf (per-repository configuration, if it doesn't exist) or /etc/slitaz/tazwok.conf (global configuration)." | fold -s >&2
3250 echo "">&2
3251 exit 1
3252 fi
3253 fi
3255 report step "Getting wok changes using hg"
3256 if [ -d .hg ]; then
3257 hg pull -u || exit 1
3258 else
3259 hg clone $HG_WOK . || exit 1
3260 fi
3261 report end-step
3262 [ -x /usr/bin/clean-chroot ] && clean-chroot
3263 else
3264 report step "Getting wok changes using tarball"
3265 { mkdir .tmp && cd .tmp
3266 wget "$TARBALL_WOK" &&
3267 case $TARBALL_WOK in
3268 *bz2) tar xjf *.bz2 -C wok; rm *.bz2;;
3269 *lzma) unlzma -c *.lzma | tar xf - -C wok; rm *.lzma ;;
3270 *gz) tar xzf *.gz -C wok; rm*.gz ;;
3271 esac &&
3272 rm -r $(ls -d $clean_wok/*) &&
3273 cp -a wok/* $clean_wok &&
3274 cd .. &&
3275 rm -r .tmp
3276 } || { echo "That's not cool: it fails!" >&2
3277 report end-step
3278 exit 1; }
3279 report end-step
3280 fi
3281 fi
3282 report step "Appending changes to wok"
3284 # Handle removed files/dir.
3285 cd $WOK
3286 for dir in *; do
3287 [ -d "$clean_wok/$dir" ] || rm -rf $dir
3288 done
3289 for file in */receipt */description.txt; do
3290 [ -f "$clean_wok/$file" ] || rm -rf $file
3291 done
3292 for i in $(find */stuff 2>/dev/null); do
3293 [ -e "$clean_wok/$i" ] || rm -rf $i
3294 done
3296 cp -a $clean_wok/* $WOK
3297 report end-step
3298 ;;
3299 maintainers)
3300 get_tazwok_config
3301 echo ""
3302 echo "List of maintainers for: $WOK"
3303 horizontal_line
3304 touch /tmp/slitaz-maintainers
3305 for pkg in $WOK/*
3306 do
3307 . $pkg/receipt
3308 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
3309 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
3310 echo "$MAINTAINER"
3311 fi
3312 done
3313 horizontal_line
3314 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
3315 echo ""
3316 # Remove tmp files
3317 rm -f /tmp/slitaz-maintainers
3318 ;;
3319 maintained-by)
3320 # Search for packages maintained by a contributor.
3321 get_tazwok_config
3322 if [ ! -n "$2" ]; then
3323 echo "Specify a name or email of a maintainer." >&2
3324 exit 1
3325 fi
3326 echo "Maintainer packages"
3327 horizontal_line
3328 for pkg in $WOK/*
3329 do
3330 . $pkg/receipt
3331 if echo "$MAINTAINER" | fgrep -q "$2"; then
3332 echo "$PACKAGE"
3333 packages=$(($PACKAGEs+1))
3334 fi
3335 done
3336 horizontal_line
3337 echo "Packages maintained by $2: $PACKAGEs"
3338 echo ""
3339 ;;
3340 tags)
3341 get_tazwok_config
3342 echo -e "\n\033[1mTags list :\033[0m"
3343 horizontal_line
3344 cd $WOK
3345 for i in */receipt; do
3346 unset TAGS
3347 source $i
3348 for t in $TAGS; do
3349 grep -q ^$t$ $tmp/tags && continue
3350 echo $t | tee -a $tmp/tags
3351 done
3352 done
3353 horizontal_line
3354 echo "$(wc -l $tmp/tags | cut -f1 -d ' ') tags listed."
3355 ;;
3356 check-src)
3357 # Verify if upstream package is still available.
3359 get_tazwok_config
3360 check_for_package_on_cmdline
3361 check_for_receipt
3362 source_receipt
3363 check_src()
3365 for url in $@; do
3366 busybox wget -s $url 2>/dev/null && break
3367 done
3369 if [ "$WGET_URL" ];then
3370 echo -n "$PACKAGE : "
3371 check_src $WGET_URL
3372 status
3373 else
3374 echo "No tarball to check for $PACKAGE"
3375 fi
3376 ;;
3377 gen-src)
3378 get_tazwok_config
3379 if [ "$2" ]; then
3380 if [ -d "$2" ]; then
3381 src_repository=$2
3382 else
3383 echo -e "\nUnable to find directory : $2\n" >&2
3384 exit 1
3385 fi
3386 fi
3387 echo -n "Rebuilding sources.list file"
3388 [ $src_repository ] || src_repository="$SOURCES_REPOSITORY"
3389 gen_sources_list $src_repository
3390 status
3391 ;;
3392 get-src)
3393 check_root
3394 get_options_list="target nounpack"
3395 get_tazwok_config
3396 check_for_package_on_cmdline
3397 check_for_receipt
3398 source_receipt
3399 if [ "$WGET_URL" ];then
3400 source_lib report
3401 report start
3402 check_for_tarball
3403 else
3404 echo "No tarball to download for $PACKAGE"
3405 fi
3406 ;;
3407 check-commit)
3408 check_root
3409 get_options_list="missing forced"
3410 get_tazwok_config
3411 source_lib report
3412 report start
3413 if [ "$forced" ]; then
3414 rm -f $WOK/*/md5
3415 unset forced
3416 fi
3417 if [ "$missing" ]; then
3418 pkg=$(ls -1 $WOK)
3419 else
3420 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3421 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3422 } | sort -u)"
3423 fi
3424 gen_cook_list
3425 ;;
3426 cook-commit)
3427 check_root
3428 get_options_list="missing forced"
3429 get_tazwok_config
3430 source_lib report
3431 report start
3432 if [ "$forced" ]; then
3433 rm -f $WOK/*/md5
3434 unset forced
3435 fi
3436 if [ "$missing" ]; then
3437 pkg=$(ls -1 $WOK)
3438 else
3439 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3440 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3441 } | sort -u)"
3442 fi
3443 gen_cook_list
3444 cook_list
3445 ;;
3446 cook-all)
3447 check_root
3448 get_options_list="forced missing"
3449 get_tazwok_config
3450 source_lib report
3451 report start
3452 if [ "$missing" ]; then
3453 pkg=$(ls -1 $WOK)
3454 else
3455 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3456 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3457 } | sort -u)"
3458 fi
3459 gen_cook_list
3460 cook_list
3461 ;;
3462 gen-wok-db)
3463 check_root
3464 get_tazwok_config
3465 source_lib report
3466 report start
3467 gen_wok_db
3468 ;;
3469 report)
3470 get_tazwok_config
3471 cd $PACKAGES_REPOSITORY
3472 if [ "$2" ]; then
3473 case $2 in
3474 commit|cooklist|incoming|broken|blocked)
3475 show="$2"
3476 ;;
3477 *)
3478 echo "usage : tazwok report [commit|cooklist|incoming|broken|blocked]" >&2
3479 exit 1
3480 ;;
3481 esac
3482 else
3483 show="commit cooklist incoming broken blocked"
3484 fi
3485 for i in $show; do
3486 if [ -s $i ]; then
3487 echo ""
3488 echo -e "\033[1m$i\033[0m"
3489 horizontal_line
3490 cat $i
3491 horizontal_line
3492 echo ""
3493 fi
3494 done
3495 ;;
3496 check-incoming)
3497 check_root
3498 get_options_list="forced"
3499 get_tazwok_config
3500 source_lib report
3501 report start
3502 [ -f $LOCAL_RESOSITORY/incoming ] && rm [ -f $LOCAL_REPOSITORY/incoming ]
3503 report step "Checking $INCOMING_REPOSITORY"
3504 report open-bloc
3505 [ -f $LOCAL_REPOSITORY/log/incoming.html ] && rm $LOCAL_REPOSITORY/log/incoming.html
3506 report sublog $LOCAL_REPOSITORY/log/incoming.html
3507 echo "incoming" > $LOCAL_REPOSITORY/log/package
3508 check_for_incoming
3509 report end-sublog
3510 report close-bloc
3511 ;;
3512 configure-chroot)
3513 check_root
3514 get_tazwok_config
3515 if [ -f /usr/bin/tazchroot ]; then
3516 cd $LOCAL_REPOSITORY
3517 configure_tazchroot
3518 else
3519 echo "The package tazchroot needs to be installed" >&2
3520 exit 1
3521 fi
3522 ;;
3523 chroot)
3524 check_root
3525 get_tazwok_config
3526 # Merge this and the other chroot function ?.
3527 if [ -f /usr/bin/tazchroot ]; then
3528 cd $LOCAL_REPOSITORY
3529 [ ! -f tazchroot.conf ] && configure_tazchroot
3530 tazchroot
3531 else
3532 echo "The package tazchroot needs to be installed" >&2
3533 exit 1
3534 fi
3535 ;;
3536 cook-toolchain)
3537 check_root
3538 get_tazwok_config
3539 echo -n "" > $PACKAGES_REPOSITORY/broken
3540 if [ -f /usr/bin/tazchroot ]; then
3541 cd $LOCAL_REPOSITORY
3542 [ -f tazchroot.conf ] || configure_tazchroot
3544 # Plan to recook all packages.
3545 if tazchroot cook-toolchain; then
3546 source_lib report
3547 report start
3548 pkg="$(grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt \
3549 $INCOMING_REPOSITORY/packages.txt | sort -u)"
3550 forced=yes
3551 gen_cook_list
3552 fi
3554 # Remove chroot where toolchain has been cooked.
3555 source $LOCAL_REPOSITORY/tazchroot.conf
3556 rm -r $LOCAL_REPOSITORY/chroot
3558 else
3559 echo -e "\nThe package tazchroot needs to be installed.\n" >&2
3560 exit 1
3561 fi
3562 ;;
3563 webserver)
3564 check_root
3565 get_tazwok_config
3566 if [ "$ARG" = on ]; then
3567 if [ "$WEBSERVER" ] && [ -f "$WEBSERVER/repositories.list" ] && \
3568 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3569 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3570 exit 1
3571 fi
3572 if ! [ -f $LOCAL_REPOSITORY/tazchroot.conf ]; then
3573 tazwok configure-chroot ${undigest:+--undigest=$undigest} --SLITAZ_VERSION=$SLITAZ_VERSION --SLITAZ_DIR=$SLITAZ_DIR
3574 fi
3575 for pkg in php lighttpd; do
3576 [ -d $INSTALLED/$pkg ] || missing="$missing $pkg"
3577 done
3578 if [ "$missing" ]; then
3579 echo "You need to install these packages to start webserver: $missing." >&2
3580 exit 1
3581 fi
3582 if [ ! -f "$LOCAL_REPOSITORY/tazwok.conf" ]; then
3583 echo "Copying /etc/slitaz/tazwok.conf to $LOCAL_REPOSITORY/tazwok.conf: webserver is configured repository-by-repository."
3584 cp /etc/slitaz/tazwok.conf $LOCAL_REPOSITORY
3585 fi
3586 if ! [ "$WEBSERVER" ]; then
3587 echo -n "Where to store php pages (default: /var/www/vhosts/bb)? "
3588 read WEBSERVER
3589 [ "$WEBSERVER" ] || WEBSERVER="/var/www/vhosts/bb"
3590 fi
3591 if [ -f "$WEBSERVER/repositories.list" ] && \
3592 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3593 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3594 exit 1
3595 fi
3596 mkdir -p $WEBSERVER
3597 echo "${undigest:-$SLITAZ_VERSION}" >> $WEBSERVER/repositories.list
3598 for file in index.php log.php download.php; do
3599 [ -f "$WEBSERVER/$file" ] || ln -s /usr/share/slitaz/web-bb/$file $WEBSERVER
3600 done
3601 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3602 ln -s $dir $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3603 done
3604 source $LOCAL_REPOSITORY/tazchroot.conf
3605 echo "<?php
3607 // Web interface configuration
3609 \$version=\"${undigest:-$SLITAZ_VERSION}\";
3610 \$chroot=\"$chroot_dir\";
3611 \$lockfile=\"\$chroot/proc/1/status\";
3612 \$db_dir=\"$PACKAGES_REPOSITORY\";
3613 \$log_dir=\"$LOCAL_REPOSITORY/log\";
3614 \$packages=\"$PACKAGES_REPOSITORY\";
3615 \$incoming=\"$INCOMING_REPOSITORY\";
3616 \$wok=\"$WOK\";
3618 ?>" > $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3619 [ -L "$WEBSERVER/web" ] || ln -s /usr/share/slitaz/web $WEBSERVER
3620 echo "WEBSERVER=\"$WEBSERVER\"" >> $LOCAL_REPOSITORY/tazwok.conf
3621 if [ -L "$WEBSERVER/conf.php" ]; then
3622 echo "Do you want to make ${undigest:-$SLITAZ_VERSION} the default page (y/N) ? "
3623 read answer
3624 if [ "$answer" = y ]; then
3625 rm $WEBSERVER/conf.php
3626 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3627 fi
3628 else
3629 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3630 fi
3631 elif [ "$ARG" = off ]; then
3632 if ! [ "$WEBSERVER" ]; then
3633 echo "No webserver running for ${undigest:-$SLITAZ_VERSION}" >&2
3634 exit 1
3635 fi
3636 sed '/^WEBSERVER/d' -i $LOCAL_REPOSITORY/tazwok.conf
3637 sed "/^${undigest:-$SLITAZ_VERSION}$/d" -i $WEBSERVER/repositories.list
3638 rm $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3639 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3640 rm $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3641 done
3642 if ! [ -s "$WEBSERVER/repositories.list" ]; then
3643 echo "$WEBSERVER/repositories.list is empty; tazwok doesn't remove the server automatically in case you have important stuff in it. If that's not the case, you can remove it using: rm -r $WEBSERVER"
3644 rm $WEBSERVER/conf.php
3645 elif [ "$(readlink $WEBSERVER/conf.php)" = "$WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php" ]; then
3646 echo "${undigest:-$SLITAZ_VERSION} was the default version to use; switched to : $(sed 1!d $WEBSERVER/repositories.list)"
3647 rm $WEBSERVER/conf.php
3648 ln -s $WEBSERVER/conf-$(sed 1!d $WEBSERVER/repositories.list).php $WEBSERVER/conf.php
3649 fi
3650 else
3651 echo "Usage: tazwok webserver on/off" >&2
3652 exit 1
3653 fi
3654 ;;
3655 block)
3656 # Add a pkg name to the list of blocked packages.
3657 get_tazwok_config
3658 check_root
3659 check_for_package_on_cmdline
3660 if ! [ -f $WOK/$PACKAGE/receipt ]; then
3661 echo "Can't find $PACKAGE in wok." >&2
3662 echo ""
3663 exit 1
3664 fi
3665 echo ""
3666 if grep -qs "^$PACKAGE$" $blocked; then
3667 echo "$PACKAGE is already in the blocked packages list." >&2
3668 echo ""
3669 exit 1
3670 else
3671 echo -n "Adding $PACKAGE to : $blocked... "
3672 echo "$PACKAGE" >> $blocked
3673 status
3674 if grep -q "^$PACKAGE$" $cooklist; then
3675 echo -n "Removing $PACKAGE from : $cooklist... "
3676 sed -i /"^$PACKAGE$"/d $cooklist
3677 status
3678 fi
3679 fi
3680 echo "" ;;
3681 unblock)
3682 # Remove a pkg name from the list of blocked packages.
3683 get_tazwok_config
3684 check_root
3685 check_for_package_on_cmdline
3686 if ! [ -f $WOK/$PACKAGE/receipt ]; then
3687 echo "Can't find $PACKAGE in wok." >&2
3688 echo ""
3689 exit 1
3690 fi
3691 echo ""
3692 if grep -qs "^$PACKAGE$" $blocked; then
3693 echo -n "Removing $PACKAGE from : $blocked... "
3694 sed -i /"^$PACKAGE$"/d $blocked
3695 sed -i '/^$/d' $blocked
3696 status
3697 else
3698 echo "$PACKAGE is not in the blocked packages list." >&2
3699 echo ""
3700 exit 1
3701 fi
3702 echo "" ;;
3703 usage|*)
3704 # Print usage also for all unknown commands.
3706 usage
3707 ;;
3708 esac
3710 # If a cook command has been used, refresh ID of the repository to avoid
3711 # useless upgrade at next cook command.
3712 case $COMMAND in
3713 cook*)
3714 for repo in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY \
3715 $( [ "$undigest" -a ! "$ref_USE_ONLINE_PKG" ] && echo $ref_PACKAGES_REPOSITORY ); do
3716 [ -f $repo/ID ] || continue
3717 MIRROR_path=$(grep -l "^$repo$" $LOCALSTATE/mirror $LOCALSTATE/undigest/*/mirror)
3718 LOCALSTATE_path=${MIRROR_path%/mirror}
3719 cp -a $repo/ID $LOCALSTATE_path
3720 done
3721 ;;
3722 esac
3724 report stop 2>/dev/null
3725 exit 0