tazwok view tazwok @ rev 492

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