tazwok view tazwok @ rev 405

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