tazwok view tazwok @ rev 554

Compatibility fix for $install variable in compile_rules
author Antoine Bodin <gokhlayeh@slitaz.org>
date Sun Mar 11 19:13:46 2012 +0100 (2012-03-11)
parents adadf23b46bc
children
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 # Cookutils compatibility
731 install="$DESTDIR"
732 export CFLAGS=$(echo "$CFLAGS" | tr -s ' ') \
733 CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ') \
734 MAKEFLAGS DESTDIR CONFIG_SITE default_prefix \
735 default_datarootdir default_datadir default_localedir \
736 default_infodir default_mandir default_build default_host \
737 BUILD_SYSTEM HOST_SYSTEM
738 local LC_ALL=POSIX LANG=POSIX
739 compile_rules
740 return_code=$?
742 if [ -f /tmp/config.site ]; then
743 rm /tmp/config.site
744 else
745 tazwok_warning "config.site hasn't been used during \
746 the configuration process."
747 fi
749 # Return the proper status to step.
750 (exit $return_code)
751 report end-step
752 fi
753 }
755 # Check for loop in deps tree. /!\ can be removed.
756 check_for_deps_loop()
757 {
758 local list
759 local pkg
760 local deps
761 pkg=$1
762 shift
763 [ -n "$1" ] || return
764 list=""
766 # Filter out already processed deps.
767 for i in $@; do
768 case " $ALL_DEPS" in
769 *\ $i\ *);;
770 *) list="$list $i";;
771 esac
772 done
773 ALL_DEPS="$ALL_DEPS$list "
774 for i in $list; do
775 [ -f $i/receipt ] || continue
776 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
777 case " $deps " in
778 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
779 *) check_for_deps_loop $pkg $deps;;
780 esac
781 done
782 }
784 # Function used by download().
785 revert_vcs_failure()
786 {
787 cd $SOURCES_REPOSITORY
788 rm -r $tmp_src
789 }
791 download()
792 {
793 if [ "$COMMAND" = get-src ]; then
794 if [ "${DEPENDS/tar}" != "$DEPENDS" ] || [ "${BUILD_DEPENDS/tar}" != "$BUILD_DEPENDS" ]; then
795 [ -f $INSTALLED/tar/receipt ] || tazpkg get-install tar --forced
796 fi
797 fi
798 for file in $@; do
799 echo "Downloading from ${file#*|}..."
800 case "$file" in
801 git\|*)
802 file=${file#git|}
803 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/git/receipt ] && tazpkg get-install git --forced
804 if [ -f $INSTALLED/git/receipt ]; then
805 mkdir $tmp_src
806 cd $tmp_src
807 if [ "$BRANCH" ]; then
808 git clone $file ${src##*/} && cd ${src##*/} && \
809 git checkout $BRANCH && rm -rf .git* && break
810 else
811 git clone $file ${src##*/} && rm -rf ${src##*/}/.git* && break
812 fi
813 revert_vcs_failure
814 else
815 tazwok_warning "Needs git to download the source tarball from $file, please add it as a build-depend."
816 continue
817 fi
818 ;;
819 bazaar\|*)
820 file=${file#bazaar|}
821 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/bazaar/receipt ] && tazpkg get-install bazaar --forced
822 if [ -f $INSTALLED/bazaar/receipt ]; then
823 mkdir $tmp_src
824 cd $tmp_src
825 if [ "$BRANCH" ]; then
826 bzr co $file -r $BRANCH ${src##*/} && rm -rf ${src##*/}/.bzr* && break
827 else
828 bzr co $file ${src##*/} && rm -rf ${src##*/}/.bzr* && break
829 fi
830 revert_vcs_failure
831 else
832 tazwok_warning "Needs bazaar to download the source tarball from $file, please add it as a build-depend."
833 continue
834 fi
835 ;;
836 svn*|subversion*)
837 if $(echo "$WGET_URL" | fgrep -q svn); then
838 file=${WGET_URL#svn|}
839 else
840 file=${WGET_URL#subversion|}
841 fi
842 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/subversion/receipt ] && tazpkg get-install subversion --forced
843 if [ -f $INSTALLED/subversion/receipt ]; then
844 mkdir $tmp_src
845 cd $tmp_src
846 if [ "$BRANCH" ]; then
847 echo t | svn co $file -r $BRANCH ${src##*/} && rm -rf ${src##*/}/.svn* && break
848 else
849 echo t | svn co $file ${src##*/} && rm -rf ${src##*/}/.svn* && break
850 fi
851 revert_vcs_failure
852 else
853 tazwok_warning "Needs subversion to download the source tarball from $file, please add it as a build-depend."
854 continue
855 fi
856 ;;
857 hg*|mercurial*)
858 if $(echo "$WGET_URL" | fgrep -q hg); then
859 file=${WGET_URL#hg|}
860 else
861 file=${WGET_URL#mercurial|}
862 fi
863 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/mercurial/receipt ] && tazpkg get-install mercurial --forced
864 if [ -f $INSTALLED/mercurial/receipt ]; then
865 mkdir $tmp_src
866 cd $tmp_src
867 if [ "$BRANCH" ]; then
868 hg clone $file --rev $BRANCH ${src##*/} && rm -rf ${src##*/}/.hg* && break
869 else
870 hg clone $file ${src##*/} && rm -rf ${src##*/}/.hg* && break
871 fi
872 revert_vcs_failure
873 else
874 tazwok_warning "Needs mercurial to download the source tarball from $file, please add it as a build-depend."
875 continue
876 fi
877 ;;
878 cvs*)
879 file=${WGET_URL#cvs|}
880 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/cvs/receipt ] && tazpkg get-install cvs --forced
881 if [ -f $INSTALLED/cvs/receipt ]; then
882 mkdir $tmp_src
883 cd $tmp_src
884 mod=${src##*/}
885 [ "$CVS_MODULE" ] && mod=$CVS_MODULE
886 cvs -z3 -d:$file co $mod && rm -rf $mod/CVS && break
887 else
888 tazwok_warning "Needs cvs to download the source tarball from $file, please add it as a build-depend."
889 continue
890 fi
891 ;;
892 https*)
893 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/wget/receipt ] && tazpkg get-install wget --forced
894 if [ -d $INSTALLED/wget ]; then
895 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
896 wget -q --no-check-certificate -O $TARBALL $file && break
897 else
898 wget -q --no-check-certificate $file && break
899 fi
900 else
901 tazwok_warning "Needs wget to download the source tarball from $file, please add it as a build-depend."
902 continue
903 fi
904 ;;
905 http*|ftp*)
906 # Handle crappy URL.
907 if [ "$COMMAND" = get-src ]; then
908 if [ "${DEPENDS/wget}" != "$DEPENDS" ] || [ "${BUILD_DEPENDS/wget}" != "$BUILD_DEPENDS" ]; then
909 [ -f $INSALLED/wget/receipt ] || tazpkg get-install wget --forced
910 fi
911 fi
912 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
913 wget -q -O $TARBALL $file && break
914 else
915 wget -q $file && break
916 fi
917 ;;
918 esac
919 done
920 }
922 # Regenerate every package that wants a PACKAGE compiled.
923 refresh_packages_from_compile()
924 {
925 # make tazwok genpkg happy.
926 mkdir $WOK/$PACKAGE/taz
928 # Cook rwanted in default or specied order.
929 genlist=" $(look_for_rwanted | tr '\n' ' ') "
930 for i in $(look_for_cookopt genpkg | tac); do
931 [ "${genlist/ $i }" = "$genlist" ] && continue
932 genlist=" $i${genlist/ $i / }"
933 done
934 if [ "$genlist" ]; then
935 local PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
936 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
937 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
938 src _pkg DESTDIR CONFIG_SITE RECEIPT LOG stuff wanted_stuff
939 for PACKAGE in $genlist; do
940 set_common_path
941 gen_package
942 done
943 fi
944 }
946 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
947 # so some packages need to copy these files with the receipt and genpkg_rules.
948 # This function is executed by gen_package when 'tazwok genpkg'.
949 copy_generic_files()
950 {
951 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
952 # using generic variables and $LOCALE from Tazwok config file.
953 if [ "$LOCALE" ]; then
954 if [ -d "$_pkg/usr/share/locale" ]; then
955 for i in $LOCALE
956 do
957 if [ -d "$_pkg/usr/share/locale/$i" ]; then
958 mkdir -p $fs/usr/share/locale
959 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
960 fi
961 done
962 fi
963 fi
965 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
966 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
967 # in pkg receipt.
968 if [ "$GENERIC_PIXMAPS" != "no" ]; then
969 if [ -d "$_pkg/usr/share/pixmaps" ]; then
970 mkdir -p $fs/usr/share/pixmaps
971 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
972 $fs/usr/share/pixmaps 2>/dev/null
973 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
974 $fs/usr/share/pixmaps 2>/dev/null
975 fi
977 # Custom or homemade PNG pixmap can be in stuff.
978 if [ -f "stuff/$PACKAGE.png" ]; then
979 mkdir -p $fs/usr/share/pixmaps
980 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
981 fi
982 fi
984 # Desktop entry (.desktop).
985 if [ -d "$_pkg/usr/share/applications" ]; then
986 cp -a $_pkg/usr/share/applications $fs/usr/share
987 fi
989 # Homemade desktop file(s) can be in stuff.
990 if [ -d "stuff/applications" ]; then
991 mkdir -p $fs/usr/share
992 cp -a stuff/applications $fs/usr/share
993 fi
994 if [ -f "stuff/$PACKAGE.desktop" ]; then
995 mkdir -p $fs/usr/share/applications
996 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
997 fi
998 }
1000 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
1001 strip_package()
1003 report step "Executing strip on all files"
1005 # Binaries.
1006 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
1007 do
1008 if [ -d "$dir" ]; then
1009 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
1010 fi
1011 done
1013 # Libraries.
1014 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
1015 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
1016 report end-step
1019 # Remove .pyc and .pyo files from packages.
1020 py_compiled_files_remove()
1022 report step "Removing all .pyc and .pyo files from package"
1023 find $fs -type f -name "*.pyc" -delete 2>/dev/null
1024 find $fs -type f -name "*.pyo" -delete 2>/dev/null
1025 report end-step
1028 # Removing all perllocal.pod and .packlist files from package
1029 perl_compiled_files_remove()
1031 report step "Removing all perllocal.pod and .packlist files from package"
1032 find $fs -type f -name "perllocal.pod" -delete 2>/dev/null
1033 find $fs -type f -name ".packlist" -delete 2>/dev/null
1034 report end-step
1037 # Check FSH in a slitaz package (Path: /:/usr)
1038 check_fsh()
1040 cd $WOK/$PACKAGE/taz/*/fs
1041 if [ -z "$(find * ! -type d)" ] && [ "$CATEGORY" != meta ]; then
1042 echo "$PACKAGE fs is empty." >&2
1043 cd $WOK/$PACKAGE && rm -rf taz
1044 return 1
1045 fi
1046 [ -n "$FSH" ] || FSH="bin boot dev etc home init lib media mnt proc \
1047 root sbin share sys tmp usr var vz usr/bin usr/games usr/include usr/lib \
1048 usr/local usr/sbin usr/share usr/src"
1049 error=0
1050 for i in `ls -d * usr/* 2>/dev/null`
1051 do
1052 if ! echo $FSH | fgrep -q $i; then
1053 echo "Wrong path: /$i" >&2
1054 error=1
1055 fi
1056 done
1057 if [ "$error" = "1" ]; then
1058 cat << _EOT_
1060 Package will install files in a non standard directory and won't be generated.
1061 You may have a wrong copy path in genpkg_rules or need to add some options to
1062 configure in compile_rules. Some valid options for SliTaz (Linux FSH):
1064 --prefix=/usr
1065 --sysconfdir=/etc
1066 --libexecdir=/usr/lib/(pkgname)
1067 --localstatedir=/var
1068 --mandir=/usr/share/man
1069 --infodir=/usr/share/info
1071 For more information please read SliTaz docs and run: ./configure --help
1072 ================================================================================
1073 $PACKAGE package generation aborted.
1075 _EOT_
1077 # Dont generate a corrupted package.
1078 cd $WOK/$PACKAGE && rm -rf taz
1079 return 1
1080 fi
1081 return 0
1084 get_cook_files()
1086 if [ -d stuff ]; then
1087 cook_files=`find receipt description.txt stuff 2>/dev/null`
1088 elif [ -f description.txt ]; then
1089 cook_files="receipt
1090 description.txt"
1091 else
1092 cook_files="receipt"
1093 fi
1096 gen_cookmd5()
1098 # md5sum of cooking stuff make tazwok able to check for changes
1099 # without hg.
1100 cd $WOK/$PACKAGE
1101 local IFS="
1104 if [ ! "$cook_files" ]; then
1105 get_cook_files
1106 fi
1108 md5sum $cook_files > md5
1110 unset cook_files
1113 set_pkg_broken()
1115 grep -q ^$PACKAGE$ $broken || echo $PACKAGE >> $broken
1117 # Remove pkg from cooklist to avoid re-cook it if no changes happen
1118 # in the cook stuff.
1119 sed "/^$PACKAGE$/d" -i $cooklist $commit
1121 gen_cookmd5
1123 # Return 1 to make report know that its mother-function failed.
1124 return 1
1127 update_lib_db()
1129 # Update lib_db
1130 libs=$(for file in $(find * -type f); do
1131 [ "$(dd if=$file bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ] || continue
1132 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $PWD/$file
1133 done | { cut -f 1 -d ' ' | tr -d '\t' | sort -u | \
1134 sed -e 's/^linux-gate.so.*$/SLIB/' -e 's~^/lib/ld-.*$~SLIB~' \
1135 -e '/^statically$/d' | tr '\n' ' '; })
1138 # Create a package tree and build the gziped cpio archive
1139 # to make a SliTaz (.tazpkg) package.
1140 gen_package()
1142 check_root
1143 check_for_package_on_cmdline
1144 check_for_receipt
1145 source_receipt
1147 # May compute VERSION
1148 if grep -q ^get_version $RECEIPT; then
1149 get_version
1150 fi
1151 check_for_wanted
1152 cd $WOK/$PACKAGE
1154 # Remove old Tazwok package files.
1155 [ -d "taz" ] && rm -rf taz
1157 # Create the package tree and set useful variables.
1158 fs=$WOK/$PACKAGE/taz/$PACKAGE-$VERSION/fs
1159 mkdir -p $fs
1161 # Set $src for standard package and $_pkg variables.
1162 set_src_path
1163 set_pkg_path
1165 # Execute genpkg_rules, check package and copy generic files to build
1166 # the package.
1167 report step "Building $PACKAGE with the receipt"
1168 report open-bloc
1169 if look_for_cookopt !fs; then
1171 elif grep -q ^genpkg_rules $RECEIPT; then
1173 # Log process.
1174 echo "executing genpkg_rules" >> $LOG
1175 report step "Executing genpkg_rules"
1176 ( set -e; genpkg_rules ) || { set_pkg_broken; report close-bloc; return 1; }
1177 check_fsh || { set_pkg_broken; report close-bloc; return 1; }
1178 cd $WOK/$PACKAGE
1179 report end-step
1181 # Skip generic files for packages with a WANTED variable
1182 # (dev and split pkgs).
1183 if [ ! "$WANTED" ]; then
1184 copy_generic_files
1185 fi
1186 look_for_cookopt !strip || strip_package
1187 perl_compiled_files_remove
1188 else
1189 echo "No package rules to gen $PACKAGE..." >&2
1190 set_pkg_broken
1191 report close-bloc
1192 return 1
1193 fi
1195 # Copy the receipt and description (if exists) into the binary package tree.
1196 cd $WOK/$PACKAGE
1197 report step "Copying the receipt"
1198 cp receipt taz/$PACKAGE-$VERSION
1199 report end-step
1200 if grep -q ^get_version $RECEIPT; then
1201 report step "Updating version in receipt"
1202 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
1203 taz/$PACKAGE-$VERSION/receipt
1204 report end-step
1205 fi
1206 if [ -f "description.txt" ]; then
1207 report step "Copying the description file"
1208 cp description.txt taz/$PACKAGE-$VERSION
1209 report end-step
1210 fi
1212 # Generate md5 of cooking stuff to look for commit later.
1213 gen_cookmd5
1214 echo -e "\n# md5sum of cooking stuff :" >> taz/$PACKAGE-$VERSION/receipt
1215 cat md5 | sed 's/^/# /' >> taz/$PACKAGE-$VERSION/receipt
1217 # Create the files.list by redirecting find output.
1218 report step "Creating the list of files"
1219 cd taz/$PACKAGE-$VERSION
1220 LAST_FILE=""
1221 { find fs -print; echo; } | while read file; do
1222 if [ "$LAST_FILE" ]; then
1223 case "$file" in
1224 $LAST_FILE/*)
1225 case "$(ls -ld "$LAST_FILE")" in
1226 drwxr-xr-x\ *\ root\ *\ root\ *);;
1227 *) echo ${LAST_FILE#fs};;
1228 esac;;
1229 *) echo ${LAST_FILE#fs};;
1230 esac
1231 fi
1232 LAST_FILE="$file"
1233 done > files.list
1235 py_compiled_files_remove
1237 # Next, check if something has changed in lib files.
1238 # Plan to recook each packages which depends on libs
1239 # which doesn't exists anymore.
1240 for rep in $INCOMING_REPOSITORY $PACKAGES_REPOSITORY; do
1241 prev_VERSION=$(get_pkg_version $rep)
1242 [ "$prev_VERSION" ] && pkg_file=$rep/$PACKAGE-$prev_VERSION.tazpkg && break
1243 done
1244 if [ "$pkg_file" ]; then
1245 report step "Looking if reverse depends needs to be refreshed"
1246 get_pkg_files $pkg_file
1247 cd $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
1249 pkg_to_check=$(diff files.list $pkg_files_dir/files.list | \
1250 grep '^-/.*\.so' | while read lib; do
1251 fgrep " ${lib##*/} " $libs_db | cut -f1
1252 done | sort -u)
1254 if [ "$pkg_to_check" ]; then
1255 for rdep in $(scan $PACKAGE --look_for=rdep | use_wanted); do
1256 echo "$pkg_to_check" | grep -q ^$PACKAGE$ || continue
1257 [ "$rdep" = "${WANTED:-$PACKAGE}" ] && continue
1258 grep -q ^$rdep$ $blocked $cooklist && continue
1259 echo "Plan to recook $rdep"
1260 echo $rdep >> $cooklist
1261 regen_cooklist=yes
1262 done
1263 fi
1265 rm -r $pkg_files_dir
1266 unset pkg_file pkg_file_dir pkg_to_check
1267 report end-step
1268 fi
1270 update_lib_db
1272 sed "/$PACKAGE\t/d" -i $lib_db
1273 if [ "$libs" ]; then
1274 libs=$(echo " $libs" | sed -r 's/( SLIB)+ / /g')
1275 echo -e "$PACKAGE\t$libs" >> $lib_db
1276 sort -o $lib_db $lib_db
1277 fi
1278 unset libs
1280 if [ ! "$EXTRAVERSION" ]; then
1281 case "$PACKAGE" in
1282 linux*);;
1283 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
1284 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
1285 esac
1286 fi
1287 rm -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
1289 report step "Creating md5sum of files"
1290 while read file; do
1291 [ -L "fs$file" ] && continue
1292 [ -f "fs$file" ] || continue
1293 md5sum "fs$file" | sed 's/ fs/ /'
1294 done < files.list > md5sum
1295 report end-step
1296 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
1297 2> /dev/null | awk '{ sz=$1 } END { print sz }')
1299 # Build cpio archives. Find, cpio and gzip the fs, finish by
1300 # removing the fs tree.
1301 # Don't log this because compression always outputs error messages.
1302 find fs -print | cpio -o -H newc | case "$PACKAGE-$COMPRESSION" in
1303 tazpkg-lzma) gzip > fs.cpio.gz;;
1304 *-lzma) lzma e fs.cpio.lzma -si;;
1305 *) gzip > fs.cpio.gz;;
1306 esac && rm -rf fs
1307 PACKED_SIZE=$(du -chs fs.cpio.* receipt files.list md5sum \
1308 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
1309 report step "Updating receipt sizes"
1310 sed -i '/^PACKED_SIZE/d' receipt
1311 sed -i '/^UNPACKED_SIZE/d' receipt
1312 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
1313 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
1314 report end-step
1315 if [ "$EXTRAVERSION" ]; then
1316 report step "Updating receipt EXTRAVERSION"
1317 sed -i s/^EXTRAVERSION.*$// receipt
1318 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
1319 fi
1320 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1321 remove_previous_package $INCOMING_REPOSITORY
1322 report step "Creating full cpio archive"
1323 find . -print | cpio -o -H newc > $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
1325 # Restore package tree in case we want to browse it.
1326 report step "Restoring original package tree"
1327 { zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma; } | cpio --quiet -id
1328 rm fs.cpio.* && cd ..
1330 # Save receipts if save_wok is enabled.
1331 [ "$save_wok" ] && copy_cooking_stuff $WOK $PACKAGE $INCOMING_REPOSITORY/wok
1333 # Recook of reverse-depends if package was broken.
1334 if grep -q "^$PACKAGE$" $broken; then
1335 report step "Planning a re-try cook of reverse depends"
1336 sed "/^$PACKAGE$/d" -i $broken
1337 for rdep in $(look_for_rdep); do
1338 grep -q "^$rdep$" $broken || continue
1339 grep -q "^$rdep$" $cooklist && continue
1340 echo "Adding $rdep to the cooklist"
1341 echo $rdep >> $cooklist
1342 regen_cooklist=t
1343 done
1344 report end-step
1345 fi
1346 sed "/^$PACKAGE$/d" -i $commit $cooklist
1348 # Log process.
1349 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
1350 report close-bloc
1351 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
1352 echo "Size : `du -sh $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
1353 echo ""
1356 ########################################################################
1357 # This section contains functions used by several other functions
1358 # below.
1359 ########################
1361 # Look for receipt/files.list in wok. If they can't be found, get them
1362 # from package. Accept one argument : absolute path to package.
1363 get_pkg_files()
1365 pkg_files_dir=$tmp/$(basename ${1%.tazpkg})
1366 mkdir -p $pkg_files_dir && \
1367 cd $pkg_files_dir && \
1368 cpio --quiet -idm receipt < $1 && \
1369 cpio --quiet -idm files.list < $1
1372 ########################################################################
1373 # This section contains functions to generate packages databases.
1374 ########################
1377 gen_packages_db()
1379 # pkg_repository can be $PACKAGES_REPOSITORY or $INCOMING_REPOSITORY.
1380 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1381 cd $pkg_repository
1382 report step "Generating packages lists: $pkg_repository"
1383 report open-bloc
1384 report step "Removing old files"
1385 for file in files.list.lzma packages.list packages.txt \
1386 packages.desc packages.equiv packages.md5; do
1387 rm -rf $file
1388 done
1389 touch files.list
1391 packages_db_start
1392 unset RECEIPT
1393 report step "Reading data from all packages"
1394 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1395 get_packages_info
1396 done
1397 report end-step
1398 packages_db_end
1399 report close-bloc
1402 update_packages_db()
1404 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1405 cd $pkg_repository
1406 for file in packages.list packages.equiv packages.md5 packages.desc \
1407 packages.txt; do
1408 if [ ! -f "$file" ]; then
1409 gen_packages_db
1410 return
1411 fi
1412 done
1413 if [ -f files.list.lzma ]; then
1414 lzma d files.list.lzma files.list
1415 else
1416 gen_packages_db
1417 return
1418 fi
1419 report step "Updating packages lists: $pkg_repository"
1420 packages_db_start
1422 # Look for removed/update packages.
1423 touch stamp -r packages.list
1424 for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
1425 pkg="$pkg_repository/$(grep -m1 ^$PACKAGE- packages.list).tazpkg"
1426 if ! [ -f "$pkg" ]; then
1427 erase_package_info
1428 else
1429 if [ "$pkg" -nt "stamp" ]; then
1430 updated_pkg="$updated_pkg
1431 $PACKAGE $pkg"
1432 elif [ ! -f $WOK/$PACKAGE/receipt ] && \
1433 [ "$COMMAND" = check-incoming -o "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
1434 erase_package_info
1435 echo "Removing $PACKAGE from $pkg_repository."
1436 rm $pkg
1437 [ "$save_wok" ] && rm -rf $pkg_repository/wok/$PACKAGE
1438 if [ "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
1439 rm -rf $WOK/$PACKAGE
1440 sed "/^$PACKAGE\t/d" -i $wan_db $dep_db $cookorder
1441 sed "/^$PACKAGE$/d" -i $cooklist $commit $blocked $broken
1442 rm -f $LOCAL_REPOSITORY/log/$PACKAGE.html
1443 if [ "$(sed 1!d $cookorder)" != "#PlanSort" ]; then
1444 sed 1i"#PlanSort" -i $cookorder
1445 regen_cooklist=yes
1446 fi
1447 else
1448 echo "$PACKAGE" >> removed
1449 sed -n '1,10p' -i removed
1450 fi
1451 fi
1452 fi
1453 done
1454 rm stamp
1455 echo "$updated_pkg" | sed 1d | while read PACKAGE pkg; do
1456 erase_package_info
1457 get_packages_info
1458 done
1459 unset updated_pkg
1461 # Look for new packages.
1462 for pkg in $pkg_repository/*.tazpkg; do
1463 fgrep -q " ${pkg##*/}" packages.md5 || get_packages_info
1464 done
1465 report end-step
1466 packages_db_end
1469 packages_db_start()
1471 if [ -s packages.txt ]; then
1472 sed -e 's/^# Packages :.*/# Packages : unknown/' \
1473 -e "s/# Date :.*/# Date : $(date +%Y-%m-%d\ \%H:%M:%S)/" \
1474 -i packages.txt
1475 else
1476 echo "# SliTaz GNU/Linux - Packages list
1478 # Packages : unknown
1479 # Date : $(date +%Y-%m-%d\ \%H:%M:%S)
1481 " > packages.txt
1482 fi
1484 # Needed in some cases as tazwok defines RECEIPT at configuration time
1485 # in this particular case it can break the script.
1486 unset RECEIPT
1488 # If $packages_repository is the main one, configure few functions
1489 # to act as they should, without having loop on them (speed-up)
1490 if [ "$pkg_repository" = "$PACKAGES_REPOSITORY" ]; then
1491 erase_package_info_extracmd="erase_package_info_main"
1492 get_packages_info_extracmd="get_packages_info_main"
1493 fi
1496 erase_package_info()
1498 cd $pkg_repository
1499 sed "/^$PACKAGE$/,/^$/d" -i packages.txt
1500 sed "/^$PACKAGE /d" -i packages.desc
1501 sed -e "s/=$PACKAGE /= /" -e "s/ $PACKAGE / /" -e "s/ $PACKAGE$//" \
1502 -e "/=$PACKAGE$/d" -e "s/=[0-9,a-z,A-Z]:$PACKAGE /= /" \
1503 -e "s/ [0-9,a-z,A-Z]:$PACKAGE / /" -e "s/ [0-9,a-z,A-Z]:$PACKAGE$/ /" \
1504 -e "/=[0-9,a-z,A-Z]:$PACKAGE$/d" \
1505 -i packages.equiv
1506 sed "/^$PACKAGE:/d" -i files.list
1507 sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
1508 sed "/ $(basename $pkg)$/d" -i packages.md5
1509 $erase_package_info_extracmd
1512 erase_package_info_main()
1514 for i in wanted.txt depends.txt libraries.txt; do
1515 [ -f $i ] || continue
1516 sed "/^$PACKAGE\t/d" -i $i
1517 done
1520 get_packages_info()
1522 # If there's no taz folder in the wok, extract info from the
1523 # package.
1524 get_pkg_files $pkg
1525 source_receipt
1526 echo "Getting data from $PACKAGE"
1528 cat >> $pkg_repository/packages.txt << _EOT_
1529 $PACKAGE
1530 $VERSION$EXTRAVERSION
1531 $SHORT_DESC
1532 _EOT_
1533 if [ "$PACKED_SIZE" ]; then
1534 cat >> $pkg_repository/packages.txt << _EOT_
1535 $PACKED_SIZE ($UNPACKED_SIZE installed)
1537 _EOT_
1538 else
1539 echo "" >> $pkg_repository/packages.txt
1540 fi
1542 # Packages.desc is used by Tazpkgbox <tree>.
1543 echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
1545 # Packages.equiv is used by tazpkg install to check depends.
1546 for i in $PROVIDE; do
1547 DEST=""
1548 echo $i | fgrep -q : && DEST="${i#*:}:"
1549 if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
1550 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
1551 else
1552 echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
1553 fi
1554 done
1556 if [ -f files.list ]; then
1557 { echo "$PACKAGE"; cat files.list; } | awk '
1558 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
1559 fi
1561 cd .. && rm -r "$pkg_files_dir"
1563 cd $pkg_repository
1564 echo $(basename ${pkg%.tazpkg}) >> packages.list
1565 md5sum $(basename $pkg) >> packages.md5
1566 $get_packages_info_extracmd
1569 get_packages_info_main()
1571 [ "$WANTED" ] && echo -e "$PACKAGE\t$WANTED" >> wanted.txt
1572 echo -e "$PACKAGE\t "$DEPENDS" \t "$BUILD_DEPENDS" " >> package.txt
1573 grep -m1 ^$PACKAGE$'\t' $lib_db >> libraries.txt
1576 source_receipt()
1578 unset PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
1579 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
1580 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
1581 src _pkg DESTDIR CONFIG_SITE BRANCH TARBALL KBASEVER \
1582 stuff wanted_stuff
1583 . ${RECEIPT:-$PWD/receipt}
1586 packages_db_end()
1588 cd $pkg_repository
1589 pkgs=$(wc -l packages.list | sed 's/ .*//')
1590 sed "s/# Packages : .*/# Packages : $pkgs/" -i packages.txt
1592 # If lists were updated it's generally needed to sort them well.
1593 if ! sort -c packages.list 2> /dev/null; then
1594 report step "Sorting packages lists"
1595 files_list="packages.list packages.desc packages.equiv"
1596 [ "${pkg_repository##*/}" = packages ] && \
1597 files_list="$files_list wanted.txt depends.txt libraries.txt"
1598 for file in $files_list; do
1599 [ -f $file ] || continue
1600 sort -o $file $file
1601 done
1602 report end-step
1603 fi
1605 md5sum packages.md5 | cut -f1 -d' ' > ID
1606 [ -s ID ] || echo null > ID
1608 # Dont log this because lzma always output errors.
1609 lzma e files.list files.list.lzma
1610 rm -f files.list
1611 [ -f packages.equiv ] || touch packages.equiv
1614 ########################################################################
1615 # This section contains functions to generate wok database.
1616 ########################
1618 gen_wok_db()
1620 report step "Generating wok database"
1621 report open-bloc
1622 report step "Removing old files"
1623 for file in $wan_db $dep_db $cookorder; do
1624 [ -f $file ] && rm $file
1625 done
1626 report step "Generating wok-wanted.txt"
1627 gen_wan_db
1628 report step "Generating wok-depends.txt"
1629 gen_dep_db
1630 sort_db
1631 report close-bloc
1634 gen_wan_db()
1636 [ -f $wan_db ] && rm -f $wan_db
1637 for RECEIPT in $(fgrep -l WANTED $WOK/*/receipt); do
1638 WANTED=
1639 source $RECEIPT
1640 [ "$WANTED" ] || continue
1641 echo -e $PACKAGE"\t"$WANTED >> $wan_db
1642 done
1645 gen_dep_db()
1647 [ -f $dep_db ] && rm -f $dep_db
1648 for PACKAGE in $(ls $WOK); do
1649 RECEIPT=$WOK/$PACKAGE/receipt
1650 if [ -s $RECEIPT ]; then
1651 source_receipt
1652 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
1653 fi
1654 done
1657 update_wan_db()
1659 local PACKAGE=$PACKAGE
1660 wanted_list=$(fgrep WANTED=\"$PACKAGE\" $WOK/*/receipt | cut -f1 -d ':')
1661 grep $'\t'$PACKAGE $wan_db | cut -f 1 | while read wan; do
1662 echo "$wanted_list" | fgrep -q /$wan/receipt && continue
1663 sed "/^$wan\t/d" -i $wan_db
1664 done
1665 for RECEIPT in $wanted_list; do
1666 unset WANTED PACKAGE
1667 source $RECEIPT
1668 [ "$WANTED" ] || continue
1669 sed "/^$PACKAGE\t/d" -i $wan_db
1670 echo -e $PACKAGE"\t"$WANTED >> $wan_db
1671 done
1672 unset wanted_list
1675 update_dep_db()
1677 sed "/^$PACKAGE\t/d" -i $dep_db
1678 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
1681 sort_db()
1683 report step "Generating cookorder.txt"
1684 sed 's/ \t / /' $dep_db | while read PACKAGE BUILD_DEPENDS; do
1685 grep -q ^$PACKAGE$'\t' $wan_db && continue
1687 # Replace each BUILD_DEPENDS with a WANTED package by it's
1688 # WANTED package.
1689 echo -e $PACKAGE"\t $(echo $BUILD_DEPENDS | use_wanted | \
1690 sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' ') "
1691 done > $tmp/db
1692 while [ -s "$tmp/db" ]; do
1693 status=start
1694 for pkg in $(cut -f 1 $tmp/db); do
1695 if ! fgrep -q ' '$pkg' ' $tmp/db; then
1696 echo $pkg >> $tmp/cookorder
1697 sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
1698 status=proceed
1699 fi
1700 done
1701 if [ "$status" = start ]; then
1702 cp -f $tmp/db /tmp/remain-depends.txt
1703 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
1704 for remaining in $(cut -f 1 $tmp/db); do
1705 if ! grep -q ^$remaining $PACKAGES_REPOSITORY/blocked; then
1706 echo "$remaining" >> $PACKAGES_REPOSITORY/blocked
1707 fi
1708 done
1709 break
1710 fi
1711 done
1712 [ -s $tmp/cookorder ] || touch $tmp/cookorder
1714 # The toolchain packages are moved in first position.
1715 grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1716 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
1717 $tmp/cookorder | tac > $cookorder
1718 for pkg in $(cat $cookorder); do
1719 sed "/^$pkg$/d" -i $tmp/cookorder
1720 done
1722 tac $tmp/cookorder >> $cookorder
1723 report end-step
1726 ########################################################################
1727 # SCAN CORE
1728 ########################
1729 # Includes various scan core-functions. It's not intended to be used
1730 # directly : prefer scan wrappers in next section.
1732 look_for_dep()
1734 grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2
1737 look_for_bdep()
1739 look_for_all
1742 look_for_all()
1744 grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2,3 | sed 's/ / /'
1747 look_for_rdep()
1749 fgrep ' '$PACKAGE' ' $dep_db | cut -f 1
1752 look_for_rbdep()
1754 fgrep ' '$PACKAGE' ' $dep_db | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
1757 # Return WANTED if it exists.
1758 look_for_wanted()
1760 grep -m1 ^$PACKAGE$'\t' $wan_db | cut -f 2
1763 # Return packages which wants PACKAGE.
1764 look_for_rwanted()
1766 grep $'\t'$PACKAGE$ $wan_db | cut -f 1
1769 look_for_dev()
1771 WANTED=$(look_for_wanted)
1772 if [ "$WANTED" ]; then
1773 [ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
1774 fi
1775 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1778 with_dev()
1780 for PACKAGE in $(cat); do
1781 echo $PACKAGE
1782 look_for_dev
1783 done
1786 with_wanted()
1788 for PACKAGE in $(cat); do
1789 echo $PACKAGE
1790 look_for_wanted
1791 done
1794 use_wanted()
1796 for input in $(cat); do
1797 { grep ^$input$'\t' $wan_db || echo $input
1799 done | sed 's/.*\t//'
1802 check_for_pkg_in_wok()
1804 [ -f $WOK/$PACKAGE/receipt ] && return
1805 echo "Can't find $PACKAGE in wok or mirror" >&2
1806 return 2
1809 # Define how theses functions should act when using --undigest.
1810 use_undigest_scan_core()
1812 look_for_dep()
1814 if [ -f "$WOK/$PACKAGE/receipt" ]; then
1815 grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2
1816 else
1817 grep -m1 ^$PACKAGE$'\t' $ref_dep_db | cut -f 2
1818 fi
1821 look_for_all()
1823 if [ -f "$WOK/$PACKAGE/receipt" ]; then
1824 grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2,3 | sed 's/ / /'
1825 else
1826 grep -m1 ^$PACKAGE$'\t' $ref_dep_db | cut -f 2,3 | sed 's/ / /'
1827 fi
1830 look_for_rdep()
1832 fgrep ' '$PACKAGE' ' $dep_db | cut -f 1
1833 for rdep in $(fgrep ' '$PACKAGE' ' $ref_dep_db | cut -f 1); do
1834 [ -f "WOK$/$rdep/receipt" ] || echo "$rdep"
1835 done
1838 look_for_rbdep()
1840 fgrep ' '$PACKAGE' ' $dep_db | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
1841 for rdep in $(fgrep ' '$PACKAGE' ' $ref_dep_db | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
1842 [ -f "WOK$/$rdep/receipt" ] || echo "$rdep"
1843 done
1846 look_for_wanted()
1848 if [ -f "$WOK/$PACKAGE/receipt" ]; then
1849 grep -m1 ^$PACKAGE$'\t' $wan_db | cut -f 2
1850 else
1851 grep -m1 ^$PACKAGE$'\t' $ref_wan_db | cut -f 2
1852 fi
1855 look_for_rwanted()
1857 if [ -f "$WOK/$PACKAGE/receipt" ]; then
1858 grep $'\t'$PACKAGE$ $wan_db | cut -f 1
1859 else
1860 grep $'\t'$PACKAGE$ $ref_wan_db | cut -f 1
1861 fi
1864 look_for_dev()
1866 WANTED=$(look_for_wanted)
1867 if [ "$WANTED" ]; then
1868 if [ -f "$WOK/$WANTED/receipt" ]; then
1869 [ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
1870 else
1871 grep -q ^$WANTED-dev$'\t' $ref_dep_db && echo $WANTED-dev
1872 fi
1873 fi
1874 if [ -f "$WOK/$PACKAGE/receipt" ]; then
1875 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1876 else
1877 grep -q ^$PACKAGE-dev$'\t' $ref_dep_db && echo $PACKAGE-dev
1878 fi
1881 check_for_pkg_in_wok()
1883 [ -f $WOK/$PACKAGE/receipt ] && return
1884 grep -q ^$PACKAGE'$\t' $ref_dep_db && return 1
1885 echo "Can't find $PACKAGE in wok or mirror" >&2
1886 return 2
1890 ########################################################################
1891 # SCAN
1892 ########################
1893 # Use wok-wanted.txt and wok-depeds.txt to scan depends.
1894 # Option in command line (must be first arg) :
1895 # --look_for=bdep/rbdep - Look for depends or reverse depends.
1896 # --with_dev - Add development packages (*-dev) in the result.
1897 # --with_wanted - Add package+reverse wanted in the result.
1898 # --with_args - Include packages in argument in the result.
1900 scan()
1902 # Get packages in argument.
1903 local PACKAGE=$PACKAGE WANTED=$WANTED pkg_list=
1904 for arg in $@; do
1905 [ "$arg" = "${arg#--}" ] || continue
1906 pkg_list="$pkg_list $arg"
1907 done
1909 # Get options.
1910 [ "$pkg_list" ] || return
1911 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
1912 get_options_list="look_for with_dev with_wanted with_args cooklist use_wanted"
1913 get_options
1915 # Get db md5 to be able to check for changes latter.
1916 db_md5=$(md5sum $dep_db $wan_db)
1918 # Cooklist is a special case where we need to modify a little
1919 # scan behavior
1920 if [ "$cooklist" ]; then
1921 gen_wan_db
1922 look_for=all && with_args=yes && with_dev= && with_wanted=
1923 filter=use_wanted
1924 if [ "$COMMAND" = gen-cooklist ]; then
1925 for PACKAGE in $pkg_list; do
1926 grep -q ^$PACKAGE$'\t' $dep_db && continue
1927 [ -d "$WOK/$p" ] || continue
1928 check_for_missing
1929 done
1930 append_to_dep()
1932 if grep -q ^$PACKAGE$'\t' $dep_db; then
1933 echo $PACKAGE >> $tmp/dep
1934 else
1935 check_for_missing && echo $PACKAGE >> $tmp/dep
1936 fi
1938 else
1939 append_to_dep()
1941 check_for_commit && echo $PACKAGE >> $tmp/dep
1943 fi
1944 else
1945 append_to_dep()
1947 echo $PACKAGE >> $tmp/dep
1949 # If requested packages are not in dep_db, partial generation of this db is needed.
1950 for PACKAGE in $pkg_list; do
1951 grep -q ^$PACKAGE$'\t' $dep_db && continue
1952 [ -d "$WOK/$p" ] || continue
1953 plan_check_for_missing=yes
1954 check_for_missing
1955 done
1956 if [ "$plan_check_for_missing" ]; then
1957 append_to_dep()
1959 if grep -q ^$PACKAGE$'\t' $dep_db; then
1960 echo $PACKAGE >> $tmp/dep
1961 else
1962 check_for_missing && echo $PACKAGE >> $tmp/dep
1963 fi
1965 unset plan_check_for_missing
1966 fi
1967 fi
1969 [ "$with_dev" ] && filter=with_dev
1970 [ "$with_wanted" ] && filter=with_wanted
1971 if [ "$filter" ]; then
1972 pkg_list=$(echo $pkg_list | $filter | sort -u)
1973 scan_pkg()
1975 look_for_$look_for | $filter
1977 else
1978 scan_pkg()
1980 look_for_$look_for
1982 fi
1983 touch $tmp/dep
1984 for PACKAGE in $pkg_list; do
1985 [ "$with_args" ] && append_to_dep
1986 scan_pkg
1987 done | tr ' ' '\n' | sort -u > $tmp/list
1988 [ "$look_for" = bdep ] && look_for=dep
1989 while [ -s $tmp/list ]; do
1990 PACKAGE=$(sed 1!d $tmp/list)
1991 sed 1d -i $tmp/list
1992 append_to_dep
1993 for pkg in $(scan_pkg); do
1994 grep -q ^$pkg$ $tmp/list $tmp/dep || echo $pkg >> $tmp/list
1995 done
1996 done
1997 if [ "$cooklist" ]; then
1998 mv $tmp/dep $tmp/cooklist
1999 else
2000 cat $tmp/dep | sort -u
2001 fi
2002 rm -f $tmp/dep $tmp/list
2003 sort -o $dep_db $dep_db
2004 sort -o $wan_db $wan_db
2005 if [ "$db_md5" != "$(md5sum $dep_db $wan_db)" ]; then
2006 grep -q "^#" $cookorder || sed 1i"#PlanSort" -i $cookorder
2007 fi
2010 ########################################################################
2011 # This section contains functions to check the package repository and
2012 # find which packages to cook.
2013 ########################
2015 check_for_missing()
2017 local PACKAGE=$PACKAGE
2018 if ! check_for_pkg_in_wok; then
2019 [ "$?" = 2 ] && return 1
2020 return
2021 fi
2022 RECEIPT=$WOK/$PACKAGE/receipt
2023 source_receipt
2024 PACKAGE=${WANTED:-$PACKAGE}
2025 update_wan_db
2026 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
2027 RECEIPT=$WOK/$PACKAGE/receipt
2028 source_receipt
2029 update_dep_db
2030 done
2033 # We use md5 of cooking stuff in the packaged receipt to check
2034 # commit. We look consecutively in 3 different locations :
2035 # - in the wok/PACKAGE/taz/* folder
2036 # - in the receipt in the package in incoming repository
2037 # - in the receipt in the package in packages repository
2038 # If md5sums match, there's no commit.
2039 check_for_commit_using_md5sum()
2041 if [ ! -f $WOK/$PACKAGE/md5 ]; then
2042 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
2043 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
2044 cd $WOK/$PACKAGE
2045 fi
2047 if [ "$1" ]; then
2048 check_for_commit_using_time && return
2049 fi
2051 if [ -s md5 ]; then
2052 if md5sum -cs md5; then
2054 # If md5sum check if ok, check for new/missing files in
2055 # cooking stuff.
2056 for file in $([ -f receipt ] && echo receipt; \
2057 [ -f description.txt ] && echo description.txt; \
2058 [ -d stuff ] && find stuff); do
2059 if ! fgrep -q " $file" md5; then
2060 set_commited
2061 fi
2062 done
2063 else
2064 set_commited
2065 fi
2066 else
2067 set_commited
2068 fi
2071 set_commited()
2073 ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/commit &&
2074 echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
2075 gen_cookmd5
2076 update_dep_db
2079 check_for_commit_using_time()
2081 local count=0 file cook_files
2083 get_cook_files
2085 for file in $cook_files; do
2086 if [ $file -nt md5 ]; then
2087 return 1
2088 else
2089 count=$((count+1))
2090 fi
2091 done
2093 if [ "$cook_files" ] \
2094 && [ ! "$count md5" = "`wc -l md5`" ]
2095 then
2096 return 1
2097 fi
2100 check_for_commit()
2102 if ! check_for_pkg_in_wok; then
2103 [ "$?" = 2 ] && return 1
2104 return
2105 fi
2106 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
2107 RECEIPT=$WOK/$PACKAGE/receipt
2108 source_receipt
2110 if [ -f $WOK/$PACKAGE/md5 ]; then
2111 cd $WOK/$PACKAGE
2112 check_for_commit_using_md5sum or time
2113 elif [ -d "$WOK/$PACKAGE/taz" ] \
2114 && taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*') \
2115 && [ -d "$taz_dir" ]
2116 then
2117 cd "$taz_dir"
2118 check_for_commit_using_md5sum or time
2119 else
2120 pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
2121 [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
2122 if [ "$pkg" ]; then
2123 get_pkg_files $pkg
2124 check_for_commit_using_md5sum
2125 rm -r $pkg_files_dir
2126 else
2127 set_commited
2128 fi
2129 fi
2130 [ "$forced" ] || echo $PACKAGE >> $tmp/checked
2131 done
2134 gen_cook_list()
2136 report step "Scanning wok"
2137 if [ "$pkg" ]; then
2138 scan $pkg --cooklist
2139 elif [ "$LIST" ]; then
2140 scan `cat $LIST` --cooklist
2141 else
2142 scan `cat $cooklist` --cooklist
2143 fi
2144 report end-step
2146 [ -s $tmp/checked ] || [ -s $tmp/cooklist ] || return
2148 # Core toolchain should not be cooked unless cook-toolchain is used.
2149 if ! [ -f /etc/config.site.tmptoolchain ] ; then
2150 for PACKAGE in $(scan gcc --look_for=all --with_args --with_wanted); do
2151 grep -q ^$PACKAGE$ $blocked || echo $PACKAGE >> $blocked
2152 done
2153 fi
2155 if [ -s $commit ] && [ "$COMMAND" != gen-cooklist ]; then
2156 for PACKAGE in $(cat $commit); do
2157 WANTED="$(look_for_wanted)"
2158 if [ "$WANTED" ]; then
2159 grep -q ^$WANTED$ $broken $cooklist $blocked $commit && continue
2160 fi
2161 grep -q ^$PACKAGE$ $blocked $cooklist && continue
2162 echo $PACKAGE >> $cooklist
2163 done
2164 fi
2165 sort_cooklist
2168 sort_cooklist()
2170 if [ "$(sed 1!d $cookorder)" = "#PlanSort" ]; then
2171 sed 1d -i $cookorder
2172 sort_db
2173 fi
2174 report step "Generating cooklist"
2175 if [ -f "$tmp/checked" ]; then
2176 rm -f $tmp/cooklist
2177 cat $tmp/checked | while read PACKAGE; do
2178 grep -q ^$PACKAGE$ $cooklist && echo $PACKAGE >> $tmp/cooklist
2179 done
2180 elif ! [ "$COMMAND" = gen-cooklist ]; then
2181 cat $blocked | while read PACKAGE; do
2182 sed "/^$PACKAGE/d" -i $tmp/cooklist
2183 done
2184 fi
2185 report end-step
2186 [ -s $tmp/cooklist ] || return
2188 report step "Sorting cooklist"
2189 for PACKAGE in $(cat $tmp/cooklist); do
2190 WANTED="$(look_for_wanted)"
2191 [ "$WANTED" ] || continue
2192 if grep -q ^$WANTED$ $broken $tmp/cooklist; then
2193 sed "/^$PACKAGE$/d" -i $tmp/cooklist
2194 elif [ ! -d $WOK/$WANTED/install ]; then
2195 sed "/^$PACKAGE$/d" -i $tmp/cooklist
2196 echo $WANTED >> $tmp/cooklist
2197 fi
2198 done
2200 # Use cookorder.txt to sort cooklist.
2201 if [ -s $tmp/cooklist ]; then
2202 cat $cookorder | while read PACKAGE; do
2203 if grep -q ^$PACKAGE$ $tmp/cooklist; then
2204 sed "/^$PACKAGE$/d" -i $tmp/cooklist
2205 echo $PACKAGE >> $tmp/cooklist.tmp
2206 fi
2207 done
2209 # Remaining packages in cooklist are those without compile_rules.
2210 # They can be cooked first in any order.
2211 if [ -f $tmp/cooklist.tmp ]; then
2212 cat $tmp/cooklist.tmp >> $tmp/cooklist
2213 rm $tmp/cooklist.tmp
2214 fi
2216 cat $tmp/cooklist
2217 [ "$LIST" ] || cat $tmp/cooklist > $cooklist
2218 fi
2220 report end-step
2223 look_for_missing_pkg()
2225 for pkg in $(cat $PACKAGES_REPOSITORY/$1); do
2226 grep -q ^$pkg$ $INCOMING_REPOSITORY/packages.txt \
2227 $PACKAGES_REPOSITORY/packages.txt || \
2228 continue
2229 echo $pkg
2230 done
2233 check_for_incoming()
2235 report step "Checking that all packages were cooked OK"
2236 [ -s $INCOMING_REPOSITORY/packages.desc ] || {
2237 echo "No packages in $INCOMING_REPOSITORY."
2238 report end-step; return; }
2239 if [ -s $broken ]; then
2240 missingpkg=$(look_for_missing_pkg broken)
2241 if [ "$missingpkg" ]; then
2242 echo "Don't move incoming packages to main repository because these ones are broken:" >&2
2243 echo "$missingpkg"
2244 report end-step
2245 return 1
2246 fi
2247 fi
2248 if [ -s $cooklist ]; then
2249 missingpkg=$(look_for_missing_pkg cooklist)
2250 if [ "$missingpkg" ]; then
2251 echo "Don't move incoming packages to main repository because these ones need to be cooked:" >&2
2252 echo "$missingpkg"
2253 report end-step
2254 return 1
2255 fi
2256 fi
2257 incoming_pkgs="$(cut -f 1 -d '|' $INCOMING_REPOSITORY/packages.desc)"
2258 if ! [ "$forced" ]; then
2259 cooklist=$PACKAGES_REPOSITORY/cooklist
2260 pkg="$incoming_pkgs"
2261 gen_cook_list
2262 if [ -s $cooklist ]; then
2263 missingpkg=$(look_for_missing_pkg cooklist)
2264 if [ "$missingpkg" ]; then
2265 echo "Don't move incoming packages to main repository because these ones need to be cooked:" >&2
2266 echo "$missingpkg"
2267 report end-step
2268 return 1
2269 fi
2270 fi
2271 fi
2273 report step "Moving incoming packages to main repository"
2274 [ "$save_wok" ] && mkdir -p $PACKAGES_REPOSITORY/wok
2275 unset EXTRAVERSION
2276 for PACKAGE in $incoming_pkgs; do
2277 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
2278 VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
2279 remove_previous_package $PACKAGES_REPOSITORY
2280 echo "Moving $PACKAGE..."
2281 mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
2282 touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
2283 previous_tarball=$(grep -m1 ^$PACKAGE:main $SOURCES_REPOSITORY/sources.list | cut -f2)
2284 sed -e "/^$PACKAGE:main/d" \
2285 -e "s/^$PACKAGE:incoming/$PACKAGE:main/" \
2286 -i $SOURCES_REPOSITORY/sources.list
2287 if [ "$previous_tarball" ]; then
2288 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
2289 rm -f $SOURCES_REPOSITORY/$previous_tarball
2290 fi
2291 [ "$save_wok" ] && mv $INCOMING_REPOSITORY/wok/$PACKAGE $PACKAGES_REPOSITORY/wok
2292 done
2294 if [ "$save_wok" = tarball ]; then
2295 rm -f $PACKAGES_REPOSITORY/wok.tar.lzma
2296 cd $PACKAGES_REPOSITORY/wok
2297 report step "Generating safe-wok tarball"
2298 tar -c * | lzma e -si $PACKAGES_REPOSITORY/wok.tar.lzma
2299 report end-step
2300 fi
2302 for file in packages.list packages.equiv packages.md5 packages.desc \
2303 packages.txt; do
2304 echo -n "" > $INCOMING_REPOSITORY/$file
2305 done
2306 rm -r $INCOMING_REPOSITORY/files.list.lzma
2307 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2309 report step "Updating flavors"
2310 if [ -x /usr/bin/tazlito ] || [ -x /usr/bin/clean-chroot ]; then
2311 if ! [ -x /usr/bin/tazlito ]; then
2312 tazpkg get-install tazlito
2313 fi
2315 # Handle cases where tazwok is used into main system;
2316 # Handle cases where SLITAZ_DIR is not /home/slitaz.
2317 [ -L /home/slitaz/flavors ] && rm /home/slitaz/flavors
2318 mkdir -p /home/slitaz
2319 ln -s $LOCAL_REPOSITORY/flavors /home/slitaz/flavors
2320 cd /home/slitaz/flavors
2321 [ -d .hg ] && hg pull -u
2323 cd $LOCAL_REPOSITORY/packages
2324 for i in $LOCAL_REPOSITORY/flavors/*; do
2325 [ -d "$i" ] || continue
2326 tazlito pack-flavor ${i##*/}
2327 done
2329 noheader=""
2330 for i in *.flavor; do
2331 tazlito show-flavor $i --brief $noheader
2332 noheader="--noheader"
2333 done > flavors.list
2334 [ -x /usr/bin/clean-chroot ] && clean-chroot
2335 else
2336 echo "Can't create up-to-date flavors because the tazlito package is missing." >&2
2337 fi
2338 report end-step
2341 # Usage: move_cooking_stuff source receipt destination
2342 # Make the argument check before calling it!
2343 copy_cooking_stuff()
2345 rm -rf $3/$2
2346 mkdir -p $3/$2
2347 cp -a $1/$2/receipt $3/$2
2348 [ -f $1/$2/description.txt ] && \
2349 cp -a $1/$2/description.txt $3/$2
2350 if [ -d "$1/$2/stuff" ]; then
2351 cp -a $1/$2/stuff $3/$2
2352 fi
2355 ########################################################################
2356 # TAZWOK MAIN FUNCTIONS
2357 ########################
2359 clean()
2361 cd $WOK/$PACKAGE
2362 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
2363 -e ^stuff$ || return
2365 [ "$COMMAND" = clean-wok ] || report step "Cleaning $PACKAGE"
2366 # Check for clean_wok function.
2367 if grep -q ^clean_wok $RECEIPT; then
2368 clean_wok
2369 fi
2370 # Clean should only have a receipt, stuff and optionals desc/md5.
2371 for f in `ls .`
2372 do
2373 case $f in
2374 receipt|stuff|description.txt|md5)
2375 continue ;;
2376 *)
2377 rm -rf $f ;;
2378 esac
2379 done
2380 [ "$COMMAND" != clean-wok ] && report end-step
2383 # Configure and make a package with the receipt.
2384 compile_package()
2386 check_for_package_on_cmdline
2388 # Include the receipt to get all needed variables and functions
2389 # and cd into the work directory to start the work.
2390 check_for_receipt
2391 source_receipt
2393 # Log the package name and date.
2394 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
2395 echo "package $PACKAGE (compile)" >> $LOG
2397 # Set wanted $src variable to help compiling.
2398 [ ! "$src" ] && set_src_path
2399 check_for_build_depends || return 1
2400 check_for_wanted
2401 unset target
2402 check_for_tarball && check_for_compile_rules
2405 # Cook command also include all features to manage lists which keep
2406 # track of wok/packages state.
2407 cook()
2409 cook_code=
2410 set_common_path
2411 check_for_receipt
2412 source_receipt
2414 # Define log path and start report.
2415 for i in $(look_for_rwanted) $PACKAGE; do
2416 rm -f $LOCAL_REPOSITORY/log/$i.html
2417 done
2418 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
2419 echo "$PACKAGE" > $LOCAL_REPOSITORY/log/package
2420 report step "Cooking $PACKAGE"
2421 report open-bloc
2423 clean $PACKAGE
2424 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
2426 if compile_package; then
2427 remove_src
2428 refresh_packages_from_compile
2429 gen_package
2431 # Update packages-incoming repository.
2432 store_pkgname=$PACKAGE
2433 pkg_repository=$INCOMING_REPOSITORY
2434 update_packages_db
2436 PACKAGE=$store_pkgname
2437 unset store_pkgname
2439 # Upgrade to cooked packages if it was previously installed.
2440 report step "Looking for package(s) to upgrade"
2441 for pkg in $(look_for_rwanted) $PACKAGE; do
2442 if [ -f $INSTALLED/$pkg/receipt ]; then
2443 tazpkg get-install $pkg --forced
2444 fi
2445 done
2446 report end-step
2447 else
2448 for PACKAGE in $(look_for_wanted) $PACKAGE; do
2449 set_pkg_broken
2450 done
2451 cook_code=1
2452 fi
2454 # Remove build_depends in cook mode (if in cooklist, it's done when
2455 # checking build_depends of next package and we remove only unneeded
2456 # packages to keep chroot minimal and gain some time).
2457 if [ "$COMMAND" = cook ]; then
2458 remove_build_depends $MISSING_PACKAGE
2459 [ -x /usr/bin/clean-chroot ] && clean-chroot
2460 fi
2462 # Regen the cooklist if it was planned and command is not cook.
2463 [ "$regen_cooklist" ] && unset regen_cooklist &&
2464 [ "$COMMAND" != cook ] && sort_cooklist
2466 # Some hacks to set the bloc & function status as failed if cook has
2467 # failed.
2468 report_return_code=$cook_code
2469 report close-bloc
2470 report end-sublog
2471 rm -f $LOCAL_REPOSITORY/log/package
2472 return $cook_code
2475 cook_list()
2477 if [ -s $tmp/cooklist ]; then
2478 if [ -f /usr/bin/tazchroot ]; then
2479 # Note : options -main variables- are automatically kept by
2480 # the sub-applications tazchroot/tazwok; as well as report data.
2481 cd $LOCAL_REPOSITORY
2482 [ ! -f tazchroot.conf ] && configure_tazchroot
2483 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
2484 return
2485 fi
2486 while [ -s $tmp/cooklist ]; do
2487 PACKAGE=$(sed 1!d $tmp/cooklist)
2488 cook
2489 done
2490 remove_build_depends $MISSING_PACKAGE $remove_later
2491 [ -x /usr/bin/clean-chroot ] && clean-chroot
2492 else
2493 echo "Nothing to cook."
2494 return
2495 fi
2498 configure_tazchroot()
2500 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
2501 # Tazchroot configuration file - created by tazwok.
2503 # Local repository definition.
2504 SLITAZ_DIR=$SLITAZ_DIR
2505 SLITAZ_VERSION=$SLITAZ_VERSION
2506 LOCAL_REPOSITORY=$SLITAZ_DIR/${undigest:-$SLITAZ_VERSION}
2507 ${USE_ONLINE_PKG:+USE_ONLINE_PKG=$USE_ONLINE_PKG}
2508 ${undigest:+undigest=$undigest}
2509 ${ref_USE_ONLINE_PKG:+ref_USE_ONLINE_PKG=$ref_USE_ONLINE_PKG}
2511 # Chroot path.
2512 # You can use a chroot into /tmp if it's mounted in RAM
2513 # to speed-up the process, be sure you have a free GB.
2514 # (minimal chroot is like 150~200MB, can be a lot more during cook)
2515 # chroot_dir=/tmp/chroot-${undigest:-$SLITAZ_VERSION}
2516 chroot_dir=\$LOCAL_REPOSITORY/chroot
2518 # Default scripts path (these scripts are added to the
2519 # $chroot_dir/usr/bin and can be called with tazchroot script).
2520 script_dir=/usr/lib/slitaz/chroot-scripts/tazwok
2522 # List of directories to mount.
2523 list_dir="$LOCAL_REPOSITORY
2524 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
2526 create_chroot()
2528 mkdir -p \$chroot_dir
2529 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
2530 tazpkg get-install \$pkg --root="\$chroot_dir"
2531 done
2533 # Store list of installed packages needed by cleanchroot.
2534 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
2536 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
2537 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
2538 -i \$chroot_dir/etc/slitaz/slitaz.conf
2539 echo \$SLITAZ_VERSION > \$chroot_dir/etc/slitaz-release
2540 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
2541 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
2543 # The build bot may run in a sandbox: link sandbox lockfile.
2544 [ -d \$LOCAL_REPOSITORY/sandbox ] && ln -s \$LOCAL_REPOSITORY/sandbox/proc/1 \$chroot_dir/proc/1
2547 mount_chroot()
2549 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
2550 $( if [ "$USE_ONLINE_PKG" ]; then
2551 echo ' echo "$USE_ONLINE_PKG" > $chroot_dir$LOCALSTATE/mirror'
2552 else
2553 echo ' echo "$LOCAL_REPOSITORY/packages" > $chroot_dir$LOCALSTATE/mirror'
2554 fi
2556 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
2557 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
2558 $( if [ "$undigest" ]; then
2559 echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION'
2560 if [ "$ref_USE_ONLINE_PKG" ]; then
2561 echo ' echo "$ref_USE_ONLINE_PKG" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror'
2562 else
2563 echo ' echo "$ref_LOCAL_REPOSITORY/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror'
2564 fi
2565 fi )
2566 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
2567 mount -o bind /proc \$chroot_dir/proc
2568 mount -o bind /sys \$chroot_dir/sys
2569 mount -o bind /dev/pts \$chroot_dir/dev/pts
2570 mount -o bind /dev/shm \$chroot_dir/dev/shm
2571 for dir in \$list_dir; do
2572 mkdir -p \$dir \$chroot_dir\$dir
2573 mount \$dir \$chroot_dir\$dir
2574 done
2577 umount_chroot()
2579 for dir in \$list_dir; do
2580 umount \$chroot_dir\$dir
2581 done
2582 umount \$chroot_dir/dev/shm
2583 umount \$chroot_dir/dev/pts
2584 umount \$chroot_dir/sys
2585 umount \$chroot_dir/proc
2587 EOF
2590 ########################################################################
2591 ######################### END OF NEW FUNCTIONS #########################
2592 ########################################################################
2594 # List packages providing a virtual package.
2595 whoprovide()
2597 local i;
2598 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
2599 . $i
2600 case " $PROVIDE " in
2601 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
2602 esac
2603 done
2606 ########################################################################
2607 # TAZWOK COMMANDS
2608 ########################
2610 case "$COMMAND" in
2611 stats)
2612 # Tazwok general statistics from the wok config file.
2614 get_tazwok_config
2615 echo -e "\n\033[1mTazwok configuration statistics\033[0m
2616 ================================================================================
2617 Wok directory : $WOK
2618 Packages repository : $PACKAGES_REPOSITORY
2619 Incoming repository : $INCOMING_REPOSITORY
2620 Sources repository : $SOURCES_REPOSITORY
2621 Log directory : $LOCAL_REPOSITORY/log
2622 Packages in the wok : `ls -1 $WOK | wc -l`
2623 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2624 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2625 ================================================================================\n"
2626 ;;
2627 edit)
2628 get_tazwok_config
2629 check_for_package_on_cmdline
2630 check_for_receipt
2631 $EDITOR $WOK/$PACKAGE/receipt
2632 ;;
2633 build-depends)
2634 # List dependencies to rebuild wok, or only a package.
2635 get_tazwok_config
2636 report(){ : ; }
2637 if [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
2638 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
2639 --look_for=dep --with_dev --with_args
2640 else
2641 check_for_package_on_cmdline
2642 scan $PACKAGE --look_for=bdep --with_dev
2643 fi
2644 ;;
2645 gen-cooklist)
2646 check_root
2647 get_options_list="pkg"
2648 get_tazwok_config
2649 report(){ : ; }
2650 if ! [ "$pkg" ]; then
2651 if [ ! "$LIST" ] || [ "$LIST" = toolchain ]; then
2652 pkg="$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA"
2653 else
2654 check_for_list
2655 fi
2656 fi
2657 gen_cook_list
2658 ;;
2659 check-depends)
2660 # Check package depends /!\.
2661 get_tazwok_config
2662 echo ""
2663 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
2664 ================================================================================"
2665 TMPDIR=/tmp/tazwok$$
2666 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
2668 # Build ALL_DEPENDS variable.
2669 scan_dep()
2671 local i
2672 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
2673 for i in $DEPENDS $SUGGESTED ; do
2674 case " $ALL_DEPENDS " in
2675 *\ $i\ *) continue;;
2676 esac
2677 [ -d $WOK/$i ] || {
2678 ALL_DEPENDS="$ALL_DEPENDS$i "
2679 continue
2681 DEPENDS=""
2682 SUGGESTED=""
2683 . $WOK/$i/receipt
2684 scan_dep
2685 done
2688 # Check for ELF file.
2689 is_elf()
2691 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ]
2694 # Print shared library dependencies.
2695 ldd()
2697 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2700 mkdir $TMPDIR
2701 cd $TMPDIR
2702 for i in $LOCALSTATE/files.list.lzma \
2703 $LOCALSTATE/undigest/*/files.list.lzma ; do
2704 [ -f $i ] && lzma d $i -so >> files.list
2705 done
2706 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2707 tazpkg extract $pkg > /dev/null 2>&1
2708 . */receipt
2709 ALL_DEPENDS="$DEFAULT_DEPENDS "
2710 scan_dep
2711 find */fs -type f | while read file ; do
2712 is_elf $file || continue
2713 case "$file" in
2714 *.o|*.ko|*.ko.gz) continue;;
2715 esac
2716 ldd $file | while read lib rem; do
2717 case "$lib" in
2718 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2719 continue;;
2720 esac
2721 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2722 case " $ALL_DEPENDS " in
2723 *\ $dep\ *) continue 2;;
2724 esac
2725 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2726 case " $ALL_DEPENDS " in
2727 *\ $vdep\ *) continue 3;;
2728 esac
2729 done
2730 done
2731 [ -n "$dep" ] || dep="UNKNOWN"
2732 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2733 done
2734 done
2735 rm -rf */
2736 done
2737 cd /tmp
2738 rm -rf $TMPDIR
2739 ;;
2740 check)
2741 # Check wok consistency.
2742 get_tazwok_config
2743 echo ""
2744 echo -e "\033[1mWok and packages checking\033[0m
2745 ================================================================================"
2746 cd $WOK
2747 for pkg in $(ls)
2748 do
2749 [ -f $pkg/receipt ] || continue
2750 RECEIPT= $pkg/receipt
2751 source_receipt
2752 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2753 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2754 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2755 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2756 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2757 if [ -n "$WANTED" ]; then
2758 if [ ! -f $WANTED/receipt ]; then
2759 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2760 else
2761 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2762 if [ "$VERSION" = "$WANTED" ]; then
2763 # BASEVERSION is computed in receipt
2764 fgrep -q '_pkg=' $pkg/receipt &&
2765 BASEVERSION=$VERSION
2766 fi
2767 if [ "$VERSION" != "$BASEVERSION" ]; then
2768 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2769 fi
2770 fi
2771 fi
2773 if [ -n "$CATEGORY" ]; then
2774 case " $(echo $CATEGORIES) " in
2775 *\ $CATEGORY\ *);;
2776 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2777 esac
2778 else
2779 echo"Package $PACKAGE has no CATEGORY" >&2
2780 fi
2781 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2782 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2783 case "$WGET_URL" in
2784 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2785 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2786 '') ;;
2787 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2788 esac
2789 case "$WEB_SITE" in
2790 ftp*|http*);;
2791 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2792 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2793 esac
2794 case "$MAINTAINER" in
2795 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2796 esac
2797 case "$MAINTAINER" in
2798 *@*);;
2799 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2800 esac
2801 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2802 for i in $DEPENDS; do
2803 [ -d $i ] && continue
2804 [ -n "$(whoprovide $i)" ] && continue
2805 echo -e "$MSG $i"
2806 MSG=""
2807 done
2808 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2809 for i in $BUILD_DEPENDS; do
2810 [ -d $i ] && continue
2811 [ -n "$(whoprovide $i)" ] && continue
2812 echo -e "$MSG $i"
2813 MSG=""
2814 done
2815 MSG="Dependency loop between $PACKAGE and :\n"
2816 ALL_DEPS=""
2817 check_for_deps_loop $PACKAGE $DEPENDS
2818 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2819 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2820 echo "$pkg should be rebuilt after $i installation"
2821 done
2822 done
2823 ;;
2824 list)
2825 # List packages in wok directory. User can specify a category.
2827 get_tazwok_config
2828 if [ "$2" = "category" ]; then
2829 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2830 exit 0
2831 fi
2832 # Check for an asked category.
2833 if [ -n "$2" ]; then
2834 ASKED_CATEGORY=$2
2835 echo ""
2836 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2837 horizontal_line
2838 for pkg in $WOK/*
2839 do
2840 [ ! -f $pkg/receipt ] && continue
2841 . $pkg/receipt
2842 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2843 echo -n "$PACKAGE"
2844 echo -e "\033[28G $VERSION"
2845 packages=$(($packages+1))
2846 fi
2847 done
2848 horizontal_line
2849 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
2850 else
2851 # By default list all packages and version.
2852 echo ""
2853 echo -e "\033[1mList of packages in the wok\033[0m"
2854 horizontal_line
2855 for pkg in $WOK/*
2856 do
2857 [ ! -f $pkg/receipt ] && continue
2858 . $pkg/receipt
2859 echo -n "$PACKAGE"
2860 echo -en "\033[28G $VERSION"
2861 echo -e "\033[42G $CATEGORY"
2862 packages=$(($packages+1))
2863 done
2864 horizontal_line
2865 echo -e "$packages packages available in the wok.\n"
2866 fi
2867 ;;
2868 info)
2869 # Information about a package.
2871 get_tazwok_config
2872 check_for_package_on_cmdline
2873 check_for_receipt
2874 . $WOK/$PACKAGE/receipt
2875 echo ""
2876 echo -e "\033[1mTazwok package information\033[0m
2877 ================================================================================
2878 Package : $PACKAGE
2879 Version : $VERSION
2880 Category : $CATEGORY
2881 Short desc : $SHORT_DESC
2882 Maintainer : $MAINTAINER"
2883 if [ ! "$WEB_SITE" = "" ]; then
2884 echo "Web site : $WEB_SITE"
2885 fi
2886 if [ ! "$DEPENDS" = "" ]; then
2887 echo "Depends : $DEPENDS"
2888 fi
2889 if [ ! "$WANTED" = "" ]; then
2890 echo "Wanted src : $WANTED"
2891 fi
2892 horizontal_line
2893 echo ""
2894 ;;
2895 check-log)
2896 # We just cat the file log to view process info.
2898 get_tazwok_config
2899 if [ ! -f "$LOG" ]; then
2900 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2901 exit 1
2902 else
2903 echo ""
2904 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2905 horizontal_line
2906 cat $LOG
2907 horizontal_line
2908 echo ""
2909 if [ -s "$WOK/$PACKAGE/warning.txt" ]; then
2910 echo -e "\033[1mCook warning(s) for :\033[0m $PACKAGE"
2911 horizontal_line
2912 cat "$WOK/$PACKAGE/warning.txt"
2913 horizontal_line
2914 echo ""
2915 fi
2916 fi
2917 ;;
2918 search)
2919 # Search for a package by pattern or name.
2921 get_tazwok_config
2922 if [ -z "$2" ]; then
2923 echo -e "\nPlease specify a pattern or a package name to search." >&2
2924 echo -e "Example : 'tazwok search gcc'.\n" >&2
2925 exit 1
2926 fi
2927 echo ""
2928 echo -e "\033[1mSearch result for :\033[0m $2"
2929 horizontal_line
2930 list=`ls -1 $WOK | fgrep $2`
2931 for pkg in $list
2932 do
2933 . $WOK/$pkg/receipt
2934 echo -n "$PACKAGE "
2935 echo -en "\033[24G $VERSION"
2936 echo -e "\033[42G $CATEGORY"
2937 packages=$(($PACKAGEs+1))
2938 done
2939 horizontal_line
2940 echo "$packages packages found for : $2"
2941 echo ""
2942 ;;
2943 compile)
2944 # Configure and make a package with the receipt.
2946 get_tazwok_config
2947 source_lib report
2948 report start
2949 compile_package
2950 ;;
2951 genpkg)
2952 # Generate a package.
2954 get_tazwok_config
2955 source_lib report
2956 report start
2957 gen_package
2958 ;;
2959 cook)
2960 # Compile and generate a package. Just execute tazwok with
2961 # the good commands.
2963 check_root
2964 get_tazwok_config
2965 source_lib report
2966 report start
2967 db_md5=$(md5sum $dep_db $wan_db)
2968 update_wan_db
2969 check_for_commit
2970 sort -o $dep_db $dep_db
2971 sort -o $wan_db $wan_db
2972 if [ "$db_md5" != "$(md5sum $dep_db $wan_db)" ]; then
2973 grep -q "^#" $cookorder || sed 1i"#PlanSort" -i $cookorder
2974 fi
2975 cook
2976 ;;
2977 sort-cooklist)
2978 check_root
2979 get_tazwok_config
2980 check_for_list
2981 report(){ : ; }
2982 # When using sort-cooklist, the script should behave as for gen-cooklist
2983 # The only difference between these two is where the output is sent.
2984 COMMAND=gen-cooklist
2985 gen_cook_list
2986 cp -af $tmp/cooklist $LIST
2987 ;;
2988 cook-list)
2989 # Cook all packages listed in a file or in default cooklist.
2990 check_root
2991 get_options_list="pkg forced"
2992 get_tazwok_config
2993 source_lib report
2994 report start
2995 if ! [ "$pkg" ]; then
2996 [ "$LIST" ] && check_for_list
2997 fi
2998 gen_cook_list
2999 cook_list
3000 ;;
3001 clean)
3002 # Clean up a package work directory + those which want it.
3004 get_tazwok_config
3005 check_for_package_on_cmdline
3006 check_for_receipt
3007 source_lib report
3008 report start
3009 . $RECEIPT
3010 clean
3011 ;;
3012 gen-clean-wok)
3013 # Generate a clean wok from the current wok by copying all receipts
3014 # and stuff directory.
3016 get_tazwok_config
3017 source_lib report
3018 report start
3019 if [ -z "$ARG" ]; then
3020 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
3021 exit 1
3022 else
3023 dest=$ARG
3024 mkdir -p $dest
3025 fi
3026 report step "Creating clean wok in : $dest"
3027 for pkg in `ls -1 $WOK`
3028 do
3029 copy_cooking_stuff $WOK $pkg $dest
3030 done
3031 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
3032 report end-step
3033 echo "Packages cleaned : `ls -1 $dest | wc -l`"
3034 echo ""
3035 ;;
3036 clean-wok)
3037 # Clean all packages in the work directory.
3039 get_tazwok_config
3040 source_lib report
3041 report start
3042 report step "Cleaning wok"
3043 for PACKAGE in `ls -1 $WOK`
3044 do
3045 set_common_path
3046 source_receipt
3047 clean
3048 done
3049 echo "`ls -1 $WOK | wc -l` packages cleaned."
3050 ;;
3051 clean-src)
3052 # Remove tarball unrelated to wok receipts from src repo.
3053 check_root
3054 get_options_list="forced"
3055 get_tazwok_config
3056 cd $SOURCES_REPOSITORY
3057 echo -n "Checking $SOURCES_REPOSITORY..."
3058 for TARBALL in *; do
3059 [ "$TARBALL" = sources.list ] && continue
3060 grep -q $'\t'$TARBALL$ $SOURCES_REPOSITORY/sources.list || \
3061 echo $TARBALL >> $tmp/obsolete
3062 done
3063 status
3064 if ! [ -f $tmp/obsolete ]; then
3065 echo "No sources need to be removed."
3066 exit 1
3067 fi
3068 echo ""
3069 echo -e "\033[1mObsolete/unrelated-to-wok sources :\033[0m"
3070 horizontal_line
3071 cat $tmp/obsolete
3072 horizontal_line
3073 echo "$(wc -l $tmp/obsolete | cut -f1 -d' ') tarballs to remove."
3074 echo ""
3075 echo -n "Please confirm before removing (type uppercase YES): "
3076 read answer
3077 if [ "$answer" = YES ]; then
3078 echo -n "Removing old sources..."
3079 cat $tmp/obsolete | while read i; do
3080 rm -f $SOURCES_REPOSITORY/$i
3081 done
3082 status
3083 fi
3084 ;;
3085 gen-list)
3086 get_tazwok_config
3087 if [ "$2" ]; then
3088 if [ -d "$2" ]; then
3089 pkg_repository=$2
3090 else
3091 echo -e "\nUnable to find directory : $2\n" >&2
3092 exit 1
3093 fi
3094 fi
3096 source_lib report
3097 report start
3098 if [ "$pkg_repository" ]; then
3099 gen_packages_db
3100 else
3101 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
3102 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
3103 fi
3104 ;;
3105 check-list)
3106 # The directory to move into by default is the repository,
3107 # if $2 is not empty cd into $2.
3109 get_tazwok_config
3110 if [ "$2" ]; then
3111 if [ -d "$2" ]; then
3112 pkg_repository=$2
3113 else
3114 echo -e "\nUnable to find directory : $2\n" >&2
3115 exit 1
3116 fi
3117 fi
3119 source_lib report
3120 report start
3121 if [ "$pkg_repository" ]; then
3122 update_packages_db
3123 else
3124 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
3125 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
3126 fi
3127 ;;
3128 new-tree)
3129 # Just create a few directories and generate an empty receipt to prepare
3130 # the creation of a new package.
3132 get_tazwok_config
3133 check_for_package_on_cmdline
3134 clean_wok=$LOCAL_REPOSITORY/clean-wok
3135 if [ -d $clean_wok/$PACKAGE ]; then
3136 echo -e "\n$PACKAGE package tree already exists.\n" >&2
3137 exit 1
3138 fi
3139 echo "Creating : $clean_wok/$PACKAGE"
3140 mkdir $clean_wok/$PACKAGE
3141 cd $clean_wok/$PACKAGE
3142 echo -n "Preparing the receipt..."
3144 # Default receipt begin.
3146 echo "# SliTaz package receipt." > receipt
3147 echo "" >> receipt
3148 echo "PACKAGE=\"$PACKAGE\"" >> receipt
3149 # Finish the empty receipt.
3150 cat >> receipt << "EOF"
3151 VERSION=""
3152 CATEGORY=""
3153 SHORT_DESC=""
3154 MAINTAINER=""
3155 DEPENDS=""
3156 TARBALL="$PACKAGE-$VERSION.tar.gz"
3157 WEB_SITE=""
3158 WGET_URL=""
3160 # Rules to configure and make the package.
3161 compile_rules()
3163 cd $src
3164 ./configure $CONFIGURE_ARGS && make && make install
3167 # Rules to gen a SliTaz package suitable for Tazpkg.
3168 genpkg_rules()
3170 mkdir -p $fs/usr
3171 cp -a $_pkg/usr/bin $fs/usr
3174 EOF
3176 # Default receipt end.
3178 status
3179 # Interactive mode, asking and seding.
3180 if [ "$3" = "--interactive" ]; then
3181 echo "Entering interactive mode..."
3182 horizontal_line
3183 echo "Package : $PACKAGE"
3184 # Version.
3185 echo -n "Version : " ; read anser
3186 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
3187 # Category.
3188 echo -n "Category : " ; read anser
3189 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
3190 # Short description.
3191 echo -n "Short desc : " ; read anser
3192 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
3193 # Maintainer.
3194 echo -n "Maintainer : " ; read anser
3195 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
3196 # Web site.
3197 echo -n "Web site : " ; read anser
3198 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
3199 echo ""
3200 # Wget URL.
3201 echo "Wget URL to download source tarball."
3202 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
3203 echo -n "Wget url : " ; read anser
3204 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
3205 # Ask for a stuff dir.
3206 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
3207 if [ "$anser" = "y" ]; then
3208 echo -n "Creating the stuff directory..."
3209 mkdir stuff && status
3210 fi
3211 # Ask for a description file.
3212 echo -n "Are you going to write a description ? (y/N) : " ; read anser
3213 if [ "$anser" = "y" ]; then
3214 echo -n "Creating the description.txt file..."
3215 echo "" > description.txt && status
3216 fi
3217 horizontal_line
3218 echo ""
3219 fi
3220 ;;
3221 remove)
3222 # Remove a package from the wok.
3224 get_tazwok_config
3225 check_for_package_on_cmdline
3226 echo ""
3227 echo -n "Please confirm deletion (y/N) : "; read anser
3228 if [ "$anser" = "y" ]; then
3229 echo -n "Removing $PACKAGE..."
3230 rm -rf $WOK/$PACKAGE && status
3231 echo ""
3232 fi
3233 ;;
3234 update-wok)
3235 # Pull and update a Hg wok.
3236 get_options_list="local"
3237 get_tazwok_config
3238 source_lib report
3239 report start
3240 clean_wok=$LOCAL_REPOSITORY/clean-wok
3241 cd $clean_wok
3242 if ! [ "$local" ]; then
3243 if [ "$WOK_UPDATE_METHOD" = hg ]; then
3244 if ! [ -f "$INSTALLED/mercurial/receipt" ]; then
3246 # Auto-install only if we are in a cook chroot.
3247 if [ -x /usr/bin/clean-chroot ]; then
3248 tazpkg get-install mercurial
3249 else
3250 echo "" >&2
3251 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
3252 echo "">&2
3253 exit 1
3254 fi
3255 fi
3257 report step "Getting wok changes using hg"
3258 if [ -d .hg ]; then
3259 hg pull -u || exit 1
3260 else
3261 hg clone $HG_WOK . || exit 1
3262 fi
3263 report end-step
3264 [ -x /usr/bin/clean-chroot ] && clean-chroot
3265 else
3266 report step "Getting wok changes using tarball"
3267 { mkdir .tmp && cd .tmp
3268 wget "$TARBALL_WOK" &&
3269 case $TARBALL_WOK in
3270 *bz2) tar xjf *.bz2 -C wok; rm *.bz2;;
3271 *lzma) unlzma -c *.lzma | tar xf - -C wok; rm *.lzma ;;
3272 *gz) tar xzf *.gz -C wok; rm*.gz ;;
3273 esac &&
3274 rm -r $(ls -d $clean_wok/*) &&
3275 cp -a wok/* $clean_wok &&
3276 cd .. &&
3277 rm -r .tmp
3278 } || { echo "That's not cool: it fails!" >&2
3279 report end-step
3280 exit 1; }
3281 report end-step
3282 fi
3283 fi
3284 report step "Appending changes to wok"
3286 # Handle removed files/dir.
3287 cd $WOK
3288 for dir in *; do
3289 [ -d "$clean_wok/$dir" ] || rm -rf $dir
3290 done
3291 for file in */receipt */description.txt; do
3292 [ -f "$clean_wok/$file" ] || rm -rf $file
3293 done
3294 for i in $(find */stuff 2>/dev/null); do
3295 [ -e "$clean_wok/$i" ] || rm -rf $i
3296 done
3298 cp -a $clean_wok/* $WOK
3299 report end-step
3300 ;;
3301 maintainers)
3302 get_tazwok_config
3303 echo ""
3304 echo "List of maintainers for: $WOK"
3305 horizontal_line
3306 touch /tmp/slitaz-maintainers
3307 for pkg in $WOK/*
3308 do
3309 . $pkg/receipt
3310 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
3311 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
3312 echo "$MAINTAINER"
3313 fi
3314 done
3315 horizontal_line
3316 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
3317 echo ""
3318 # Remove tmp files
3319 rm -f /tmp/slitaz-maintainers
3320 ;;
3321 maintained-by)
3322 # Search for packages maintained by a contributor.
3323 get_tazwok_config
3324 if [ ! -n "$2" ]; then
3325 echo "Specify a name or email of a maintainer." >&2
3326 exit 1
3327 fi
3328 echo "Maintainer packages"
3329 horizontal_line
3330 for pkg in $WOK/*
3331 do
3332 . $pkg/receipt
3333 if echo "$MAINTAINER" | fgrep -q "$2"; then
3334 echo "$PACKAGE"
3335 packages=$(($PACKAGEs+1))
3336 fi
3337 done
3338 horizontal_line
3339 echo "Packages maintained by $2: $PACKAGEs"
3340 echo ""
3341 ;;
3342 tags)
3343 get_tazwok_config
3344 echo -e "\n\033[1mTags list :\033[0m"
3345 horizontal_line
3346 cd $WOK
3347 for i in */receipt; do
3348 unset TAGS
3349 source $i
3350 for t in $TAGS; do
3351 grep -q ^$t$ $tmp/tags && continue
3352 echo $t | tee -a $tmp/tags
3353 done
3354 done
3355 horizontal_line
3356 echo "$(wc -l $tmp/tags | cut -f1 -d ' ') tags listed."
3357 ;;
3358 check-src)
3359 # Verify if upstream package is still available.
3361 get_tazwok_config
3362 check_for_package_on_cmdline
3363 check_for_receipt
3364 source_receipt
3365 check_src()
3367 for url in $@; do
3368 busybox wget -s $url 2>/dev/null && break
3369 done
3371 if [ "$WGET_URL" ];then
3372 echo -n "$PACKAGE : "
3373 check_src $WGET_URL
3374 status
3375 else
3376 echo "No tarball to check for $PACKAGE"
3377 fi
3378 ;;
3379 gen-src)
3380 get_tazwok_config
3381 if [ "$2" ]; then
3382 if [ -d "$2" ]; then
3383 src_repository=$2
3384 else
3385 echo -e "\nUnable to find directory : $2\n" >&2
3386 exit 1
3387 fi
3388 fi
3389 echo -n "Rebuilding sources.list file"
3390 [ $src_repository ] || src_repository="$SOURCES_REPOSITORY"
3391 gen_sources_list $src_repository
3392 status
3393 ;;
3394 get-src)
3395 check_root
3396 get_options_list="target nounpack"
3397 get_tazwok_config
3398 check_for_package_on_cmdline
3399 check_for_receipt
3400 source_receipt
3401 if [ "$WGET_URL" ];then
3402 source_lib report
3403 report start
3404 check_for_tarball
3405 else
3406 echo "No tarball to download for $PACKAGE"
3407 fi
3408 ;;
3409 check-commit)
3410 check_root
3411 get_options_list="missing forced"
3412 get_tazwok_config
3413 source_lib report
3414 report start
3415 if [ "$forced" ]; then
3416 rm -f $WOK/*/md5
3417 unset forced
3418 fi
3419 if [ "$missing" ]; then
3420 pkg=$(ls -1 $WOK)
3421 else
3422 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3423 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3424 } | sort -u)"
3425 fi
3426 gen_cook_list
3427 ;;
3428 cook-commit)
3429 check_root
3430 get_options_list="missing forced"
3431 get_tazwok_config
3432 source_lib report
3433 report start
3434 if [ "$forced" ]; then
3435 rm -f $WOK/*/md5
3436 unset forced
3437 fi
3438 if [ "$missing" ]; then
3439 pkg=$(ls -1 $WOK)
3440 else
3441 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3442 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3443 } | sort -u)"
3444 fi
3445 gen_cook_list
3446 cook_list
3447 ;;
3448 cook-all)
3449 check_root
3450 get_options_list="forced missing"
3451 get_tazwok_config
3452 source_lib report
3453 report start
3454 if [ "$missing" ]; then
3455 pkg=$(ls -1 $WOK)
3456 else
3457 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3458 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3459 } | sort -u)"
3460 fi
3461 gen_cook_list
3462 cook_list
3463 ;;
3464 gen-wok-db)
3465 check_root
3466 get_tazwok_config
3467 source_lib report
3468 report start
3469 gen_wok_db
3470 ;;
3471 report)
3472 get_tazwok_config
3473 cd $PACKAGES_REPOSITORY
3474 if [ "$2" ]; then
3475 case $2 in
3476 commit|cooklist|incoming|broken|blocked)
3477 show="$2"
3478 ;;
3479 *)
3480 echo "usage : tazwok report [commit|cooklist|incoming|broken|blocked]" >&2
3481 exit 1
3482 ;;
3483 esac
3484 else
3485 show="commit cooklist incoming broken blocked"
3486 fi
3487 for i in $show; do
3488 if [ -s $i ]; then
3489 echo ""
3490 echo -e "\033[1m$i\033[0m"
3491 horizontal_line
3492 cat $i
3493 horizontal_line
3494 echo ""
3495 fi
3496 done
3497 ;;
3498 check-incoming)
3499 check_root
3500 get_options_list="forced"
3501 get_tazwok_config
3502 source_lib report
3503 report start
3504 [ -f $LOCAL_RESOSITORY/incoming ] && rm [ -f $LOCAL_REPOSITORY/incoming ]
3505 report step "Checking $INCOMING_REPOSITORY"
3506 report open-bloc
3507 [ -f $LOCAL_REPOSITORY/log/incoming.html ] && rm $LOCAL_REPOSITORY/log/incoming.html
3508 report sublog $LOCAL_REPOSITORY/log/incoming.html
3509 echo "incoming" > $LOCAL_REPOSITORY/log/package
3510 check_for_incoming
3511 report end-sublog
3512 report close-bloc
3513 ;;
3514 configure-chroot)
3515 check_root
3516 get_tazwok_config
3517 if [ -f /usr/bin/tazchroot ]; then
3518 cd $LOCAL_REPOSITORY
3519 configure_tazchroot
3520 else
3521 echo "The package tazchroot needs to be installed" >&2
3522 exit 1
3523 fi
3524 ;;
3525 chroot)
3526 check_root
3527 get_tazwok_config
3528 # Merge this and the other chroot function ?.
3529 if [ -f /usr/bin/tazchroot ]; then
3530 cd $LOCAL_REPOSITORY
3531 [ ! -f tazchroot.conf ] && configure_tazchroot
3532 tazchroot
3533 else
3534 echo "The package tazchroot needs to be installed" >&2
3535 exit 1
3536 fi
3537 ;;
3538 cook-toolchain)
3539 check_root
3540 get_tazwok_config
3541 echo -n "" > $PACKAGES_REPOSITORY/broken
3542 if [ -f /usr/bin/tazchroot ]; then
3543 cd $LOCAL_REPOSITORY
3544 [ -f tazchroot.conf ] || configure_tazchroot
3546 # Plan to recook all packages.
3547 if tazchroot cook-toolchain; then
3548 source_lib report
3549 report start
3550 pkg="$(grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt \
3551 $INCOMING_REPOSITORY/packages.txt | sort -u)"
3552 forced=yes
3553 gen_cook_list
3554 fi
3556 # Remove chroot where toolchain has been cooked.
3557 source $LOCAL_REPOSITORY/tazchroot.conf
3558 rm -r $LOCAL_REPOSITORY/chroot
3560 else
3561 echo -e "\nThe package tazchroot needs to be installed.\n" >&2
3562 exit 1
3563 fi
3564 ;;
3565 webserver)
3566 check_root
3567 get_tazwok_config
3568 if [ "$ARG" = on ]; then
3569 if [ "$WEBSERVER" ] && [ -f "$WEBSERVER/repositories.list" ] && \
3570 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3571 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3572 exit 1
3573 fi
3574 if ! [ -f $LOCAL_REPOSITORY/tazchroot.conf ]; then
3575 tazwok configure-chroot ${undigest:+--undigest=$undigest} --SLITAZ_VERSION=$SLITAZ_VERSION --SLITAZ_DIR=$SLITAZ_DIR
3576 fi
3577 for pkg in php lighttpd; do
3578 [ -d $INSTALLED/$pkg ] || missing="$missing $pkg"
3579 done
3580 if [ "$missing" ]; then
3581 echo "You need to install these packages to start webserver: $missing." >&2
3582 exit 1
3583 fi
3584 if [ ! -f "$LOCAL_REPOSITORY/tazwok.conf" ]; then
3585 echo "Copying /etc/slitaz/tazwok.conf to $LOCAL_REPOSITORY/tazwok.conf: webserver is configured repository-by-repository."
3586 cp /etc/slitaz/tazwok.conf $LOCAL_REPOSITORY
3587 fi
3588 if ! [ "$WEBSERVER" ]; then
3589 echo -n "Where to store php pages (default: /var/www/vhosts/bb)? "
3590 read WEBSERVER
3591 [ "$WEBSERVER" ] || WEBSERVER="/var/www/vhosts/bb"
3592 fi
3593 if [ -f "$WEBSERVER/repositories.list" ] && \
3594 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3595 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3596 exit 1
3597 fi
3598 mkdir -p $WEBSERVER
3599 echo "${undigest:-$SLITAZ_VERSION}" >> $WEBSERVER/repositories.list
3600 for file in index.php log.php download.php; do
3601 [ -f "$WEBSERVER/$file" ] || ln -s /usr/share/slitaz/web-bb/$file $WEBSERVER
3602 done
3603 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3604 ln -s $dir $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3605 done
3606 source $LOCAL_REPOSITORY/tazchroot.conf
3607 echo "<?php
3609 // Web interface configuration
3611 \$version=\"${undigest:-$SLITAZ_VERSION}\";
3612 \$chroot=\"$chroot_dir\";
3613 \$lockfile=\"\$chroot/proc/1/status\";
3614 \$db_dir=\"$PACKAGES_REPOSITORY\";
3615 \$log_dir=\"$LOCAL_REPOSITORY/log\";
3616 \$packages=\"$PACKAGES_REPOSITORY\";
3617 \$incoming=\"$INCOMING_REPOSITORY\";
3618 \$wok=\"$WOK\";
3620 ?>" > $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3621 [ -L "$WEBSERVER/web" ] || ln -s /usr/share/slitaz/web $WEBSERVER
3622 echo "WEBSERVER=\"$WEBSERVER\"" >> $LOCAL_REPOSITORY/tazwok.conf
3623 if [ -L "$WEBSERVER/conf.php" ]; then
3624 echo "Do you want to make ${undigest:-$SLITAZ_VERSION} the default page (y/N) ? "
3625 read answer
3626 if [ "$answer" = y ]; then
3627 rm $WEBSERVER/conf.php
3628 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3629 fi
3630 else
3631 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3632 fi
3633 elif [ "$ARG" = off ]; then
3634 if ! [ "$WEBSERVER" ]; then
3635 echo "No webserver running for ${undigest:-$SLITAZ_VERSION}" >&2
3636 exit 1
3637 fi
3638 sed '/^WEBSERVER/d' -i $LOCAL_REPOSITORY/tazwok.conf
3639 sed "/^${undigest:-$SLITAZ_VERSION}$/d" -i $WEBSERVER/repositories.list
3640 rm $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3641 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3642 rm $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3643 done
3644 if ! [ -s "$WEBSERVER/repositories.list" ]; then
3645 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"
3646 rm $WEBSERVER/conf.php
3647 elif [ "$(readlink $WEBSERVER/conf.php)" = "$WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php" ]; then
3648 echo "${undigest:-$SLITAZ_VERSION} was the default version to use; switched to : $(sed 1!d $WEBSERVER/repositories.list)"
3649 rm $WEBSERVER/conf.php
3650 ln -s $WEBSERVER/conf-$(sed 1!d $WEBSERVER/repositories.list).php $WEBSERVER/conf.php
3651 fi
3652 else
3653 echo "Usage: tazwok webserver on/off" >&2
3654 exit 1
3655 fi
3656 ;;
3657 block)
3658 # Add a pkg name to the list of blocked packages.
3659 get_tazwok_config
3660 check_root
3661 check_for_package_on_cmdline
3662 if ! [ -f $WOK/$PACKAGE/receipt ]; then
3663 echo "Can't find $PACKAGE in wok." >&2
3664 echo ""
3665 exit 1
3666 fi
3667 echo ""
3668 if grep -qs "^$PACKAGE$" $blocked; then
3669 echo "$PACKAGE is already in the blocked packages list." >&2
3670 echo ""
3671 exit 1
3672 else
3673 echo -n "Adding $PACKAGE to : $blocked... "
3674 echo "$PACKAGE" >> $blocked
3675 status
3676 if grep -q "^$PACKAGE$" $cooklist; then
3677 echo -n "Removing $PACKAGE from : $cooklist... "
3678 sed -i /"^$PACKAGE$"/d $cooklist
3679 status
3680 fi
3681 fi
3682 echo "" ;;
3683 unblock)
3684 # Remove a pkg name from the list of blocked packages.
3685 get_tazwok_config
3686 check_root
3687 check_for_package_on_cmdline
3688 if ! [ -f $WOK/$PACKAGE/receipt ]; then
3689 echo "Can't find $PACKAGE in wok." >&2
3690 echo ""
3691 exit 1
3692 fi
3693 echo ""
3694 if grep -qs "^$PACKAGE$" $blocked; then
3695 echo -n "Removing $PACKAGE from : $blocked... "
3696 sed -i /"^$PACKAGE$"/d $blocked
3697 sed -i '/^$/d' $blocked
3698 status
3699 else
3700 echo "$PACKAGE is not in the blocked packages list." >&2
3701 echo ""
3702 exit 1
3703 fi
3704 echo "" ;;
3705 usage|*)
3706 # Print usage also for all unknown commands.
3708 usage
3709 ;;
3710 esac
3712 # If a cook command has been used, refresh ID of the repository to avoid
3713 # useless upgrade at next cook command.
3714 case $COMMAND in
3715 cook*)
3716 for repo in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY \
3717 $( [ "$undigest" -a ! "$ref_USE_ONLINE_PKG" ] && echo $ref_PACKAGES_REPOSITORY ); do
3718 [ -f $repo/ID ] || continue
3719 MIRROR_path=$(grep -l "^$repo$" $LOCALSTATE/mirror $LOCALSTATE/undigest/*/mirror)
3720 LOCALSTATE_path=${MIRROR_path%/mirror}
3721 cp -a $repo/ID $LOCALSTATE_path
3722 done
3723 ;;
3724 esac
3726 report stop 2>/dev/null
3727 exit 0