tazwok view tazwok @ rev 403

Merge changes from default (4.3)
author Antoine Bodin <gokhlayeh@slitaz.org>
date Fri Mar 04 03:01:03 2011 +0100 (2011-03-04)
parents c02e68d59ecf 13e14fe449a3
children 20b8ac3d3a68
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 excepted 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 clean Clean all generated files in the package tree.
53 new-tree Prepare a new package tree and receipt (--interactive).
54 gen-list (Re-)Generate a packages list for a repository.
55 check-list Update packages lists for a repository.
56 gen-wok-db (Re-)Generate wok lists with depends and wanted datas.
57 gen-clean-wok Generate a clean wok in a dir.
58 clean-wok Clean entirely the wok.
59 clean-src Remove old/unrelated-to-wok sources.
60 remove Remove a package from the wok.
61 webserver Enable/disable webserver on localhost.
62 update-wok Update the wok.
63 maintainers List all maintainers in the wok.
64 maintained-by List packages maintained by a contributor.
65 tags List all tags used in wok receipts.
66 block Add package from the blocked list to prevent cooking it.
67 unblock Remove package from the blocked list.\n
69 You can use `basename $0` command --help to list avaible options.
70 \033[1mImportant - *: \033[0m Commands which need a rewrite."
71 }
73 # This function display an error message without returning any error code.
74 # It also log the message in source package's warnings.txt; this file can be
75 # used on an eventual package page on website to display cooking warnings.
76 tazwok_warning()
77 {
78 echo -e "tazwok: $1" >&2
79 echo -e "$1" >> $WOK/${WANTED:-$PACKAGE}/warning.txt
80 return
81 }
83 ########################################################################
84 # TAZWOK VARIABLES & INITIAL CONFIGURATION
85 ########################
87 # Check if all packages are up to date into build environnement
88 check_env_status()
89 {
90 { [ "${COMMAND#cook}" = "$COMMAND" ] || \
91 [ "$COMMAND" = cook-toolchain ] ; } && return
92 MIRROR_path=$(grep -l "^$1$" $LOCALSTATE/mirror $LOCALSTATE/undigest/*/mirror)
94 if [ ! "$MIRROR_path" ]; then
95 echo "You are trying to cook something but you don't use $1 repository, which is \
96 needed for this operation." | fold -s >&2
97 exit 1
98 fi
100 LOCALSTATE_path=${MIRROR_path%/mirror}
102 # Check is possible only if repository use ID.
103 if [ "${MIRROR_path:0:1}" = '/' ]; then
104 [ -f "$MIRROR_path/ID" ] || return
105 else
106 wget -a -s $MIRROR_path/ID 2>/dev/null || return
107 fi
109 [ -f $LOCALSTATE_path/ID ] && ID=$(cat $LOCALSATE_path/ID)
111 if [ "$LOCALSTATE_path" = "$LOCALSTATE" ]; then
112 tazpkg recharge main
113 else
114 tazpkg recharge ${LOCALSTATE_path##*/}
115 fi
117 [ "$(cat $LOCALSTATE_path/ID)" = "$ID" ] || env_status=1
118 }
120 get_tazwok_config()
121 {
122 # Get configuration file.
123 get_config
125 # Define & get options.
126 get_options_list="$get_options_list SLITAZ_DIR SLITAZ_VERSION undigest"
127 get_options
129 LOCAL_REPOSITORY=$SLITAZ_DIR/${undigest:-$SLITAZ_VERSION}
131 if ! [ "$save_dir" ]; then
132 if [ -f $LOCAL_REPOSITORY/tazwok.conf ] || [ -f $LOCAL_REPOSITORY/slitaz.conf ]; then
133 save_dir=$LOCAL_REPOSITORY
134 [ -f $LOCAL_REPOSITORY/slitaz.conf ] && source $LOCAL_REPOSITORY/slitaz.conf
135 cd $save_dir
136 get_tazwok_config
137 unset save_dir
138 return
139 fi
140 fi
142 # The path to the most important files/dir used by Tazwok.
143 PACKAGES_REPOSITORY=$LOCAL_REPOSITORY/packages
144 WOK=$LOCAL_REPOSITORY/wok
145 INCOMING_REPOSITORY=$LOCAL_REPOSITORY/packages-incoming
146 SOURCES_REPOSITORY=$LOCAL_REPOSITORY/src
147 set_common_path
148 dep_db=$INCOMING_REPOSITORY/wok-depends.txt
149 wan_db=$INCOMING_REPOSITORY/wok-wanted.txt
150 cookorder=$PACKAGES_REPOSITORY/cookorder.txt
153 # Check that packages are up to date if user intend to cook.
154 check_env_status ${USE_ONLINE_PKG:-$PACKAGES_REPOSITORY}
155 check_env_status $INCOMING_REPOSITORY
157 # In case undigest is used, we need to upgrade system.
158 if [ "$undigest" ]; then
159 ref_PACKAGES_REPOSITORY=$SLITAZ_DIR/$SLITAZ_VERSION/packages
160 if [ -f $SLITAZ_DIR/$SLITAZ_VERSION/tazwok.conf ] && \
161 grep -q ^USE_ONLINE_PKG $SLITAZ_DIR/$SLITAZ_VERSION/tazwok.conf; then
162 ref_USE_ONLINE_PKG=$(source $SLITAZ_DIR/$SLITAZ_VERSION/tazwok.conf && \
163 echo $USE_ONLINE_PKG)
164 fi
166 check_env_status ${ref_USE_ONLINE_PKG:-$ref_PACKAGES_REPOSITORY}
167 cd $ref_PACKAGES_REPOSITORY
168 if [ "$ref_USE_ONLINE_PKG" ]; then
169 ref_dep_db=$LOCALSTATE_path/wok-depends.txt
170 ref_wan_db=$LOCALSTATE_path/wok-wanted.txt
171 else
172 ref_dep_db=$ref_PACKAGES_REPOSITORY/wok-depends.txt
173 ref_wan_db=$ref_PACKAGES_REPOSITORY/wok-wanted.txt
174 fi
176 for file in $ref_dep_db $ref_wan_db; do
177 [ -f "$file" ] && continue
178 missing_file=t
179 echo "$file is missing." >&2
180 done
181 if [ "$missing_file" ]; then
182 echo "
183 Theses files are needed to get datas about packages from the reference repository $SLITAZ_VERSION. \
184 If you don't intend to build this reference repository yourself, you should set USE_ONLINE_PKG variable \
185 into tazwok.conf of this reference repository. How-to:" | fold -s >&2
186 echo "echo 'USE_ONLINE_PKG=\"packages_repository_url\"' >> $SLITAZ_DIR/$SLITAZ_VERSION/tazwok.conf"
187 echo ""
188 exit 1
189 fi
190 fi
192 # If $env_status exists, it means an upgrade may be needed.
193 if [ "$env_status" ]; then
194 if [ -x /usr/bin/clean-chroot ]; then
195 echo y | tazpkg upgrade
196 else
197 echo "\e[0;31mWarning: \e[m"
198 echo "You're environnement may need a package upgrade."
199 echo "Upgrading is highly recommanded to ensure repository consistency."
200 echo "You can (E)xit, (U)pgrade, or (C)ontinue."
201 echo -n "What do you want to do ?"
202 read answer
203 case $answer in
204 [Cc]*) ;;
205 [Uu]*) echo y | tazpkg upgrade ;;
206 *) exit
207 esac
208 fi
209 fi
211 # Check commons directories, create them if user is root.
212 if test $(id -u) = 0 ; then
213 check_dir $WOK || chmod 777 $WOK
214 check_dir $LOCAL_REPOSITORY/clean-wok || chmod 777 $LOCAL_REPOSITORY/clean-wok
215 check_dir $PACKAGES_REPOSITORY
216 check_dir $SOURCES_REPOSITORY
217 check_dir $INCOMING_REPOSITORY
218 check_dir $LOCAL_REPOSITORY/log
219 [ -f $dep_db ] || touch $dep_db
220 [ -f $wan_db ] || touch $wan_db
221 [ -f $cookorder ] || touch $cookorder
222 for file in broken blocked commit incoming cooklist; do
223 [ ! -f $PACKAGES_REPOSITORY/$file ] && touch $PACKAGES_REPOSITORY/$file
224 done
225 touch $SOURCES_REPOSITORY/sources.list
226 fi
228 # Limit memory usage.
229 ulimit -v $(awk '/MemTotal|SwapTotal/ { n+=$2 } END { print int((n*80)/100) }' < /proc/meminfo)
231 # log steps for webserver.
232 log_step="$LOCAL_REPOSITORY/log/step"
233 run_on_exit="$run_on_exit
234 rm -f $LOCAL_REPOSITORY/log/step
235 rm -f $LOCAL_REPOSITORY/log/package"
236 }
238 # Used in several functions.
239 set_common_path()
240 {
241 # The receipt is used to compile the source code and
242 # generate suitable packages for Tazpkg.
243 RECEIPT="$WOK/$PACKAGE/receipt"
245 # The path to the process log file.
246 LOG="$WOK/$PACKAGE/process.log"
247 }
249 ########################################################################
250 # TAZWOK CHECK FUNCTIONS
251 ########################
253 # Check for a package name on cmdline.
254 check_for_package_on_cmdline()
255 {
256 if [ ! "$PACKAGE" ]; then
257 echo -e "\nYou must specify a package name on the command line." >&2
258 echo -e "Example : tazwok $COMMAND package\n" >&2
259 exit 1
260 fi
261 }
263 # Check for the receipt of a package used to cook.
264 check_for_receipt()
265 {
266 if [ ! -f "$RECEIPT" ]; then
267 echo -e "\nUnable to find the receipt : $RECEIPT\n" >&2
268 exit 1
269 fi
270 }
272 # Check for a specified file list on cmdline.
273 check_for_list()
274 {
275 if [ ! "$LIST" ]; then
276 echo -e "\nPlease specify the path to the list of packages to cook.\n" >&2
277 exit 1
278 fi
280 # Check if the list of packages exists.
281 if [ -f "$LIST" ]; then
282 LIST=`cat $LIST`
283 else
284 echo -e "\nUnable to find $LIST packages list.\n" >&2
285 exit 1
286 fi
288 if [ ! "$LIST" ]; then
289 echo -e "\nList is empty.\n" >&2
290 exit 1
291 fi
292 }
294 check_for_pkg_in_wok()
295 {
296 [ -f $WOK/$PACKAGE/receipt ] && return
297 if [ "$undigest" ]; then
298 [ -f "$SLITAZ_VERSION/wok/$PACKAGE/receipt" ] && return 1
299 grep -q ^$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages/packages.txt && return 1
300 fi
301 echo "Can't find $PACKAGE in wok or mirror" >&2
302 return 2
303 }
305 ########################################################################
306 # TAZWOK CORE FUNCTIONS
307 ########################
309 remove_src()
310 {
311 [ "$WANTED" ] && return
312 look_for_cookopt !remove_src && return
313 if [ ! -d $WOK/$PACKAGE/install ] && [ "$src" ] && [ -d "$src/_pkg" ]; then
314 check_for_var_modification _pkg src || return
315 mv "$src/_pkg" $WOK/$PACKAGE/install
316 fi
318 # Don't remove sources if a package use src variable in his
319 # genpkg_rules: it maybe need something inside.
320 for i in $PACKAGE $(look_for_rwanted); do
321 sed -n '/^genpkg_rules\(\)/','/}/'p $WOK/$i/receipt | \
322 fgrep -q '$src' && tazwok_warning "Sources will not be removed \
323 because $i use \$src in his receipt." && return
324 done
326 report step "Removing sources directory"
327 rm -fr "$src"
328 report end-step
329 }
331 # Check $COOK_OPT; usage : get_cookopt particular_opt
332 # Return error if not founded
333 # Return args if the opt is in the format opt=arg1:arg2:etc
334 look_for_cookopt()
335 {
336 for arg in $COOK_OPT; do
337 case $arg in
338 $1=*)
339 arg=${arg#$1=}
340 while [ "$arg" ]; do
341 echo "${arg%%:*}"
342 [ "${arg/:}" = "$arg" ] && return
343 arg=${arg#*:}
344 done
345 ;;
346 $1)
347 return
348 ;;
349 esac
350 done
351 return 1
352 }
354 # Check for the wanted package if specified in WANTED
355 # receipt variable. Set the $src/$_pkg variable to help compile
356 # and generate packages.
357 check_for_wanted()
358 {
359 if [ "$WANTED" ]; then
360 report "Checking for the wanted package"
361 if [ ! -d "$WOK/$WANTED" ]; then
362 report exit "\nWanted package is missing in the work directory.\n"
363 fi
365 # Checking for buildtree of Wanted package
366 if [ ! -d "$WOK/$WANTED/taz" ]; then
367 echo -e "\n\nSource files of wanted package is missing in the work directory."
368 echo -n "Would you like to build the missing package (y/N) ? " ; read anser
369 if [ "$anser" == "y" ]; then
370 tazwok cook $WANTED
371 else
372 report exit "\nWanted package source tree is missing in the work directory.\n"
373 fi
374 fi
375 report end-step
377 # Set wanted src path.
378 set_src_path && set_pkg_path
380 fi
381 }
383 # Check for build dependencies, notify user and install if specified.
384 check_for_build_depends()
385 {
386 [ "$WANTED" ] && return
387 [ "$CATEGORY" = meta ] && ! fgrep -q compile_rules $RECEIPT && return
388 [ ! "$BUILD_DEPENDS" ] && ! fgrep -q compile_rules $RECEIPT && return
389 report step "Looking for build dependencies"
391 # Keep the list of previously installed build_depends then compare
392 # it with new build_depends to know what to install and what to
393 # what to remove.
394 plan_remove=" $MISSING_PACKAGE $remove_later "
395 [ ! "${plan_remove// }" ] && unset plan_remove
396 unset MISSING_PACKAGE remove_later
397 rwanted=$(look_for_rwanted)
399 for pkg in $(scan $PACKAGE --look_for=bdep --with_dev | \
400 grep -v $(for i in $(look_for_rwanted) $PACKAGE; do echo " -e ^$i$"; done))
401 do
403 # Delay the removing of previous cook depends if they are needed
404 # for next cook too.
405 if [ ! -d "$INSTALLED/$pkg" ] ; then
406 MISSING_PACKAGE="$MISSING_PACKAGE $pkg"
407 fi
408 if [ "$plan_remove" != "${plan_remove/ $pkg }" ]; then
409 plan_remove="${plan_remove/ $pkg / }"
410 remove_later="$remove_later $pkg"
411 fi
412 if grep -q ^$pkg$ $PACKAGES_REPOSITORY/broken; then
413 broken="$broken$pkg "
414 fi
415 done
417 # Don't cook if a depend is broken.
418 if [ "$broken" ]; then
419 MISSING_PACKAGE=$plan_remove
420 echo "Can't cook $PACKAGE because broken depend(s) : $broken" >&2
421 unset plan_remove broken
423 # Set report step to failed.
424 report_return_code=1
425 report end-step
426 return 1
427 fi
428 if [ "$MISSING_PACKAGE" ]; then
429 install_missing()
430 {
431 echo "Installing missing packages : $MISSING_PACKAGE"
432 for pkg in $MISSING_PACKAGE; do
433 [ -d "$INSTALLED/$pkg" ] || tazpkg get-install $pkg
434 done
435 }
436 if [ "$auto_install" = yes ]; then
437 install_missing
438 else
439 echo "================================================================================"
440 for pkg in $MISSING_PACKAGE
441 do
442 echo "Missing : $pkg"
443 done
444 echo "================================================================================"
445 echo "You can continue, exit or install missing dependencies."
446 echo -n "Install, continue or exit (install/y/N) ? "; read answer
447 case $answer in
448 install)
449 install_missing ;;
450 y|yes)
451 unset MISSING_PACKAGE;;
452 *)
453 report stop
454 exit 0 ;;
455 esac
456 fi
457 fi
458 report end-step
459 remove_build_depends $plan_remove
460 unset plan_remove
461 }
463 remove_build_depends()
464 {
465 [ "$1" ] || return
466 report step "Removing previous build dependencies"
467 echo "Removing theses packages : $@"
468 for pkg in $@; do
469 [ -f "$INSTALLED/$pkg/receipt" ] && tazpkg remove $pkg --auto
470 done
471 cd $PWD
472 report end-step
473 }
475 # Check if we can use the new way to handle tarball
476 # or if we keep the previous method by check for
477 # _pkg=/src= in receipt and reverse-wanted.
478 check_for_var_modification()
479 {
480 for var in $@; do
481 for pkg in $PACKAGE $(look_for_wanted) $(look_for_rwanted); do
482 [ -f $WOK/$pkg/receipt ] || continue
483 fgrep -q "$var=" $WOK/$pkg/receipt && return 1
484 done
485 done
487 # Tweak to make if; then...; fi function working with this one.
488 echo -n ""
489 }
491 set_src_path()
492 {
493 if check_for_var_modification src _pkg; then
494 src=$WOK/${WANTED:-$PACKAGE}/${WANTED:-$PACKAGE}-$VERSION
495 else
496 tazwok_warning "Use original name or tarball root directory because src/_pkg are defined into the receipt (this is no more needed!)."
497 src=$WOK/${WANTED:-$PACKAGE}/${SOURCE:-${WANTED:-$PACKAGE}}-$VERSION
498 fi
499 stuff=$WOK/$PACKAGE/stuff
500 [ "$WANTED" ] && wanted_stuff=$WOK/$WANTED/stuff
501 }
503 set_pkg_path()
504 {
505 if [ -d $WOK/${WANTED:-$PACKAGE}/install ] ; then
506 _pkg=$WOK/${WANTED:-$PACKAGE}/install
507 else
508 _pkg=$src/_pkg
509 fi
510 }
512 # Output $VERSION-$EXTRAVERSION using packages.txt
513 get_pkg_version()
514 {
515 [ "$PACKAGE" ] || return
516 grep -m1 -A1 -sh ^$PACKAGE$ $1/packages.txt | tail -1 | sed 's/ *//'
517 }
519 remove_previous_package()
520 {
521 [ "$prev_VERSION" ] || return
522 if [ "$VERSION$EXTRAVERSION" != "$prev_VERSION" ]; then
523 rm -f $1/$PACKAGE-$prev_VERSION.tazpkg
524 fi
525 return 0
526 }
528 # Check for src tarball and wget if needed.
529 check_for_tarball()
530 {
531 [ "$WGET_URL" ] || return 0
532 look_for_cookopt !unpack && nounpack=yes
533 report step "Checking for source tarball: $PACKAGE"
534 local repack_src=$repack_src TARBALL=$TARBALL
535 if [ "$repack_src" = yes ] && look_for_cookopt !repack_src; then
536 repack_src=no
537 fi
538 if [ "$target" ]; then
539 src="$target"
540 else
541 set_src_path
542 fi
543 tmp_src=$tmp/tarball-$$
544 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
545 [ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] ; then
546 cd $SOURCES_REPOSITORY
547 if [ "$SOURCE" ]; then
548 alt_url="http://mirror.slitaz.org/sources/packages/${SOURCE:0:1}/$SOURCE-$VERSION.tar.lzma"
549 alt_url2="http://mirror.slitaz.org/sources/packages/${SOURCE:0:1}/$TARBALL"
550 else
551 alt_url="http://mirror.slitaz.org/sources/packages/${PACKAGE:0:1}/$PACKAGE-$VERSION.tar.lzma"
552 alt_url2="http://mirror.slitaz.org/sources/packages/${PACKAGE:0:1}/$TARBALL"
553 fi
554 download $WGET_URL $alt_url $alt_url2 http://mirror.slitaz.org/sources/packages/${file:0:1}/$file
555 unset alt_url
556 unset alt_url2
557 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
558 [ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && \
559 [ ! -d $tmp_src ]; then
560 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n" >&2
561 report end-step
562 return 1
563 fi
564 fi
565 report end-step
566 if { [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && [ "$nounpack" ] ; } || \
567 { [ -f "$SOURCES_REPOSITORY/$TARBALL" ] && [ "$repack_src" != yes ] && [ "$nounpack" ] ; }; then
568 [ -d "$tmp_src" ] && rm -r $tmp_src
569 return 0
570 fi
572 # Untaring source if necessary. We don't need to extract source if
573 # the package is built with a wanted source package.
574 if [ "$WANTED" ]; then
575 [ -d "$tmp_src" ] && rm -r $tmp_src
576 return
577 fi
579 report step "Untaring source tarball"
581 # Log process.
582 echo "untaring source tarball" >> $LOG
584 # If $tmp_src exists, there's already the unpacked tarball into it.
585 if ! [ -d $tmp_src ]; then
586 mkdir $tmp_src
587 if [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && [ "$repack_src" = yes ]; then
588 lzma d $SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma -so | \
589 tar xf - -C $tmp_src
590 repack_src=no
591 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
592 elif [ -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
593 case "$TARBALL" in
594 *zip|*xpi) cd $tmp_src && unzip -o $SOURCES_REPOSITORY/$TARBALL ;;
595 *bz2|*tbz|*gem) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
596 *tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
597 *lzma|*lz) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
598 *xz) unxz -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
599 *Z|*taz) uncompress -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
600 *gz) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
601 *rpm) cd $tmp_src && rpm2cpio $SOURCES_REPOSITORY/$TARBALL | cpio -idm --quiet;;
603 # It's a plain file or something receipt unpack itself.
604 *)
605 mkdir $tmp_src/${SOURCE:-$PACKAGE}-$VERSION
606 cp $SOURCES_REPOSITORY/$TARBALL $tmp_src/${src##*/}
607 ;;
609 esac || { report end-step
610 rm -f $SOURCES_REPOSITORY/$TARBALL
611 rm -r $tmp_src
612 return 1
613 }
614 fi
616 # Check if uncompressed tarball is in a root dir or not.
617 if [ "$(ls -A $tmp_src | wc -l)" -gt 1 ] || [ -f $(echo $tmp_src/*) ]; then
618 if check_for_var_modification src _pkg; then
619 mv $tmp_src $tmp_src-1
620 mkdir $tmp_src
621 mv $tmp_src-1 $tmp_src/${SOURCE:-$PACKAGE}-$VERSION
622 else
623 mv $tmp_src/* $WOK/$PACKAGE
624 repack_src=no
625 rm -r $tmp_src
626 tazwok_warning "Put all files into $WOK/$PACKAGE; not sure about how to handle this tarball (no root dir)... Please try to remove src/_pkg definition from receipt if you encounter a problem."
627 fi
628 fi
629 fi
631 if [ "$repack_src" = yes ]; then
632 report step "Repacking sources in .tar.lzma format"
633 [ "$TARBALL" ] && rm -f $SOURCES_REPOSITORY/$TARBALL
634 TARBALL=${SOURCE:-$PACKAGE}-$VERSION.tar.lzma
635 cd $tmp_src
636 tar -c * | lzma e $SOURCES_REPOSITORY/$TARBALL -si
637 fi
639 # Remove previous tarball if no other package needs it. We take care to
640 # keep tarball if the same package use it into main repository.
641 if [ "$TARBALL" ]; then
642 previous_tarball=$(grep ^$PACKAGE:incoming $SOURCES_REPOSITORY/sources.list | cut -f2)
643 if [ "$previous_tarball" ]; then
644 sed "/^$PACKAGE:incoming/ s/.*/$PACKAGE:incoming\t$TARBALL/" \
645 -i $SOURCES_REPOSITORY/sources.list
646 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
647 rm -f $SOURCES_REPOSITORY/$previous_tarball
648 else
649 echo -e "$PACKAGE:incoming\t$TARBALL" >> $SOURCES_REPOSITORY/sources.list
650 fi
651 fi
653 if [ "$nounpack" ]; then
654 [ -d "$tmp_src" ] && rm -r $tmp_src
655 report end-step
656 return
657 fi
658 if [ ! -d "$src" ]|| [ "$target" ]; then
659 # Permissions settings.
660 chown -R root.root "$tmp_src"
661 if [ -d "$src" ]; then
662 mkdir -p $src
663 for f in $tmp_src/*/*; do
664 cp -a $f $src || { report end-step; rm -r $tmp_src; return 1; }
665 done
666 else
667 if ! check_for_var_modification src _pkg && ! [ "$target" ]; then
668 src="${src%/*}/$(ls $tmp_src)"
669 fi
670 mv $(echo $tmp_src/*) "$src" || { report end-step; rm -r $tmp_src; return 1; }
671 fi
672 rm -r $tmp_src
673 else
674 [ -d "$tmp_src" ] && rm -r $tmp_src
675 echo "There's already something at $src. Abort." >&2
676 fi
677 report end-step
678 }
680 # Log and execute compile_rules function if it exists, to configure and
681 # make the package if it exists.
682 check_for_compile_rules()
683 {
684 if grep -q ^compile_rules $RECEIPT; then
685 echo "executing compile_rules" >> $LOG
686 report step "Executing compile_rules"
687 cd $WOK/$PACKAGE
688 rm -f /tmp/config.site
689 ulimit -d unlimited
690 ulimit -m unlimited
692 # Free some RAM by cleaning cache if option is enabled.
693 freeram=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
695 # Disable -pipe in CFLAGS/CXXFLAGS if less than 512Mb of free
696 # RAM are available.
697 if [ "$freeram" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" -o \
698 "$CXXFLAGS" != "${CXXFLAGS/-pipe}" ]; then
699 tazwok_warning "Disabling -pipe compile flag because only ${freeram}b of RAM are available."
700 CFLAGS="${CFLAGS/-pipe}"
701 CXXFLAGS="${CXXFLAGS/-pipe}"
702 fi
703 unset freeram
705 # Set cook environnement variables.
706 [ "$src" ] || set_src_path
707 [ "$DESTDIR" ] || DESTDIR="$WOK/$PACKAGE/install"
708 [ "$CONFIG_SITE" ] || CONFIG_SITE=/etc/config.site
709 export CFLAGS CXXFLAGS MAKEFLAGS DESTDIR BUILD_HOST \
710 CONFIG_SITE default_prefix \
711 default_datarootdir default_datadir default_localedir \
712 default_infodir default_mandir default_build default_host
713 local LC_ALL=POSIX LANG=POSIX
714 compile_rules
716 # Check if config.site has been used.
717 # /!\ disabled since it screw the return_code of the step.
718 #if [ -f /tmp/config.site ]; then
719 # rm /tmp/config.site
720 #else
721 # tazwok_warning "config.site hasn't been used during \
722 #configuration process."
723 #fi
724 report end-step
725 fi
726 }
728 # Check for loop in deps tree. /!\ can be removed
729 check_for_deps_loop()
730 {
731 local list
732 local pkg
733 local deps
734 pkg=$1
735 shift
736 [ -n "$1" ] || return
737 list=""
739 # Filter out already processed deps
740 for i in $@; do
741 case " $ALL_DEPS" in
742 *\ $i\ *);;
743 *) list="$list $i";;
744 esac
745 done
746 ALL_DEPS="$ALL_DEPS$list "
747 for i in $list; do
748 [ -f $i/receipt ] || continue
749 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
750 case " $deps " in
751 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
752 *) check_for_deps_loop $pkg $deps;;
753 esac
754 done
755 }
757 # Function used by download().
758 revert_vcs_failure()
759 {
760 cd $SOURCES_REPOSITORY
761 rm -r $tmp_src
762 }
764 download()
765 {
766 if [ "$COMMAND" = get-src ]; then
767 if [ "${DEPENDS/tar}" != "$DEPENDS" ] || [ "${BUILD_DEPENDS/tar}" != "$BUILD_DEPENDS" ]; then
768 [ -f $INSTALLED/tar/receipt ] || tazpkg get-install tar --forced
769 fi
770 fi
771 for file in $@; do
772 echo "Downloading from ${file#*|}..."
773 case "$file" in
774 git\|*)
775 file=${file#git|}
776 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/git/receipt ] && tazpkg get-install git --forced
777 if [ -f $INSTALLED/git/receipt ]; then
778 mkdir $tmp_src
779 cd $tmp_src
780 if [ "$BRANCH" ]; then
781 git clone $file ${src##*/} && cd ${src##*/} && \
782 git checkout $BRANCH && rm -rf .git* && break
783 else
784 git clone $file ${src##*/} && rm -rf ${src##*/}/.git* && break
785 fi
786 revert_vcs_failure
787 else
788 tazwok_warning "Needs git to download the source tarball from $file, please add it as build-depend."
789 continue
790 fi
791 ;;
792 subversion\|*)
793 file=${file#subversion|}
794 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/subversion/receipt ] && tazpkg get-install subversion --forced
795 if [ -f $INSTALLED/subversion/receipt ]; then
796 mkdir $tmp_src
797 cd $tmp_src
798 if [ "$BRANCH" ]; then
799 echo t | svn co $file -r $BRANCH ${src##*/} && rm -rf ${src##*/}/.svn* && break
800 else
801 echo t | svn co $file ${src##*/} && rm -rf ${src##*/}/.svn* && break
802 fi
803 revert_vcs_failure
804 else
805 tazwok_warning "Needs subversion to download the source tarball from $file, please add it as build-depend."
806 continue
807 fi
808 ;;
809 mercurial\|*)
810 file=${file#mercurial|}
811 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/mercurial/receipt ] && tazpkg get-install mercurial --forced
812 if [ -f $INSTALLED/mercurial/receipt ]; then
813 mkdir $tmp_src
814 cd $tmp_src
815 if [ "$BRANCH" ]; then
816 hg clone $file --rev $BRANCH ${src##*/} && rm -rf ${src##*/}/.hg* && break
817 else
818 hg clone $file ${src##*/} && rm -rf ${src##*/}/.hg* && break
819 fi
820 revert_vcs_failure
821 else
822 tazwok_warning "Needs mercurial to download the source tarball from $file, please add it as build-depend."
823 continue
824 fi
825 ;;
826 https*)
827 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/wget/receipt ] && tazpkg get-install wget --forced
828 if [ -d $INSTALLED/wget ]; then
829 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
830 wget -q --no-check-certificate -O $TARBALL $file && break
831 else
832 wget -q --no-check-certificate $file && break
833 fi
834 else
835 tazwok_warning "Needs wget to download the source tarball from $file, please add it as build-depend."
836 continue
837 fi
838 ;;
839 http*|ftp*)
840 # Handle crappy URL.
841 if [ "$COMMAND" = get-src ]; then
842 if [ "${DEPENDS/wget}" != "$DEPENDS" ] || [ "${BUILD_DEPENDS/wget}" != "$BUILD_DEPENDS" ]; then
843 [ -f $INSALLED/wget/receipt ] || tazpkg get-install wget --forced
844 fi
845 fi
846 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
847 wget -q -O $TARBALL $file && break
848 else
849 wget -q $file && break
850 fi
851 ;;
852 esac
853 done
854 }
856 # Regenerate every package that wants a PACKAGE compiled
857 refresh_packages_from_compile()
858 {
859 # make tazwok genpkg happy
860 mkdir $WOK/$PACKAGE/taz
862 # Cook rwanted in default or specied order
863 genlist=" $(look_for_rwanted | tr '\n' ' ') "
864 for i in $(look_for_cookopt genpkg | tac); do
865 [ "${genlist/ $i }" = "$genlist" ] && continue
866 genlist=" $i${genlist/ $i / }"
867 done
868 if [ "$genlist" ]; then
869 local PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
870 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
871 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
872 src _pkg DESTDIR CONFIG_SITE RECEIPT LOG stuff wanted_stuff
873 for PACKAGE in $genlist; do
874 set_common_path
875 gen_package
876 done
877 fi
878 }
880 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
881 # so some packages need to copy these files with the receipt and genpkg_rules.
882 # This function is executed by gen_package when 'tazwok genpkg'.
883 copy_generic_files()
884 {
885 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
886 # using generic variables and $LOCALE from Tazwok config file.
887 if [ "$LOCALE" ]; then
888 if [ -d "$_pkg/usr/share/locale" ]; then
889 for i in $LOCALE
890 do
891 if [ -d "$_pkg/usr/share/locale/$i" ]; then
892 mkdir -p $fs/usr/share/locale
893 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
894 fi
895 done
896 fi
897 fi
899 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
900 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
901 # in pkg receipt.
902 if [ "$GENERIC_PIXMAPS" != "no" ]; then
903 if [ -d "$_pkg/usr/share/pixmaps" ]; then
904 mkdir -p $fs/usr/share/pixmaps
905 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
906 $fs/usr/share/pixmaps 2>/dev/null
907 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
908 $fs/usr/share/pixmaps 2>/dev/null
909 fi
911 # Custom or homemade PNG pixmap can be in stuff.
912 if [ -f "stuff/$PACKAGE.png" ]; then
913 mkdir -p $fs/usr/share/pixmaps
914 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
915 fi
916 fi
918 # Desktop entry (.desktop).
919 if [ -d "$_pkg/usr/share/applications" ]; then
920 cp -a $_pkg/usr/share/applications $fs/usr/share
921 fi
923 # Homemade desktop file(s) can be in stuff.
924 if [ -d "stuff/applications" ]; then
925 mkdir -p $fs/usr/share
926 cp -a stuff/applications $fs/usr/share
927 fi
928 if [ -f "stuff/$PACKAGE.desktop" ]; then
929 mkdir -p $fs/usr/share/applications
930 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
931 fi
932 }
934 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
935 strip_package()
936 {
937 report step "Executing strip on all files"
939 # Binaries.
940 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
941 do
942 if [ -d "$dir" ]; then
943 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
944 fi
945 done
947 # Libraries.
948 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
949 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
950 report end-step
951 }
953 # Remove .pyc and .pyo files from packages
954 py_compiled_files_remove()
955 {
956 report step "Removing all .pyc and .pyo files from package ..."
957 find $fs -type f -name "*.pyc" -delete 2>/dev/null
958 find $fs -type f -name "*.pyo" -delete 2>/dev/null
959 report end-step
960 }
962 # Check FSH in a slitaz package (Path: /:/usr)
963 check_fsh()
964 {
965 cd $WOK/$PACKAGE/taz/*/fs
966 if [ -z "$(find * -type f)" ] && [ "$CATEGORY" != meta ]; then
967 echo "$PACKAGE fs is empty." >&2
968 cd $WOK/$PACKAGE && rm -rf taz
969 return 1
970 fi
971 [ -n "$FSH" ] || FSH="bin boot dev etc home init lib media mnt proc \
972 root sbin share sys tmp usr var vz usr/bin usr/games usr/include usr/lib \
973 usr/local usr/sbin usr/share usr/src"
974 for i in `ls -d * usr/* 2>/dev/null`
975 do
976 if ! echo $FSH | fgrep -q $i; then
977 echo "Wrong path: /$i" >&2
978 error=1
979 fi
980 done
981 if [ "$error" = "1" ]; then
982 cat << _EOT_
984 Package will install files in a non standard directory and won't be generated.
985 You may have a wrong copy path in genpkg_rules or need to add some options to
986 configure in compile_rules. Some valid options for SliTaz (Linux FSH):
988 --prefix=/usr
989 --sysconfdir=/etc
990 --libexecdir=/usr/lib/(pkgname)
991 --localstatedir=/var
992 --mandir=/usr/share/man
993 --infodir=/usr/share/info
995 For more information please read SliTaz docs and run: ./configure --help
996 ================================================================================
997 $PACKAGE package generation aborted.
999 _EOT_
1001 # Dont generate a corrupted package.
1002 cd $WOK/$PACKAGE && rm -rf taz
1003 return 1
1004 fi
1005 return 0
1008 gen_cookmd5()
1010 # md5sum of cooking stuff make tazwok able to check for changes
1011 # without hg.
1012 cd $WOK/$PACKAGE
1013 md5sum receipt > md5
1014 [ -f description.txt ] && md5sum description.txt >> md5
1015 if [ -d stuff ]; then
1016 find stuff | while read file; do
1017 md5sum $file >> md5
1018 done
1019 fi
1022 set_pkg_broken()
1024 if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
1025 echo $PACKAGE >> $PACKAGES_REPOSITORY/broken
1026 fi
1028 # Remove pkg from cooklist to avoid re-cook it if no changes happens
1029 # in the cook stuff.
1030 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist
1031 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit
1033 gen_cookmd5
1035 # Return 1 to make report know that's mother-function failed.
1036 return 1
1039 # Create a package tree and build the gziped cpio archive
1040 # to make a SliTaz (.tazpkg) package.
1041 gen_package()
1043 check_root
1044 check_for_package_on_cmdline
1045 check_for_receipt
1046 source_receipt
1048 # May compute VERSION
1049 if grep -q ^get_version $RECEIPT; then
1050 get_version
1051 fi
1052 check_for_wanted
1053 cd $WOK/$PACKAGE
1055 # Remove old Tazwok package files.
1056 [ -d "taz" ] && rm -rf taz
1058 # Create the package tree and set useful variables.
1059 fs=$WOK/$PACKAGE/taz/$PACKAGE-$VERSION/fs
1060 mkdir -p $fs
1062 # Set $src for standard package and $_pkg variables.
1063 set_src_path
1064 set_pkg_path
1066 # Execute genpkg_rules, check package and copy generic files to build
1067 # the package.
1068 report step "Building $PACKAGE with the receipt"
1069 report open-bloc
1070 if look_for_cookopt !fs; then
1072 elif grep -q ^genpkg_rules $RECEIPT; then
1074 # Log process.
1075 echo "executing genpkg_rules" >> $LOG
1076 report step "Executing genpkg_rules"
1077 ( set -e; genpkg_rules ) || { set_pkg_broken; report close-bloc; return 1; }
1078 check_fsh || { set_pkg_broken; report close-bloc; return 1; }
1079 cd $WOK/$PACKAGE
1080 report end-step
1082 # Skip generic files for packages with a WANTED variable
1083 # (dev and splited pkgs).
1084 if [ ! "$WANTED" ]; then
1085 copy_generic_files
1086 fi
1087 look_for_cookopt !strip || strip_package
1088 py_compiled_files_remove
1089 else
1090 echo "No package rules to gen $PACKAGE..." >&2
1091 set_pkg_broken
1092 report close-bloc
1093 return 1
1094 fi
1096 # Copy the receipt and description (if exists) into the binary package tree.
1097 cd $WOK/$PACKAGE
1098 report step "Copying the receipt"
1099 cp receipt taz/$PACKAGE-$VERSION
1100 report end-step
1101 if grep -q ^get_version $RECEIPT; then
1102 report step "Updating version in receipt"
1103 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
1104 taz/$PACKAGE-$VERSION/receipt
1105 report end-step
1106 fi
1107 if [ -f "description.txt" ]; then
1108 report step "Copying the description file"
1109 cp description.txt taz/$PACKAGE-$VERSION
1110 report end-step
1111 fi
1113 # Generate md5 of cooking stuff to look for commit later.
1114 gen_cookmd5
1115 echo -e "\n# md5sum of cooking stuff :" >> taz/$PACKAGE-$VERSION/receipt
1116 cat md5 | sed 's/^/# /' >> taz/$PACKAGE-$VERSION/receipt
1118 # Create the files.list by redirecting find output.
1119 report step "Creating the list of files"
1120 cd taz/$PACKAGE-$VERSION
1121 LAST_FILE=""
1122 { find fs -print; echo; } | while read file; do
1123 if [ "$LAST_FILE" ]; then
1124 case "$file" in
1125 $LAST_FILE/*)
1126 case "$(ls -ld "$LAST_FILE")" in
1127 drwxr-xr-x\ *\ root\ *\ root\ *);;
1128 *) echo ${LAST_FILE#fs};;
1129 esac;;
1130 *) echo ${LAST_FILE#fs};;
1131 esac
1132 fi
1133 LAST_FILE="$file"
1134 done > files.list
1136 # Next, check if something has changed in lib files.
1137 if fgrep -q '.so' files.list; then
1138 for rep in $INCOMING_REPOSITORY $PACKAGES_REPOSITORY \
1139 $([ "$undigest" ] && echo $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming && \
1140 echo $SLITAZ_DIR/$SLITAZ_VERSION/packages); do
1141 prev_VERSION=$(get_pkg_version $rep)
1142 [ "$prev_VERSION" ] && pkg_file=$rep/$PACKAGE-$prev_VERSION.tazpkg && break
1143 done
1144 if [ "$pkg_file" ]; then
1145 report step "Look for major/minor update in libraries"
1146 get_pkg_files $pkg_file
1147 cd $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
1148 fgrep ".so" files.list | egrep -v "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*" | \
1149 while read lib; do
1150 fgrep -q "$lib" $pkg_files_dir/files.list && continue
1151 echo "A minor/major update in libraries is detected, planning re-cook of reverse-depends of $PACKAGE."
1152 for rdep in $(scan $PACKAGE --look_for=rdep | use_wanted); do
1153 [ "$rdep" = "${WANTED:-$PACKAGE}" ] && continue
1154 grep -q ^$rdep$ $PACKAGES_REPOSITORY/blocked \
1155 $PACKAGES_REPOSITORY/cooklist && continue
1156 echo $rdep >> $PACKAGES_REPOSITORY/cooklist
1157 done
1158 regen_cooklist=yes
1159 break
1160 done
1161 rm -r $pkg_files_dir
1162 unset pkg_file
1163 report end-step
1164 fi
1165 fi
1166 if [ ! "$EXTRAVERSION" ]; then
1167 case "$PACKAGE" in
1168 linux*);;
1169 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
1170 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
1171 esac
1172 fi
1173 rm -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
1174 report step "Creating md5sum of files"
1175 while read file; do
1176 [ -L "fs$file" ] && continue
1177 [ -f "fs$file" ] || continue
1178 md5sum "fs$file" | sed 's/ fs/ /'
1179 done < files.list > md5sum
1180 report end-step
1181 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
1182 2> /dev/null | awk '{ sz=$1 } END { print sz }')
1184 # Build cpio archives. Find, cpio and gzip the fs, finish by
1185 # removing the fs tree.
1186 # Don't log this because compression always output error messages.
1187 find fs -print | cpio -o -H newc | case "$PACKAGE-$COMPRESSION" in
1188 tazpkg-lzma) gzip > fs.cpio.gz;;
1189 *-lzma) lzma e fs.cpio.lzma -si;;
1190 *) gzip > fs.cpio.gz;;
1191 esac && rm -rf fs
1192 PACKED_SIZE=$(du -chs fs.cpio.* receipt files.list md5sum \
1193 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
1194 report step "Updating receipt sizes"
1195 sed -i '/^PACKED_SIZE/d' receipt
1196 sed -i '/^UNPACKED_SIZE/d' receipt
1197 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
1198 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
1199 report end-step
1200 if [ "$EXTRAVERSION" ]; then
1201 report step "Updating receipt EXTRAVERSION"
1202 sed -i s/^EXTRAVERSION.*$// receipt
1203 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
1204 fi
1205 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1206 remove_previous_package $INCOMING_REPOSITORY
1207 report step "Creating full cpio archive"
1208 find . -print | cpio -o -H newc > $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
1210 # Restore package tree in case we want to browse it.
1211 report step "Restoring original package tree"
1212 { zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma; } | cpio --quiet -id
1213 rm fs.cpio.* && cd ..
1215 # Recook of reverse-depends if package was broken.
1216 if grep -q "^$PACKAGE$" $PACKAGES_REPOSITORY/broken; then
1217 report step "Planning re-try a cook of reverse depends"
1218 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/broken
1219 for rdep in $(look_for_rdep); do
1220 grep -q "^$rdep$" $PACKAGES_REPOSITORY/broken || continue
1221 grep -q "^$rdep$" $PACKAGES_REPOSITORY/cooklist && continue
1222 echo "Adding $rdep to the cooklist"
1223 echo $rdep >> $PACKAGES_REPOSITORY/cooklist
1224 regen_cooklist=t
1225 done
1226 report end-step
1227 fi
1228 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit
1229 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist
1231 # Log process.
1232 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
1233 report close-bloc
1234 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
1235 echo "Size : `du -sh $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
1236 echo ""
1239 ########################################################################
1240 # This section contains functions used by several other functions
1241 # bellow.
1242 ########################
1244 # Look for receipt/files.list in wok. If they can't be found, get them
1245 # from package. Accept one argument : absolute path to package.
1246 get_pkg_files()
1248 pkg_files_dir=$tmp/$(basename ${1%.tazpkg})
1249 mkdir -p $pkg_files_dir && \
1250 cd $pkg_files_dir && \
1251 cpio --quiet -idm receipt < $1 && \
1252 cpio --quiet -idm files.list < $1
1255 ########################################################################
1256 # This section contains functions to generate packages databases.
1257 ########################
1260 gen_packages_db()
1262 # pkg_repository can be $PACKAGES_REPOSITORY or $INCOMING_REPOSITORY.
1263 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1264 cd $pkg_repository
1265 report step "Generating packages lists: $pkg_repository"
1266 report open-bloc
1267 report step "Removing old files"
1268 for file in files.list.lzma packages.list packages.txt \
1269 packages.desc packages.equiv packages.md5; do
1270 [ -f $file ] && rm $file
1271 done
1272 touch files.list
1274 packages_db_start
1275 unset RECEIPT
1276 report step "Reading datas from all packages"
1277 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1278 get_packages_info
1279 done
1280 report end-step
1281 packages_db_end
1282 report close-bloc
1285 update_packages_db()
1287 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1288 cd $pkg_repository
1289 for file in packages.list packages.equiv packages.md5 packages.desc \
1290 packages.txt; do
1291 if [ ! -f "$file" ]; then
1292 gen_packages_db
1293 return
1294 fi
1295 done
1296 if [ -f files.list.lzma ]; then
1297 lzma d files.list.lzma files.list
1298 else
1299 gen_packages_db
1300 fi
1301 report step "Updating packages lists: $pkg_repository"
1302 packages_db_start
1304 # Look for removed/update packages.
1305 for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
1306 pkg="$pkg_repository/$(grep -m1 ^$PACKAGE- packages.list).tazpkg"
1307 if ! [ -f "$pkg" ]; then
1308 erase_package_info
1309 else
1310 if [ "$pkg" -nt "packages.list" ]; then
1311 updated_pkg="$updated_pkg
1312 $PACKAGE $pkg"
1313 elif [ ! -f $WOK/$PACKAGE/receipt ] && \
1314 [ "$COMMAND" = check-incoming -o "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
1315 erase_package_info
1316 echo "Removing $PACKAGE from $pkg_repository."
1317 rm $pkg
1318 [ -d $WOK/$PACKAGE ] && rm -r $WOK/$PACKAGE
1319 sed "/^$PACKAGE\t/d" -i $wan_db $dep_db $cookorder
1320 for i in cooklist commit blocked broken; do
1321 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/$i
1322 done
1323 rm -f $LOCAL_REPOSITORY/log/$PACKAGE.html
1324 if [ "$pkg_repository" = "$INCOMING_REPOSITORY" ] && \
1325 [ "$(sed 1!d $cookorder)" != "#PlanSort" ] ; then
1326 sed 1i"#PlanSort" -i $cookorder
1327 regen_cooklist=yes
1328 else
1329 echo "$PACKAGE" >> $PACKAGES_REPOSITORY/removed
1330 sed -n '1,10p' -i $PACKAGES_REPOSITORY/removed
1331 fi
1332 fi
1333 fi
1334 done
1335 echo "$updated_pkg" | sed 1d | while read PACKAGE pkg; do
1336 erase_package_info
1337 get_packages_info
1338 done
1339 unset updated_pkg
1341 # Look for new packages.
1342 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1343 if ! fgrep -q " ${pkg##*/}" $pkg_repository/packages.md5; then
1344 get_packages_info
1345 fi
1346 done
1347 report end-step
1348 packages_db_end
1351 packages_db_start()
1353 if [ ! -s packages.txt ]; then
1354 echo "# SliTaz GNU/Linux - Packages list
1356 # Packages : unknow
1357 # Date : $(date +%Y-%m-%d\ \%H:%M:%S)
1359 " > packages.txt
1360 else
1361 sed -e 's/^# Packages :.*/# Packages : unknow/' \
1362 -e "s/# Date :.*/# Date : $(date +%Y-%m-%d\ \%H:%M:%S)/" \
1363 -i packages.txt
1364 fi
1366 # Needed in some case as tazwok define RECEIPT at configuration time
1367 # in this particular case it can broke the script.
1368 unset RECEIPT
1371 erase_package_info()
1373 cd $pkg_repository
1374 sed "/^$PACKAGE$/,/^$/d" -i packages.txt
1375 sed "/^$PACKAGE /d" -i packages.desc
1376 sed -e "s/=$PACKAGE /= /" -e "s/ $PACKAGE / /" -e "s/ $PACKAGE$//" \
1377 -e "/=$PACKAGE$/d" -e "s/=[0-9,a-z,A-Z]:$PACKAGE /= /" \
1378 -e "s/ [0-9,a-z,A-Z]:$PACKAGE / /" -e "s/ [0-9,a-z,A-Z]:$PACKAGE$/ /" \
1379 -e "/=[0-9,a-z,A-Z]:$PACKAGE$/d" \
1380 -i packages.equiv
1381 sed "/^$PACKAGE:/d" -i files.list
1382 sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
1383 sed "/ $(basename $pkg)$/d" -i packages.md5
1384 [ "$pkg_repository" != "$PACKAGES_REPOSITORY" ] && return 0
1385 for i in wok-wanted.txt wok-depends.txt; do
1386 [ -f $i ] || continue
1387 sed "/^$PACKAGE\t/d" -i $i
1388 done
1391 get_packages_info()
1393 # If there's no taz folder in the wok, extract infos from the
1394 # package.
1395 get_pkg_files $pkg
1396 source_receipt
1397 echo "Getting datas from $PACKAGE"
1399 cat >> $pkg_repository/packages.txt << _EOT_
1400 $PACKAGE
1401 $VERSION$EXTRAVERSION
1402 $SHORT_DESC
1403 _EOT_
1404 if [ "$PACKED_SIZE" ]; then
1405 cat >> $pkg_repository/packages.txt << _EOT_
1406 $PACKED_SIZE ($UNPACKED_SIZE installed)
1408 _EOT_
1409 else
1410 echo "" >> $pkg_repository/packages.txt
1411 fi
1413 # Packages.desc is used by Tazpkgbox <tree>.
1414 echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
1416 # Packages.equiv is used by tazpkg install to check depends
1417 for i in $PROVIDE; do
1418 DEST=""
1419 echo $i | fgrep -q : && DEST="${i#*:}:"
1420 if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
1421 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
1422 else
1423 echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
1424 fi
1425 done
1427 if [ -f files.list ]; then
1428 { echo "$PACKAGE"; cat files.list; } | awk '
1429 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
1430 fi
1432 cd .. && rm -r "$pkg_files_dir"
1434 cd $pkg_repository
1435 echo $(basename ${pkg%.tazpkg}) >> packages.list
1436 [ ! "$package_md5" ] && package_md5=$(md5sum $(basename $pkg))
1437 echo "$package_md5" >> packages.md5
1438 unset package_md5
1440 if [ "$pkg_repository" = "$PACKAGES_REPOSITORY" ]; then
1441 [ "$WANTED" ] && echo -e "$PACKAGE\t$WANTED" >> wok-wanted.txt
1442 echo -e "$PACKAGE\t "$DEPENDS" \t "$BUILD_DEPENDS" " >> wok-package.txt
1443 fi
1446 source_receipt()
1448 unset PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
1449 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
1450 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
1451 src _pkg DESTDIR CONFIG_SITE BRANCH TARBALL stuff wanted_stuff
1452 . ${RECEIPT:-$PWD/receipt}
1455 packages_db_end()
1457 cd $pkg_repository
1458 pkgs=$(wc -l packages.list | sed 's/ .*//')
1459 sed "s/# Packages : .*/# Packages : $pkgs/" -i packages.txt
1461 # If lists was updated it's generally needed to sort them well.
1462 if ! sort -c packages.list 2> /dev/null; then
1463 report step "Sorting packages lists"
1464 files_list="packages.list packages.desc packages.equiv"
1465 [ "$pkg_repository" = "$PACKAGES_REPOSITORY" ] && \
1466 files_list="$files_list wok-wanted.txt wok-depends.txt"
1467 for file in $files_list; do
1468 [ -f $file ] || continue
1469 sort -o $file $file
1470 done
1471 md5sum packages.md5 | cut -f1 -d' ' > ID
1472 report end-step
1473 fi
1475 # Dont log this because lzma always output error.
1476 lzma e files.list files.list.lzma
1477 rm -f files.list
1478 [ -f packages.equiv ] || touch packages.equiv
1481 ########################################################################
1482 # This section contains functions to generate wok database.
1483 ########################
1485 gen_wok_db()
1487 report step "Generating wok database"
1488 report open-bloc
1489 report step "Removing old files"
1490 for file in $wan_db $dep_db $cookorder; do
1491 [ -f $file ] && rm $file
1492 done
1493 report step "Generating wok-wanted.txt"
1494 gen_wan_db
1495 report step "Generating wok-depends.txt"
1496 for PACKAGE in $(cut -f1 -d '|' $PACKAGES_REPOSITORY/packages.desc \
1497 $INCOMING_REPOSITORY/packages.desc | sort -u); do
1498 RECEIPT=$WOK/$PACKAGE/receipt
1499 if [ -s $RECEIPT ]; then
1500 source_receipt
1501 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
1502 fi
1503 done
1504 sort_db
1505 report close-bloc
1508 gen_wan_db()
1510 for RECEIPT in $(fgrep -l WANTED $WOK/*/receipt); do
1511 WANTED=
1512 source $RECEIPT
1513 [ "$WANTED" ] || continue
1514 echo -e $PACKAGE"\t"$WANTED >> $tmp/wan_db
1515 done
1516 if ! [ -f $wan_db ] || [ "$(diff -q $tmp/wan_db $wan_db)" ]; then
1517 mv -f $tmp/wan_db $wan_db
1518 plan_regen_cookorder=yes
1519 else
1520 rm $tmp/wan_db
1521 fi
1524 update_wan_db()
1526 local PACKAGE=$PACKAGE
1527 for RECEIPT in $(fgrep WANTED $WOK/*/receipt | \
1528 fgrep $PACKAGE | cut -f1 -d ':'); do
1529 WANTED=
1530 source $RECEIPT
1531 [ "$WANTED" ] || continue
1532 wan_info=$(echo -e $PACKAGE"\t"$WANTED)
1533 [ "$wan_info" = "$(grep -m1 ^$PACKAGE$'\t' $wan_db 2>/dev/null)" ] && return
1534 sed "/^$PACKAGE\t/d" -i $wan_db
1535 echo "$wan_info" >> $wan_db
1536 plan_regen_cookorder=yes
1537 plan_sort_wandb=yes
1538 done
1541 update_dep_db()
1543 dep_info=$(echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ')
1544 [ "$dep_info" = "$(grep -m1 ^$PACKAGE$'\t' $dep_db 2>/dev/null)" ] && return
1545 sed "/^$PACKAGE\t/d" -i $dep_db
1546 echo "$dep_info" >> $dep_db
1547 plan_regen_cookorder=yes
1548 plan_sort_depdb=yes
1551 sort_db()
1553 report step "Generating cookorder.txt"
1554 cat $dep_db | sed 's/ \t / /' | while read PACKAGE BUILD_DEPENDS; do
1555 grep -q ^$PACKAGE$'\t' $wan_db && continue
1557 # Replace each BUILD_DEPENDS with a WANTED package by it's
1558 # WANTED package.
1559 replace_by_wanted()
1561 for p in $BUILD_DEPENDS; do
1562 if grep -q ^$p$'\t' $wan_db; then
1563 echo -n $(grep ^$p$'\t' $wan_db | cut -f 2)' '
1564 else
1565 echo -n $p' '
1566 fi
1567 done | tr ' ' '\n' | sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' '
1569 echo -e $PACKAGE"\t $(replace_by_wanted) "
1570 done > $tmp/db
1571 while [ -s "$tmp/db" ]; do
1572 status=start
1573 for pkg in $(cut -f 1 $tmp/db); do
1574 if ! fgrep -q ' '$pkg' ' $tmp/db; then
1575 echo $pkg >> $tmp/cookorder
1576 sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
1577 status=proceed
1578 fi
1579 done
1580 if [ "$status" = start ]; then
1581 cp -f $tmp/db /tmp/remain-depends.txt
1582 echo "Can't go further because there's depency(ies) loop(s). The remaining packages will be commentend in the cookorder and will be unbuild in case of major update until the problem is solved." >&2
1583 for blocked in $(cut -f 1 $tmp/db); do
1584 echo "$blocked" >> $PACKAGES_REPOSITORY/blocked
1585 done
1586 break
1587 fi
1588 done
1589 [ -s $tmp/cookorder ] || touch $tmp/cookorder
1591 # The toolchain packages are moved in first position.
1592 grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1593 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
1594 $tmp/cookorder | tac > $cookorder
1595 for pkg in $(cat $cookorder); do
1596 sed "/^$pkg$/d" -i $tmp/cookorder
1597 done
1599 tac $tmp/cookorder >> $cookorder
1600 unset plan_regen_cookorder
1601 report end-step
1604 ########################################################################
1605 # SCAN CORE
1606 ########################
1607 # Include various scan core-functions. It's not intended to be used
1608 # directly : prefer scan wrappers in next section.
1610 look_for_dep()
1612 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1613 grep -m1 ^$PACKAGE$'\t' $ref_dep_db | cut -f 2
1614 else
1615 grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2
1616 fi
1619 look_for_bdep()
1621 look_for_all
1624 look_for_all()
1626 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1627 grep -m1 ^$PACKAGE$'\t' $ref_dep_db | cut -f 2,3 | sed 's/ / /'
1628 else
1629 grep -m1 ^$PACKAGE$'\t' $dep_db | cut -f 2,3 | sed 's/ / /'
1630 fi
1633 look_for_rdep()
1635 fgrep ' '$PACKAGE' ' $dep_db | cut -f 1
1636 if [ "$undigest" ]; then
1637 for rdep in $(fgrep ' '$PACKAGE' ' $ref_dep_db | cut -f 1); do
1638 if [ ! -f "WOK$/$rdep/receipt" ]; then
1639 echo "$rdep"
1640 fi
1641 done
1642 fi
1645 look_for_rbdep()
1647 fgrep ' '$PACKAGE' ' $dep_db | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
1648 if [ "$undigest" ]; then
1649 for rdep in $(fgrep ' '$PACKAGE' ' $ref_dep_db | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
1650 if [ ! -f "WOK$/$rdep/receipt" ]; then
1651 echo "$rdep"
1652 fi
1653 done
1654 fi
1657 # Return WANTED if it exists.
1658 look_for_wanted()
1660 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1661 grep -m1 ^$PACKAGE$'\t' $ref_wan_db | cut -f 2
1662 else
1663 grep -m1 ^$PACKAGE$'\t' $wan_db | cut -f 2
1664 fi
1667 # Return packages which wants PACKAGE.
1668 look_for_rwanted()
1670 grep $'\t'$PACKAGE$ $wan_db | cut -f 1
1671 if [ "$undigest" ]; then
1672 for rwanted in $(grep $'\t' $ref_wan_db | cut -f 1); do
1673 if [ ! -f "$WOK/$rwanted/receipt" ]; then
1674 echo "$rwanted"
1675 fi
1676 done
1677 fi
1680 look_for_dev()
1682 WANTED=$(look_for_wanted)
1683 if [ "$WANTED" ]; then
1684 if [ "$undigest" ] && [ ! -f "$WOK/$WANTED/receipt" ]; then
1685 grep -q ^$WANTED-dev$'\t' $ref_dep_db && echo $WANTED-dev
1686 else
1687 [ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
1688 fi
1689 fi
1690 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1691 grep -q ^$PACKAGE-dev$'\t' $ref_dep_db && echo $PACKAGE-dev
1692 else
1693 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1694 fi
1697 with_dev()
1699 for PACKAGE in $(cat); do
1700 echo $PACKAGE
1701 look_for_dev
1702 done
1705 with_wanted()
1707 for PACKAGE in $(cat); do
1708 echo $PACKAGE
1709 look_for_wanted
1710 done
1713 use_wanted()
1715 for input in $(cat); do
1716 { grep ^$input$'\t' $wan_db || echo $input
1717 } | sed 's/.*\t//'
1718 done
1721 ########################################################################
1722 # SCAN
1723 ########################
1724 # Use wok-wanted.txt and wok-depeds.txt to scan depends.
1725 # Option in command line (must be first arg) :
1726 # --look_for=bdep/rbdep - Look for depends or reverse depends.
1727 # --with_dev - Add development packages (*-dev) in the result.
1728 # --with_wanted - Add package+reverse wanted in the result.
1729 # --with_args - Include packages in argument in the result.
1731 scan()
1733 # Get packages in argument.
1734 local PACKAGE=$PACKAGE WANTED=$WANTED pkg_list=
1735 for arg in $@; do
1736 [ "$arg" = "${arg#--}" ] || continue
1737 pkg_list="$pkg_list $arg"
1738 done
1740 # Get options.
1741 [ "$pkg_list" ] || return
1742 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
1743 get_options_list="look_for with_dev with_wanted with_args cooklist use_wanted"
1744 get_options
1746 # Cooklist is a special case where we need to modify a little
1747 # scan behavior
1748 if [ "$cooklist" ]; then
1749 gen_wan_db
1750 look_for=all && with_args=yes && with_dev= && with_wanted=
1751 filter=use_wanted
1752 if [ "$COMMAND" = gen-cooklist ]; then
1753 for PACKAGE in $pkg_list; do
1754 grep -q ^$PACKAGE$'\t' $dep_db && continue
1755 [ -d "$WOK/$p" ] || continue
1756 check_for_missing
1757 done
1758 append_to_dep()
1760 if ! grep -q ^$PACKAGE$'\t' $dep_db; then
1761 check_for_missing && echo $PACKAGE >> $tmp/dep
1762 else
1763 echo $PACKAGE >> $tmp/dep
1764 fi
1766 else
1767 append_to_dep()
1769 check_for_commit && echo $PACKAGE >> $tmp/dep
1771 fi
1772 else
1773 append_to_dep()
1775 echo $PACKAGE >> $tmp/dep
1777 # If requested packages are not in dep_db, partial generation of this db is needed.
1778 for PACKAGE in $pkg_list; do
1779 grep -q ^$PACKAGE$'\t' $dep_db && continue
1780 [ -d "$WOK/$p" ] || continue
1781 plan_check_for_missing=yes
1782 check_for_missing
1783 done
1784 if [ "$plan_check_for_missing" ]; then
1785 append_to_dep()
1787 if ! grep -q ^$PACKAGE$'\t' $dep_db; then
1788 check_for_missing && echo $PACKAGE >> $tmp/dep
1789 else
1790 echo $PACKAGE >> $tmp/dep
1791 fi
1793 check_db_status=yes
1794 unset plan_check_for_missing
1795 fi
1796 fi
1798 [ "$with_dev" ] && filter=with_dev
1799 [ "$with_wanted" ] && filter=with_wanted
1800 if [ "$filter" ]; then
1801 pkg_list=$(echo $pkg_list | $filter | sort -u)
1802 scan_pkg()
1804 look_for_$look_for | $filter
1806 else
1807 scan_pkg()
1809 look_for_$look_for
1811 fi
1812 touch $tmp/dep
1813 for PACKAGE in $pkg_list; do
1814 [ "$with_args" ] && append_to_dep
1815 scan_pkg
1816 done | tr ' ' '\n' | sort -u > $tmp/list
1817 [ "$look_for" = bdep ] && look_for=dep
1818 while [ -s $tmp/list ]; do
1819 PACKAGE=$(sed 1!d $tmp/list)
1820 sed 1d -i $tmp/list
1821 append_to_dep
1822 for pkg in $(scan_pkg); do
1823 if ! grep -q ^$pkg$ $tmp/list $tmp/dep; then
1824 echo $pkg >> $tmp/list
1825 fi
1826 done
1827 done
1828 if [ "$cooklist" ]; then
1829 mv $tmp/dep $tmp/cooklist
1830 else
1831 cat $tmp/dep | sort -u
1832 fi
1833 rm -f $tmp/dep $tmp/list
1834 if [ "$check_db_status" ]; then
1835 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
1836 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
1837 if [ "$plan_regen_cookorder" ] && \
1838 [ "$(sed 1!d $cookorder)" != "#PlanSort" ]; then
1839 grep -q "^#" $cookorder || sed 1i"#PlanSort" -i $cookorder
1840 fi
1841 fi
1844 ########################################################################
1845 # This section contains functions to check package repository and
1846 # find which packages to cook.
1847 ########################
1849 check_for_missing()
1851 local PACKAGE=$PACKAGE
1852 if ! check_for_pkg_in_wok; then
1853 [ "$?" = 2 ] && return 1
1854 return
1855 fi
1856 RECEIPT=$WOK/$PACKAGE/receipt
1857 source_receipt
1858 PACKAGE=${WANTED:-$PACKAGE}
1859 update_wan_db
1860 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
1861 RECEIPT=$WOK/$PACKAGE/receipt
1862 source_receipt
1863 update_dep_db
1864 done
1867 check_for_commit()
1869 if ! check_for_pkg_in_wok; then
1870 [ "$?" = 2 ] && return 1
1871 return
1872 fi
1873 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
1874 RECEIPT=$WOK/$PACKAGE/receipt
1875 source_receipt
1877 # We use md5 of cooking stuff in the packaged receipt to check
1878 # commit. We look consecutively in 3 different locations :
1879 # - in the wok/PACKAGE/taz/* folder
1880 # - in the receipt in the package in incoming repository
1881 # - in the receipt in the package in packages repository
1882 # If md5sum match, there's no commit.
1883 check_for_commit_using_md5sum()
1885 if [ ! -f $WOK/$PACKAGE/md5 ]; then
1886 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
1887 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
1888 cd $WOK/$PACKAGE
1889 fi
1891 if [ -s md5 ]; then
1892 if md5sum -cs md5; then
1894 # If md5sum check if ok, check for new/missing files in
1895 # cooking stuff.
1896 for file in $([ -f receipt ] && echo receipt; \
1897 [ -f description.txt ] && echo description.txt; \
1898 [ -d stuff ] && find stuff); do
1899 if ! fgrep -q " $file" md5; then
1900 set_commited
1901 fi
1902 done
1903 else
1904 set_commited
1905 fi
1906 else
1907 set_commited
1908 fi
1910 set_commited()
1912 ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/commit &&
1913 echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
1914 gen_cookmd5
1915 update_dep_db
1917 taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*')
1918 if [ -f $WOK/$PACKAGE/md5 ]; then
1919 cd $WOK/$PACKAGE
1920 check_for_commit_using_md5sum
1921 elif [ "$taz_dir" ]; then
1922 cd $taz_dir
1923 check_for_commit_using_md5sum
1924 else
1925 pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1926 [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1927 if [ "$pkg" ]; then
1928 get_pkg_files $pkg
1929 check_for_commit_using_md5sum
1930 rm -r $pkg_files_dir
1931 else
1932 set_commited
1933 fi
1934 fi
1935 [ "$forced" ] || echo $PACKAGE >> $tmp/checked
1936 done
1937 return
1940 gen_cook_list()
1942 report step "Scanning wok"
1943 if [ "$pkg" ]; then
1944 scan $pkg --cooklist
1945 else
1946 scan `cat $cooklist` --cooklist
1947 fi
1948 report end-step
1950 [ -s $tmp/checked ] || [ -s $tmp/cooklist ] || return
1952 # Core toolchain should not be cooked unless cook-toolchain is used.
1953 if ! [ -f /etc/config.site.tmptoolchain ] ; then
1954 for PACKAGE in $(scan gcc --look_for=all --with_args --with_wanted); do
1955 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/blocked || \
1956 echo $PACKAGE >> $PACKAGES_REPOSITORY/blocked
1957 done
1958 fi
1960 if [ -s $PACKAGES_REPOSITORY/commit ] && [ "$COMMAND" != gen-cooklist ]; then
1961 cd $PACKAGES_REPOSITORY
1962 for PACKAGE in $(cat commit); do
1963 WANTED="$(look_for_wanted)"
1964 if [ "$WANTED" ]; then
1965 grep -q ^$WANTED$ broken cooklist blocked commit && continue
1966 fi
1967 grep -q ^$PACKAGE$ blocked cooklist && continue
1968 echo $PACKAGE >> cooklist
1969 done
1970 fi
1971 sort_cooklist
1974 sort_cooklist()
1976 if [ "$(sed 1!d $cookorder)" = "#PlanSort" ]; then
1977 sed 1d -i $cookorder
1978 plan_regen_cookorder=yes
1979 fi
1980 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
1981 [ "$plan_regen_cookorder" ] && sort_db
1982 report step "Generating cooklist"
1983 if [ -f "$tmp/checked" ]; then
1984 rm -f $tmp/cooklist
1985 cat $tmp/checked | while read PACKAGE; do
1986 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/cooklist && \
1987 echo $PACKAGE >> $tmp/cooklist
1988 done
1989 elif ! [ "$COMMAND" = gen-cooklist ]; then
1990 cat $PACKAGES_REPOSITORY/blocked | while read PACKAGE; do
1991 sed "/^$PACKAGE/d" -i $tmp/cooklist
1992 done
1993 fi
1994 report end-step
1995 [ -s $tmp/cooklist ] || return
1997 report step "Sorting cooklist"
1998 for PACKAGE in $(cat $tmp/cooklist); do
1999 WANTED="$(look_for_wanted)"
2000 [ "$WANTED" ] || continue
2001 if grep -q ^$WANTED$ $PACKAGES_REPOSITORY/broken $tmp/cooklist; then
2002 sed "/^$PACKAGE$/d" -i $tmp/cooklist
2003 elif [ ! -d $WOK/$WANTED/install ]; then
2004 sed "/^$PACKAGE$/d" -i $tmp/cooklist
2005 echo $WANTED >> $tmp/cooklist
2006 fi
2007 done
2009 # Use cookorder.txt to sort cooklist.
2010 if [ -s $tmp/cooklist ]; then
2011 cat $cookorder | while read PACKAGE; do
2012 if grep -q ^$PACKAGE$ $tmp/cooklist; then
2013 sed "/^$PACKAGE$/d" -i $tmp/cooklist
2014 echo $PACKAGE >> $tmp/cooklist.tmp
2015 fi
2016 done
2018 # Remaining packages in cooklist are thoses without compile_rules.
2019 # They can be cooked first in any order.
2020 if [ -f $tmp/cooklist.tmp ]; then
2021 cat $tmp/cooklist.tmp >> $tmp/cooklist
2022 rm $tmp/cooklist.tmp
2023 fi
2025 cat $tmp/cooklist
2026 [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
2027 cat $tmp/cooklist > $cooklist
2028 fi
2030 report end-step
2033 look_for_missing_pkg()
2035 for pkg in $(cat $PACKAGES_REPOSITORY/$1); do
2036 grep -q ^$pkg$ $INCOMING_REPOSITORY/packages.txt \
2037 $PACKAGES_REPOSITORY/packages.txt || \
2038 continue
2039 echo $pkg
2040 done
2043 check_for_incoming()
2045 report step "Check that all packages were cooked fine"
2046 [ -s $INCOMING_REPOSITORY/packages.desc ] || {
2047 echo "No packages in $INCOMING_REPOSITORY."
2048 report end-step; return; }
2049 if [ -s $PACKAGES_REPOSITORY/broken ]; then
2050 missingpkg=$(look_for_missing_pkg broken)
2051 if [ "$missingpkg" ]; then
2052 echo "Don't move incoming packages to main repository because theses ones are broken:" >&2
2053 echo "$missingpkg"
2054 report end-step
2055 return 1
2056 fi
2057 fi
2058 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
2059 missingpkg=$(look_for_missing_pkg cooklist)
2060 if [ "$missingpkg" ]; then
2061 echo "Don't move incoming packages to main repository because theses ones needs to be cooked:" >&2
2062 echo "$missingpkg"
2063 report end-step
2064 return 1
2065 fi
2066 fi
2067 incoming_pkgs="$(cut -f 1 -d '|' $INCOMING_REPOSITORY/packages.desc)"
2068 if ! [ "$forced" ]; then
2069 cooklist=$PACKAGES_REPOSITORY/cooklist
2070 pkg="$incoming_pkgs"
2071 gen_cook_list
2072 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
2073 missingpkg=$(look_for_missing_pkg cooklist)
2074 if [ "$missingpkg" ]; then
2075 echo "Don't move incoming packages to main repository because theses ones needs to be cooked:" >&2
2076 echo "$missingpkg"
2077 report end-step
2078 return 1
2079 fi
2080 fi
2081 fi
2083 report step "Moving incoming packages to main repository"
2084 mkdir -p $PACKAGES_REPOSITORY/wok
2085 unset EXTRAVERSION
2086 for PACKAGE in $incoming_pkgs; do
2087 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
2088 VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
2089 remove_previous_package $PACKAGES_REPOSITORY
2090 echo "Moving $PACKAGE..."
2091 mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
2092 touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
2093 previous_tarball=$(grep ^$PACKAGE:main $SOURCES_REPOSITORY/sources.list | cut -f2)
2094 sed -e "/^$PACKAGE:main/d" \
2095 -e "s/^$PACKAGE:incoming/$PACKAGE:main/" \
2096 -i $SOURCES_REPOSITORY/sources.list
2097 if [ "$previous_tarball" ]; then
2098 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
2099 rm -f $SOURCES_REPOSITORY/$previous_tarball
2100 fi
2101 rm -rf $PACKAGES_REPOSITORY/wok/$PACKAGE
2102 mkdir -p $PACKAGES_REPOSITORY/wok/$PACKAGE
2103 for i in $WOK/$PACKAGE/receipt $WOK/$PACKAGE/description.txt \
2104 $WOK/$PACKAGE/stuff; do
2105 cp -a $i $PACKAGES_REPOSITORY/wok/$PACKAGE
2106 done
2107 done
2109 if [ "$GEN_SAFE_WOK_TARBALL" ]; then
2110 rm -rf $PACKAGES_REPOSITORY/wok.tar.lzma
2111 cd $PACKAGES_REPOSITORY/wok
2112 report step "Generating safe-wok tarball"
2113 tar -c * | lzma e $PACKAGES_REPOSITORY/wok.tar.lzma
2114 report end-step
2115 fi
2117 for file in packages.list packages.equiv packages.md5 packages.desc \
2118 packages.txt; do
2119 echo -n "" > $INCOMING_REPOSITORY/$file
2120 done
2121 rm -r $INCOMING_REPOSITORY/files.list.lzma
2122 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2124 report step "Updating flavors"
2125 if [ -x /usr/bin/tazlito ] || [ -x /usr/bin/clean-chroot ]; then
2126 if ! [ -x /usr/bin/tazlito ]; then
2127 tazpkg get-install tazlito
2128 fi
2130 # Handle cases where tazwok is used into main system;
2131 # Handle cases where SLITAZ_DIR is not /home/slitaz.
2132 [ -L /home/slitaz/flavors ] && rm /home/slitaz/flavors
2133 mkdir -p /home/slitaz
2134 ln -s $LOCAL_REPOSITORY/flavors /home/slitaz/flavors
2136 cd $LOCAL_REPOSITORY/packages
2137 for i in $LOCAL_REPOSITORY/flavors/*; do
2138 [ -d "$i" ] || continue
2139 tazlito pack-flavor ${i##*/}
2140 done
2142 noheader=""
2143 for i in *.flavor; do
2144 tazlito show-flavor $i --brief $noheader
2145 noheader="--noheader"
2146 done > flavors.list
2147 [ -x /usr/bin/clean-chroot ] && clean-chroot
2148 else
2149 echo "Can't create up-to-date flavors because tazlito package is missing." >&2
2150 fi
2151 report end-step
2154 ########################################################################
2155 # TAZWOK MAIN FUNCTIONS
2156 ########################
2158 clean()
2160 cd $WOK/$PACKAGE
2161 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
2162 -e ^stuff$ || return
2164 [ "$COMMAND" = clean-wok ] || report step "Cleaning $PACKAGE"
2165 # Check for clean_wok function.
2166 if grep -q ^clean_wok $RECEIPT; then
2167 clean_wok
2168 fi
2169 # Clean should only have a receipt, stuff and optional desc.
2170 for f in `ls .`
2171 do
2172 case $f in
2173 receipt|stuff|description.txt|md5)
2174 continue ;;
2175 *)
2176 rm -rf $f ;;
2177 esac
2178 done
2179 [ "$COMMAND" != clean-wok ] && report end-step
2182 # Configure and make a package with the receipt.
2183 compile_package()
2185 check_for_package_on_cmdline
2187 # Include the receipt to get all needed variables and functions
2188 # and cd into the work directory to start the work.
2189 check_for_receipt
2190 source_receipt
2192 # Log the package name and date.
2193 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
2194 echo "package $PACKAGE (compile)" >> $LOG
2196 # Set wanted $src variable to help compiling.
2197 [ ! "$src" ] && set_src_path
2198 check_for_build_depends || return 1
2199 check_for_wanted
2200 unset target
2201 check_for_tarball && check_for_compile_rules
2204 # Cook command also include all features to manage lists which keep
2205 # track of wok/packages state.
2206 cook()
2208 cook_code=
2209 set_common_path
2210 check_for_receipt
2211 source_receipt
2213 # Define log path and start report.
2214 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
2215 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
2216 echo "$PACKAGE" > $LOCAL_REPOSITORY/log/package
2217 report step "Cooking $PACKAGE"
2218 report open-bloc
2220 clean $PACKAGE
2221 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
2223 if compile_package; then
2224 remove_src
2225 refresh_packages_from_compile
2226 gen_package
2228 # Update packages-incoming repository.
2229 store_pkgname=$PACKAGE
2230 pkg_repository=$INCOMING_REPOSITORY
2231 update_packages_db
2233 PACKAGE=$store_pkgname
2234 unset store_pkgname
2236 # Upgrade to cooked packages if it was previously installed.
2237 report step "Look for package(s) to upgrade"
2238 for pkg in $(look_for_rwanted) $PACKAGE; do
2239 if [ -d $INSTALLED/$pkg ]; then
2240 tazpkg get-install $pkg --forced
2241 fi
2242 done
2243 report end-step
2244 else
2245 set_pkg_broken
2246 cook_code=1
2247 fi
2249 # Remove build_depends in cook mode (if in cooklist, it's done when
2250 # checking build_depends of next package and we remove only unneeded
2251 # packages to keep chroot minimal and gain some time).
2252 if [ "$COMMAND" = cook ]; then
2253 remove_build_depends $MISSING_PACKAGE
2254 [ -x /usr/bin/clean-chroot ] && clean-chroot
2255 fi
2257 # Regen the cooklist if it was planned and command is not cook.
2258 [ "$regen_cooklist" ] && unset regen_cooklist && \
2259 [ "$COMMAND" != cook ] && sort_cooklist
2261 # Some hacks to set the bloc & function status as failed if cook was
2262 # failed.
2263 report_return_code=$cook_code
2264 report close-bloc
2265 report end-sublog
2266 rm -f $LOCAL_REPOSITORY/log/package
2267 return $cook_code
2270 cook_list()
2272 if [ -s $tmp/cooklist ]; then
2273 if [ -f /usr/bin/tazchroot ]; then
2274 # Note : options -main variables- are automatically keeped by
2275 # the sub-applications tazchroot/tazwok; as well as report data.
2276 cd $LOCAL_REPOSITORY
2277 [ ! -f tazchroot.conf ] && configure_tazchroot
2278 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
2279 return
2280 fi
2281 while [ -s $tmp/cooklist ]; do
2282 PACKAGE=$(sed 1!d $tmp/cooklist)
2283 cook
2284 done
2285 remove_build_depends $MISSING_PACKAGE $remove_later
2286 [ -x /usr/bin/clean-chroot ] && clean-chroot
2287 else
2288 echo "Nothing to cook."
2289 return
2290 fi
2293 configure_tazchroot()
2295 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
2296 # Tazchroot configuration file - created by tazwok.
2298 # Default chroot path
2299 SLITAZ_DIR=$SLITAZ_DIR
2300 SLITAZ_VERSION=$SLITAZ_VERSION
2301 $( [ "$undigest" ] && echo "undigest=$undigest" )
2302 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
2303 chroot_dir=\$LOCAL_REPOSITORY/chroot
2305 # Default scripts path (theses scripts are added in the
2306 # $chroot_dir/usr/bin and can be called with tazchroot script)
2307 script_dir=/usr/lib/slitaz/chroot-scripts/tazwok
2309 # List of directories to mount.
2310 list_dir="$(for dir in packages wok src packages-incoming log flavors iso clean-wok; do echo $LOCAL_REPOSITORY/$dir; done)
2311 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
2313 create_chroot()
2315 mkdir -p \$chroot_dir
2316 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
2317 tazpkg get-install \$pkg --root="\$chroot_dir"
2318 done
2320 # Store list of installed packages needed by cleanchroot.
2321 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
2323 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
2324 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
2325 -i \$chroot_dir/etc/slitaz/slitaz.conf
2326 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
2327 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
2328 # The build bot may run in a sandbox: link sandbox lockfile
2329 ln -s \$LOCAL_REPOSITORY/sandbox/proc/1 \$chroot_dir/proc/1
2332 mount_chroot()
2334 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
2335 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
2336 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
2337 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
2338 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
2339 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
2340 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
2341 mount -t proc proc \$chroot_dir/proc
2342 mount -t sysfs sysfs \$chroot_dir/sys
2343 mount -t devpts devpts \$chroot_dir/dev/pts
2344 mount -t tmpfs shm \$chroot_dir/dev/shm
2345 for dir in \$list_dir; do
2346 mkdir -p \$dir \$chroot_dir\$dir
2347 mount \$dir \$chroot_dir\$dir
2348 done
2351 umount_chroot()
2353 for dir in \$list_dir; do
2354 umount \$chroot_dir\$dir
2355 done
2356 umount \$chroot_dir/dev/shm
2357 umount \$chroot_dir/dev/pts
2358 umount \$chroot_dir/sys
2359 umount \$chroot_dir/proc
2361 EOF
2364 ########################################################################
2365 ######################### END OF NEW FUNCTIONS #########################
2366 ########################################################################
2368 # List packages providing a virtual package
2369 whoprovide()
2371 local i;
2372 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
2373 . $i
2374 case " $PROVIDE " in
2375 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
2376 esac
2377 done
2380 ########################################################################
2381 # TAZWOK COMMANDS
2382 ########################
2384 case "$COMMAND" in
2385 stats)
2386 # Tazwok general statistics from the wok config file.
2388 get_tazwok_config
2389 echo -e "\n\033[1mTazwok configuration statistics\033[0m
2390 ================================================================================
2391 Wok directory : $WOK
2392 Packages repository : $PACKAGES_REPOSITORY
2393 Incoming repository : $INCOMING_REPOSITORY
2394 Sources repository : $SOURCES_REPOSITORY
2395 Log directory : $LOCAL_REPOSITORY/log
2396 Packages in the wok : `ls -1 $WOK | wc -l`
2397 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2398 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2399 ================================================================================\n"
2400 ;;
2401 edit)
2402 get_tazwok_config
2403 check_for_package_on_cmdline
2404 check_for_receipt
2405 $EDITOR $WOK/$PACKAGE/receipt
2406 ;;
2407 build-depends)
2408 # List dependencies to rebuild wok, or only a package
2409 get_tazwok_config
2410 report(){ : ; }
2411 if [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
2412 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
2413 --look_for=dep --with_dev --with_args
2414 else
2415 check_for_package_on_cmdline
2416 scan $PACKAGE --look_for=bdep --with_dev
2417 fi
2418 ;;
2419 gen-cooklist)
2420 check_root
2421 get_options_list="pkg"
2422 get_tazwok_config
2423 report(){ : ; }
2424 if ! [ "$pkg" ]; then
2425 if [ ! "$LIST" ] || [ "$LIST" = toolchain ]; then
2426 pkg="$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA"
2427 else
2428 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2429 fi
2430 fi
2431 gen_cook_list
2432 ;;
2433 check-depends)
2434 # Check package depends /!\
2435 get_tazwok_config
2436 echo ""
2437 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
2438 ================================================================================"
2439 TMPDIR=/tmp/tazwok$$
2440 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
2442 # Build ALL_DEPENDS variable
2443 scan_dep()
2445 local i
2446 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
2447 for i in $DEPENDS $SUGGESTED ; do
2448 case " $ALL_DEPENDS " in
2449 *\ $i\ *) continue;;
2450 esac
2451 [ -d $WOK/$i ] || {
2452 ALL_DEPENDS="$ALL_DEPENDS$i "
2453 continue
2455 DEPENDS=""
2456 SUGGESTED=""
2457 . $WOK/$i/receipt
2458 scan_dep
2459 done
2462 # Check for ELF file
2463 is_elf()
2465 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ]
2468 # Print shared library dependencies
2469 ldd()
2471 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2474 mkdir $TMPDIR
2475 cd $TMPDIR
2476 for i in $LOCALSTATE/files.list.lzma \
2477 $LOCALSTATE/undigest/*/files.list.lzma ; do
2478 [ -f $i ] && lzma d $i -so >> files.list
2479 done
2480 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2481 tazpkg extract $pkg > /dev/null 2>&1
2482 . */receipt
2483 ALL_DEPENDS="$DEFAULT_DEPENDS "
2484 scan_dep
2485 find */fs -type f | while read file ; do
2486 is_elf $file || continue
2487 case "$file" in
2488 *.o|*.ko|*.ko.gz) continue;;
2489 esac
2490 ldd $file | while read lib rem; do
2491 case "$lib" in
2492 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2493 continue;;
2494 esac
2495 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2496 case " $ALL_DEPENDS " in
2497 *\ $dep\ *) continue 2;;
2498 esac
2499 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2500 case " $ALL_DEPENDS " in
2501 *\ $vdep\ *) continue 3;;
2502 esac
2503 done
2504 done
2505 [ -n "$dep" ] || dep="UNKNOWN"
2506 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2507 done
2508 done
2509 rm -rf */
2510 done
2511 cd /tmp
2512 rm -rf $TMPDIR
2513 ;;
2514 check)
2515 # Check wok consistency
2516 get_tazwok_config
2517 echo ""
2518 echo -e "\033[1mWok and packages checking\033[0m
2519 ================================================================================"
2520 cd $WOK
2521 for pkg in $(ls)
2522 do
2523 [ -f $pkg/receipt ] || continue
2524 RECEIPT= $pkg/receipt
2525 source_receipt
2526 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2527 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2528 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2529 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2530 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2531 if [ -n "$WANTED" ]; then
2532 if [ ! -f $WANTED/receipt ]; then
2533 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2534 else
2535 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2536 if [ "$VERSION" = "$WANTED" ]; then
2537 # BASEVERSION is computed in receipt
2538 fgrep -q '_pkg=' $pkg/receipt &&
2539 BASEVERSION=$VERSION
2540 fi
2541 if [ "$VERSION" != "$BASEVERSION" ]; then
2542 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2543 fi
2544 fi
2545 fi
2547 if [ -n "$CATEGORY" ]; then
2548 case " $(echo $CATEGORIES) " in
2549 *\ $CATEGORY\ *);;
2550 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2551 esac
2552 else
2553 echo"Package $PACKAGE has no CATEGORY" >&2
2554 fi
2555 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2556 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2557 case "$WGET_URL" in
2558 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2559 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2560 '') ;;
2561 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2562 esac
2563 case "$WEB_SITE" in
2564 ftp*|http*);;
2565 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2566 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2567 esac
2568 case "$MAINTAINER" in
2569 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2570 esac
2571 case "$MAINTAINER" in
2572 *@*);;
2573 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2574 esac
2575 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2576 for i in $DEPENDS; do
2577 [ -d $i ] && continue
2578 [ -n "$(whoprovide $i)" ] && continue
2579 echo -e "$MSG $i"
2580 MSG=""
2581 done
2582 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2583 for i in $BUILD_DEPENDS; do
2584 [ -d $i ] && continue
2585 [ -n "$(whoprovide $i)" ] && continue
2586 echo -e "$MSG $i"
2587 MSG=""
2588 done
2589 MSG="Dependencies loop between $PACKAGE and :\n"
2590 ALL_DEPS=""
2591 check_for_deps_loop $PACKAGE $DEPENDS
2592 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2593 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2594 echo "$pkg should be rebuilt after $i installation"
2595 done
2596 done
2597 ;;
2598 list)
2599 # List packages in wok directory. User can specify a category.
2601 get_tazwok_config
2602 if [ "$2" = "category" ]; then
2603 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2604 exit 0
2605 fi
2606 # Check for an asked category.
2607 if [ -n "$2" ]; then
2608 ASKED_CATEGORY=$2
2609 echo ""
2610 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2611 echo "================================================================================"
2612 for pkg in $WOK/*
2613 do
2614 [ ! -f $pkg/receipt ] && continue
2615 . $pkg/receipt
2616 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2617 echo -n "$PACKAGE"
2618 echo -e "\033[28G $VERSION"
2619 packages=$(($packages+1))
2620 fi
2621 done
2622 echo "================================================================================"
2623 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
2624 else
2625 # By default list all packages and version.
2626 echo ""
2627 echo -e "\033[1mList of packages in the wok\033[0m"
2628 echo "================================================================================"
2629 for pkg in $WOK/*
2630 do
2631 [ ! -f $pkg/receipt ] && continue
2632 . $pkg/receipt
2633 echo -n "$PACKAGE"
2634 echo -en "\033[28G $VERSION"
2635 echo -e "\033[42G $CATEGORY"
2636 packages=$(($packages+1))
2637 done
2638 echo "================================================================================"
2639 echo -e "$packages packages available in the wok.\n"
2640 fi
2641 ;;
2642 info)
2643 # Information about a package.
2645 get_tazwok_config
2646 check_for_package_on_cmdline
2647 check_for_receipt
2648 . $WOK/$PACKAGE/receipt
2649 echo ""
2650 echo -e "\033[1mTazwok package information\033[0m
2651 ================================================================================
2652 Package : $PACKAGE
2653 Version : $VERSION
2654 Category : $CATEGORY
2655 Short desc : $SHORT_DESC
2656 Maintainer : $MAINTAINER"
2657 if [ ! "$WEB_SITE" = "" ]; then
2658 echo "Web site : $WEB_SITE"
2659 fi
2660 if [ ! "$DEPENDS" = "" ]; then
2661 echo "Depends : $DEPENDS"
2662 fi
2663 if [ ! "$WANTED" = "" ]; then
2664 echo "Wanted src : $WANTED"
2665 fi
2666 echo "================================================================================"
2667 echo ""
2668 ;;
2669 check-log)
2670 # We just cat the file log to view process info.
2672 get_tazwok_config
2673 if [ ! -f "$LOG" ]; then
2674 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2675 exit 1
2676 else
2677 echo ""
2678 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2679 echo "================================================================================"
2680 cat $LOG
2681 echo "================================================================================"
2682 echo ""
2683 if [ -s "$WOK/$PACKAGE/warning.txt" ]; then
2684 echo -e "\033[1mCook warning(s) for :\033[0m $PACKAGE"
2685 echo "================================================================================"
2686 cat "$WOK/$PACKAGE/warning.txt"
2687 echo "================================================================================"
2688 echo ""
2689 fi
2690 fi
2691 ;;
2692 search)
2693 # Search for a package by pattern or name.
2695 get_tazwok_config
2696 if [ -z "$2" ]; then
2697 echo -e "\nPlease specify a pattern or a package name to search." >&2
2698 echo -e "Example : 'tazwok search gcc'.\n" >&2
2699 exit 1
2700 fi
2701 echo ""
2702 echo -e "\033[1mSearch result for :\033[0m $2"
2703 echo "================================================================================"
2704 list=`ls -1 $WOK | fgrep $2`
2705 for pkg in $list
2706 do
2707 . $WOK/$pkg/receipt
2708 echo -n "$PACKAGE "
2709 echo -en "\033[24G $VERSION"
2710 echo -e "\033[42G $CATEGORY"
2711 packages=$(($PACKAGEs+1))
2712 done
2713 echo "================================================================================"
2714 echo "$packages packages found for : $2"
2715 echo ""
2716 ;;
2717 compile)
2718 # Configure and make a package with the receipt.
2720 get_tazwok_config
2721 source_lib report
2722 report start
2723 compile_package
2724 ;;
2725 genpkg)
2726 # Generate a package.
2728 get_tazwok_config
2729 source_lib report
2730 report start
2731 gen_package
2732 ;;
2733 cook)
2734 # Compile and generate a package. Just execute tazwok with
2735 # the good commands.
2737 check_root
2738 get_tazwok_config
2739 source_lib report
2740 report start
2741 update_wan_db
2742 check_for_commit
2743 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
2744 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
2745 if [ "$plan_regen_cookorder" ]; then
2746 [ "$(sed 1!d $cookorder)" = "#PlanSort" ] || \
2747 sed 1i"#PlanSort" -i $cookorder
2748 fi
2749 cook
2750 ;;
2751 sort-cooklist)
2752 if [ ! -f "$LIST" ]; then
2753 echo "Usage : tazwok sort-cooklist cooklist" >&2
2754 exit 1
2755 fi
2756 check_root
2757 get_tazwok_config
2758 report(){ : ; }
2759 # When using sort-cooklist, the script should behave as for gen-cooklist
2760 # The only difference between theses two is where the output is sended.
2761 COMMAND=gen-cooklist
2762 cooklist=$LIST
2763 gen_cook_list
2764 cp -af $tmp/cooklist $cooklist
2765 ;;
2766 cook-list)
2767 # Cook all packages listed in a file or in default cooklist.
2768 check_root
2769 get_options_list="pkg forced"
2770 get_tazwok_config
2771 source_lib report
2772 report start
2773 if ! [ "$pkg" ]; then
2774 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2775 fi
2776 gen_cook_list
2777 cook_list
2778 ;;
2779 clean)
2780 # Clean up a package work directory + thoses which want it.
2782 get_tazwok_config
2783 check_for_package_on_cmdline
2784 check_for_receipt
2785 source_lib report
2786 report start
2787 . $RECEIPT
2788 clean
2789 ;;
2790 gen-clean-wok)
2791 # Generate a clean wok from the current wok by copying all receipts
2792 # and stuff directory.
2794 get_tazwok_config
2795 source_lib report
2796 report start
2797 if [ -z "$ARG" ]; then
2798 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2799 exit 1
2800 else
2801 dest=$ARG
2802 mkdir -p $dest
2803 fi
2804 report step "Creating clean wok in : $dest"
2805 for pkg in `ls -1 $WOK`
2806 do
2807 mkdir -p $dest/$pkg
2808 cp -a $WOK/$pkg/receipt $dest/$pkg
2809 [ -f $WOK/$pkg/description.txt ] && \
2810 cp -a $WOK/$pkg/description.txt $dest/$pkg
2811 if [ -d "$WOK/$pkg/stuff" ]; then
2812 cp -a $WOK/$pkg/stuff $dest/$pkg
2813 fi
2814 done
2815 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2816 report end-step
2817 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2818 echo ""
2819 ;;
2820 clean-wok)
2821 # Clean all packages in the work directory
2823 get_tazwok_config
2824 source_lib report
2825 report start
2826 report step "Cleaning wok"
2827 for PACKAGE in `ls -1 $WOK`
2828 do
2829 set_common_path
2830 source_receipt
2831 clean
2832 done
2833 echo "`ls -1 $WOK | wc -l` packages cleaned."
2834 ;;
2835 clean-src)
2836 # Remove tarball unrelated to wok receipts from src repo.
2837 check_root
2838 get_options_list="forced"
2839 get_tazwok_config
2840 cd $SOURCES_REPOSITORY
2841 echo -n "Checking $SOURCES_REPOSITORY..."
2842 for TARBALL in *; do
2843 [ "$TARBALL" = sources.list ] && continue
2844 grep -q $'\t'$TARBALL$ $SOURCES_REPOSITORY/sources.list || \
2845 echo $TARBALL >> $tmp/obsolete
2846 done
2847 status
2848 if ! [ -f $tmp/obsolete ]; then
2849 echo "No sources need to be removed."
2850 exit 1
2851 fi
2852 echo ""
2853 echo -e "\033[1mObsolete/unrelated-to-wok sourcess :\033[0m"
2854 horizontal_line
2855 cat $tmp/obsolete
2856 horizontal_line
2857 echo "$(wc -l $tmp/obsolete | cut -f1 -d' ') tarballs to remove."
2858 echo ""
2859 echo -n "Please confirm removing (type uppercase YES): "
2860 read answer
2861 if [ "$answer" = YES ]; then
2862 echo -n "Removing old sources..."
2863 cat $tmp/obsolete | while read i; do
2864 rm -f $SOURCES_REPOSITORY/$i
2865 done
2866 status
2867 fi
2868 ;;
2869 gen-list)
2870 get_tazwok_config
2871 if [ "$2" ]; then
2872 if [ -d "$2" ]; then
2873 pkg_repository=$2
2874 else
2875 echo -e "\nUnable to find directory : $2\n" >&2
2876 exit 1
2877 fi
2878 fi
2880 source_lib report
2881 report start
2882 if [ "$pkg_repository" ]; then
2883 gen_packages_db
2884 else
2885 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
2886 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
2887 fi
2888 ;;
2889 check-list)
2890 # The directory to move into by default is the repository,
2891 # if $2 is not empty cd into $2.
2893 get_tazwok_config
2894 if [ "$2" ]; then
2895 if [ -d "$2" ]; then
2896 pkg_repository=$2
2897 else
2898 echo -e "\nUnable to find directory : $2\n" >&2
2899 exit 1
2900 fi
2901 fi
2903 source_lib report
2904 report start
2905 if [ "$pkg_repository" ]; then
2906 update_packages_db
2907 else
2908 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2909 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
2910 fi
2911 ;;
2912 new-tree)
2913 # Just create a few directories and generate an empty receipt to prepare
2914 # the creation of a new package.
2916 get_tazwok_config
2917 check_for_package_on_cmdline
2918 clean_wok=$LOCAL_REPOSITORY/clean-wok
2919 if [ -d $clean_wok/$PACKAGE ]; then
2920 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2921 exit 1
2922 fi
2923 echo "Creating : $WOK/$PACKAGE"
2924 mkdir $clean_wok/$PACKAGE
2925 cd $clean_wok/$PACKAGE
2926 echo -n "Preparing the receipt..."
2928 # Default receipt begin.
2930 echo "# SliTaz package receipt." > receipt
2931 echo "" >> receipt
2932 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2933 # Finish the empty receipt.
2934 cat >> receipt << "EOF"
2935 VERSION=""
2936 CATEGORY=""
2937 SHORT_DESC=""
2938 MAINTAINER=""
2939 DEPENDS=""
2940 TARBALL="$PACKAGE-$VERSION.tar.gz"
2941 WEB_SITE=""
2942 WGET_URL=""
2944 # Rules to configure and make the package.
2945 compile_rules()
2947 cd $src
2948 ./configure && make && make install
2951 # Rules to gen a SliTaz package suitable for Tazpkg.
2952 genpkg_rules()
2954 mkdir -p $fs/usr
2955 cp -a $_pkg/usr/bin $fs/usr
2958 EOF
2960 # Default receipt end.
2962 status
2963 # Interactive mode, asking and seding.
2964 if [ "$3" = "--interactive" ]; then
2965 echo "Entering into interactive mode..."
2966 echo "================================================================================"
2967 echo "Package : $PACKAGE"
2968 # Version.
2969 echo -n "Version : " ; read anser
2970 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2971 # Category.
2972 echo -n "Category : " ; read anser
2973 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2974 # Short description.
2975 echo -n "Short desc : " ; read anser
2976 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2977 # Maintainer.
2978 echo -n "Maintainer : " ; read anser
2979 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2980 # Web site.
2981 echo -n "Web site : " ; read anser
2982 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2983 echo ""
2984 # Wget URL.
2985 echo "Wget URL to download source tarball."
2986 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2987 echo -n "Wget url : " ; read anser
2988 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2989 # Ask for a stuff dir.
2990 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2991 if [ "$anser" = "y" ]; then
2992 echo -n "Creating the stuff directory..."
2993 mkdir stuff && status
2994 fi
2995 # Ask for a description file.
2996 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2997 if [ "$anser" = "y" ]; then
2998 echo -n "Creating the description.txt file..."
2999 echo "" > description.txt && status
3000 fi
3001 echo "================================================================================"
3002 echo ""
3003 fi
3004 ;;
3005 remove)
3006 # Remove a package from the wok.
3008 get_tazwok_config
3009 check_for_package_on_cmdline
3010 echo ""
3011 echo -n "Please confirm deletion (y/N) : "; read anser
3012 if [ "$anser" = "y" ]; then
3013 echo -n "Removing $PACKAGE..."
3014 rm -rf $WOK/$PACKAGE && status
3015 echo ""
3016 fi
3017 ;;
3018 update-wok)
3019 # Pull and update a Hg wok.
3020 get_options_list="local"
3021 get_tazwok_config
3022 source_lib report
3023 report start
3024 clean_wok=$LOCAL_REPOSITORY/clean-wok
3025 cd $clean_wok
3026 if ! [ "$local" ]; then
3027 if [ "$WOK_UPDATE_METHOD" = hg ]; then
3028 if ! [ -f "$INSTALLED/mercurial/receipt" ]; then
3030 # Auto-install only if we are in a cook chroot.
3031 if [ -x /usr/bin/clean-chroot ]; then
3032 tazpkg get-install mercurial
3033 else
3034 echo "" >&2
3035 echo "You need to install mercurial to get wok from hg (recommended). Oherwise, you can switch wok get method to \"tarball\" into $LOCAL_RESOSITORY/tazwok.conf (per-repository configuration, it not always exists) or /etc/slitaz/tazwok.conf (global configuration)." | fold -s >&2
3036 echo "">&2
3037 exit 1
3038 fi
3039 fi
3041 report step "Getting wok changes using hg"
3042 if [ -d .hg ]; then
3043 hg pull -u || exit 1
3044 else
3045 hg clone $HG_WOK . || exit 1
3046 fi
3047 report end-step
3048 [ -x /usr/bin/clean-chroot ] && clean-chroot
3049 else
3050 report step "Getting wok changes using tarball"
3051 { mkdir .tmp && cd .tmp
3052 wget "$TARBALL_WOK" &&
3053 case $TARBALL_WOK in
3054 *bz2) tar xjf *.bz2 -C wok; rm *.bz2;;
3055 *lzma) unlzma -c *.lzma | tar xf - -C wok; rm *.lzma ;;
3056 *gz) tar xzf *.gz -C wok; rm*.gz ;;
3057 esac &&
3058 rm -r $(ls -d $clean_wok/*) &&
3059 cp -a wok/* $clean_wok &&
3060 cd .. &&
3061 rm -r .tmp
3062 } || { echo "That's not cool: it fails!" >&2
3063 report end-step
3064 exit 1; }
3065 report end-step
3066 fi
3067 fi
3068 report step "Appending changes to wok"
3070 # Handle removed files/dir.
3071 cd $WOK
3072 for dir in *; do
3073 [ -d "$clean_wok/$dir" ] || rm -rf $dir
3074 done
3075 for file in */receipt */description.txt; do
3076 [ -f "$clean_wok/$file" ] || rm -rf $file
3077 done
3078 for i in $(find */stuff 2>/dev/null); do
3079 [ -e "$clean_wok/$i" ] || rm -rf $i
3080 done
3082 cp -a $clean_wok/* $WOK
3083 report end-step
3084 ;;
3085 maintainers)
3086 get_tazwok_config
3087 echo ""
3088 echo "List of maintainers for: $WOK"
3089 echo "================================================================================"
3090 touch /tmp/slitaz-maintainers
3091 for pkg in $WOK/*
3092 do
3093 . $pkg/receipt
3094 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
3095 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
3096 echo "$MAINTAINER"
3097 fi
3098 done
3099 echo "================================================================================"
3100 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
3101 echo ""
3102 # Remove tmp files
3103 rm -f /tmp/slitaz-maintainers
3104 ;;
3105 maintained-by)
3106 # Search for packages maintained by a contributor.
3107 get_tazwok_config
3108 if [ ! -n "$2" ]; then
3109 echo "Specify a name or email of a maintainer." >&2
3110 exit 1
3111 fi
3112 echo "Maintainer packages"
3113 echo "================================================================================"
3114 for pkg in $WOK/*
3115 do
3116 . $pkg/receipt
3117 if echo "$MAINTAINER" | fgrep -q "$2"; then
3118 echo "$PACKAGE"
3119 packages=$(($PACKAGEs+1))
3120 fi
3121 done
3122 echo "================================================================================"
3123 echo "Packages maintained by $2: $PACKAGEs"
3124 echo ""
3125 ;;
3126 tags)
3127 get_tazwok_config
3128 echo -e "\n\033[1mTags list :\033[0m"
3129 horizontal_line
3130 cd $WOK
3131 for i in */receipt; do
3132 unset TAGS
3133 source $i
3134 for t in $TAGS; do
3135 grep -q ^$t$ $tmp/tags && continue
3136 echo $t | tee -a $tmp/tags
3137 done
3138 done
3139 horizontal_line
3140 echo "$(wc -l $tmp/tags | cut -f1 -d ' ') tags listed."
3141 ;;
3142 check-src)
3143 # Verify if upstream package is still available
3145 get_tazwok_config
3146 check_for_package_on_cmdline
3147 check_for_receipt
3148 source_receipt
3149 check_src()
3151 for url in $@; do
3152 busybox wget -s $url 2>/dev/null && break
3153 done
3155 if [ "$WGET_URL" ];then
3156 echo -n "$PACKAGE : "
3157 check_src $WGET_URL
3158 status
3159 else
3160 echo "No tarball to check for $PACKAGE"
3161 fi
3162 ;;
3163 get-src)
3164 check_root
3165 get_options_list="target nounpack"
3166 get_tazwok_config
3167 check_for_package_on_cmdline
3168 check_for_receipt
3169 source_receipt
3170 if [ "$WGET_URL" ];then
3171 source_lib report
3172 report start
3173 check_for_tarball
3174 else
3175 echo "No tarball to download for $PACKAGE"
3176 fi
3177 ;;
3178 check-commit)
3179 check_root
3180 get_options_list="missing forced"
3181 get_tazwok_config
3182 source_lib report
3183 report start
3184 if [ "$forced" ]; then
3185 rm -f $WOK/*/md5
3186 unset forced
3187 fi
3188 if [ "$missing" ]; then
3189 pkg=$(ls -1 $WOK)
3190 else
3191 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3192 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3193 } | sort -u)"
3194 fi
3195 cooklist=$PACKAGES_REPOSITORY/cooklist
3196 gen_cook_list
3197 ;;
3198 cook-commit)
3199 check_root
3200 get_options_list="missing forced"
3201 get_tazwok_config
3202 source_lib report
3203 report start
3204 if [ "$forced" ]; then
3205 rm -f $WOK/*/md5
3206 unset forced
3207 fi
3208 if [ "$missing" ]; then
3209 pkg=$(ls -1 $WOK)
3210 else
3211 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3212 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3213 } | sort -u)"
3214 fi
3215 cooklist=$PACKAGES_REPOSITORY/cooklist
3216 gen_cook_list
3217 cook_list
3218 ;;
3219 cook-all)
3220 check_root
3221 get_options_list="forced missing"
3222 get_tazwok_config
3223 source_lib report
3224 report start
3225 if [ "$missing" ]; then
3226 pkg=$(ls -1 $WOK)
3227 else
3228 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3229 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3230 } | sort -u)"
3231 fi
3232 cooklist=$PACKAGES_REPOSITORY/cooklist
3233 gen_cook_list
3234 cook_list
3235 ;;
3236 gen-wok-db)
3237 check_root
3238 get_tazwok_config
3239 source_lib report
3240 report start
3241 gen_wok_db
3242 ;;
3243 report)
3244 get_tazwok_config
3245 cd $PACKAGES_REPOSITORY
3246 if [ "$2" ]; then
3247 case $2 in
3248 commit|cooklist|incoming|broken|blocked)
3249 show="$2"
3250 ;;
3251 *)
3252 echo "usage : tazwok report [commit|cooklist|incoming|broken|blocked]" >&2
3253 exit 1
3254 ;;
3255 esac
3256 else
3257 show="commit cooklist incoming broken blocked"
3258 fi
3259 for i in $show; do
3260 if [ -s $i ]; then
3261 echo ""
3262 echo -e "\033[1m$i\033[0m"
3263 echo "================================================================================"
3264 cat $i
3265 echo "================================================================================"
3266 echo ""
3267 fi
3268 done
3269 ;;
3270 check-incoming)
3271 check_root
3272 get_options_list="forced"
3273 get_tazwok_config
3274 source_lib report
3275 report start
3276 [ -f $LOCAL_RESOSITORY/incoming ] && rm [ -f $LOCAL_REPOSITORY/incoming ]
3277 report step "Checking $INCOMING_REPOSITORY"
3278 report open-bloc
3279 [ -f $LOCAL_REPOSITORY/log/incoming.html ] && rm $LOCAL_REPOSITORY/log/incoming.html
3280 report sublog $LOCAL_REPOSITORY/log/incoming.html
3281 echo "incoming" > $LOCAL_REPOSITORY/log/package
3282 check_for_incoming
3283 report end-sublog
3284 report close-bloc
3285 ;;
3286 configure-chroot)
3287 check_root
3288 get_tazwok_config
3289 if [ -f /usr/bin/tazchroot ]; then
3290 cd $LOCAL_REPOSITORY
3291 configure_tazchroot
3292 else
3293 echo "The packages tazchroot need to be installed" >&2
3294 exit 1
3295 fi
3296 ;;
3297 chroot)
3298 check_root
3299 get_tazwok_config
3300 # Merge this and the other chroot function ?.
3301 if [ -f /usr/bin/tazchroot ]; then
3302 cd $LOCAL_REPOSITORY
3303 [ ! -f tazchroot.conf ] && configure_tazchroot
3304 tazchroot
3305 else
3306 echo "The packages tazchroot need to be installed" >&2
3307 exit 1
3308 fi
3309 ;;
3310 cook-toolchain)
3311 check_root
3312 get_tazwok_config
3313 echo -n "" > $PACKAGES_REPOSITORY/broken
3314 if [ -f /usr/bin/tazchroot ]; then
3315 cd $LOCAL_REPOSITORY
3316 [ ! -f tazchroot.conf ] && configure_tazchroot
3317 tazchroot cook-toolchain
3318 # Buggy : chroot can be elsewhere.
3319 rm -r $LOCAL_REPOSITORY/chroot
3320 # /!\ to be writed :
3321 # next rm chroot and plan cook-all by pushing all packages
3322 # in cooklist.
3323 else
3324 echo "The packages tazchroot need to be installed" >&2
3325 exit 1
3326 fi
3327 ;;
3328 webserver)
3329 check_root
3330 get_tazwok_config
3331 if [ "$ARG" = on ]; then
3332 if [ "$WEBSERVER" ] && [ -f "$WEBSERVER/repositories.list" ] && \
3333 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3334 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3335 exit 1
3336 fi
3337 if ! [ -f $LOCAL_REPOSITORY/tazchroot.conf ]; then
3338 tazwok configure-chroot ${undigest:+--undigest=$undigest} --SLITAZ_VERSION=$SLITAZ_VERSION --SLITAZ_DIR=$SLITAZ_DIR
3339 fi
3340 for pkg in php lighttpd; do
3341 [ -d $INSTALLED/$pkg ] || missing="$missing $pkg"
3342 done
3343 if [ "$missing" ]; then
3344 echo "You need to install those packages to start webserver: $missing." >&2
3345 exit 1
3346 fi
3347 if [ ! -f "$LOCAL_REPOSITORY/tazwok.conf" ]; then
3348 echo "Copying /etc/slitaz/tazwok.conf to $LOCAL_REPOSITORY/tazwok.conf: webserver is configured repository-by-repository."
3349 cp /etc/slitaz/tazwok.conf $LOCAL_REPOSITORY
3350 fi
3351 if ! [ "$WEBSERVER" ]; then
3352 echo -n "Where to store php pages (default: /var/www/vhosts/bb)? "
3353 read WEBSERVER
3354 [ "$WEBSERVER" ] || WEBSERVER="/var/www/vhosts/bb"
3355 fi
3356 if [ -f "$WEBSERVER/repositories.list" ] && \
3357 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3358 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3359 exit 1
3360 fi
3361 mkdir -p $WEBSERVER
3362 echo "${undigest:-$SLITAZ_VERSION}" >> $WEBSERVER/repositories.list
3363 for file in index.php log.php download.php; do
3364 [ -f "$WEBSERVER/$file" ] || ln -s /usr/share/slitaz/web-bb/$file $WEBSERVER
3365 done
3366 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3367 ln -s $dir $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3368 done
3369 source $LOCAL_REPOSITORY/tazchroot.conf
3370 echo "<?php
3372 // Web interface configuration
3374 \$version=\"${undigest:-$SLITAZ_VERSION}\";
3375 \$chroot=\"$chroot_dir\";
3376 \$lockfile=\"\$chroot/proc/1/status\";
3377 \$db_dir=\"$PACKAGES_REPOSITORY\";
3378 \$log_dir=\"$LOCAL_REPOSITORY/log\";
3379 \$packages=\"$PACKAGES_REPOSITORY\";
3380 \$incoming=\"$INCOMING_REPOSITORY\";
3381 \$wok=\"$WOK\";
3383 ?>" > $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3384 [ -L "$WEBSERVER/web" ] || ln -s /usr/share/slitaz/web $WEBSERVER
3385 echo "WEBSERVER=\"$WEBSERVER\"" >> $LOCAL_REPOSITORY/tazwok.conf
3386 if [ -L "$WEBSERVER/conf.php" ]; then
3387 echo "Do yo want to make ${undigest:-$SLITAZ_VERSION} the default page (y/N) ? "
3388 read answer
3389 if [ "$answer" = y ]; then
3390 rm $WEBSERVER/conf.php
3391 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3392 fi
3393 else
3394 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3395 fi
3396 elif [ "$ARG" = off ]; then
3397 if ! [ "$WEBSERVER" ]; then
3398 echo "No webserver running for ${undigest:-$SLITAZ_VERSION}" >&2
3399 exit 1
3400 fi
3401 sed '/^WEBSERVER/d' -i $LOCAL_REPOSITORY/tazwok.conf
3402 sed "/^${undigest:-$SLITAZ_VERSION}$/d" -i $WEBSERVER/repositories.list
3403 rm $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3404 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3405 rm $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3406 done
3407 if ! [ -s "$WEBSERVER/repositories.list" ]; then
3408 echo "$WEBSERVER/repositories.list is empty; tazwok doesn't remove the server automatically in case you have important stuff in it. If it's not the case, you can remove it using: rm -r $WEBSERVER"
3409 rm $WEBSERVER/conf.php
3410 elif [ "$(readlink $WEBSERVER/conf.php)" = "$WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php" ]; then
3411 echo "${undigest:-$SLITAZ_VERSION} was the default version to use; switched to : $(sed 1!d $WEBSERVER/repositories.list)"
3412 rm $WEBSERVER/conf.php
3413 ln -s $WEBSERVER/conf-$(sed 1!d $WEBSERVER/repositories.list).php $WEBSERVER/conf.php
3414 fi
3415 else
3416 echo "Usage: tazwok webserver on/off" >&2
3417 exit 1
3418 fi
3419 ;;
3420 block)
3421 # Add a pkg name to the list of blocked packages.
3422 get_tazwok_config
3423 check_root
3424 check_for_package_on_cmdline
3425 if ! [ -f $WOK/$PACKAGE/receipt ]; then
3426 echo "Can't find $PACKAGE into wok." >&2
3427 echo ""
3428 exit 1
3429 fi
3430 echo ""
3431 if grep -qs "^$PACKAGE$" $PACKAGES_REPOSITORY/blocked; then
3432 echo "$PACKAGE is already in the blocked packages list." >&2
3433 echo ""
3434 exit 1
3435 else
3436 echo -n "Adding $PACKAGE to : $PACKAGES_REPOSITORY/blocked... "
3437 echo "$PACKAGE" >> $PACKAGES_REPOSITORY/blocked
3438 status
3439 if grep -q "^$PACKAGE$" $PACKAGES_REPOSITORY/cooklist; then
3440 echo -n "Removing $PACKAGE from : $PACKAGES_REPOSITORY/cooklist... "
3441 sed -i /"^$PACKAGE$"/d $PACKAGES_REPOSITORY/cooklist
3442 status
3443 fi
3444 fi
3445 echo "" ;;
3446 unblock)
3447 # Remove a pkg name from the list of blocked packages.
3448 get_tazwok_config
3449 check_root
3450 check_for_package_on_cmdline
3451 if ! [ -f $WOK/$PACKAGE/receipt ]; then
3452 echo "Can't find $PACKAGE into wok." >&2
3453 echo ""
3454 exit 1
3455 fi
3456 echo ""
3457 if grep -qs "^$PACKAGE$" $PACKAGES_REPOSITORY/blocked; then
3458 echo -n "Removing $PACKAGE from : $PACKAGES_REPOSITORY/blocked... "
3459 sed -i /"^$PACKAGE$"/d $PACKAGES_REPOSITORY/blocked
3460 sed -i '/^$/d' $PACKAGES_REPOSITORY/blocked
3461 status
3462 else
3463 echo "$PACKAGE is not in the blocked packages list." >&2
3464 echo ""
3465 exit 1
3466 fi
3467 echo "" ;;
3468 usage|*)
3469 # Print usage also for all unknown commands.
3471 usage
3472 ;;
3473 esac
3475 report stop 2>/dev/null
3476 exit 0