tazwok view tazwok @ rev 477

Set VERSION to 4.2.10
author Antoine Bodin <gokhlayeh@slitaz.org>
date Mon Apr 04 03:10:23 2011 +0200 (2011-04-04)
parents c545a19df5b5
children 137774577ccb
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.10
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=$(echo "$CFLAGS" | tr -s ' ') \
653 CXXFLAGS=$(echo "$CXXFLAGS" | tr -s ' ') \
654 MAKEFLAGS DESTDIR BUILD_HOST CONFIG_SITE default_prefix \
655 default_datarootdir default_datadir default_localedir \
656 default_infodir default_mandir default_build default_host
657 local LC_ALL=POSIX LANG=POSIX
658 compile_rules
660 # Check if config.site has been used.
661 # /!\ disabled since it screws the return_code of the step.
662 #if [ -f /tmp/config.site ]; then
663 # rm /tmp/config.site
664 #else
665 # tazwok_warning "config.site hasn't been used during \
666 #the configuration process."
667 #fi
668 report end-step
669 fi
670 }
672 # Check for loop in deps tree. /!\ can be removed.
673 check_for_deps_loop()
674 {
675 local list
676 local pkg
677 local deps
678 pkg=$1
679 shift
680 [ -n "$1" ] || return
681 list=""
683 # Filter out already processed deps.
684 for i in $@; do
685 case " $ALL_DEPS" in
686 *\ $i\ *);;
687 *) list="$list $i";;
688 esac
689 done
690 ALL_DEPS="$ALL_DEPS$list "
691 for i in $list; do
692 [ -f $i/receipt ] || continue
693 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
694 case " $deps " in
695 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
696 *) check_for_deps_loop $pkg $deps;;
697 esac
698 done
699 }
701 # Function used by download().
702 revert_vcs_failure()
703 {
704 cd $SOURCES_REPOSITORY
705 rm -r $tmp_src
706 }
708 download()
709 {
710 if [ "$COMMAND" = get-src ]; then
711 if [ "${DEPENDS/tar}" != "$DEPENDS" ] || [ "${BUILD_DEPENDS/tar}" != "$BUILD_DEPENDS" ]; then
712 [ -f $INSTALLED/tar/receipt ] || tazpkg get-install tar --forced
713 fi
714 fi
715 for file in $@; do
716 echo "Downloading from ${file#*|}..."
717 case "$file" in
718 git\|*)
719 file=${file#git|}
720 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/git/receipt ] && tazpkg get-install git --forced
721 if [ -f $INSTALLED/git/receipt ]; then
722 mkdir $tmp_src
723 cd $tmp_src
724 if [ "$BRANCH" ]; then
725 git clone $file ${src##*/} && cd ${src##*/} && \
726 git checkout $BRANCH && rm -rf .git* && break
727 else
728 git clone $file ${src##*/} && rm -rf ${src##*/}/.git* && break
729 fi
730 revert_vcs_failure
731 else
732 tazwok_warning "Needs git to download the source tarball from $file, please add it as a build-depend."
733 continue
734 fi
735 ;;
736 bazaar\|*)
737 file=${file#bazaar|}
738 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/bazaar/receipt ] && tazpkg get-install bazaar --forced
739 if [ -f $INSTALLED/bazaar/receipt ]; then
740 mkdir $tmp_src
741 cd $tmp_src
742 if [ "$BRANCH" ]; then
743 bzr co $file -r $BRANCH ${src##*/} && rm -rf ${src##*/}/.bzr* && break
744 else
745 bzr co $file ${src##*/} && rm -rf ${src##*/}/.bzr* && break
746 fi
747 revert_vcs_failure
748 else
749 tazwok_warning "Needs bazaar to download the source tarball from $file, please add it as a build-depend."
750 continue
751 fi
752 ;;
753 subversion\|*)
754 file=${file#subversion|}
755 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/subversion/receipt ] && tazpkg get-install subversion --forced
756 if [ -f $INSTALLED/subversion/receipt ]; then
757 mkdir $tmp_src
758 cd $tmp_src
759 if [ "$BRANCH" ]; then
760 echo t | svn co $file -r $BRANCH ${src##*/} && rm -rf ${src##*/}/.svn* && break
761 else
762 echo t | svn co $file ${src##*/} && rm -rf ${src##*/}/.svn* && break
763 fi
764 revert_vcs_failure
765 else
766 tazwok_warning "Needs subversion to download the source tarball from $file, please add it as a build-depend."
767 continue
768 fi
769 ;;
770 mercurial\|*)
771 file=${file#mercurial|}
772 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/mercurial/receipt ] && tazpkg get-install mercurial --forced
773 if [ -f $INSTALLED/mercurial/receipt ]; then
774 mkdir $tmp_src
775 cd $tmp_src
776 if [ "$BRANCH" ]; then
777 hg clone $file --rev $BRANCH ${src##*/} && rm -rf ${src##*/}/.hg* && break
778 else
779 hg clone $file ${src##*/} && rm -rf ${src##*/}/.hg* && break
780 fi
781 revert_vcs_failure
782 else
783 tazwok_warning "Needs mercurial to download the source tarball from $file, please add it as a build-depend."
784 continue
785 fi
786 ;;
787 https*)
788 [ "$COMMAND" = get-src ] && [ ! -f $INSTALLED/wget/receipt ] && tazpkg get-install wget --forced
789 if [ -d $INSTALLED/wget ]; then
790 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
791 wget -q --no-check-certificate -O $TARBALL $file && break
792 else
793 wget -q --no-check-certificate $file && break
794 fi
795 else
796 tazwok_warning "Needs wget to download the source tarball from $file, please add it as a build-depend."
797 continue
798 fi
799 ;;
800 http*|ftp*)
801 # Handle crappy URL.
802 if [ "$COMMAND" = get-src ]; then
803 if [ "${DEPENDS/wget}" != "$DEPENDS" ] || [ "${BUILD_DEPENDS/wget}" != "$BUILD_DEPENDS" ]; then
804 [ -f $INSALLED/wget/receipt ] || tazpkg get-install wget --forced
805 fi
806 fi
807 if [ "${WGET_URL%$TARBALL}" = "$WGET_URL" ] && [ "$file" = "$WGET_URL" ]; then
808 wget -q -O $TARBALL $file && break
809 else
810 wget -q $file && break
811 fi
812 ;;
813 esac
814 done
815 }
817 # Regenerate every package that wants a PACKAGE compiled.
818 refresh_packages_from_compile()
819 {
820 # make tazwok genpkg happy.
821 mkdir $WOK/$PACKAGE/taz
823 # Cook rwanted in default or specied order.
824 genlist=" $(look_for_rwanted | tr '\n' ' ') "
825 for i in $(look_for_cookopt genpkg | tac); do
826 [ "${genlist/ $i }" = "$genlist" ] && continue
827 genlist=" $i${genlist/ $i / }"
828 done
829 if [ "$genlist" ]; then
830 local PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
831 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
832 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
833 src _pkg DESTDIR CONFIG_SITE RECEIPT LOG stuff wanted_stuff
834 for PACKAGE in $genlist; do
835 set_common_path
836 gen_package
837 done
838 fi
839 }
841 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
842 # so some packages need to copy these files with the receipt and genpkg_rules.
843 # This function is executed by gen_package when 'tazwok genpkg'.
844 copy_generic_files()
845 {
846 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
847 # using generic variables and $LOCALE from Tazwok config file.
848 if [ "$LOCALE" ]; then
849 if [ -d "$_pkg/usr/share/locale" ]; then
850 for i in $LOCALE
851 do
852 if [ -d "$_pkg/usr/share/locale/$i" ]; then
853 mkdir -p $fs/usr/share/locale
854 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
855 fi
856 done
857 fi
858 fi
860 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
861 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
862 # in pkg receipt.
863 if [ "$GENERIC_PIXMAPS" != "no" ]; then
864 if [ -d "$_pkg/usr/share/pixmaps" ]; then
865 mkdir -p $fs/usr/share/pixmaps
866 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
867 $fs/usr/share/pixmaps 2>/dev/null
868 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
869 $fs/usr/share/pixmaps 2>/dev/null
870 fi
872 # Custom or homemade PNG pixmap can be in stuff.
873 if [ -f "stuff/$PACKAGE.png" ]; then
874 mkdir -p $fs/usr/share/pixmaps
875 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
876 fi
877 fi
879 # Desktop entry (.desktop).
880 if [ -d "$_pkg/usr/share/applications" ]; then
881 cp -a $_pkg/usr/share/applications $fs/usr/share
882 fi
884 # Homemade desktop file(s) can be in stuff.
885 if [ -d "stuff/applications" ]; then
886 mkdir -p $fs/usr/share
887 cp -a stuff/applications $fs/usr/share
888 fi
889 if [ -f "stuff/$PACKAGE.desktop" ]; then
890 mkdir -p $fs/usr/share/applications
891 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
892 fi
893 }
895 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
896 strip_package()
897 {
898 report step "Executing strip on all files"
900 # Binaries.
901 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
902 do
903 if [ -d "$dir" ]; then
904 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
905 fi
906 done
908 # Libraries.
909 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
910 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
911 report end-step
912 }
914 # Remove .pyc and .pyo files from packages.
915 py_compiled_files_remove()
916 {
917 report step "Removing all .pyc and .pyo files from package"
918 find $fs -type f -name "*.pyc" -delete 2>/dev/null
919 find $fs -type f -name "*.pyo" -delete 2>/dev/null
920 report end-step
921 }
923 # Check FSH in a slitaz package (Path: /:/usr)
924 check_fsh()
925 {
926 cd $WOK/$PACKAGE/taz/*/fs
927 if [ -z "$(find * ! -type d)" ] && [ "$CATEGORY" != meta ]; then
928 echo "$PACKAGE fs is empty." >&2
929 cd $WOK/$PACKAGE && rm -rf taz
930 return 1
931 fi
932 [ -n "$FSH" ] || FSH="bin boot dev etc home init lib media mnt proc \
933 root sbin share sys tmp usr var vz usr/bin usr/games usr/include usr/lib \
934 usr/local usr/sbin usr/share usr/src"
935 error=0
936 for i in `ls -d * usr/* 2>/dev/null`
937 do
938 if ! echo $FSH | fgrep -q $i; then
939 echo "Wrong path: /$i" >&2
940 error=1
941 fi
942 done
943 if [ "$error" = "1" ]; then
944 cat << _EOT_
946 Package will install files in a non standard directory and won't be generated.
947 You may have a wrong copy path in genpkg_rules or need to add some options to
948 configure in compile_rules. Some valid options for SliTaz (Linux FSH):
950 --prefix=/usr
951 --sysconfdir=/etc
952 --libexecdir=/usr/lib/(pkgname)
953 --localstatedir=/var
954 --mandir=/usr/share/man
955 --infodir=/usr/share/info
957 For more information please read SliTaz docs and run: ./configure --help
958 ================================================================================
959 $PACKAGE package generation aborted.
961 _EOT_
963 # Dont generate a corrupted package.
964 cd $WOK/$PACKAGE && rm -rf taz
965 return 1
966 fi
967 return 0
968 }
970 gen_cookmd5()
971 {
972 # md5sum of cooking stuff make tazwok able to check for changes
973 # without hg.
974 cd $WOK/$PACKAGE
975 md5sum receipt > md5
976 [ -f description.txt ] && md5sum description.txt >> md5
977 if [ -d stuff ]; then
978 find stuff | while read file; do
979 md5sum $file >> md5
980 done
981 fi
982 }
984 set_pkg_broken()
985 {
986 if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
987 echo $PACKAGE >> $PACKAGES_REPOSITORY/broken
988 fi
990 # Remove pkg from cooklist to avoid re-cook it if no changes happen
991 # in the cook stuff.
992 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist
993 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit
995 gen_cookmd5
997 # Return 1 to make report know that its mother-function failed.
998 return 1
999 }
1001 # Create a package tree and build the gziped cpio archive
1002 # to make a SliTaz (.tazpkg) package.
1003 gen_package()
1005 check_root
1006 check_for_package_on_cmdline
1007 check_for_receipt
1008 source_receipt
1010 # May compute VERSION
1011 if grep -q ^get_version $RECEIPT; then
1012 get_version
1013 fi
1014 check_for_wanted
1015 cd $WOK/$PACKAGE
1017 # Remove old Tazwok package files.
1018 [ -d "taz" ] && rm -rf taz
1020 # Create the package tree and set useful variables.
1021 fs=$WOK/$PACKAGE/taz/$PACKAGE-$VERSION/fs
1022 mkdir -p $fs
1024 # Set $src for standard package and $_pkg variables.
1025 set_src_path
1026 set_pkg_path
1028 # Execute genpkg_rules, check package and copy generic files to build
1029 # the package.
1030 report step "Building $PACKAGE with the receipt"
1031 report open-bloc
1032 if look_for_cookopt !fs; then
1034 elif grep -q ^genpkg_rules $RECEIPT; then
1036 # Log process.
1037 echo "executing genpkg_rules" >> $LOG
1038 report step "Executing genpkg_rules"
1039 ( set -e; genpkg_rules ) || { set_pkg_broken; report close-bloc; return 1; }
1040 check_fsh || { set_pkg_broken; report close-bloc; return 1; }
1041 cd $WOK/$PACKAGE
1042 report end-step
1044 # Skip generic files for packages with a WANTED variable
1045 # (dev and split pkgs).
1046 if [ ! "$WANTED" ]; then
1047 copy_generic_files
1048 fi
1049 look_for_cookopt !strip || strip_package
1050 py_compiled_files_remove
1051 else
1052 echo "No package rules to gen $PACKAGE..." >&2
1053 set_pkg_broken
1054 report close-bloc
1055 return 1
1056 fi
1058 # Copy the receipt and description (if exists) into the binary package tree.
1059 cd $WOK/$PACKAGE
1060 report step "Copying the receipt"
1061 cp receipt taz/$PACKAGE-$VERSION
1062 report end-step
1063 if grep -q ^get_version $RECEIPT; then
1064 report step "Updating version in receipt"
1065 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
1066 taz/$PACKAGE-$VERSION/receipt
1067 report end-step
1068 fi
1069 if [ -f "description.txt" ]; then
1070 report step "Copying the description file"
1071 cp description.txt taz/$PACKAGE-$VERSION
1072 report end-step
1073 fi
1075 # Generate md5 of cooking stuff to look for commit later.
1076 gen_cookmd5
1077 echo -e "\n# md5sum of cooking stuff :" >> taz/$PACKAGE-$VERSION/receipt
1078 cat md5 | sed 's/^/# /' >> taz/$PACKAGE-$VERSION/receipt
1080 # Create the files.list by redirecting find output.
1081 report step "Creating the list of files"
1082 cd taz/$PACKAGE-$VERSION
1083 LAST_FILE=""
1084 { find fs -print; echo; } | while read file; do
1085 if [ "$LAST_FILE" ]; then
1086 case "$file" in
1087 $LAST_FILE/*)
1088 case "$(ls -ld "$LAST_FILE")" in
1089 drwxr-xr-x\ *\ root\ *\ root\ *);;
1090 *) echo ${LAST_FILE#fs};;
1091 esac;;
1092 *) echo ${LAST_FILE#fs};;
1093 esac
1094 fi
1095 LAST_FILE="$file"
1096 done > files.list
1098 # Next, check if something has changed in lib files.
1099 if fgrep -q '.so' files.list; then
1100 for rep in $INCOMING_REPOSITORY $PACKAGES_REPOSITORY \
1101 $([ "$undigest" ] && echo $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming && \
1102 echo $SLITAZ_DIR/$SLITAZ_VERSION/packages); do
1103 prev_VERSION=$(get_pkg_version $rep)
1104 [ "$prev_VERSION" ] && pkg_file=$rep/$PACKAGE-$prev_VERSION.tazpkg && break
1105 done
1106 if [ "$pkg_file" ]; then
1107 report step "Looking for major/minor updates in libraries"
1108 get_pkg_files $pkg_file
1109 cd $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
1110 fgrep ".so" files.list | egrep -v "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*" | \
1111 while read lib; do
1112 fgrep -q "$lib" $pkg_files_dir/files.list && continue
1113 echo "A minor/major update in libraries is detected, planning re-cook of reverse-depends of $PACKAGE."
1114 for rdep in $(scan $PACKAGE --look_for=rdep | use_wanted); do
1115 [ "$rdep" = "${WANTED:-$PACKAGE}" ] && continue
1116 grep -q ^$rdep$ $PACKAGES_REPOSITORY/blocked \
1117 $PACKAGES_REPOSITORY/cooklist && continue
1118 echo $rdep >> $PACKAGES_REPOSITORY/cooklist
1119 done
1120 regen_cooklist=yes
1121 break
1122 done
1123 rm -r $pkg_files_dir
1124 unset pkg_file
1125 report end-step
1126 fi
1127 fi
1128 if [ ! "$EXTRAVERSION" ]; then
1129 case "$PACKAGE" in
1130 linux*);;
1131 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
1132 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
1133 esac
1134 fi
1135 rm -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
1136 report step "Creating md5sum of files"
1137 while read file; do
1138 [ -L "fs$file" ] && continue
1139 [ -f "fs$file" ] || continue
1140 md5sum "fs$file" | sed 's/ fs/ /'
1141 done < files.list > md5sum
1142 report end-step
1143 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
1144 2> /dev/null | awk '{ sz=$1 } END { print sz }')
1146 # Build cpio archives. Find, cpio and gzip the fs, finish by
1147 # removing the fs tree.
1148 # Don't log this because compression always outputs error messages.
1149 find fs -print | cpio -o -H newc | case "$PACKAGE-$COMPRESSION" in
1150 tazpkg-lzma) gzip > fs.cpio.gz;;
1151 *-lzma) lzma e fs.cpio.lzma -si;;
1152 *) gzip > fs.cpio.gz;;
1153 esac && rm -rf fs
1154 PACKED_SIZE=$(du -chs fs.cpio.* receipt files.list md5sum \
1155 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
1156 report step "Updating receipt sizes"
1157 sed -i '/^PACKED_SIZE/d' receipt
1158 sed -i '/^UNPACKED_SIZE/d' receipt
1159 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
1160 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
1161 report end-step
1162 if [ "$EXTRAVERSION" ]; then
1163 report step "Updating receipt EXTRAVERSION"
1164 sed -i s/^EXTRAVERSION.*$// receipt
1165 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
1166 fi
1167 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1168 remove_previous_package $INCOMING_REPOSITORY
1169 report step "Creating full cpio archive"
1170 find . -print | cpio -o -H newc > $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
1172 # Restore package tree in case we want to browse it.
1173 report step "Restoring original package tree"
1174 { zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma; } | cpio --quiet -id
1175 rm fs.cpio.* && cd ..
1177 # Recook of reverse-depends if package was broken.
1178 if grep -q "^$PACKAGE$" $PACKAGES_REPOSITORY/broken; then
1179 report step "Planning a re-try cook of reverse depends"
1180 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/broken
1181 for rdep in $(look_for_rdep); do
1182 grep -q "^$rdep$" $PACKAGES_REPOSITORY/broken || continue
1183 grep -q "^$rdep$" $PACKAGES_REPOSITORY/cooklist && continue
1184 echo "Adding $rdep to the cooklist"
1185 echo $rdep >> $PACKAGES_REPOSITORY/cooklist
1186 regen_cooklist=t
1187 done
1188 report end-step
1189 fi
1190 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit
1191 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist
1193 # Log process.
1194 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
1195 report close-bloc
1196 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
1197 echo "Size : `du -sh $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
1198 echo ""
1201 ########################################################################
1202 # This section contains functions used by several other functions
1203 # below.
1204 ########################
1206 # Look for receipt/files.list in wok. If they can't be found, get them
1207 # from package. Accept one argument : absolute path to package.
1208 get_pkg_files()
1210 pkg_files_dir=$tmp/$(basename ${1%.tazpkg})
1211 mkdir -p $pkg_files_dir && \
1212 cd $pkg_files_dir && \
1213 cpio --quiet -idm receipt < $1 && \
1214 cpio --quiet -idm files.list < $1
1217 ########################################################################
1218 # This section contains functions to generate packages databases.
1219 ########################
1222 gen_packages_db()
1224 # pkg_repository can be $PACKAGES_REPOSITORY or $INCOMING_REPOSITORY.
1225 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1226 cd $pkg_repository
1227 report step "Generating packages lists: $pkg_repository"
1228 report open-bloc
1229 report step "Removing old files"
1230 for file in files.list.lzma packages.list packages.txt \
1231 packages.desc packages.equiv packages.md5; do
1232 [ -f $file ] && rm $file
1233 done
1234 touch files.list
1236 packages_db_start
1237 unset RECEIPT
1238 report step "Reading data from all packages"
1239 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1240 get_packages_info
1241 done
1242 report end-step
1243 packages_db_end
1244 report close-bloc
1247 update_packages_db()
1249 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1250 cd $pkg_repository
1251 for file in packages.list packages.equiv packages.md5 packages.desc \
1252 packages.txt; do
1253 if [ ! -f "$file" ]; then
1254 gen_packages_db
1255 return
1256 fi
1257 done
1258 if [ -f files.list.lzma ]; then
1259 lzma d files.list.lzma files.list
1260 else
1261 gen_packages_db
1262 return
1263 fi
1264 report step "Updating packages lists: $pkg_repository"
1265 packages_db_start
1267 # Look for removed/update packages.
1268 touch stamp -r packages.list
1269 for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
1270 pkg="$pkg_repository/$(grep -m1 ^$PACKAGE- packages.list).tazpkg"
1271 if ! [ -f "$pkg" ]; then
1272 erase_package_info
1273 else
1274 if [ "$pkg" -nt "stamp" ]; then
1275 updated_pkg="$updated_pkg
1276 $PACKAGE $pkg"
1277 elif [ ! -f $WOK/$PACKAGE/receipt ] && \
1278 [ "$COMMAND" = check-incoming -o "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
1279 erase_package_info
1280 echo "Removing $PACKAGE from $pkg_repository."
1281 rm $pkg
1282 [ -d $WOK/$PACKAGE ] && rm -r $WOK/$PACKAGE
1283 sed "/^$PACKAGE\t/d" -i $wan_db $dep_db
1284 for i in cookorder.txt cooklist commit blocked broken; do
1285 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/$i
1286 done
1287 rm -f $LOCAL_REPOSITORY/log/$PACKAGE.html
1288 if [ "$pkg_repository" = "$INCOMING_REPOSITORY" ] && \
1289 [ "$(sed 1!d $PACKAGES_REPOSITORY/cookorder.txt)" != "#PlanSort" ] ; then
1290 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
1291 regen_cooklist=yes
1292 else
1293 echo "$PACKAGE" >> $PACKAGES_REPOSITORY/removed
1294 sed -n '1,10p' -i $PACKAGES_REPOSITORY/removed
1295 fi
1296 fi
1297 fi
1298 done
1299 rm stamp
1300 echo "$updated_pkg" | sed 1d | while read PACKAGE pkg; do
1301 erase_package_info
1302 get_packages_info
1303 done
1304 unset updated_pkg
1306 # Look for new packages.
1307 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1308 if ! fgrep -q " ${pkg##*/}" $pkg_repository/packages.md5; then
1309 get_packages_info
1310 fi
1311 done
1312 report end-step
1313 packages_db_end
1316 packages_db_start()
1318 if [ ! -s packages.txt ]; then
1319 echo "# SliTaz GNU/Linux - Packages list
1321 # Packages : unknown
1322 # Date : $(date +%Y-%m-%d\ \%H:%M:%S)
1324 " > packages.txt
1325 else
1326 sed -e 's/^# Packages :.*/# Packages : unknown/' \
1327 -e "s/# Date :.*/# Date : $(date +%Y-%m-%d\ \%H:%M:%S)/" \
1328 -i packages.txt
1329 fi
1331 # Needed in some cases as tazwok defines RECEIPT at configuration time
1332 # in this particular case it can break the script.
1333 unset RECEIPT
1336 erase_package_info()
1338 cd $pkg_repository
1339 sed "/^$PACKAGE$/,/^$/d" -i packages.txt
1340 sed "/^$PACKAGE /d" -i packages.desc
1341 sed -e "s/=$PACKAGE /= /" -e "s/ $PACKAGE / /" -e "s/ $PACKAGE$//" \
1342 -e "/=$PACKAGE$/d" -e "s/=[0-9,a-z,A-Z]:$PACKAGE /= /" \
1343 -e "s/ [0-9,a-z,A-Z]:$PACKAGE / /" -e "s/ [0-9,a-z,A-Z]:$PACKAGE$/ /" \
1344 -e "/=[0-9,a-z,A-Z]:$PACKAGE$/d" \
1345 -i packages.equiv
1346 sed "/^$PACKAGE:/d" -i files.list
1347 sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
1348 sed "/ $(basename $pkg)$/d" -i packages.md5
1351 get_packages_info()
1353 # If there's no taz folder in the wok, extract info from the
1354 # package.
1355 get_pkg_files $pkg
1356 source_receipt
1357 echo "Getting data from $PACKAGE"
1359 cat >> $pkg_repository/packages.txt << _EOT_
1360 $PACKAGE
1361 $VERSION$EXTRAVERSION
1362 $SHORT_DESC
1363 _EOT_
1364 if [ "$PACKED_SIZE" ]; then
1365 cat >> $pkg_repository/packages.txt << _EOT_
1366 $PACKED_SIZE ($UNPACKED_SIZE installed)
1368 _EOT_
1369 else
1370 echo "" >> $pkg_repository/packages.txt
1371 fi
1373 # Packages.desc is used by Tazpkgbox <tree>.
1374 echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
1376 # Packages.equiv is used by tazpkg install to check depends.
1377 for i in $PROVIDE; do
1378 DEST=""
1379 echo $i | fgrep -q : && DEST="${i#*:}:"
1380 if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
1381 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
1382 else
1383 echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
1384 fi
1385 done
1387 if [ -f files.list ]; then
1388 { echo "$PACKAGE"; cat files.list; } | awk '
1389 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
1390 fi
1392 cd .. && rm -r "$pkg_files_dir"
1394 cd $pkg_repository
1395 echo $(basename ${pkg%.tazpkg}) >> packages.list
1396 [ ! "$package_md5" ] && package_md5=$(md5sum $(basename $pkg))
1397 echo "$package_md5" >> packages.md5
1398 unset package_md5
1401 source_receipt()
1403 unset PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
1404 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
1405 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
1406 src _pkg DESTDIR CONFIG_SITE BRANCH TARBALL stuff wanted_stuff
1407 . ${RECEIPT:-$PWD/receipt}
1410 packages_db_end()
1412 cd $pkg_repository
1413 pkgs=$(wc -l packages.list | sed 's/ .*//')
1414 sed "s/# Packages : .*/# Packages : $pkgs/" -i packages.txt
1416 # If lists were updated it's generally needed to sort them well.
1417 if ! sort -c packages.list 2> /dev/null; then
1418 report step "Sorting packages lists"
1419 for file in packages.list packages.desc packages.equiv; do
1420 [ -f $file ] || continue
1421 sort -o $file $file
1422 done
1423 report end-step
1424 fi
1426 # Dont log this because lzma always output errors.
1427 lzma e files.list files.list.lzma
1428 rm -f files.list
1429 [ -f packages.equiv ] || touch packages.equiv
1432 ########################################################################
1433 # This section contains functions to generate wok database.
1434 ########################
1436 gen_wok_db()
1438 report step "Generating wok database"
1439 report open-bloc
1440 report step "Removing old files"
1441 for file in $wan_db $dep_db $PACKAGES_REPOSITORY/cookorder.txt; do
1442 [ -f $file ] && rm $file
1443 done
1444 report step "Generating wok-wanted.txt"
1445 gen_wan_db
1446 report step "Generating wok-depends.txt"
1447 for PACKAGE in $(cut -f1 -d '|' $PACKAGES_REPOSITORY/packages.desc \
1448 $INCOMING_REPOSITORY/packages.desc | sort -u); do
1449 RECEIPT=$WOK/$PACKAGE/receipt
1450 if [ -s $RECEIPT ]; then
1451 source_receipt
1452 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
1453 fi
1454 done
1455 sort_db
1456 report close-bloc
1459 gen_wan_db()
1461 rm -f $wan_db
1462 for RECEIPT in $(fgrep -l WANTED $WOK/*/receipt); do
1463 WANTED=
1464 source $RECEIPT
1465 [ "$WANTED" ] || continue
1466 echo -e $PACKAGE"\t"$WANTED >> $wan_db
1467 done
1470 update_wan_db()
1472 local PACKAGE=$PACKAGE
1473 wanted_list=$(fgrep WANTED=\"$PACKAGE\" $WOK/*/receipt | cut -f1 -d ':')
1474 grep $'\t'$PACKAGE $wan_db | cut -f 1 | while read wan; do
1475 echo "$wanted_list" | fgrep -q /$wan/receipt && continue
1476 sed "/^$wan\t/d" -i $wan_db
1477 done
1478 for RECEIPT in $wanted_list; do
1479 unset WANTED PACKAGE
1480 source $RECEIPT
1481 [ "$WANTED" ] || continue
1482 sed "/^$PACKAGE\t/d" -i $wan_db
1483 echo -e $PACKAGE"\t"$WANTED >> $wan_db
1484 done
1485 unset wanted_list
1488 update_dep_db()
1490 sed "/^$PACKAGE\t/d" -i $dep_db
1491 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
1494 sort_db()
1496 report step "Generating cookorder.txt"
1497 cat $dep_db | sed 's/ \t / /' | while read PACKAGE BUILD_DEPENDS; do
1498 grep -q ^$PACKAGE$'\t' $wan_db && continue
1500 # Replace each BUILD_DEPENDS with a WANTED package by it's
1501 # WANTED package.
1502 replace_by_wanted()
1504 for p in $BUILD_DEPENDS; do
1505 if grep -q ^$p$'\t' $wan_db; then
1506 echo -n $(grep ^$p$'\t' $wan_db | cut -f 2)' '
1507 else
1508 echo -n $p' '
1509 fi
1510 done | tr ' ' '\n' | sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' '
1512 echo -e $PACKAGE"\t $(replace_by_wanted) "
1513 done > $tmp/db
1514 while [ -s "$tmp/db" ]; do
1515 status=start
1516 for pkg in $(cut -f 1 $tmp/db); do
1517 if ! fgrep -q ' '$pkg' ' $tmp/db; then
1518 echo $pkg >> $tmp/cookorder
1519 sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
1520 status=proceed
1521 fi
1522 done
1523 if [ "$status" = start ]; then
1524 cp -f $tmp/db /tmp/remain-depends.txt
1525 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
1526 for blocked in $(cut -f 1 $tmp/db); do
1527 echo "$blocked" >> $PACKAGES_REPOSITORY/blocked
1528 done
1529 break
1530 fi
1531 done
1532 [ -s $tmp/cookorder ] || touch $tmp/cookorder
1534 # The toolchain packages are moved in first position.
1535 grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1536 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
1537 $tmp/cookorder | tac > $PACKAGES_REPOSITORY/cookorder.txt
1538 for pkg in $(cat $PACKAGES_REPOSITORY/cookorder.txt); do
1539 sed "/^$pkg$/d" -i $tmp/cookorder
1540 done
1542 tac $tmp/cookorder >> $PACKAGES_REPOSITORY/cookorder.txt
1543 report end-step
1546 ########################################################################
1547 # SCAN CORE
1548 ########################
1549 # Includes various scan core-functions. It's not intended to be used
1550 # directly : prefer scan wrappers in next section.
1552 look_for_dep()
1554 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1555 grep -m1 ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
1556 | cut -f 2
1557 else
1558 grep -m1 ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1559 cut -f 2
1560 fi
1563 look_for_bdep()
1565 look_for_all
1568 look_for_all()
1570 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1571 grep -m1 ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
1572 | cut -f 2,3 | sed 's/ / /'
1573 else
1574 grep -m1 ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1575 cut -f 2,3 | sed 's/ / /'
1576 fi
1579 look_for_rdep()
1581 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | cut -f 1
1582 if [ "$undigest" ]; then
1583 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt | cut -f 1); do
1584 if [ ! -f "WOK$/$rdep/receipt" ]; then
1585 echo "$rdep"
1586 fi
1587 done
1588 fi
1591 look_for_rbdep()
1593 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | \
1594 cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
1595 if [ "$undigest" ]; then
1596 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
1597 | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
1598 if [ ! -f "WOK$/$rdep/receipt" ]; then
1599 echo "$rdep"
1600 fi
1601 done
1602 fi
1605 # Return WANTED if it exists.
1606 look_for_wanted()
1608 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1609 grep -m1 ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-wanted.txt | cut -f 2
1610 else
1611 grep -m1 ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 2
1612 fi
1615 # Return packages which wants PACKAGE.
1616 look_for_rwanted()
1618 grep $'\t'$PACKAGE$ $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 1
1619 if [ "$undigest" ]; then
1620 for rwanted in $(grep $'\t'$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-wanted.txt | cut -f 1); do
1621 if [ ! -f "$WOK/$rwanted/receipt" ]; then
1622 echo "$rwanted"
1623 fi
1624 done
1625 fi
1628 look_for_dev()
1630 WANTED=$(look_for_wanted)
1631 if [ "$WANTED" ]; then
1632 if [ "$undigest" ] && [ ! -f "$WOK/$WANTED/receipt" ]; then
1633 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$WANTED-dev/receipt" ] && echo $WANTED-dev
1634 else
1635 [ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
1636 fi
1637 fi
1638 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1639 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1640 else
1641 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1642 fi
1645 with_dev()
1647 for PACKAGE in $(cat); do
1648 echo $PACKAGE
1649 look_for_dev
1650 done
1653 with_wanted()
1655 for PACKAGE in $(cat); do
1656 echo $PACKAGE
1657 look_for_wanted
1658 done
1661 use_wanted()
1663 for input in $(cat); do
1664 { grep ^$input$'\t' $wan_db || echo $input
1665 } | sed 's/.*\t//'
1666 done
1669 ########################################################################
1670 # SCAN
1671 ########################
1672 # Use wok-wanted.txt and wok-depeds.txt to scan depends.
1673 # Option in command line (must be first arg) :
1674 # --look_for=bdep/rbdep - Look for depends or reverse depends.
1675 # --with_dev - Add development packages (*-dev) in the result.
1676 # --with_wanted - Add package+reverse wanted in the result.
1677 # --with_args - Include packages in argument in the result.
1679 scan()
1681 # Get packages in argument.
1682 local PACKAGE=$PACKAGE WANTED=$WANTED pkg_list=
1683 for arg in $@; do
1684 [ "$arg" = "${arg#--}" ] || continue
1685 pkg_list="$pkg_list $arg"
1686 done
1688 # Get options.
1689 [ "$pkg_list" ] || return
1690 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
1691 get_options_list="look_for with_dev with_wanted with_args cooklist use_wanted"
1692 get_options
1694 # Get db md5 to be able to check for changes latter.
1695 db_md5=$(md5sum $dep_db $wan_db)
1697 # Cooklist is a special case where we need to modify a little
1698 # scan behavior
1699 if [ "$cooklist" ]; then
1700 gen_wan_db
1701 look_for=all && with_args=yes && with_dev= && with_wanted=
1702 filter=use_wanted
1703 if [ "$COMMAND" = gen-cooklist ]; then
1704 for PACKAGE in $pkg_list; do
1705 grep -q ^$PACKAGE$'\t' $dep_db && continue
1706 [ -d "$WOK/$p" ] || continue
1707 check_for_missing
1708 done
1709 append_to_dep()
1711 if ! grep -q ^$PACKAGE$'\t' $dep_db; then
1712 check_for_missing && echo $PACKAGE >> $tmp/dep
1713 else
1714 echo $PACKAGE >> $tmp/dep
1715 fi
1717 else
1718 append_to_dep()
1720 check_for_commit && echo $PACKAGE >> $tmp/dep
1722 fi
1723 else
1724 append_to_dep()
1726 echo $PACKAGE >> $tmp/dep
1728 # If requested packages are not in dep_db, partial generation of this db is needed.
1729 for PACKAGE in $pkg_list; do
1730 grep -q ^$PACKAGE$'\t' $dep_db && continue
1731 [ -d "$WOK/$p" ] || continue
1732 plan_check_for_missing=yes
1733 check_for_missing
1734 done
1735 if [ "$plan_check_for_missing" ]; then
1736 append_to_dep()
1738 if ! grep -q ^$PACKAGE$'\t' $dep_db; then
1739 check_for_missing && echo $PACKAGE >> $tmp/dep
1740 else
1741 echo $PACKAGE >> $tmp/dep
1742 fi
1744 unset plan_check_for_missing
1745 fi
1746 fi
1748 [ "$with_dev" ] && filter=with_dev
1749 [ "$with_wanted" ] && filter=with_wanted
1750 if [ "$filter" ]; then
1751 pkg_list=$(echo $pkg_list | $filter | sort -u)
1752 scan_pkg()
1754 look_for_$look_for | $filter
1756 else
1757 scan_pkg()
1759 look_for_$look_for
1761 fi
1762 touch $tmp/dep
1763 for PACKAGE in $pkg_list; do
1764 [ "$with_args" ] && append_to_dep
1765 scan_pkg
1766 done | tr ' ' '\n' | sort -u > $tmp/list
1767 [ "$look_for" = bdep ] && look_for=dep
1768 while [ -s $tmp/list ]; do
1769 PACKAGE=$(sed 1!d $tmp/list)
1770 sed 1d -i $tmp/list
1771 append_to_dep
1772 for pkg in $(scan_pkg); do
1773 if ! grep -q ^$pkg$ $tmp/list $tmp/dep; then
1774 echo $pkg >> $tmp/list
1775 fi
1776 done
1777 done
1778 if [ "$cooklist" ]; then
1779 mv $tmp/dep $tmp/cooklist
1780 else
1781 cat $tmp/dep | sort -u
1782 fi
1783 rm -f $tmp/dep $tmp/list
1784 sort -o $dep_db $dep_db
1785 sort -o $wan_db $wan_db
1786 if [ "$db_md5" != "$(md5sum $dep_db $wan_db)" ]; then
1787 grep -q "^#" $PACKAGES_REPOSITORY/cookorder.txt ||
1788 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
1789 fi
1792 ########################################################################
1793 # This section contains functions to check the package repository and
1794 # find which packages to cook.
1795 ########################
1797 check_for_missing()
1799 local PACKAGE=$PACKAGE
1800 if ! check_for_pkg_in_wok; then
1801 [ "$?" = 2 ] && return 1
1802 return
1803 fi
1804 RECEIPT=$WOK/$PACKAGE/receipt
1805 source_receipt
1806 PACKAGE=${WANTED:-$PACKAGE}
1807 update_wan_db
1808 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
1809 RECEIPT=$WOK/$PACKAGE/receipt
1810 source_receipt
1811 update_dep_db
1812 done
1815 check_for_commit()
1817 if ! check_for_pkg_in_wok; then
1818 [ "$?" = 2 ] && return 1
1819 return
1820 fi
1821 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
1822 RECEIPT=$WOK/$PACKAGE/receipt
1823 source_receipt
1825 # We use md5 of cooking stuff in the packaged receipt to check
1826 # commit. We look consecutively in 3 different locations :
1827 # - in the wok/PACKAGE/taz/* folder
1828 # - in the receipt in the package in incoming repository
1829 # - in the receipt in the package in packages repository
1830 # If md5sums match, there's no commit.
1831 check_for_commit_using_md5sum()
1833 if [ ! -f $WOK/$PACKAGE/md5 ]; then
1834 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
1835 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
1836 cd $WOK/$PACKAGE
1837 fi
1839 if [ -s md5 ]; then
1840 if md5sum -cs md5; then
1842 # If md5sum check if ok, check for new/missing files in
1843 # cooking stuff.
1844 for file in $([ -f receipt ] && echo receipt; \
1845 [ -f description.txt ] && echo description.txt; \
1846 [ -d stuff ] && find stuff); do
1847 if ! fgrep -q " $file" md5; then
1848 set_commited
1849 fi
1850 done
1851 else
1852 set_commited
1853 fi
1854 else
1855 set_commited
1856 fi
1858 set_commited()
1860 ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/commit &&
1861 echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
1862 gen_cookmd5
1863 update_dep_db
1865 taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*')
1866 if [ -f $WOK/$PACKAGE/md5 ]; then
1867 cd $WOK/$PACKAGE
1868 check_for_commit_using_md5sum
1869 elif [ "$taz_dir" ]; then
1870 cd $taz_dir
1871 check_for_commit_using_md5sum
1872 else
1873 pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1874 [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1875 if [ "$pkg" ]; then
1876 get_pkg_files $pkg
1877 check_for_commit_using_md5sum
1878 rm -r $pkg_files_dir
1879 else
1880 set_commited
1881 fi
1882 fi
1883 [ "$forced" ] || echo $PACKAGE >> $tmp/checked
1884 done
1885 return
1888 gen_cook_list()
1890 report step "Scanning wok"
1891 if [ "$pkg" ]; then
1892 scan $pkg --cooklist
1893 else
1894 scan `cat $cooklist` --cooklist
1895 fi
1896 report end-step
1898 [ -s $tmp/checked ] || [ -s $tmp/cooklist ] || return
1900 # Core toolchain should not be cooked unless cook-toolchain is used.
1901 if ! [ -f /etc/config.site.tmptoolchain ] ; then
1902 for PACKAGE in $(scan gcc --look_for=all --with_args --with_wanted); do
1903 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/blocked || \
1904 echo $PACKAGE >> $PACKAGES_REPOSITORY/blocked
1905 done
1906 fi
1908 if [ -s $PACKAGES_REPOSITORY/commit ] && [ "$COMMAND" != gen-cooklist ]; then
1909 cd $PACKAGES_REPOSITORY
1910 for PACKAGE in $(cat commit); do
1911 WANTED="$(look_for_wanted)"
1912 if [ "$WANTED" ]; then
1913 grep -q ^$WANTED$ broken cooklist blocked commit && continue
1914 fi
1915 grep -q ^$PACKAGE$ blocked cooklist && continue
1916 echo $PACKAGE >> cooklist
1917 done
1918 fi
1919 sort_cooklist
1922 sort_cooklist()
1924 if [ "$(sed 1!d $PACKAGES_REPOSITORY/cookorder.txt)" = "#PlanSort" ]; then
1925 sed 1d -i $PACKAGES_REPOSITORY/cookorder.txt
1926 sort_db
1927 fi
1928 report step "Generating cooklist"
1929 if [ -f "$tmp/checked" ]; then
1930 rm -f $tmp/cooklist
1931 cat $tmp/checked | while read PACKAGE; do
1932 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/cooklist && \
1933 echo $PACKAGE >> $tmp/cooklist
1934 done
1935 elif ! [ "$COMMAND" = gen-cooklist ]; then
1936 cat $PACKAGES_REPOSITORY/blocked | while read PACKAGE; do
1937 sed "/^$PACKAGE/d" -i $tmp/cooklist
1938 done
1939 fi
1940 report end-step
1941 [ -s $tmp/cooklist ] || return
1943 report step "Sorting cooklist"
1944 for PACKAGE in $(cat $tmp/cooklist); do
1945 WANTED="$(look_for_wanted)"
1946 [ "$WANTED" ] || continue
1947 if grep -q ^$WANTED$ $PACKAGES_REPOSITORY/broken $tmp/cooklist; then
1948 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1949 elif [ ! -d $WOK/$WANTED/install ]; then
1950 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1951 echo $WANTED >> $tmp/cooklist
1952 fi
1953 done
1955 # Use cookorder.txt to sort cooklist.
1956 if [ -s $tmp/cooklist ]; then
1957 cat $PACKAGES_REPOSITORY/cookorder.txt | while read PACKAGE; do
1958 if grep -q ^$PACKAGE$ $tmp/cooklist; then
1959 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1960 echo $PACKAGE >> $tmp/cooklist.tmp
1961 fi
1962 done
1964 # Remaining packages in cooklist are those without compile_rules.
1965 # They can be cooked first in any order.
1966 if [ -f $tmp/cooklist.tmp ]; then
1967 cat $tmp/cooklist.tmp >> $tmp/cooklist
1968 rm $tmp/cooklist.tmp
1969 fi
1971 cat $tmp/cooklist
1972 [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
1973 cat $tmp/cooklist > $cooklist
1974 fi
1976 report end-step
1979 look_for_missing_pkg()
1981 for pkg in $(cat $PACKAGES_REPOSITORY/$1); do
1982 grep -q ^$pkg$ $INCOMING_REPOSITORY/packages.txt \
1983 $PACKAGES_REPOSITORY/packages.txt || \
1984 continue
1985 echo $pkg
1986 done
1989 check_for_incoming()
1991 report step "Checking that all packages were cooked OK"
1992 [ -s $INCOMING_REPOSITORY/packages.desc ] || {
1993 echo "No packages in $INCOMING_REPOSITORY."
1994 report end-step; return; }
1995 if [ -s $PACKAGES_REPOSITORY/broken ]; then
1996 missingpkg=$(look_for_missing_pkg broken)
1997 if [ "$missingpkg" ]; then
1998 echo "Don't move incoming packages to main repository because these ones are broken:" >&2
1999 echo "$missingpkg"
2000 report end-step
2001 return 1
2002 fi
2003 fi
2004 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
2005 missingpkg=$(look_for_missing_pkg cooklist)
2006 if [ "$missingpkg" ]; then
2007 echo "Don't move incoming packages to main repository because these ones need to be cooked:" >&2
2008 echo "$missingpkg"
2009 report end-step
2010 return 1
2011 fi
2012 fi
2013 incoming_pkgs="$(cut -f 1 -d '|' $INCOMING_REPOSITORY/packages.desc)"
2014 if ! [ "$forced" ]; then
2015 cooklist=$PACKAGES_REPOSITORY/cooklist
2016 pkg="$incoming_pkgs"
2017 gen_cook_list
2018 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
2019 missingpkg=$(look_for_missing_pkg cooklist)
2020 if [ "$missingpkg" ]; then
2021 echo "Don't move incoming packages to main repository because these ones need to be cooked:" >&2
2022 echo "$missingpkg"
2023 report end-step
2024 return 1
2025 fi
2026 fi
2027 fi
2029 report step "Moving incoming packages to main repository"
2030 unset EXTRAVERSION
2031 for PACKAGE in $incoming_pkgs; do
2032 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
2033 VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
2034 remove_previous_package $PACKAGES_REPOSITORY
2035 echo "Moving $PACKAGE..."
2036 mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
2037 touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
2038 previous_tarball=$(grep ^$PACKAGE:main $SOURCES_REPOSITORY/sources.list | cut -f2)
2039 sed -e "/^$PACKAGE:main/d" \
2040 -e "s/^$PACKAGE:incoming/$PACKAGE:main/" \
2041 -i $SOURCES_REPOSITORY/sources.list
2042 if [ "$previous_tarball" ]; then
2043 grep -q $'\t'$previous_tarball$ $SOURCES_REPOSITORY/sources.list || \
2044 rm -f $SOURCES_REPOSITORY/$previous_tarball
2045 fi
2046 done
2047 for file in packages.list packages.equiv packages.md5 packages.desc \
2048 packages.txt; do
2049 echo -n "" > $INCOMING_REPOSITORY/$file
2050 done
2051 rm -r $INCOMING_REPOSITORY/files.list.lzma
2052 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2054 report step "Updating flavors"
2055 if [ -x /usr/bin/tazlito ] || [ -x /usr/bin/clean-chroot ]; then
2056 if ! [ -x /usr/bin/tazlito ]; then
2057 tazpkg get-install tazlito
2058 fi
2060 # Handle cases where tazwok is used into main system;
2061 # Handle cases where SLITAZ_DIR is not /home/slitaz.
2062 [ -L /home/slitaz/flavors ] && rm /home/slitaz/flavors
2063 mkdir -p /home/slitaz
2064 ln -s $LOCAL_REPOSITORY/flavors /home/slitaz/flavors
2066 cd $LOCAL_REPOSITORY/packages
2067 for i in $LOCAL_REPOSITORY/flavors/*; do
2068 [ -d "$i" ] || continue
2069 tazlito pack-flavor ${i##*/}
2070 done
2072 noheader=""
2073 for i in *.flavor; do
2074 tazlito show-flavor $i --brief $noheader
2075 noheader="--noheader"
2076 done > flavors.list
2077 [ -x /usr/bin/clean-chroot ] && clean-chroot
2078 else
2079 echo "Can't create up-to-date flavors because the tazlito package is missing." >&2
2080 fi
2081 report end-step
2084 ########################################################################
2085 # TAZWOK MAIN FUNCTIONS
2086 ########################
2088 clean()
2090 cd $WOK/$PACKAGE
2091 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
2092 -e ^stuff$ || return
2094 [ "$COMMAND" = clean-wok ] || report step "Cleaning $PACKAGE"
2095 # Check for clean_wok function.
2096 if grep -q ^clean_wok $RECEIPT; then
2097 clean_wok
2098 fi
2099 # Clean should only have a receipt, stuff and optional desc.
2100 for f in `ls .`
2101 do
2102 case $f in
2103 receipt|stuff|description.txt|md5)
2104 continue ;;
2105 *)
2106 rm -rf $f ;;
2107 esac
2108 done
2109 [ "$COMMAND" != clean-wok ] && report end-step
2112 # Configure and make a package with the receipt.
2113 compile_package()
2115 check_for_package_on_cmdline
2117 # Include the receipt to get all needed variables and functions
2118 # and cd into the work directory to start the work.
2119 check_for_receipt
2120 source_receipt
2122 # Log the package name and date.
2123 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
2124 echo "package $PACKAGE (compile)" >> $LOG
2126 # Set wanted $src variable to help compiling.
2127 [ ! "$src" ] && set_src_path
2128 check_for_build_depends || return 1
2129 check_for_wanted
2130 unset target
2131 check_for_tarball && check_for_compile_rules
2134 # Cook command also include all features to manage lists which keep
2135 # track of wok/packages state.
2136 cook()
2138 cook_code=
2139 set_common_path
2140 check_for_receipt
2141 source_receipt
2143 # Define log path and start report.
2144 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
2145 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
2146 echo "$PACKAGE" > $LOCAL_REPOSITORY/log/package
2147 report step "Cooking $PACKAGE"
2148 report open-bloc
2150 clean $PACKAGE
2151 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
2153 if compile_package; then
2154 remove_src
2155 refresh_packages_from_compile
2156 gen_package
2158 # Update packages-incoming repository.
2159 store_pkgname=$PACKAGE
2160 pkg_repository=$INCOMING_REPOSITORY
2161 update_packages_db
2163 PACKAGE=$store_pkgname
2164 unset store_pkgname
2166 # Upgrade to cooked packages if it was previously installed.
2167 report step "Looking for package(s) to upgrade"
2168 for pkg in $(look_for_rwanted) $PACKAGE; do
2169 if [ -d $INSTALLED/$pkg ]; then
2170 tazpkg get-install $pkg --forced
2171 fi
2172 done
2173 report end-step
2174 else
2175 set_pkg_broken
2176 cook_code=1
2177 fi
2179 # Remove build_depends in cook mode (if in cooklist, it's done when
2180 # checking build_depends of next package and we remove only unneeded
2181 # packages to keep chroot minimal and gain some time).
2182 if [ "$COMMAND" = cook ]; then
2183 remove_build_depends $MISSING_PACKAGE
2184 [ -x /usr/bin/clean-chroot ] && clean-chroot
2185 fi
2187 # Regen the cooklist if it was planned and command is not cook.
2188 [ "$regen_cooklist" ] && unset regen_cooklist && \
2189 [ "$COMMAND" != cook ] && sort_cooklist
2191 # Some hacks to set the bloc & function status as failed if cook has
2192 # failed.
2193 report_return_code=$cook_code
2194 report close-bloc
2195 report end-sublog
2196 rm -f $LOCAL_REPOSITORY/log/package
2197 return $cook_code
2200 cook_list()
2202 if [ -s $tmp/cooklist ]; then
2203 if [ -f /usr/bin/tazchroot ]; then
2204 # Note : options -main variables- are automatically kept by
2205 # the sub-applications tazchroot/tazwok; as well as report data.
2206 cd $LOCAL_REPOSITORY
2207 [ ! -f tazchroot.conf ] && configure_tazchroot
2208 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
2209 return
2210 fi
2211 while [ -s $tmp/cooklist ]; do
2212 PACKAGE=$(sed 1!d $tmp/cooklist)
2213 cook
2214 done
2215 remove_build_depends $MISSING_PACKAGE $remove_later
2216 [ -x /usr/bin/clean-chroot ] && clean-chroot
2217 else
2218 echo "Nothing to cook."
2219 return
2220 fi
2223 configure_tazchroot()
2225 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
2226 # Tazchroot configuration file - created by tazwok.
2228 # Default chroot path.
2229 SLITAZ_DIR=$SLITAZ_DIR
2230 SLITAZ_VERSION=$SLITAZ_VERSION
2231 $( [ "$undigest" ] && echo "undigest=$undigest" )
2232 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
2233 chroot_dir=\$LOCAL_REPOSITORY/chroot
2235 # Default scripts path (these scripts are added to the
2236 # $chroot_dir/usr/bin and can be called with tazchroot script).
2237 script_dir=/usr/lib/slitaz/chroot-scripts/tazwok
2239 # List of directories to mount.
2240 list_dir="$(for dir in packages wok src packages-incoming log flavors iso clean-wok; do echo $LOCAL_REPOSITORY/$dir; done)
2241 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
2243 create_chroot()
2245 mkdir -p \$chroot_dir
2246 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
2247 tazpkg get-install \$pkg --root="\$chroot_dir"
2248 done
2250 # Store list of installed packages needed by cleanchroot.
2251 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
2253 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
2254 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
2255 -i \$chroot_dir/etc/slitaz/slitaz.conf
2256 echo \$SLITAZ_VERSION > \$chroot_dir/etc/slitaz-release
2257 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
2258 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
2259 # The build bot may run in a sandbox: link sandbox lockfile.
2260 ln -s \$LOCAL_REPOSITORY/sandbox/proc/1 \$chroot_dir/proc/1
2263 mount_chroot()
2265 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
2266 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
2267 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
2268 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
2269 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
2270 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
2271 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
2272 mount -o bind /proc \$chroot_dir/proc
2273 mount -o bind /sys \$chroot_dir/sys
2274 mount -o bind /dev/pts \$chroot_dir/dev/pts
2275 mount -o bind /dev/shm \$chroot_dir/dev/shm
2276 for dir in \$list_dir; do
2277 mkdir -p \$dir \$chroot_dir\$dir
2278 mount \$dir \$chroot_dir\$dir
2279 done
2282 umount_chroot()
2284 for dir in \$list_dir; do
2285 umount \$chroot_dir\$dir
2286 done
2287 umount \$chroot_dir/dev/shm
2288 umount \$chroot_dir/dev/pts
2289 umount \$chroot_dir/sys
2290 umount \$chroot_dir/proc
2292 EOF
2295 ########################################################################
2296 ######################### END OF NEW FUNCTIONS #########################
2297 ########################################################################
2299 # List packages providing a virtual package.
2300 whoprovide()
2302 local i;
2303 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
2304 . $i
2305 case " $PROVIDE " in
2306 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
2307 esac
2308 done
2311 ########################################################################
2312 # TAZWOK COMMANDS
2313 ########################
2315 case "$COMMAND" in
2316 stats)
2317 # Tazwok general statistics from the wok config file.
2319 get_tazwok_config
2320 echo -e "\n\033[1mTazwok configuration statistics\033[0m
2321 ================================================================================
2322 Wok directory : $WOK
2323 Packages repository : $PACKAGES_REPOSITORY
2324 Incoming repository : $INCOMING_REPOSITORY
2325 Sources repository : $SOURCES_REPOSITORY
2326 Log directory : $LOCAL_REPOSITORY/log
2327 Packages in the wok : `ls -1 $WOK | wc -l`
2328 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2329 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2330 ================================================================================\n"
2331 ;;
2332 edit)
2333 get_tazwok_config
2334 check_for_package_on_cmdline
2335 check_for_receipt
2336 $EDITOR $WOK/$PACKAGE/receipt
2337 ;;
2338 build-depends)
2339 # List dependencies to rebuild wok, or only a package.
2340 get_tazwok_config
2341 report(){ : ; }
2342 if [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
2343 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
2344 --look_for=dep --with_dev --with_args
2345 else
2346 check_for_package_on_cmdline
2347 scan $PACKAGE --look_for=bdep --with_dev
2348 fi
2349 ;;
2350 gen-cooklist)
2351 check_root
2352 get_options_list="pkg"
2353 get_tazwok_config
2354 report(){ : ; }
2355 if ! [ "$pkg" ]; then
2356 if [ ! "$LIST" ] || [ "$LIST" = toolchain ]; then
2357 pkg="$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA"
2358 else
2359 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2360 fi
2361 fi
2362 gen_cook_list
2363 ;;
2364 check-depends)
2365 # Check package depends /!\.
2366 get_tazwok_config
2367 echo ""
2368 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
2369 ================================================================================"
2370 TMPDIR=/tmp/tazwok$$
2371 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
2373 # Build ALL_DEPENDS variable.
2374 scan_dep()
2376 local i
2377 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
2378 for i in $DEPENDS $SUGGESTED ; do
2379 case " $ALL_DEPENDS " in
2380 *\ $i\ *) continue;;
2381 esac
2382 [ -d $WOK/$i ] || {
2383 ALL_DEPENDS="$ALL_DEPENDS$i "
2384 continue
2386 DEPENDS=""
2387 SUGGESTED=""
2388 . $WOK/$i/receipt
2389 scan_dep
2390 done
2393 # Check for ELF file.
2394 is_elf()
2396 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ]
2399 # Print shared library dependencies.
2400 ldd()
2402 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2405 mkdir $TMPDIR
2406 cd $TMPDIR
2407 for i in $LOCALSTATE/files.list.lzma \
2408 $LOCALSTATE/undigest/*/files.list.lzma ; do
2409 [ -f $i ] && lzma d $i -so >> files.list
2410 done
2411 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2412 tazpkg extract $pkg > /dev/null 2>&1
2413 . */receipt
2414 ALL_DEPENDS="$DEFAULT_DEPENDS "
2415 scan_dep
2416 find */fs -type f | while read file ; do
2417 is_elf $file || continue
2418 case "$file" in
2419 *.o|*.ko|*.ko.gz) continue;;
2420 esac
2421 ldd $file | while read lib rem; do
2422 case "$lib" in
2423 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2424 continue;;
2425 esac
2426 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2427 case " $ALL_DEPENDS " in
2428 *\ $dep\ *) continue 2;;
2429 esac
2430 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2431 case " $ALL_DEPENDS " in
2432 *\ $vdep\ *) continue 3;;
2433 esac
2434 done
2435 done
2436 [ -n "$dep" ] || dep="UNKNOWN"
2437 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2438 done
2439 done
2440 rm -rf */
2441 done
2442 cd /tmp
2443 rm -rf $TMPDIR
2444 ;;
2445 check)
2446 # Check wok consistency.
2447 get_tazwok_config
2448 echo ""
2449 echo -e "\033[1mWok and packages checking\033[0m
2450 ================================================================================"
2451 cd $WOK
2452 for pkg in $(ls)
2453 do
2454 [ -f $pkg/receipt ] || continue
2455 RECEIPT= $pkg/receipt
2456 source_receipt
2457 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2458 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2459 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2460 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2461 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2462 if [ -n "$WANTED" ]; then
2463 if [ ! -f $WANTED/receipt ]; then
2464 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2465 else
2466 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2467 if [ "$VERSION" = "$WANTED" ]; then
2468 # BASEVERSION is computed in receipt
2469 fgrep -q '_pkg=' $pkg/receipt &&
2470 BASEVERSION=$VERSION
2471 fi
2472 if [ "$VERSION" != "$BASEVERSION" ]; then
2473 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2474 fi
2475 fi
2476 fi
2478 if [ -n "$CATEGORY" ]; then
2479 case " $(echo $CATEGORIES) " in
2480 *\ $CATEGORY\ *);;
2481 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2482 esac
2483 else
2484 echo"Package $PACKAGE has no CATEGORY" >&2
2485 fi
2486 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2487 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2488 case "$WGET_URL" in
2489 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2490 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2491 '') ;;
2492 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2493 esac
2494 case "$WEB_SITE" in
2495 ftp*|http*);;
2496 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2497 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2498 esac
2499 case "$MAINTAINER" in
2500 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2501 esac
2502 case "$MAINTAINER" in
2503 *@*);;
2504 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2505 esac
2506 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2507 for i in $DEPENDS; do
2508 [ -d $i ] && continue
2509 [ -n "$(whoprovide $i)" ] && continue
2510 echo -e "$MSG $i"
2511 MSG=""
2512 done
2513 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2514 for i in $BUILD_DEPENDS; do
2515 [ -d $i ] && continue
2516 [ -n "$(whoprovide $i)" ] && continue
2517 echo -e "$MSG $i"
2518 MSG=""
2519 done
2520 MSG="Dependency loop between $PACKAGE and :\n"
2521 ALL_DEPS=""
2522 check_for_deps_loop $PACKAGE $DEPENDS
2523 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2524 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2525 echo "$pkg should be rebuilt after $i installation"
2526 done
2527 done
2528 ;;
2529 list)
2530 # List packages in wok directory. User can specify a category.
2532 get_tazwok_config
2533 if [ "$2" = "category" ]; then
2534 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2535 exit 0
2536 fi
2537 # Check for an asked category.
2538 if [ -n "$2" ]; then
2539 ASKED_CATEGORY=$2
2540 echo ""
2541 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2542 echo "================================================================================"
2543 for pkg in $WOK/*
2544 do
2545 [ ! -f $pkg/receipt ] && continue
2546 . $pkg/receipt
2547 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2548 echo -n "$PACKAGE"
2549 echo -e "\033[28G $VERSION"
2550 packages=$(($packages+1))
2551 fi
2552 done
2553 echo "================================================================================"
2554 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
2555 else
2556 # By default list all packages and version.
2557 echo ""
2558 echo -e "\033[1mList of packages in the wok\033[0m"
2559 echo "================================================================================"
2560 for pkg in $WOK/*
2561 do
2562 [ ! -f $pkg/receipt ] && continue
2563 . $pkg/receipt
2564 echo -n "$PACKAGE"
2565 echo -en "\033[28G $VERSION"
2566 echo -e "\033[42G $CATEGORY"
2567 packages=$(($packages+1))
2568 done
2569 echo "================================================================================"
2570 echo -e "$packages packages available in the wok.\n"
2571 fi
2572 ;;
2573 info)
2574 # Information about a package.
2576 get_tazwok_config
2577 check_for_package_on_cmdline
2578 check_for_receipt
2579 . $WOK/$PACKAGE/receipt
2580 echo ""
2581 echo -e "\033[1mTazwok package information\033[0m
2582 ================================================================================
2583 Package : $PACKAGE
2584 Version : $VERSION
2585 Category : $CATEGORY
2586 Short desc : $SHORT_DESC
2587 Maintainer : $MAINTAINER"
2588 if [ ! "$WEB_SITE" = "" ]; then
2589 echo "Web site : $WEB_SITE"
2590 fi
2591 if [ ! "$DEPENDS" = "" ]; then
2592 echo "Depends : $DEPENDS"
2593 fi
2594 if [ ! "$WANTED" = "" ]; then
2595 echo "Wanted src : $WANTED"
2596 fi
2597 echo "================================================================================"
2598 echo ""
2599 ;;
2600 check-log)
2601 # We just cat the file log to view process info.
2603 get_tazwok_config
2604 if [ ! -f "$LOG" ]; then
2605 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2606 exit 1
2607 else
2608 echo ""
2609 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2610 echo "================================================================================"
2611 cat $LOG
2612 echo "================================================================================"
2613 echo ""
2614 if [ -s "$WOK/$PACKAGE/warning.txt" ]; then
2615 echo -e "\033[1mCook warning(s) for :\033[0m $PACKAGE"
2616 echo "================================================================================"
2617 cat "$WOK/$PACKAGE/warning.txt"
2618 echo "================================================================================"
2619 echo ""
2620 fi
2621 fi
2622 ;;
2623 search)
2624 # Search for a package by pattern or name.
2626 get_tazwok_config
2627 if [ -z "$2" ]; then
2628 echo -e "\nPlease specify a pattern or a package name to search." >&2
2629 echo -e "Example : 'tazwok search gcc'.\n" >&2
2630 exit 1
2631 fi
2632 echo ""
2633 echo -e "\033[1mSearch result for :\033[0m $2"
2634 echo "================================================================================"
2635 list=`ls -1 $WOK | fgrep $2`
2636 for pkg in $list
2637 do
2638 . $WOK/$pkg/receipt
2639 echo -n "$PACKAGE "
2640 echo -en "\033[24G $VERSION"
2641 echo -e "\033[42G $CATEGORY"
2642 packages=$(($PACKAGEs+1))
2643 done
2644 echo "================================================================================"
2645 echo "$packages packages found for : $2"
2646 echo ""
2647 ;;
2648 compile)
2649 # Configure and make a package with the receipt.
2651 get_tazwok_config
2652 source_lib report
2653 report start
2654 compile_package
2655 ;;
2656 genpkg)
2657 # Generate a package.
2659 get_tazwok_config
2660 source_lib report
2661 report start
2662 gen_package
2663 ;;
2664 cook)
2665 # Compile and generate a package. Just execute tazwok with
2666 # the good commands.
2668 check_root
2669 get_tazwok_config
2670 source_lib report
2671 report start
2672 db_md5=$(md5sum $dep_db $wan_db)
2673 update_wan_db
2674 check_for_commit
2675 sort -o $dep_db $dep_db
2676 sort -o $wan_db $wan_db
2677 if [ "$db_md5" != "$(md5sum $dep_db $wan_db)" ]; then
2678 grep -q "^#" $PACKAGES_REPOSITORY/cookorder.txt ||
2679 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
2680 fi
2681 cook
2682 ;;
2683 sort-cooklist)
2684 if [ ! -f "$LIST" ]; then
2685 echo "Usage : tazwok sort-cooklist cooklist" >&2
2686 exit 1
2687 fi
2688 check_root
2689 get_tazwok_config
2690 report(){ : ; }
2691 # When using sort-cooklist, the script should behave as for gen-cooklist
2692 # The only difference between these two is where the output is sent.
2693 COMMAND=gen-cooklist
2694 cooklist=$LIST
2695 gen_cook_list
2696 cp -af $tmp/cooklist $cooklist
2697 ;;
2698 cook-list)
2699 # Cook all packages listed in a file or in default cooklist.
2700 check_root
2701 get_options_list="pkg forced"
2702 get_tazwok_config
2703 source_lib report
2704 report start
2705 if ! [ "$pkg" ]; then
2706 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2707 fi
2708 gen_cook_list
2709 cook_list
2710 ;;
2711 clean)
2712 # Clean up a package work directory + those which want it.
2714 get_tazwok_config
2715 check_for_package_on_cmdline
2716 check_for_receipt
2717 source_lib report
2718 report start
2719 . $RECEIPT
2720 clean
2721 ;;
2722 gen-clean-wok)
2723 # Generate a clean wok from the current wok by copying all receipts
2724 # and stuff directory.
2726 get_tazwok_config
2727 source_lib report
2728 report start
2729 if [ -z "$ARG" ]; then
2730 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2731 exit 1
2732 else
2733 dest=$ARG
2734 mkdir -p $dest
2735 fi
2736 report step "Creating clean wok in : $dest"
2737 for pkg in `ls -1 $WOK`
2738 do
2739 mkdir -p $dest/$pkg
2740 cp -a $WOK/$pkg/receipt $dest/$pkg
2741 [ -f $WOK/$pkg/description.txt ] && \
2742 cp -a $WOK/$pkg/description.txt $dest/$pkg
2743 if [ -d "$WOK/$pkg/stuff" ]; then
2744 cp -a $WOK/$pkg/stuff $dest/$pkg
2745 fi
2746 done
2747 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2748 report end-step
2749 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2750 echo ""
2751 ;;
2752 clean-wok)
2753 # Clean all packages in the work directory.
2755 get_tazwok_config
2756 source_lib report
2757 report start
2758 report step "Cleaning wok"
2759 for PACKAGE in `ls -1 $WOK`
2760 do
2761 set_common_path
2762 source_receipt
2763 clean
2764 done
2765 echo "`ls -1 $WOK | wc -l` packages cleaned."
2766 ;;
2767 clean-src)
2768 # Remove tarball unrelated to wok receipts from src repo.
2769 check_root
2770 get_options_list="forced"
2771 get_tazwok_config
2772 cd $SOURCES_REPOSITORY
2773 echo -n "Checking $SOURCES_REPOSITORY..."
2774 for TARBALL in *; do
2775 [ "$TARBALL" = sources.list ] && continue
2776 grep -q $'\t'$TARBALL$ $SOURCES_REPOSITORY/sources.list || \
2777 echo $TARBALL >> $tmp/obsolete
2778 done
2779 status
2780 if ! [ -f $tmp/obsolete ]; then
2781 echo "No sources need to be removed."
2782 exit 1
2783 fi
2784 echo ""
2785 echo -e "\033[1mObsolete/unrelated-to-wok sources :\033[0m"
2786 horizontal_line
2787 cat $tmp/obsolete
2788 horizontal_line
2789 echo "$(wc -l $tmp/obsolete | cut -f1 -d' ') tarballs to remove."
2790 echo ""
2791 echo -n "Please confirm before removing (type uppercase YES): "
2792 read answer
2793 if [ "$answer" = YES ]; then
2794 echo -n "Removing old sources..."
2795 cat $tmp/obsolete | while read i; do
2796 rm -f $SOURCES_REPOSITORY/$i
2797 done
2798 status
2799 fi
2800 ;;
2801 gen-list)
2802 get_tazwok_config
2803 if [ "$2" ]; then
2804 if [ -d "$2" ]; then
2805 pkg_repository=$2
2806 else
2807 echo -e "\nUnable to find directory : $2\n" >&2
2808 exit 1
2809 fi
2810 fi
2812 source_lib report
2813 report start
2814 if [ "$pkg_repository" ]; then
2815 gen_packages_db
2816 else
2817 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
2818 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
2819 fi
2820 ;;
2821 check-list)
2822 # The directory to move into by default is the repository,
2823 # if $2 is not empty cd into $2.
2825 get_tazwok_config
2826 if [ "$2" ]; then
2827 if [ -d "$2" ]; then
2828 pkg_repository=$2
2829 else
2830 echo -e "\nUnable to find directory : $2\n" >&2
2831 exit 1
2832 fi
2833 fi
2835 source_lib report
2836 report start
2837 if [ "$pkg_repository" ]; then
2838 update_packages_db
2839 else
2840 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2841 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
2842 fi
2843 ;;
2844 new-tree)
2845 # Just create a few directories and generate an empty receipt to prepare
2846 # the creation of a new package.
2848 get_tazwok_config
2849 check_for_package_on_cmdline
2850 clean_wok=$LOCAL_REPOSITORY/clean-wok
2851 if [ -d $clean_wok/$PACKAGE ]; then
2852 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2853 exit 1
2854 fi
2855 echo "Creating : $clean_wok/$PACKAGE"
2856 mkdir $clean_wok/$PACKAGE
2857 cd $clean_wok/$PACKAGE
2858 echo -n "Preparing the receipt..."
2860 # Default receipt begin.
2862 echo "# SliTaz package receipt." > receipt
2863 echo "" >> receipt
2864 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2865 # Finish the empty receipt.
2866 cat >> receipt << "EOF"
2867 VERSION=""
2868 CATEGORY=""
2869 SHORT_DESC=""
2870 MAINTAINER=""
2871 DEPENDS=""
2872 TARBALL="$PACKAGE-$VERSION.tar.gz"
2873 WEB_SITE=""
2874 WGET_URL=""
2876 # Rules to configure and make the package.
2877 compile_rules()
2879 cd $src
2880 ./configure && make && make install
2883 # Rules to gen a SliTaz package suitable for Tazpkg.
2884 genpkg_rules()
2886 mkdir -p $fs/usr
2887 cp -a $_pkg/usr/bin $fs/usr
2890 EOF
2892 # Default receipt end.
2894 status
2895 # Interactive mode, asking and seding.
2896 if [ "$3" = "--interactive" ]; then
2897 echo "Entering interactive mode..."
2898 echo "================================================================================"
2899 echo "Package : $PACKAGE"
2900 # Version.
2901 echo -n "Version : " ; read anser
2902 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2903 # Category.
2904 echo -n "Category : " ; read anser
2905 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2906 # Short description.
2907 echo -n "Short desc : " ; read anser
2908 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2909 # Maintainer.
2910 echo -n "Maintainer : " ; read anser
2911 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2912 # Web site.
2913 echo -n "Web site : " ; read anser
2914 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2915 echo ""
2916 # Wget URL.
2917 echo "Wget URL to download source tarball."
2918 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2919 echo -n "Wget url : " ; read anser
2920 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2921 # Ask for a stuff dir.
2922 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2923 if [ "$anser" = "y" ]; then
2924 echo -n "Creating the stuff directory..."
2925 mkdir stuff && status
2926 fi
2927 # Ask for a description file.
2928 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2929 if [ "$anser" = "y" ]; then
2930 echo -n "Creating the description.txt file..."
2931 echo "" > description.txt && status
2932 fi
2933 echo "================================================================================"
2934 echo ""
2935 fi
2936 ;;
2937 remove)
2938 # Remove a package from the wok.
2940 get_tazwok_config
2941 check_for_package_on_cmdline
2942 echo ""
2943 echo -n "Please confirm deletion (y/N) : "; read anser
2944 if [ "$anser" = "y" ]; then
2945 echo -n "Removing $PACKAGE..."
2946 rm -rf $WOK/$PACKAGE && status
2947 echo ""
2948 fi
2949 ;;
2950 update-wok)
2951 # Pull and update a Hg wok.
2952 get_options_list="local"
2953 get_tazwok_config
2954 source_lib report
2955 report start
2956 clean_wok=$LOCAL_REPOSITORY/clean-wok
2957 cd $clean_wok
2958 if ! [ "$local" ]; then
2959 if [ "$WOK_UPDATE_METHOD" = hg ]; then
2960 if ! [ -f "$INSTALLED/mercurial/receipt" ]; then
2962 # Auto-install only if we are in a cook chroot.
2963 if [ -x /usr/bin/clean-chroot ]; then
2964 tazpkg get-install mercurial
2965 else
2966 echo "" >&2
2967 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
2968 echo "">&2
2969 exit 1
2970 fi
2971 fi
2973 report step "Getting wok changes using hg"
2974 if [ -d .hg ]; then
2975 hg pull -u || exit 1
2976 else
2977 hg clone $HG_WOK . || exit 1
2978 fi
2979 report end-step
2980 [ -x /usr/bin/clean-chroot ] && clean-chroot
2981 else
2982 report step "Getting wok changes using tarball"
2983 { mkdir .tmp && cd .tmp
2984 wget "$TARBALL_WOK" &&
2985 case $TARBALL_WOK in
2986 *bz2) tar xjf *.bz2 -C wok; rm *.bz2;;
2987 *lzma) unlzma -c *.lzma | tar xf - -C wok; rm *.lzma ;;
2988 *gz) tar xzf *.gz -C wok; rm*.gz ;;
2989 esac &&
2990 rm -r $(ls -d $clean_wok/*) &&
2991 cp -a wok/* $clean_wok &&
2992 cd .. &&
2993 rm -r .tmp
2994 } || { echo "That's not cool: it fails!" >&2
2995 report end-step
2996 exit 1; }
2997 report end-step
2998 fi
2999 fi
3000 report step "Appending changes to wok"
3002 # Handle removed files/dir.
3003 cd $WOK
3004 for dir in *; do
3005 [ -d "$clean_wok/$dir" ] || rm -rf $dir
3006 done
3007 for file in */receipt */description.txt; do
3008 [ -f "$clean_wok/$file" ] || rm -rf $file
3009 done
3010 for i in $(find */stuff 2>/dev/null); do
3011 [ -e "$clean_wok/$i" ] || rm -rf $i
3012 done
3014 cp -a $clean_wok/* $WOK
3015 report end-step
3016 ;;
3017 maintainers)
3018 get_tazwok_config
3019 echo ""
3020 echo "List of maintainers for: $WOK"
3021 echo "================================================================================"
3022 touch /tmp/slitaz-maintainers
3023 for pkg in $WOK/*
3024 do
3025 . $pkg/receipt
3026 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
3027 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
3028 echo "$MAINTAINER"
3029 fi
3030 done
3031 echo "================================================================================"
3032 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
3033 echo ""
3034 # Remove tmp files
3035 rm -f /tmp/slitaz-maintainers
3036 ;;
3037 maintained-by)
3038 # Search for packages maintained by a contributor.
3039 get_tazwok_config
3040 if [ ! -n "$2" ]; then
3041 echo "Specify a name or email of a maintainer." >&2
3042 exit 1
3043 fi
3044 echo "Maintainer packages"
3045 echo "================================================================================"
3046 for pkg in $WOK/*
3047 do
3048 . $pkg/receipt
3049 if echo "$MAINTAINER" | fgrep -q "$2"; then
3050 echo "$PACKAGE"
3051 packages=$(($PACKAGEs+1))
3052 fi
3053 done
3054 echo "================================================================================"
3055 echo "Packages maintained by $2: $PACKAGEs"
3056 echo ""
3057 ;;
3058 tags)
3059 get_tazwok_config
3060 echo -e "\n\033[1mTags list :\033[0m"
3061 horizontal_line
3062 cd $WOK
3063 for i in */receipt; do
3064 unset TAGS
3065 source $i
3066 for t in $TAGS; do
3067 grep -q ^$t$ $tmp/tags && continue
3068 echo $t | tee -a $tmp/tags
3069 done
3070 done
3071 horizontal_line
3072 echo "$(wc -l $tmp/tags | cut -f1 -d ' ') tags listed."
3073 ;;
3074 check-src)
3075 # Verify if upstream package is still available.
3077 get_tazwok_config
3078 check_for_package_on_cmdline
3079 check_for_receipt
3080 source_receipt
3081 check_src()
3083 for url in $@; do
3084 busybox wget -s $url 2>/dev/null && break
3085 done
3087 if [ "$WGET_URL" ];then
3088 echo -n "$PACKAGE : "
3089 check_src $WGET_URL
3090 status
3091 else
3092 echo "No tarball to check for $PACKAGE"
3093 fi
3094 ;;
3095 gen-src)
3096 get_tazwok_config
3097 if [ "$2" ]; then
3098 if [ -d "$2" ]; then
3099 src_repository=$2
3100 else
3101 echo -e "\nUnable to find directory : $2\n" >&2
3102 exit 1
3103 fi
3104 fi
3105 echo -n "Rebuilding sources.list file"
3106 [ $src_repository ] || src_repository="$SOURCES_REPOSITORY"
3107 gen_sources_list $src_repository
3108 status
3109 ;;
3110 get-src)
3111 check_root
3112 get_options_list="target nounpack"
3113 get_tazwok_config
3114 check_for_package_on_cmdline
3115 check_for_receipt
3116 source_receipt
3117 if [ "$WGET_URL" ];then
3118 source_lib report
3119 report start
3120 check_for_tarball
3121 else
3122 echo "No tarball to download for $PACKAGE"
3123 fi
3124 ;;
3125 check-commit)
3126 check_root
3127 get_options_list="missing forced"
3128 get_tazwok_config
3129 source_lib report
3130 report start
3131 if [ "$forced" ]; then
3132 rm -f $WOK/*/md5
3133 unset forced
3134 fi
3135 if [ "$missing" ]; then
3136 pkg=$(ls -1 $WOK)
3137 else
3138 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3139 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3140 } | sort -u)"
3141 fi
3142 cooklist=$PACKAGES_REPOSITORY/cooklist
3143 gen_cook_list
3144 ;;
3145 cook-commit)
3146 check_root
3147 get_options_list="missing forced"
3148 get_tazwok_config
3149 source_lib report
3150 report start
3151 if [ "$forced" ]; then
3152 rm -f $WOK/*/md5
3153 unset forced
3154 fi
3155 if [ "$missing" ]; then
3156 pkg=$(ls -1 $WOK)
3157 else
3158 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3159 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3160 } | sort -u)"
3161 fi
3162 cooklist=$PACKAGES_REPOSITORY/cooklist
3163 gen_cook_list
3164 cook_list
3165 ;;
3166 cook-all)
3167 check_root
3168 get_options_list="forced missing"
3169 get_tazwok_config
3170 source_lib report
3171 report start
3172 if [ "$missing" ]; then
3173 pkg=$(ls -1 $WOK)
3174 else
3175 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3176 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3177 } | sort -u)"
3178 fi
3179 cooklist=$PACKAGES_REPOSITORY/cooklist
3180 gen_cook_list
3181 cook_list
3182 ;;
3183 gen-wok-db)
3184 check_root
3185 get_tazwok_config
3186 source_lib report
3187 report start
3188 gen_wok_db
3189 ;;
3190 report)
3191 get_tazwok_config
3192 cd $PACKAGES_REPOSITORY
3193 if [ "$2" ]; then
3194 case $2 in
3195 commit|cooklist|incoming|broken|blocked)
3196 show="$2"
3197 ;;
3198 *)
3199 echo "usage : tazwok report [commit|cooklist|incoming|broken|blocked]" >&2
3200 exit 1
3201 ;;
3202 esac
3203 else
3204 show="commit cooklist incoming broken blocked"
3205 fi
3206 for i in $show; do
3207 if [ -s $i ]; then
3208 echo ""
3209 echo -e "\033[1m$i\033[0m"
3210 echo "================================================================================"
3211 cat $i
3212 echo "================================================================================"
3213 echo ""
3214 fi
3215 done
3216 ;;
3217 check-incoming)
3218 check_root
3219 get_options_list="forced"
3220 get_tazwok_config
3221 source_lib report
3222 report start
3223 [ -f $LOCAL_RESOSITORY/incoming ] && rm [ -f $LOCAL_REPOSITORY/incoming ]
3224 report step "Checking $INCOMING_REPOSITORY"
3225 report open-bloc
3226 [ -f $LOCAL_REPOSITORY/log/incoming.html ] && rm $LOCAL_REPOSITORY/log/incoming.html
3227 report sublog $LOCAL_REPOSITORY/log/incoming.html
3228 echo "incoming" > $LOCAL_REPOSITORY/log/package
3229 check_for_incoming
3230 report end-sublog
3231 report close-bloc
3232 ;;
3233 configure-chroot)
3234 check_root
3235 get_tazwok_config
3236 if [ -f /usr/bin/tazchroot ]; then
3237 cd $LOCAL_REPOSITORY
3238 configure_tazchroot
3239 else
3240 echo "The package tazchroot needs to be installed" >&2
3241 exit 1
3242 fi
3243 ;;
3244 chroot)
3245 check_root
3246 get_tazwok_config
3247 # Merge this and the other chroot function ?.
3248 if [ -f /usr/bin/tazchroot ]; then
3249 cd $LOCAL_REPOSITORY
3250 [ ! -f tazchroot.conf ] && configure_tazchroot
3251 tazchroot
3252 else
3253 echo "The package tazchroot needs to be installed" >&2
3254 exit 1
3255 fi
3256 ;;
3257 cook-toolchain)
3258 check_root
3259 get_tazwok_config
3260 echo -n "" > $PACKAGES_REPOSITORY/broken
3261 if [ -f /usr/bin/tazchroot ]; then
3262 cd $LOCAL_REPOSITORY
3263 [ ! -f tazchroot.conf ] && configure_tazchroot
3264 tazchroot cook-toolchain
3265 # Buggy : chroot can be elsewhere.
3266 rm -r $LOCAL_REPOSITORY/chroot
3267 # /!\ to be written :
3268 # next rm chroot and plan cook-all by pushing all packages
3269 # in cooklist.
3270 else
3271 echo "The package tazchroot needs to be installed" >&2
3272 exit 1
3273 fi
3274 ;;
3275 webserver)
3276 check_root
3277 get_tazwok_config
3278 if [ "$ARG" = on ]; then
3279 if [ "$WEBSERVER" ] && [ -f "$WEBSERVER/repositories.list" ] && \
3280 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3281 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3282 exit 1
3283 fi
3284 if ! [ -f $LOCAL_REPOSITORY/tazchroot.conf ]; then
3285 tazwok configure-chroot ${undigest:+--undigest=$undigest} --SLITAZ_VERSION=$SLITAZ_VERSION --SLITAZ_DIR=$SLITAZ_DIR
3286 fi
3287 for pkg in php lighttpd; do
3288 [ -d $INSTALLED/$pkg ] || missing="$missing $pkg"
3289 done
3290 if [ "$missing" ]; then
3291 echo "You need to install these packages to start webserver: $missing." >&2
3292 exit 1
3293 fi
3294 if [ ! -f "$LOCAL_REPOSITORY/tazwok.conf" ]; then
3295 echo "Copying /etc/slitaz/tazwok.conf to $LOCAL_REPOSITORY/tazwok.conf: webserver is configured repository-by-repository."
3296 cp /etc/slitaz/tazwok.conf $LOCAL_REPOSITORY
3297 fi
3298 if ! [ "$WEBSERVER" ]; then
3299 echo -n "Where to store php pages (default: /var/www/vhosts/bb)? "
3300 read WEBSERVER
3301 [ "$WEBSERVER" ] || WEBSERVER="/var/www/vhosts/bb"
3302 fi
3303 if [ -f "$WEBSERVER/repositories.list" ] && \
3304 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3305 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3306 exit 1
3307 fi
3308 mkdir -p $WEBSERVER
3309 echo "${undigest:-$SLITAZ_VERSION}" >> $WEBSERVER/repositories.list
3310 for file in index.php log.php download.php; do
3311 [ -f "$WEBSERVER/$file" ] || ln -s /usr/share/slitaz/web-bb/$file $WEBSERVER
3312 done
3313 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3314 ln -s $dir $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3315 done
3316 source $LOCAL_REPOSITORY/tazchroot.conf
3317 echo "<?php
3319 // Web interface configuration
3321 \$version=\"${undigest:-$SLITAZ_VERSION}\";
3322 \$chroot=\"$chroot_dir\";
3323 \$lockfile=\"\$chroot/proc/1/status\";
3324 \$db_dir=\"$PACKAGES_REPOSITORY\";
3325 \$log_dir=\"$LOCAL_REPOSITORY/log\";
3326 \$packages=\"$PACKAGES_REPOSITORY\";
3327 \$incoming=\"$INCOMING_REPOSITORY\";
3328 \$wok=\"$WOK\";
3330 ?>" > $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3331 [ -L "$WEBSERVER/web" ] || ln -s /usr/share/slitaz/web $WEBSERVER
3332 echo "WEBSERVER=\"$WEBSERVER\"" >> $LOCAL_REPOSITORY/tazwok.conf
3333 if [ -L "$WEBSERVER/conf.php" ]; then
3334 echo "Do you want to make ${undigest:-$SLITAZ_VERSION} the default page (y/N) ? "
3335 read answer
3336 if [ "$answer" = y ]; then
3337 rm $WEBSERVER/conf.php
3338 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3339 fi
3340 else
3341 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3342 fi
3343 elif [ "$ARG" = off ]; then
3344 if ! [ "$WEBSERVER" ]; then
3345 echo "No webserver running for ${undigest:-$SLITAZ_VERSION}" >&2
3346 exit 1
3347 fi
3348 sed '/^WEBSERVER/d' -i $LOCAL_REPOSITORY/tazwok.conf
3349 sed "/^${undigest:-$SLITAZ_VERSION}$/d" -i $WEBSERVER/repositories.list
3350 rm $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3351 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3352 rm $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3353 done
3354 if ! [ -s "$WEBSERVER/repositories.list" ]; then
3355 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"
3356 rm $WEBSERVER/conf.php
3357 elif [ "$(readlink $WEBSERVER/conf.php)" = "$WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php" ]; then
3358 echo "${undigest:-$SLITAZ_VERSION} was the default version to use; switched to : $(sed 1!d $WEBSERVER/repositories.list)"
3359 rm $WEBSERVER/conf.php
3360 ln -s $WEBSERVER/conf-$(sed 1!d $WEBSERVER/repositories.list).php $WEBSERVER/conf.php
3361 fi
3362 else
3363 echo "Usage: tazwok webserver on/off" >&2
3364 exit 1
3365 fi
3366 ;;
3367 block)
3368 # Add a pkg name to the list of blocked packages.
3369 get_tazwok_config
3370 check_root
3371 check_for_package_on_cmdline
3372 if ! [ -f $WOK/$PACKAGE/receipt ]; then
3373 echo "Can't find $PACKAGE in wok." >&2
3374 echo ""
3375 exit 1
3376 fi
3377 echo ""
3378 if grep -qs "^$PACKAGE$" $PACKAGES_REPOSITORY/blocked; then
3379 echo "$PACKAGE is already in the blocked packages list." >&2
3380 echo ""
3381 exit 1
3382 else
3383 echo -n "Adding $PACKAGE to : $PACKAGES_REPOSITORY/blocked... "
3384 echo "$PACKAGE" >> $PACKAGES_REPOSITORY/blocked
3385 status
3386 if grep -q "^$PACKAGE$" $PACKAGES_REPOSITORY/cooklist; then
3387 echo -n "Removing $PACKAGE from : $PACKAGES_REPOSITORY/cooklist... "
3388 sed -i /"^$PACKAGE$"/d $PACKAGES_REPOSITORY/cooklist
3389 status
3390 fi
3391 fi
3392 echo "" ;;
3393 unblock)
3394 # Remove a pkg name from the list of blocked packages.
3395 get_tazwok_config
3396 check_root
3397 check_for_package_on_cmdline
3398 if ! [ -f $WOK/$PACKAGE/receipt ]; then
3399 echo "Can't find $PACKAGE in wok." >&2
3400 echo ""
3401 exit 1
3402 fi
3403 echo ""
3404 if grep -qs "^$PACKAGE$" $PACKAGES_REPOSITORY/blocked; then
3405 echo -n "Removing $PACKAGE from : $PACKAGES_REPOSITORY/blocked... "
3406 sed -i /"^$PACKAGE$"/d $PACKAGES_REPOSITORY/blocked
3407 sed -i '/^$/d' $PACKAGES_REPOSITORY/blocked
3408 status
3409 else
3410 echo "$PACKAGE is not in the blocked packages list." >&2
3411 echo ""
3412 exit 1
3413 fi
3414 echo "" ;;
3415 usage|*)
3416 # Print usage also for all unknown commands.
3418 usage
3419 ;;
3420 esac
3422 report stop 2>/dev/null
3423 exit 0