tazwok view tazwok @ rev 462

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