tazwok view tazwok @ rev 400

Continue to have cookorder.txt into PACKAGES_REPOSITORY until 4.3 release; this file and cooklist/commit/broken/blocked will be moved to INCOMING_REPOSITORY at 4.3 release because we don't wan't them into mirrored main packages repopsitory. (4.3)
author Antoine Bodin <gokhlayeh@slitaz.org>
date Thu Mar 03 22:40:03 2011 +0100 (2011-03-03)
parents 248bcbd6490b
children c02e68d59ecf
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 fgrep -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 unset EXTRAVERSION
2085 for PACKAGE in $incoming_pkgs; do
2086 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
2087 VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
2088 remove_previous_package $PACKAGES_REPOSITORY
2089 echo "Moving $PACKAGE..."
2090 mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
2091 touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
2092 previous_tarball=$(grep ^$PACKAGE:main $SOURCES_REPOSITORY/sources.list | cut -f2)
2093 sed -e "/^$PACKAGE:main/d" \
2094 -e "s/^$PACKAGE:incoming/$PACKAGE:main/" \
2095 -i $SOURCES_REPOSITORY/sources.list
2096 if [ "$previous_tarball" ]; then
2097 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
2098 rm -f $SOURCES_REPOSITORY/$previous_tarball
2099 fi
2100 done
2101 for file in packages.list packages.equiv packages.md5 packages.desc \
2102 packages.txt; do
2103 echo -n "" > $INCOMING_REPOSITORY/$file
2104 done
2105 rm -r $INCOMING_REPOSITORY/files.list.lzma
2106 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2108 report step "Updating flavors"
2109 if [ -x /usr/bin/tazlito ] || [ -x /usr/bin/clean-chroot ]; then
2110 if ! [ -x /usr/bin/tazlito ]; then
2111 tazpkg get-install tazlito
2112 fi
2114 # Handle cases where tazwok is used into main system;
2115 # Handle cases where SLITAZ_DIR is not /home/slitaz.
2116 [ -L /home/slitaz/flavors ] && rm /home/slitaz/flavors
2117 mkdir -p /home/slitaz
2118 ln -s $LOCAL_REPOSITORY/flavors /home/slitaz/flavors
2120 cd $LOCAL_REPOSITORY/packages
2121 for i in $LOCAL_REPOSITORY/flavors/*; do
2122 [ -d "$i" ] || continue
2123 tazlito pack-flavor ${i##*/}
2124 done
2126 noheader=""
2127 for i in *.flavor; do
2128 tazlito show-flavor $i --brief $noheader
2129 noheader="--noheader"
2130 done > flavors.list
2131 [ -x /usr/bin/clean-chroot ] && clean-chroot
2132 else
2133 echo "Can't create up-to-date flavors because tazlito package is missing." >&2
2134 fi
2135 report end-step
2138 ########################################################################
2139 # TAZWOK MAIN FUNCTIONS
2140 ########################
2142 clean()
2144 cd $WOK/$PACKAGE
2145 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
2146 -e ^stuff$ || return
2148 [ "$COMMAND" = clean-wok ] || report step "Cleaning $PACKAGE"
2149 # Check for clean_wok function.
2150 if grep -q ^clean_wok $RECEIPT; then
2151 clean_wok
2152 fi
2153 # Clean should only have a receipt, stuff and optional desc.
2154 for f in `ls .`
2155 do
2156 case $f in
2157 receipt|stuff|description.txt|md5)
2158 continue ;;
2159 *)
2160 rm -rf $f ;;
2161 esac
2162 done
2163 [ "$COMMAND" != clean-wok ] && report end-step
2166 # Configure and make a package with the receipt.
2167 compile_package()
2169 check_for_package_on_cmdline
2171 # Include the receipt to get all needed variables and functions
2172 # and cd into the work directory to start the work.
2173 check_for_receipt
2174 source_receipt
2176 # Log the package name and date.
2177 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
2178 echo "package $PACKAGE (compile)" >> $LOG
2180 # Set wanted $src variable to help compiling.
2181 [ ! "$src" ] && set_src_path
2182 check_for_build_depends || return 1
2183 check_for_wanted
2184 unset target
2185 check_for_tarball && check_for_compile_rules
2188 # Cook command also include all features to manage lists which keep
2189 # track of wok/packages state.
2190 cook()
2192 cook_code=
2193 set_common_path
2194 check_for_receipt
2195 source_receipt
2197 # Define log path and start report.
2198 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
2199 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
2200 echo "$PACKAGE" > $LOCAL_REPOSITORY/log/package
2201 report step "Cooking $PACKAGE"
2202 report open-bloc
2204 clean $PACKAGE
2205 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
2207 if compile_package; then
2208 remove_src
2209 refresh_packages_from_compile
2210 gen_package
2212 # Update packages-incoming repository.
2213 store_pkgname=$PACKAGE
2214 pkg_repository=$INCOMING_REPOSITORY
2215 update_packages_db
2217 PACKAGE=$store_pkgname
2218 unset store_pkgname
2220 # Upgrade to cooked packages if it was previously installed.
2221 report step "Look for package(s) to upgrade"
2222 for pkg in $(look_for_rwanted) $PACKAGE; do
2223 if [ -d $INSTALLED/$pkg ]; then
2224 tazpkg get-install $pkg --forced
2225 fi
2226 done
2227 report end-step
2228 else
2229 set_pkg_broken
2230 cook_code=1
2231 fi
2233 # Remove build_depends in cook mode (if in cooklist, it's done when
2234 # checking build_depends of next package and we remove only unneeded
2235 # packages to keep chroot minimal and gain some time).
2236 if [ "$COMMAND" = cook ]; then
2237 remove_build_depends $MISSING_PACKAGE
2238 [ -x /usr/bin/clean-chroot ] && clean-chroot
2239 fi
2241 # Regen the cooklist if it was planned and command is not cook.
2242 [ "$regen_cooklist" ] && unset regen_cooklist && \
2243 [ "$COMMAND" != cook ] && sort_cooklist
2245 # Some hacks to set the bloc & function status as failed if cook was
2246 # failed.
2247 report_return_code=$cook_code
2248 report close-bloc
2249 report end-sublog
2250 rm -f $LOCAL_REPOSITORY/log/package
2251 return $cook_code
2254 cook_list()
2256 if [ -s $tmp/cooklist ]; then
2257 if [ -f /usr/bin/tazchroot ]; then
2258 # Note : options -main variables- are automatically keeped by
2259 # the sub-applications tazchroot/tazwok; as well as report data.
2260 cd $LOCAL_REPOSITORY
2261 [ ! -f tazchroot.conf ] && configure_tazchroot
2262 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
2263 return
2264 fi
2265 while [ -s $tmp/cooklist ]; do
2266 PACKAGE=$(sed 1!d $tmp/cooklist)
2267 cook
2268 done
2269 remove_build_depends $MISSING_PACKAGE $remove_later
2270 [ -x /usr/bin/clean-chroot ] && clean-chroot
2271 else
2272 echo "Nothing to cook."
2273 return
2274 fi
2277 configure_tazchroot()
2279 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
2280 # Tazchroot configuration file - created by tazwok.
2282 # Default chroot path
2283 SLITAZ_DIR=$SLITAZ_DIR
2284 SLITAZ_VERSION=$SLITAZ_VERSION
2285 $( [ "$undigest" ] && echo "undigest=$undigest" )
2286 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
2287 chroot_dir=\$LOCAL_REPOSITORY/chroot
2289 # Default scripts path (theses scripts are added in the
2290 # $chroot_dir/usr/bin and can be called with tazchroot script)
2291 script_dir=/usr/lib/slitaz/chroot-scripts/tazwok
2293 # List of directories to mount.
2294 list_dir="$(for dir in packages wok src packages-incoming log flavors iso clean-wok; do echo $LOCAL_REPOSITORY/$dir; done)
2295 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
2297 create_chroot()
2299 mkdir -p \$chroot_dir
2300 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
2301 tazpkg get-install \$pkg --root="\$chroot_dir"
2302 done
2304 # Store list of installed packages needed by cleanchroot.
2305 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
2307 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
2308 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
2309 -i \$chroot_dir/etc/slitaz/slitaz.conf
2310 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
2311 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
2312 # The build bot may run in a sandbox: link sandbox lockfile
2313 ln -s \$LOCAL_REPOSITORY/sandbox/proc/1 \$chroot_dir/proc/1
2316 mount_chroot()
2318 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
2319 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
2320 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
2321 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
2322 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
2323 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
2324 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
2325 mount -t proc proc \$chroot_dir/proc
2326 mount -t sysfs sysfs \$chroot_dir/sys
2327 mount -t devpts devpts \$chroot_dir/dev/pts
2328 mount -t tmpfs shm \$chroot_dir/dev/shm
2329 for dir in \$list_dir; do
2330 mkdir -p \$dir \$chroot_dir\$dir
2331 mount \$dir \$chroot_dir\$dir
2332 done
2335 umount_chroot()
2337 for dir in \$list_dir; do
2338 umount \$chroot_dir\$dir
2339 done
2340 umount \$chroot_dir/dev/shm
2341 umount \$chroot_dir/dev/pts
2342 umount \$chroot_dir/sys
2343 umount \$chroot_dir/proc
2345 EOF
2348 ########################################################################
2349 ######################### END OF NEW FUNCTIONS #########################
2350 ########################################################################
2352 # List packages providing a virtual package
2353 whoprovide()
2355 local i;
2356 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
2357 . $i
2358 case " $PROVIDE " in
2359 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
2360 esac
2361 done
2364 ########################################################################
2365 # TAZWOK COMMANDS
2366 ########################
2368 case "$COMMAND" in
2369 stats)
2370 # Tazwok general statistics from the wok config file.
2372 get_tazwok_config
2373 echo -e "\n\033[1mTazwok configuration statistics\033[0m
2374 ================================================================================
2375 Wok directory : $WOK
2376 Packages repository : $PACKAGES_REPOSITORY
2377 Incoming repository : $INCOMING_REPOSITORY
2378 Sources repository : $SOURCES_REPOSITORY
2379 Log directory : $LOCAL_REPOSITORY/log
2380 Packages in the wok : `ls -1 $WOK | wc -l`
2381 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2382 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2383 ================================================================================\n"
2384 ;;
2385 edit)
2386 get_tazwok_config
2387 check_for_package_on_cmdline
2388 check_for_receipt
2389 $EDITOR $WOK/$PACKAGE/receipt
2390 ;;
2391 build-depends)
2392 # List dependencies to rebuild wok, or only a package
2393 get_tazwok_config
2394 report(){ : ; }
2395 if [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
2396 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
2397 --look_for=dep --with_dev --with_args
2398 else
2399 check_for_package_on_cmdline
2400 scan $PACKAGE --look_for=bdep --with_dev
2401 fi
2402 ;;
2403 gen-cooklist)
2404 check_root
2405 get_options_list="pkg"
2406 get_tazwok_config
2407 report(){ : ; }
2408 if ! [ "$pkg" ]; then
2409 if [ ! "$LIST" ] || [ "$LIST" = toolchain ]; then
2410 pkg="$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA"
2411 else
2412 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2413 fi
2414 fi
2415 gen_cook_list
2416 ;;
2417 check-depends)
2418 # Check package depends /!\
2419 get_tazwok_config
2420 echo ""
2421 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
2422 ================================================================================"
2423 TMPDIR=/tmp/tazwok$$
2424 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
2426 # Build ALL_DEPENDS variable
2427 scan_dep()
2429 local i
2430 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
2431 for i in $DEPENDS $SUGGESTED ; do
2432 case " $ALL_DEPENDS " in
2433 *\ $i\ *) continue;;
2434 esac
2435 [ -d $WOK/$i ] || {
2436 ALL_DEPENDS="$ALL_DEPENDS$i "
2437 continue
2439 DEPENDS=""
2440 SUGGESTED=""
2441 . $WOK/$i/receipt
2442 scan_dep
2443 done
2446 # Check for ELF file
2447 is_elf()
2449 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ]
2452 # Print shared library dependencies
2453 ldd()
2455 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2458 mkdir $TMPDIR
2459 cd $TMPDIR
2460 for i in $LOCALSTATE/files.list.lzma \
2461 $LOCALSTATE/undigest/*/files.list.lzma ; do
2462 [ -f $i ] && lzma d $i -so >> files.list
2463 done
2464 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2465 tazpkg extract $pkg > /dev/null 2>&1
2466 . */receipt
2467 ALL_DEPENDS="$DEFAULT_DEPENDS "
2468 scan_dep
2469 find */fs -type f | while read file ; do
2470 is_elf $file || continue
2471 case "$file" in
2472 *.o|*.ko|*.ko.gz) continue;;
2473 esac
2474 ldd $file | while read lib rem; do
2475 case "$lib" in
2476 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2477 continue;;
2478 esac
2479 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2480 case " $ALL_DEPENDS " in
2481 *\ $dep\ *) continue 2;;
2482 esac
2483 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2484 case " $ALL_DEPENDS " in
2485 *\ $vdep\ *) continue 3;;
2486 esac
2487 done
2488 done
2489 [ -n "$dep" ] || dep="UNKNOWN"
2490 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2491 done
2492 done
2493 rm -rf */
2494 done
2495 cd /tmp
2496 rm -rf $TMPDIR
2497 ;;
2498 check)
2499 # Check wok consistency
2500 get_tazwok_config
2501 echo ""
2502 echo -e "\033[1mWok and packages checking\033[0m
2503 ================================================================================"
2504 cd $WOK
2505 for pkg in $(ls)
2506 do
2507 [ -f $pkg/receipt ] || continue
2508 RECEIPT= $pkg/receipt
2509 source_receipt
2510 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2511 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2512 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2513 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2514 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2515 if [ -n "$WANTED" ]; then
2516 if [ ! -f $WANTED/receipt ]; then
2517 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2518 else
2519 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2520 if [ "$VERSION" = "$WANTED" ]; then
2521 # BASEVERSION is computed in receipt
2522 fgrep -q '_pkg=' $pkg/receipt &&
2523 BASEVERSION=$VERSION
2524 fi
2525 if [ "$VERSION" != "$BASEVERSION" ]; then
2526 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2527 fi
2528 fi
2529 fi
2531 if [ -n "$CATEGORY" ]; then
2532 case " $(echo $CATEGORIES) " in
2533 *\ $CATEGORY\ *);;
2534 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2535 esac
2536 else
2537 echo"Package $PACKAGE has no CATEGORY" >&2
2538 fi
2539 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2540 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2541 case "$WGET_URL" in
2542 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2543 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2544 '') ;;
2545 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2546 esac
2547 case "$WEB_SITE" in
2548 ftp*|http*);;
2549 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2550 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2551 esac
2552 case "$MAINTAINER" in
2553 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2554 esac
2555 case "$MAINTAINER" in
2556 *@*);;
2557 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2558 esac
2559 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2560 for i in $DEPENDS; do
2561 [ -d $i ] && continue
2562 [ -n "$(whoprovide $i)" ] && continue
2563 echo -e "$MSG $i"
2564 MSG=""
2565 done
2566 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2567 for i in $BUILD_DEPENDS; do
2568 [ -d $i ] && continue
2569 [ -n "$(whoprovide $i)" ] && continue
2570 echo -e "$MSG $i"
2571 MSG=""
2572 done
2573 MSG="Dependencies loop between $PACKAGE and :\n"
2574 ALL_DEPS=""
2575 check_for_deps_loop $PACKAGE $DEPENDS
2576 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2577 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2578 echo "$pkg should be rebuilt after $i installation"
2579 done
2580 done
2581 ;;
2582 list)
2583 # List packages in wok directory. User can specify a category.
2585 get_tazwok_config
2586 if [ "$2" = "category" ]; then
2587 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2588 exit 0
2589 fi
2590 # Check for an asked category.
2591 if [ -n "$2" ]; then
2592 ASKED_CATEGORY=$2
2593 echo ""
2594 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2595 echo "================================================================================"
2596 for pkg in $WOK/*
2597 do
2598 [ ! -f $pkg/receipt ] && continue
2599 . $pkg/receipt
2600 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2601 echo -n "$PACKAGE"
2602 echo -e "\033[28G $VERSION"
2603 packages=$(($packages+1))
2604 fi
2605 done
2606 echo "================================================================================"
2607 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
2608 else
2609 # By default list all packages and version.
2610 echo ""
2611 echo -e "\033[1mList of packages in the wok\033[0m"
2612 echo "================================================================================"
2613 for pkg in $WOK/*
2614 do
2615 [ ! -f $pkg/receipt ] && continue
2616 . $pkg/receipt
2617 echo -n "$PACKAGE"
2618 echo -en "\033[28G $VERSION"
2619 echo -e "\033[42G $CATEGORY"
2620 packages=$(($packages+1))
2621 done
2622 echo "================================================================================"
2623 echo -e "$packages packages available in the wok.\n"
2624 fi
2625 ;;
2626 info)
2627 # Information about a package.
2629 get_tazwok_config
2630 check_for_package_on_cmdline
2631 check_for_receipt
2632 . $WOK/$PACKAGE/receipt
2633 echo ""
2634 echo -e "\033[1mTazwok package information\033[0m
2635 ================================================================================
2636 Package : $PACKAGE
2637 Version : $VERSION
2638 Category : $CATEGORY
2639 Short desc : $SHORT_DESC
2640 Maintainer : $MAINTAINER"
2641 if [ ! "$WEB_SITE" = "" ]; then
2642 echo "Web site : $WEB_SITE"
2643 fi
2644 if [ ! "$DEPENDS" = "" ]; then
2645 echo "Depends : $DEPENDS"
2646 fi
2647 if [ ! "$WANTED" = "" ]; then
2648 echo "Wanted src : $WANTED"
2649 fi
2650 echo "================================================================================"
2651 echo ""
2652 ;;
2653 check-log)
2654 # We just cat the file log to view process info.
2656 get_tazwok_config
2657 if [ ! -f "$LOG" ]; then
2658 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2659 exit 1
2660 else
2661 echo ""
2662 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2663 echo "================================================================================"
2664 cat $LOG
2665 echo "================================================================================"
2666 echo ""
2667 if [ -s "$WOK/$PACKAGE/warning.txt" ]; then
2668 echo -e "\033[1mCook warning(s) for :\033[0m $PACKAGE"
2669 echo "================================================================================"
2670 cat "$WOK/$PACKAGE/warning.txt"
2671 echo "================================================================================"
2672 echo ""
2673 fi
2674 fi
2675 ;;
2676 search)
2677 # Search for a package by pattern or name.
2679 get_tazwok_config
2680 if [ -z "$2" ]; then
2681 echo -e "\nPlease specify a pattern or a package name to search." >&2
2682 echo -e "Example : 'tazwok search gcc'.\n" >&2
2683 exit 1
2684 fi
2685 echo ""
2686 echo -e "\033[1mSearch result for :\033[0m $2"
2687 echo "================================================================================"
2688 list=`ls -1 $WOK | fgrep $2`
2689 for pkg in $list
2690 do
2691 . $WOK/$pkg/receipt
2692 echo -n "$PACKAGE "
2693 echo -en "\033[24G $VERSION"
2694 echo -e "\033[42G $CATEGORY"
2695 packages=$(($PACKAGEs+1))
2696 done
2697 echo "================================================================================"
2698 echo "$packages packages found for : $2"
2699 echo ""
2700 ;;
2701 compile)
2702 # Configure and make a package with the receipt.
2704 get_tazwok_config
2705 source_lib report
2706 report start
2707 compile_package
2708 ;;
2709 genpkg)
2710 # Generate a package.
2712 get_tazwok_config
2713 source_lib report
2714 report start
2715 gen_package
2716 ;;
2717 cook)
2718 # Compile and generate a package. Just execute tazwok with
2719 # the good commands.
2721 check_root
2722 get_tazwok_config
2723 source_lib report
2724 report start
2725 update_wan_db
2726 check_for_commit
2727 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
2728 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
2729 if [ "$plan_regen_cookorder" ]; then
2730 [ "$(sed 1!d $cookorder)" = "#PlanSort" ] || \
2731 sed 1i"#PlanSort" -i $cookorder
2732 fi
2733 cook
2734 ;;
2735 sort-cooklist)
2736 if [ ! -f "$LIST" ]; then
2737 echo "Usage : tazwok sort-cooklist cooklist" >&2
2738 exit 1
2739 fi
2740 check_root
2741 get_tazwok_config
2742 report(){ : ; }
2743 # When using sort-cooklist, the script should behave as for gen-cooklist
2744 # The only difference between theses two is where the output is sended.
2745 COMMAND=gen-cooklist
2746 cooklist=$LIST
2747 gen_cook_list
2748 cp -af $tmp/cooklist $cooklist
2749 ;;
2750 cook-list)
2751 # Cook all packages listed in a file or in default cooklist.
2752 check_root
2753 get_options_list="pkg forced"
2754 get_tazwok_config
2755 source_lib report
2756 report start
2757 if ! [ "$pkg" ]; then
2758 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2759 fi
2760 gen_cook_list
2761 cook_list
2762 ;;
2763 clean)
2764 # Clean up a package work directory + thoses which want it.
2766 get_tazwok_config
2767 check_for_package_on_cmdline
2768 check_for_receipt
2769 source_lib report
2770 report start
2771 . $RECEIPT
2772 clean
2773 ;;
2774 gen-clean-wok)
2775 # Generate a clean wok from the current wok by copying all receipts
2776 # and stuff directory.
2778 get_tazwok_config
2779 source_lib report
2780 report start
2781 if [ -z "$ARG" ]; then
2782 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2783 exit 1
2784 else
2785 dest=$ARG
2786 mkdir -p $dest
2787 fi
2788 report step "Creating clean wok in : $dest"
2789 for pkg in `ls -1 $WOK`
2790 do
2791 mkdir -p $dest/$pkg
2792 cp -a $WOK/$pkg/receipt $dest/$pkg
2793 [ -f $WOK/$pkg/description.txt ] && \
2794 cp -a $WOK/$pkg/description.txt $dest/$pkg
2795 if [ -d "$WOK/$pkg/stuff" ]; then
2796 cp -a $WOK/$pkg/stuff $dest/$pkg
2797 fi
2798 done
2799 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2800 report end-step
2801 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2802 echo ""
2803 ;;
2804 clean-wok)
2805 # Clean all packages in the work directory
2807 get_tazwok_config
2808 source_lib report
2809 report start
2810 report step "Cleaning wok"
2811 for PACKAGE in `ls -1 $WOK`
2812 do
2813 set_common_path
2814 source_receipt
2815 clean
2816 done
2817 echo "`ls -1 $WOK | wc -l` packages cleaned."
2818 ;;
2819 clean-src)
2820 # Remove tarball unrelated to wok receipts from src repo.
2821 check_root
2822 get_options_list="forced"
2823 get_tazwok_config
2824 cd $SOURCES_REPOSITORY
2825 echo -n "Checking $SOURCES_REPOSITORY..."
2826 for TARBALL in *; do
2827 [ "$TARBALL" = sources.list ] && continue
2828 grep -q $'\t'$TARBALL$ $SOURCES_REPOSITORY/sources.list || \
2829 echo $TARBALL >> $tmp/obsolete
2830 done
2831 status
2832 if ! [ -f $tmp/obsolete ]; then
2833 echo "No sources need to be removed."
2834 exit 1
2835 fi
2836 echo ""
2837 echo -e "\033[1mObsolete/unrelated-to-wok sourcess :\033[0m"
2838 horizontal_line
2839 cat $tmp/obsolete
2840 horizontal_line
2841 echo "$(wc -l $tmp/obsolete | cut -f1 -d' ') tarballs to remove."
2842 echo ""
2843 echo -n "Please confirm removing (type uppercase YES): "
2844 read answer
2845 if [ "$answer" = YES ]; then
2846 echo -n "Removing old sources..."
2847 cat $tmp/obsolete | while read i; do
2848 rm -f $SOURCES_REPOSITORY/$i
2849 done
2850 status
2851 fi
2852 ;;
2853 gen-list)
2854 get_tazwok_config
2855 if [ "$2" ]; then
2856 if [ -d "$2" ]; then
2857 pkg_repository=$2
2858 else
2859 echo -e "\nUnable to find directory : $2\n" >&2
2860 exit 1
2861 fi
2862 fi
2864 source_lib report
2865 report start
2866 if [ "$pkg_repository" ]; then
2867 gen_packages_db
2868 else
2869 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
2870 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
2871 fi
2872 ;;
2873 check-list)
2874 # The directory to move into by default is the repository,
2875 # if $2 is not empty cd into $2.
2877 get_tazwok_config
2878 if [ "$2" ]; then
2879 if [ -d "$2" ]; then
2880 pkg_repository=$2
2881 else
2882 echo -e "\nUnable to find directory : $2\n" >&2
2883 exit 1
2884 fi
2885 fi
2887 source_lib report
2888 report start
2889 if [ "$pkg_repository" ]; then
2890 update_packages_db
2891 else
2892 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2893 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
2894 fi
2895 ;;
2896 new-tree)
2897 # Just create a few directories and generate an empty receipt to prepare
2898 # the creation of a new package.
2900 get_tazwok_config
2901 check_for_package_on_cmdline
2902 clean_wok=$LOCAL_REPOSITORY/clean-wok
2903 if [ -d $clean_wok/$PACKAGE ]; then
2904 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2905 exit 1
2906 fi
2907 echo "Creating : $WOK/$PACKAGE"
2908 mkdir $clean_wok/$PACKAGE
2909 cd $clean_wok/$PACKAGE
2910 echo -n "Preparing the receipt..."
2912 # Default receipt begin.
2914 echo "# SliTaz package receipt." > receipt
2915 echo "" >> receipt
2916 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2917 # Finish the empty receipt.
2918 cat >> receipt << "EOF"
2919 VERSION=""
2920 CATEGORY=""
2921 SHORT_DESC=""
2922 MAINTAINER=""
2923 DEPENDS=""
2924 TARBALL="$PACKAGE-$VERSION.tar.gz"
2925 WEB_SITE=""
2926 WGET_URL=""
2928 # Rules to configure and make the package.
2929 compile_rules()
2931 cd $src
2932 ./configure && make && make install
2935 # Rules to gen a SliTaz package suitable for Tazpkg.
2936 genpkg_rules()
2938 mkdir -p $fs/usr
2939 cp -a $_pkg/usr/bin $fs/usr
2942 EOF
2944 # Default receipt end.
2946 status
2947 # Interactive mode, asking and seding.
2948 if [ "$3" = "--interactive" ]; then
2949 echo "Entering into interactive mode..."
2950 echo "================================================================================"
2951 echo "Package : $PACKAGE"
2952 # Version.
2953 echo -n "Version : " ; read anser
2954 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2955 # Category.
2956 echo -n "Category : " ; read anser
2957 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2958 # Short description.
2959 echo -n "Short desc : " ; read anser
2960 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2961 # Maintainer.
2962 echo -n "Maintainer : " ; read anser
2963 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2964 # Web site.
2965 echo -n "Web site : " ; read anser
2966 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2967 echo ""
2968 # Wget URL.
2969 echo "Wget URL to download source tarball."
2970 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2971 echo -n "Wget url : " ; read anser
2972 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2973 # Ask for a stuff dir.
2974 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2975 if [ "$anser" = "y" ]; then
2976 echo -n "Creating the stuff directory..."
2977 mkdir stuff && status
2978 fi
2979 # Ask for a description file.
2980 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2981 if [ "$anser" = "y" ]; then
2982 echo -n "Creating the description.txt file..."
2983 echo "" > description.txt && status
2984 fi
2985 echo "================================================================================"
2986 echo ""
2987 fi
2988 ;;
2989 remove)
2990 # Remove a package from the wok.
2992 get_tazwok_config
2993 check_for_package_on_cmdline
2994 echo ""
2995 echo -n "Please confirm deletion (y/N) : "; read anser
2996 if [ "$anser" = "y" ]; then
2997 echo -n "Removing $PACKAGE..."
2998 rm -rf $WOK/$PACKAGE && status
2999 echo ""
3000 fi
3001 ;;
3002 update-wok)
3003 # Pull and update a Hg wok.
3004 get_options_list="local"
3005 get_tazwok_config
3006 source_lib report
3007 report start
3008 clean_wok=$LOCAL_REPOSITORY/clean-wok
3009 cd $clean_wok
3010 if ! [ "$local" ]; then
3011 if [ "$WOK_UPDATE_METHOD" = hg ]; then
3012 if ! [ -f "$INSTALLED/mercurial/receipt" ]; then
3014 # Auto-install only if we are in a cook chroot.
3015 if [ -x /usr/bin/clean-chroot ]; then
3016 echo "" >&2
3017 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
3018 echo "">&2
3019 exit 1
3020 else
3021 tazpkg get-install mercurial
3022 fi
3023 fi
3025 report step "Getting wok changes using hg"
3026 if [ -d .hg ]; then
3027 hg pull -u || exit 1
3028 else
3029 hg clone $HG_WOK . || exit 1
3030 fi
3031 report end-step
3032 [ -x /usr/bin/clean-chroot ] && clean-chroot
3033 else
3034 report step "Getting wok changes using tarball"
3035 { mkdir .tmp && cd .tmp
3036 wget "$TARBALL_WOK" &&
3037 case $TARBALL_WOK in
3038 *bz2) tar xjf *.bz2 -C wok; rm *.bz2;;
3039 *lzma) unlzma -c *.lzma | tar xf - -C wok; rm *.lzma ;;
3040 *gz) tar xzf *.gz -C wok; rm*.gz ;;
3041 esac &&
3042 rm -r $(ls -d $clean_wok/*) &&
3043 cp -a wok/* $clean_wok &&
3044 cd .. &&
3045 rm -r .tmp
3046 } || { echo "That's not cool: it fails!" >&2
3047 report end-step
3048 exit 1; }
3049 report end-step
3050 fi
3051 fi
3052 report step "Appending changes to wok"
3054 # Handle removed files/dir.
3055 cd $WOK
3056 for dir in *; do
3057 [ -d "$clean_wok/$dir" ] || rm -rf $dir
3058 done
3059 for file in */receipt */description.txt; do
3060 [ -f "$clean_wok/$file" ] || rm -rf $file
3061 done
3062 for i in $(find */stuff 2>/dev/null); do
3063 [ -e "$clean_wok/$i" ] || rm -rf $i
3064 done
3066 cp -a $clean_wok/* $WOK
3067 report end-step
3068 ;;
3069 maintainers)
3070 get_tazwok_config
3071 echo ""
3072 echo "List of maintainers for: $WOK"
3073 echo "================================================================================"
3074 touch /tmp/slitaz-maintainers
3075 for pkg in $WOK/*
3076 do
3077 . $pkg/receipt
3078 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
3079 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
3080 echo "$MAINTAINER"
3081 fi
3082 done
3083 echo "================================================================================"
3084 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
3085 echo ""
3086 # Remove tmp files
3087 rm -f /tmp/slitaz-maintainers
3088 ;;
3089 maintained-by)
3090 # Search for packages maintained by a contributor.
3091 get_tazwok_config
3092 if [ ! -n "$2" ]; then
3093 echo "Specify a name or email of a maintainer." >&2
3094 exit 1
3095 fi
3096 echo "Maintainer packages"
3097 echo "================================================================================"
3098 for pkg in $WOK/*
3099 do
3100 . $pkg/receipt
3101 if echo "$MAINTAINER" | fgrep -q "$2"; then
3102 echo "$PACKAGE"
3103 packages=$(($PACKAGEs+1))
3104 fi
3105 done
3106 echo "================================================================================"
3107 echo "Packages maintained by $2: $PACKAGEs"
3108 echo ""
3109 ;;
3110 tags)
3111 get_tazwok_config
3112 echo -e "\n\033[1mTags list :\033[0m"
3113 horizontal_line
3114 cd $WOK
3115 for i in */receipt; do
3116 unset TAGS
3117 source $i
3118 for t in $TAGS; do
3119 grep -q ^$t$ $tmp/tags && continue
3120 echo $t | tee -a $tmp/tags
3121 done
3122 done
3123 horizontal_line
3124 echo "$(wc -l $tmp/tags | cut -f1 -d ' ') tags listed."
3125 ;;
3126 check-src)
3127 # Verify if upstream package is still available
3129 get_tazwok_config
3130 check_for_package_on_cmdline
3131 check_for_receipt
3132 source_receipt
3133 check_src()
3135 for url in $@; do
3136 busybox wget -s $url 2>/dev/null && break
3137 done
3139 if [ "$WGET_URL" ];then
3140 echo -n "$PACKAGE : "
3141 check_src $WGET_URL
3142 status
3143 else
3144 echo "No tarball to check for $PACKAGE"
3145 fi
3146 ;;
3147 get-src)
3148 check_root
3149 get_options_list="target nounpack"
3150 get_tazwok_config
3151 check_for_package_on_cmdline
3152 check_for_receipt
3153 source_receipt
3154 if [ "$WGET_URL" ];then
3155 source_lib report
3156 report start
3157 check_for_tarball
3158 else
3159 echo "No tarball to download for $PACKAGE"
3160 fi
3161 ;;
3162 check-commit)
3163 check_root
3164 get_options_list="missing forced"
3165 get_tazwok_config
3166 source_lib report
3167 report start
3168 if [ "$forced" ]; then
3169 rm -f $WOK/*/md5
3170 unset forced
3171 fi
3172 if [ "$missing" ]; then
3173 pkg=$(ls -1 $WOK)
3174 else
3175 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3176 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3177 } | sort -u)"
3178 fi
3179 cooklist=$PACKAGES_REPOSITORY/cooklist
3180 gen_cook_list
3181 ;;
3182 cook-commit)
3183 check_root
3184 get_options_list="missing forced"
3185 get_tazwok_config
3186 source_lib report
3187 report start
3188 if [ "$forced" ]; then
3189 rm -f $WOK/*/md5
3190 unset forced
3191 fi
3192 if [ "$missing" ]; then
3193 pkg=$(ls -1 $WOK)
3194 else
3195 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3196 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3197 } | sort -u)"
3198 fi
3199 cooklist=$PACKAGES_REPOSITORY/cooklist
3200 gen_cook_list
3201 cook_list
3202 ;;
3203 cook-all)
3204 check_root
3205 get_options_list="forced missing"
3206 get_tazwok_config
3207 source_lib report
3208 report start
3209 if [ "$missing" ]; then
3210 pkg=$(ls -1 $WOK)
3211 else
3212 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3213 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3214 } | sort -u)"
3215 fi
3216 cooklist=$PACKAGES_REPOSITORY/cooklist
3217 gen_cook_list
3218 cook_list
3219 ;;
3220 gen-wok-db)
3221 check_root
3222 get_tazwok_config
3223 source_lib report
3224 report start
3225 gen_wok_db
3226 ;;
3227 report)
3228 get_tazwok_config
3229 cd $PACKAGES_REPOSITORY
3230 if [ "$2" ]; then
3231 case $2 in
3232 commit|cooklist|incoming|broken|blocked)
3233 show="$2"
3234 ;;
3235 *)
3236 echo "usage : tazwok report [commit|cooklist|incoming|broken|blocked]" >&2
3237 exit 1
3238 ;;
3239 esac
3240 else
3241 show="commit cooklist incoming broken blocked"
3242 fi
3243 for i in $show; do
3244 if [ -s $i ]; then
3245 echo ""
3246 echo -e "\033[1m$i\033[0m"
3247 echo "================================================================================"
3248 cat $i
3249 echo "================================================================================"
3250 echo ""
3251 fi
3252 done
3253 ;;
3254 check-incoming)
3255 check_root
3256 get_options_list="forced"
3257 get_tazwok_config
3258 source_lib report
3259 report start
3260 [ -f $LOCAL_RESOSITORY/incoming ] && rm [ -f $LOCAL_REPOSITORY/incoming ]
3261 report step "Checking $INCOMING_REPOSITORY"
3262 report open-bloc
3263 [ -f $LOCAL_REPOSITORY/log/incoming.html ] && rm $LOCAL_REPOSITORY/log/incoming.html
3264 report sublog $LOCAL_REPOSITORY/log/incoming.html
3265 echo "incoming" > $LOCAL_REPOSITORY/log/package
3266 check_for_incoming
3267 report end-sublog
3268 report close-bloc
3269 ;;
3270 configure-chroot)
3271 check_root
3272 get_tazwok_config
3273 if [ -f /usr/bin/tazchroot ]; then
3274 cd $LOCAL_REPOSITORY
3275 configure_tazchroot
3276 else
3277 echo "The packages tazchroot need to be installed" >&2
3278 exit 1
3279 fi
3280 ;;
3281 chroot)
3282 check_root
3283 get_tazwok_config
3284 # Merge this and the other chroot function ?.
3285 if [ -f /usr/bin/tazchroot ]; then
3286 cd $LOCAL_REPOSITORY
3287 [ ! -f tazchroot.conf ] && configure_tazchroot
3288 tazchroot
3289 else
3290 echo "The packages tazchroot need to be installed" >&2
3291 exit 1
3292 fi
3293 ;;
3294 cook-toolchain)
3295 check_root
3296 get_tazwok_config
3297 echo -n "" > $PACKAGES_REPOSITORY/broken
3298 if [ -f /usr/bin/tazchroot ]; then
3299 cd $LOCAL_REPOSITORY
3300 [ ! -f tazchroot.conf ] && configure_tazchroot
3301 tazchroot cook-toolchain
3302 # Buggy : chroot can be elsewhere.
3303 rm -r $LOCAL_REPOSITORY/chroot
3304 # /!\ to be writed :
3305 # next rm chroot and plan cook-all by pushing all packages
3306 # in cooklist.
3307 else
3308 echo "The packages tazchroot need to be installed" >&2
3309 exit 1
3310 fi
3311 ;;
3312 webserver)
3313 check_root
3314 get_tazwok_config
3315 if [ "$ARG" = on ]; then
3316 if [ "$WEBSERVER" ] && [ -f "$WEBSERVER/repositories.list" ] && \
3317 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3318 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3319 exit 1
3320 fi
3321 if ! [ -f $LOCAL_REPOSITORY/tazchroot.conf ]; then
3322 tazwok configure-chroot ${undigest:+--undigest=$undigest} --SLITAZ_VERSION=$SLITAZ_VERSION --SLITAZ_DIR=$SLITAZ_DIR
3323 fi
3324 for pkg in php lighttpd; do
3325 [ -d $INSTALLED/$pkg ] || missing="$missing $pkg"
3326 done
3327 if [ "$missing" ]; then
3328 echo "You need to install those packages to start webserver: $missing." >&2
3329 exit 1
3330 fi
3331 if [ ! -f "$LOCAL_REPOSITORY/tazwok.conf" ]; then
3332 echo "Copying /etc/slitaz/tazwok.conf to $LOCAL_REPOSITORY/tazwok.conf: webserver is configured repository-by-repository."
3333 cp /etc/slitaz/tazwok.conf $LOCAL_REPOSITORY
3334 fi
3335 if ! [ "$WEBSERVER" ]; then
3336 echo -n "Where to store php pages (default: /var/www/vhosts/bb)? "
3337 read WEBSERVER
3338 [ "$WEBSERVER" ] || WEBSERVER="/var/www/vhosts/bb"
3339 fi
3340 if [ -f "$WEBSERVER/repositories.list" ] && \
3341 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3342 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3343 exit 1
3344 fi
3345 mkdir -p $WEBSERVER
3346 echo "${undigest:-$SLITAZ_VERSION}" >> $WEBSERVER/repositories.list
3347 for file in index.php log.php download.php; do
3348 [ -f "$WEBSERVER/$file" ] || ln -s /usr/share/slitaz/web-bb/$file $WEBSERVER
3349 done
3350 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3351 ln -s $dir $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3352 done
3353 source $LOCAL_REPOSITORY/tazchroot.conf
3354 echo "<?php
3356 // Web interface configuration
3358 \$version=\"${undigest:-$SLITAZ_VERSION}\";
3359 \$chroot=\"$chroot_dir\";
3360 \$lockfile=\"\$chroot/proc/1/status\";
3361 \$db_dir=\"$PACKAGES_REPOSITORY\";
3362 \$log_dir=\"$LOCAL_REPOSITORY/log\";
3363 \$packages=\"$PACKAGES_REPOSITORY\";
3364 \$incoming=\"$INCOMING_REPOSITORY\";
3365 \$wok=\"$WOK\";
3367 ?>" > $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3368 [ -L "$WEBSERVER/web" ] || ln -s /usr/share/slitaz/web $WEBSERVER
3369 echo "WEBSERVER=\"$WEBSERVER\"" >> $LOCAL_REPOSITORY/tazwok.conf
3370 if [ -L "$WEBSERVER/conf.php" ]; then
3371 echo "Do yo want to make ${undigest:-$SLITAZ_VERSION} the default page (y/N) ? "
3372 read answer
3373 if [ "$answer" = y ]; then
3374 rm $WEBSERVER/conf.php
3375 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3376 fi
3377 else
3378 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3379 fi
3380 elif [ "$ARG" = off ]; then
3381 if ! [ "$WEBSERVER" ]; then
3382 echo "No webserver running for ${undigest:-$SLITAZ_VERSION}" >&2
3383 exit 1
3384 fi
3385 sed '/^WEBSERVER/d' -i $LOCAL_REPOSITORY/tazwok.conf
3386 sed "/^${undigest:-$SLITAZ_VERSION}$/d" -i $WEBSERVER/repositories.list
3387 rm $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3388 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3389 rm $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3390 done
3391 if ! [ -s "$WEBSERVER/repositories.list" ]; then
3392 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"
3393 rm $WEBSERVER/conf.php
3394 elif [ "$(readlink $WEBSERVER/conf.php)" = "$WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php" ]; then
3395 echo "${undigest:-$SLITAZ_VERSION} was the default version to use; switched to : $(sed 1!d $WEBSERVER/repositories.list)"
3396 rm $WEBSERVER/conf.php
3397 ln -s $WEBSERVER/conf-$(sed 1!d $WEBSERVER/repositories.list).php $WEBSERVER/conf.php
3398 fi
3399 else
3400 echo "Usage: tazwok webserver on/off" >&2
3401 exit 1
3402 fi
3403 ;;
3404 block)
3405 # Add a pkg name to the list of blocked packages.
3406 get_tazwok_config
3407 check_root
3408 check_for_package_on_cmdline
3409 if ! [ -f $WOK/$PACKAGE/receipt ]; then
3410 echo "Can't find $PACKAGE into wok." >&2
3411 echo ""
3412 exit 1
3413 fi
3414 echo ""
3415 if grep -qs "^$PACKAGE$" $PACKAGES_REPOSITORY/blocked; then
3416 echo "$PACKAGE is already in the blocked packages list." >&2
3417 echo ""
3418 exit 1
3419 else
3420 echo -n "Adding $PACKAGE to : $PACKAGES_REPOSITORY/blocked... "
3421 echo "$PACKAGE" >> $PACKAGES_REPOSITORY/blocked
3422 status
3423 if grep -q "^$PACKAGE$" $PACKAGES_REPOSITORY/cooklist; then
3424 echo -n "Removing $PACKAGE from : $PACKAGES_REPOSITORY/cooklist... "
3425 sed -i /"^$PACKAGE$"/d $PACKAGES_REPOSITORY/cooklist
3426 status
3427 fi
3428 fi
3429 echo "" ;;
3430 unblock)
3431 # Remove a pkg name from the list of blocked packages.
3432 get_tazwok_config
3433 check_root
3434 check_for_package_on_cmdline
3435 if ! [ -f $WOK/$PACKAGE/receipt ]; then
3436 echo "Can't find $PACKAGE into wok." >&2
3437 echo ""
3438 exit 1
3439 fi
3440 echo ""
3441 if grep -qs "^$PACKAGE$" $PACKAGES_REPOSITORY/blocked; then
3442 echo -n "Removing $PACKAGE from : $PACKAGES_REPOSITORY/blocked... "
3443 sed -i /"^$PACKAGE$"/d $PACKAGES_REPOSITORY/blocked
3444 sed -i '/^$/d' $PACKAGES_REPOSITORY/blocked
3445 status
3446 else
3447 echo "$PACKAGE is not in the blocked packages list." >&2
3448 echo ""
3449 exit 1
3450 fi
3451 echo "" ;;
3452 usage|*)
3453 # Print usage also for all unknown commands.
3455 usage
3456 ;;
3457 esac
3459 report stop 2>/dev/null
3460 exit 0