tazwok view tazwok @ rev 416

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