tazwok view tazwok @ rev 495

tazwok/check_for_incoming: update flavors from hg
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Apr 24 22:23:11 2011 +0200 (2011-04-24)
parents 621bcc0de8ca
children 70f1125c1c10
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
2059 cd /home/slitaz/flavors
2060 [ -d .hg ] && hg pull -u
2062 cd $LOCAL_REPOSITORY/packages
2063 for i in $LOCAL_REPOSITORY/flavors/*; do
2064 [ -d "$i" ] || continue
2065 tazlito pack-flavor ${i##*/}
2066 done
2068 noheader=""
2069 for i in *.flavor; do
2070 tazlito show-flavor $i --brief $noheader
2071 noheader="--noheader"
2072 done > flavors.list
2073 [ -x /usr/bin/clean-chroot ] && clean-chroot
2074 else
2075 echo "Can't create up-to-date flavors because the tazlito package is missing." >&2
2076 fi
2077 report end-step
2080 ########################################################################
2081 # TAZWOK MAIN FUNCTIONS
2082 ########################
2084 clean()
2086 cd $WOK/$PACKAGE
2087 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
2088 -e ^stuff$ || return
2090 [ "$COMMAND" = clean-wok ] || report step "Cleaning $PACKAGE"
2091 # Check for clean_wok function.
2092 if grep -q ^clean_wok $RECEIPT; then
2093 clean_wok
2094 fi
2095 # Clean should only have a receipt, stuff and optional desc.
2096 for f in `ls .`
2097 do
2098 case $f in
2099 receipt|stuff|description.txt|md5)
2100 continue ;;
2101 *)
2102 rm -rf $f ;;
2103 esac
2104 done
2105 [ "$COMMAND" != clean-wok ] && report end-step
2108 # Configure and make a package with the receipt.
2109 compile_package()
2111 check_for_package_on_cmdline
2113 # Include the receipt to get all needed variables and functions
2114 # and cd into the work directory to start the work.
2115 check_for_receipt
2116 source_receipt
2118 # Log the package name and date.
2119 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
2120 echo "package $PACKAGE (compile)" >> $LOG
2122 # Set wanted $src variable to help compiling.
2123 [ ! "$src" ] && set_src_path
2124 check_for_build_depends || return 1
2125 check_for_wanted
2126 unset target
2127 check_for_tarball && check_for_compile_rules
2130 # Cook command also include all features to manage lists which keep
2131 # track of wok/packages state.
2132 cook()
2134 cook_code=
2135 set_common_path
2136 check_for_receipt
2137 source_receipt
2139 # Define log path and start report.
2140 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
2141 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
2142 echo "$PACKAGE" > $LOCAL_REPOSITORY/log/package
2143 report step "Cooking $PACKAGE"
2144 report open-bloc
2146 clean $PACKAGE
2147 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
2149 if compile_package; then
2150 remove_src
2151 refresh_packages_from_compile
2152 gen_package
2154 # Update packages-incoming repository.
2155 store_pkgname=$PACKAGE
2156 pkg_repository=$INCOMING_REPOSITORY
2157 update_packages_db
2159 PACKAGE=$store_pkgname
2160 unset store_pkgname
2162 # Upgrade to cooked packages if it was previously installed.
2163 report step "Looking for package(s) to upgrade"
2164 for pkg in $(look_for_rwanted) $PACKAGE; do
2165 if [ -d $INSTALLED/$pkg ]; then
2166 tazpkg get-install $pkg --forced
2167 fi
2168 done
2169 report end-step
2170 else
2171 for PACKAGE in $(look_for_wanted) $PACKAGE; do
2172 set_pkg_broken
2173 done
2174 cook_code=1
2175 fi
2177 # Remove build_depends in cook mode (if in cooklist, it's done when
2178 # checking build_depends of next package and we remove only unneeded
2179 # packages to keep chroot minimal and gain some time).
2180 if [ "$COMMAND" = cook ]; then
2181 remove_build_depends $MISSING_PACKAGE
2182 [ -x /usr/bin/clean-chroot ] && clean-chroot
2183 fi
2185 # Regen the cooklist if it was planned and command is not cook.
2186 [ "$regen_cooklist" ] && unset regen_cooklist && \
2187 [ "$COMMAND" != cook ] && sort_cooklist
2189 # Some hacks to set the bloc & function status as failed if cook has
2190 # failed.
2191 report_return_code=$cook_code
2192 report close-bloc
2193 report end-sublog
2194 rm -f $LOCAL_REPOSITORY/log/package
2195 return $cook_code
2198 cook_list()
2200 if [ -s $tmp/cooklist ]; then
2201 if [ -f /usr/bin/tazchroot ]; then
2202 # Note : options -main variables- are automatically kept by
2203 # the sub-applications tazchroot/tazwok; as well as report data.
2204 cd $LOCAL_REPOSITORY
2205 [ ! -f tazchroot.conf ] && configure_tazchroot
2206 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
2207 return
2208 fi
2209 while [ -s $tmp/cooklist ]; do
2210 PACKAGE=$(sed 1!d $tmp/cooklist)
2211 cook
2212 done
2213 remove_build_depends $MISSING_PACKAGE $remove_later
2214 [ -x /usr/bin/clean-chroot ] && clean-chroot
2215 else
2216 echo "Nothing to cook."
2217 return
2218 fi
2221 configure_tazchroot()
2223 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
2224 # Tazchroot configuration file - created by tazwok.
2226 # Default chroot path.
2227 SLITAZ_DIR=$SLITAZ_DIR
2228 SLITAZ_VERSION=$SLITAZ_VERSION
2229 $( [ "$undigest" ] && echo "undigest=$undigest" )
2230 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
2231 chroot_dir=\$LOCAL_REPOSITORY/chroot
2233 # Default scripts path (these scripts are added to the
2234 # $chroot_dir/usr/bin and can be called with tazchroot script).
2235 script_dir=/usr/lib/slitaz/chroot-scripts/tazwok
2237 # List of directories to mount.
2238 list_dir="$(for dir in packages wok src packages-incoming log flavors iso clean-wok; do echo $LOCAL_REPOSITORY/$dir; done)
2239 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
2241 create_chroot()
2243 mkdir -p \$chroot_dir
2244 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
2245 tazpkg get-install \$pkg --root="\$chroot_dir"
2246 done
2248 # Store list of installed packages needed by cleanchroot.
2249 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
2251 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
2252 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
2253 -i \$chroot_dir/etc/slitaz/slitaz.conf
2254 echo \$SLITAZ_VERSION > \$chroot_dir/etc/slitaz-release
2255 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
2256 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
2257 # The build bot may run in a sandbox: link sandbox lockfile.
2258 ln -s \$LOCAL_REPOSITORY/sandbox/proc/1 \$chroot_dir/proc/1
2261 mount_chroot()
2263 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
2264 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
2265 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
2266 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
2267 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
2268 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
2269 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
2270 mount -o bind /proc \$chroot_dir/proc
2271 mount -o bind /sys \$chroot_dir/sys
2272 mount -o bind /dev/pts \$chroot_dir/dev/pts
2273 mount -o bind /dev/shm \$chroot_dir/dev/shm
2274 for dir in \$list_dir; do
2275 mkdir -p \$dir \$chroot_dir\$dir
2276 mount \$dir \$chroot_dir\$dir
2277 done
2280 umount_chroot()
2282 for dir in \$list_dir; do
2283 umount \$chroot_dir\$dir
2284 done
2285 umount \$chroot_dir/dev/shm
2286 umount \$chroot_dir/dev/pts
2287 umount \$chroot_dir/sys
2288 umount \$chroot_dir/proc
2290 EOF
2293 ########################################################################
2294 ######################### END OF NEW FUNCTIONS #########################
2295 ########################################################################
2297 # List packages providing a virtual package.
2298 whoprovide()
2300 local i;
2301 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
2302 . $i
2303 case " $PROVIDE " in
2304 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
2305 esac
2306 done
2309 ########################################################################
2310 # TAZWOK COMMANDS
2311 ########################
2313 case "$COMMAND" in
2314 stats)
2315 # Tazwok general statistics from the wok config file.
2317 get_tazwok_config
2318 echo -e "\n\033[1mTazwok configuration statistics\033[0m
2319 ================================================================================
2320 Wok directory : $WOK
2321 Packages repository : $PACKAGES_REPOSITORY
2322 Incoming repository : $INCOMING_REPOSITORY
2323 Sources repository : $SOURCES_REPOSITORY
2324 Log directory : $LOCAL_REPOSITORY/log
2325 Packages in the wok : `ls -1 $WOK | wc -l`
2326 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2327 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2328 ================================================================================\n"
2329 ;;
2330 edit)
2331 get_tazwok_config
2332 check_for_package_on_cmdline
2333 check_for_receipt
2334 $EDITOR $WOK/$PACKAGE/receipt
2335 ;;
2336 build-depends)
2337 # List dependencies to rebuild wok, or only a package.
2338 get_tazwok_config
2339 report(){ : ; }
2340 if [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
2341 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
2342 --look_for=dep --with_dev --with_args
2343 else
2344 check_for_package_on_cmdline
2345 scan $PACKAGE --look_for=bdep --with_dev
2346 fi
2347 ;;
2348 gen-cooklist)
2349 check_root
2350 get_options_list="pkg"
2351 get_tazwok_config
2352 report(){ : ; }
2353 if ! [ "$pkg" ]; then
2354 if [ ! "$LIST" ] || [ "$LIST" = toolchain ]; then
2355 pkg="$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA"
2356 else
2357 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2358 fi
2359 fi
2360 gen_cook_list
2361 ;;
2362 check-depends)
2363 # Check package depends /!\.
2364 get_tazwok_config
2365 echo ""
2366 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
2367 ================================================================================"
2368 TMPDIR=/tmp/tazwok$$
2369 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
2371 # Build ALL_DEPENDS variable.
2372 scan_dep()
2374 local i
2375 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
2376 for i in $DEPENDS $SUGGESTED ; do
2377 case " $ALL_DEPENDS " in
2378 *\ $i\ *) continue;;
2379 esac
2380 [ -d $WOK/$i ] || {
2381 ALL_DEPENDS="$ALL_DEPENDS$i "
2382 continue
2384 DEPENDS=""
2385 SUGGESTED=""
2386 . $WOK/$i/receipt
2387 scan_dep
2388 done
2391 # Check for ELF file.
2392 is_elf()
2394 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ]
2397 # Print shared library dependencies.
2398 ldd()
2400 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2403 mkdir $TMPDIR
2404 cd $TMPDIR
2405 for i in $LOCALSTATE/files.list.lzma \
2406 $LOCALSTATE/undigest/*/files.list.lzma ; do
2407 [ -f $i ] && lzma d $i -so >> files.list
2408 done
2409 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2410 tazpkg extract $pkg > /dev/null 2>&1
2411 . */receipt
2412 ALL_DEPENDS="$DEFAULT_DEPENDS "
2413 scan_dep
2414 find */fs -type f | while read file ; do
2415 is_elf $file || continue
2416 case "$file" in
2417 *.o|*.ko|*.ko.gz) continue;;
2418 esac
2419 ldd $file | while read lib rem; do
2420 case "$lib" in
2421 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2422 continue;;
2423 esac
2424 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2425 case " $ALL_DEPENDS " in
2426 *\ $dep\ *) continue 2;;
2427 esac
2428 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2429 case " $ALL_DEPENDS " in
2430 *\ $vdep\ *) continue 3;;
2431 esac
2432 done
2433 done
2434 [ -n "$dep" ] || dep="UNKNOWN"
2435 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2436 done
2437 done
2438 rm -rf */
2439 done
2440 cd /tmp
2441 rm -rf $TMPDIR
2442 ;;
2443 check)
2444 # Check wok consistency.
2445 get_tazwok_config
2446 echo ""
2447 echo -e "\033[1mWok and packages checking\033[0m
2448 ================================================================================"
2449 cd $WOK
2450 for pkg in $(ls)
2451 do
2452 [ -f $pkg/receipt ] || continue
2453 RECEIPT= $pkg/receipt
2454 source_receipt
2455 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2456 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2457 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2458 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2459 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2460 if [ -n "$WANTED" ]; then
2461 if [ ! -f $WANTED/receipt ]; then
2462 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2463 else
2464 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2465 if [ "$VERSION" = "$WANTED" ]; then
2466 # BASEVERSION is computed in receipt
2467 fgrep -q '_pkg=' $pkg/receipt &&
2468 BASEVERSION=$VERSION
2469 fi
2470 if [ "$VERSION" != "$BASEVERSION" ]; then
2471 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2472 fi
2473 fi
2474 fi
2476 if [ -n "$CATEGORY" ]; then
2477 case " $(echo $CATEGORIES) " in
2478 *\ $CATEGORY\ *);;
2479 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2480 esac
2481 else
2482 echo"Package $PACKAGE has no CATEGORY" >&2
2483 fi
2484 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2485 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2486 case "$WGET_URL" in
2487 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2488 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2489 '') ;;
2490 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2491 esac
2492 case "$WEB_SITE" in
2493 ftp*|http*);;
2494 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2495 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2496 esac
2497 case "$MAINTAINER" in
2498 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2499 esac
2500 case "$MAINTAINER" in
2501 *@*);;
2502 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2503 esac
2504 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2505 for i in $DEPENDS; do
2506 [ -d $i ] && continue
2507 [ -n "$(whoprovide $i)" ] && continue
2508 echo -e "$MSG $i"
2509 MSG=""
2510 done
2511 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2512 for i in $BUILD_DEPENDS; do
2513 [ -d $i ] && continue
2514 [ -n "$(whoprovide $i)" ] && continue
2515 echo -e "$MSG $i"
2516 MSG=""
2517 done
2518 MSG="Dependency loop between $PACKAGE and :\n"
2519 ALL_DEPS=""
2520 check_for_deps_loop $PACKAGE $DEPENDS
2521 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2522 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2523 echo "$pkg should be rebuilt after $i installation"
2524 done
2525 done
2526 ;;
2527 list)
2528 # List packages in wok directory. User can specify a category.
2530 get_tazwok_config
2531 if [ "$2" = "category" ]; then
2532 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2533 exit 0
2534 fi
2535 # Check for an asked category.
2536 if [ -n "$2" ]; then
2537 ASKED_CATEGORY=$2
2538 echo ""
2539 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2540 echo "================================================================================"
2541 for pkg in $WOK/*
2542 do
2543 [ ! -f $pkg/receipt ] && continue
2544 . $pkg/receipt
2545 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2546 echo -n "$PACKAGE"
2547 echo -e "\033[28G $VERSION"
2548 packages=$(($packages+1))
2549 fi
2550 done
2551 echo "================================================================================"
2552 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
2553 else
2554 # By default list all packages and version.
2555 echo ""
2556 echo -e "\033[1mList of packages in the wok\033[0m"
2557 echo "================================================================================"
2558 for pkg in $WOK/*
2559 do
2560 [ ! -f $pkg/receipt ] && continue
2561 . $pkg/receipt
2562 echo -n "$PACKAGE"
2563 echo -en "\033[28G $VERSION"
2564 echo -e "\033[42G $CATEGORY"
2565 packages=$(($packages+1))
2566 done
2567 echo "================================================================================"
2568 echo -e "$packages packages available in the wok.\n"
2569 fi
2570 ;;
2571 info)
2572 # Information about a package.
2574 get_tazwok_config
2575 check_for_package_on_cmdline
2576 check_for_receipt
2577 . $WOK/$PACKAGE/receipt
2578 echo ""
2579 echo -e "\033[1mTazwok package information\033[0m
2580 ================================================================================
2581 Package : $PACKAGE
2582 Version : $VERSION
2583 Category : $CATEGORY
2584 Short desc : $SHORT_DESC
2585 Maintainer : $MAINTAINER"
2586 if [ ! "$WEB_SITE" = "" ]; then
2587 echo "Web site : $WEB_SITE"
2588 fi
2589 if [ ! "$DEPENDS" = "" ]; then
2590 echo "Depends : $DEPENDS"
2591 fi
2592 if [ ! "$WANTED" = "" ]; then
2593 echo "Wanted src : $WANTED"
2594 fi
2595 echo "================================================================================"
2596 echo ""
2597 ;;
2598 check-log)
2599 # We just cat the file log to view process info.
2601 get_tazwok_config
2602 if [ ! -f "$LOG" ]; then
2603 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2604 exit 1
2605 else
2606 echo ""
2607 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2608 echo "================================================================================"
2609 cat $LOG
2610 echo "================================================================================"
2611 echo ""
2612 if [ -s "$WOK/$PACKAGE/warning.txt" ]; then
2613 echo -e "\033[1mCook warning(s) for :\033[0m $PACKAGE"
2614 echo "================================================================================"
2615 cat "$WOK/$PACKAGE/warning.txt"
2616 echo "================================================================================"
2617 echo ""
2618 fi
2619 fi
2620 ;;
2621 search)
2622 # Search for a package by pattern or name.
2624 get_tazwok_config
2625 if [ -z "$2" ]; then
2626 echo -e "\nPlease specify a pattern or a package name to search." >&2
2627 echo -e "Example : 'tazwok search gcc'.\n" >&2
2628 exit 1
2629 fi
2630 echo ""
2631 echo -e "\033[1mSearch result for :\033[0m $2"
2632 echo "================================================================================"
2633 list=`ls -1 $WOK | fgrep $2`
2634 for pkg in $list
2635 do
2636 . $WOK/$pkg/receipt
2637 echo -n "$PACKAGE "
2638 echo -en "\033[24G $VERSION"
2639 echo -e "\033[42G $CATEGORY"
2640 packages=$(($PACKAGEs+1))
2641 done
2642 echo "================================================================================"
2643 echo "$packages packages found for : $2"
2644 echo ""
2645 ;;
2646 compile)
2647 # Configure and make a package with the receipt.
2649 get_tazwok_config
2650 source_lib report
2651 report start
2652 compile_package
2653 ;;
2654 genpkg)
2655 # Generate a package.
2657 get_tazwok_config
2658 source_lib report
2659 report start
2660 gen_package
2661 ;;
2662 cook)
2663 # Compile and generate a package. Just execute tazwok with
2664 # the good commands.
2666 check_root
2667 get_tazwok_config
2668 source_lib report
2669 report start
2670 db_md5=$(md5sum $dep_db $wan_db)
2671 update_wan_db
2672 check_for_commit
2673 sort -o $dep_db $dep_db
2674 sort -o $wan_db $wan_db
2675 if [ "$db_md5" != "$(md5sum $dep_db $wan_db)" ]; then
2676 grep -q "^#" $PACKAGES_REPOSITORY/cookorder.txt ||
2677 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
2678 fi
2679 cook
2680 ;;
2681 sort-cooklist)
2682 if [ ! -f "$LIST" ]; then
2683 echo "Usage : tazwok sort-cooklist cooklist" >&2
2684 exit 1
2685 fi
2686 check_root
2687 get_tazwok_config
2688 report(){ : ; }
2689 # When using sort-cooklist, the script should behave as for gen-cooklist
2690 # The only difference between these two is where the output is sent.
2691 COMMAND=gen-cooklist
2692 cooklist=$LIST
2693 gen_cook_list
2694 cp -af $tmp/cooklist $cooklist
2695 ;;
2696 cook-list)
2697 # Cook all packages listed in a file or in default cooklist.
2698 check_root
2699 get_options_list="pkg forced"
2700 get_tazwok_config
2701 source_lib report
2702 report start
2703 if ! [ "$pkg" ]; then
2704 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2705 fi
2706 gen_cook_list
2707 cook_list
2708 ;;
2709 clean)
2710 # Clean up a package work directory + those which want it.
2712 get_tazwok_config
2713 check_for_package_on_cmdline
2714 check_for_receipt
2715 source_lib report
2716 report start
2717 . $RECEIPT
2718 clean
2719 ;;
2720 gen-clean-wok)
2721 # Generate a clean wok from the current wok by copying all receipts
2722 # and stuff directory.
2724 get_tazwok_config
2725 source_lib report
2726 report start
2727 if [ -z "$ARG" ]; then
2728 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2729 exit 1
2730 else
2731 dest=$ARG
2732 mkdir -p $dest
2733 fi
2734 report step "Creating clean wok in : $dest"
2735 for pkg in `ls -1 $WOK`
2736 do
2737 mkdir -p $dest/$pkg
2738 cp -a $WOK/$pkg/receipt $dest/$pkg
2739 [ -f $WOK/$pkg/description.txt ] && \
2740 cp -a $WOK/$pkg/description.txt $dest/$pkg
2741 if [ -d "$WOK/$pkg/stuff" ]; then
2742 cp -a $WOK/$pkg/stuff $dest/$pkg
2743 fi
2744 done
2745 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2746 report end-step
2747 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2748 echo ""
2749 ;;
2750 clean-wok)
2751 # Clean all packages in the work directory.
2753 get_tazwok_config
2754 source_lib report
2755 report start
2756 report step "Cleaning wok"
2757 for PACKAGE in `ls -1 $WOK`
2758 do
2759 set_common_path
2760 source_receipt
2761 clean
2762 done
2763 echo "`ls -1 $WOK | wc -l` packages cleaned."
2764 ;;
2765 clean-src)
2766 # Remove tarball unrelated to wok receipts from src repo.
2767 check_root
2768 get_options_list="forced"
2769 get_tazwok_config
2770 cd $SOURCES_REPOSITORY
2771 echo -n "Checking $SOURCES_REPOSITORY..."
2772 for TARBALL in *; do
2773 [ "$TARBALL" = sources.list ] && continue
2774 grep -q $'\t'$TARBALL$ $SOURCES_REPOSITORY/sources.list || \
2775 echo $TARBALL >> $tmp/obsolete
2776 done
2777 status
2778 if ! [ -f $tmp/obsolete ]; then
2779 echo "No sources need to be removed."
2780 exit 1
2781 fi
2782 echo ""
2783 echo -e "\033[1mObsolete/unrelated-to-wok sources :\033[0m"
2784 horizontal_line
2785 cat $tmp/obsolete
2786 horizontal_line
2787 echo "$(wc -l $tmp/obsolete | cut -f1 -d' ') tarballs to remove."
2788 echo ""
2789 echo -n "Please confirm before removing (type uppercase YES): "
2790 read answer
2791 if [ "$answer" = YES ]; then
2792 echo -n "Removing old sources..."
2793 cat $tmp/obsolete | while read i; do
2794 rm -f $SOURCES_REPOSITORY/$i
2795 done
2796 status
2797 fi
2798 ;;
2799 gen-list)
2800 get_tazwok_config
2801 if [ "$2" ]; then
2802 if [ -d "$2" ]; then
2803 pkg_repository=$2
2804 else
2805 echo -e "\nUnable to find directory : $2\n" >&2
2806 exit 1
2807 fi
2808 fi
2810 source_lib report
2811 report start
2812 if [ "$pkg_repository" ]; then
2813 gen_packages_db
2814 else
2815 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
2816 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
2817 fi
2818 ;;
2819 check-list)
2820 # The directory to move into by default is the repository,
2821 # if $2 is not empty cd into $2.
2823 get_tazwok_config
2824 if [ "$2" ]; then
2825 if [ -d "$2" ]; then
2826 pkg_repository=$2
2827 else
2828 echo -e "\nUnable to find directory : $2\n" >&2
2829 exit 1
2830 fi
2831 fi
2833 source_lib report
2834 report start
2835 if [ "$pkg_repository" ]; then
2836 update_packages_db
2837 else
2838 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2839 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
2840 fi
2841 ;;
2842 new-tree)
2843 # Just create a few directories and generate an empty receipt to prepare
2844 # the creation of a new package.
2846 get_tazwok_config
2847 check_for_package_on_cmdline
2848 clean_wok=$LOCAL_REPOSITORY/clean-wok
2849 if [ -d $clean_wok/$PACKAGE ]; then
2850 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2851 exit 1
2852 fi
2853 echo "Creating : $clean_wok/$PACKAGE"
2854 mkdir $clean_wok/$PACKAGE
2855 cd $clean_wok/$PACKAGE
2856 echo -n "Preparing the receipt..."
2858 # Default receipt begin.
2860 echo "# SliTaz package receipt." > receipt
2861 echo "" >> receipt
2862 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2863 # Finish the empty receipt.
2864 cat >> receipt << "EOF"
2865 VERSION=""
2866 CATEGORY=""
2867 SHORT_DESC=""
2868 MAINTAINER=""
2869 DEPENDS=""
2870 TARBALL="$PACKAGE-$VERSION.tar.gz"
2871 WEB_SITE=""
2872 WGET_URL=""
2874 # Rules to configure and make the package.
2875 compile_rules()
2877 cd $src
2878 ./configure && make && make install
2881 # Rules to gen a SliTaz package suitable for Tazpkg.
2882 genpkg_rules()
2884 mkdir -p $fs/usr
2885 cp -a $_pkg/usr/bin $fs/usr
2888 EOF
2890 # Default receipt end.
2892 status
2893 # Interactive mode, asking and seding.
2894 if [ "$3" = "--interactive" ]; then
2895 echo "Entering interactive mode..."
2896 echo "================================================================================"
2897 echo "Package : $PACKAGE"
2898 # Version.
2899 echo -n "Version : " ; read anser
2900 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2901 # Category.
2902 echo -n "Category : " ; read anser
2903 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2904 # Short description.
2905 echo -n "Short desc : " ; read anser
2906 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2907 # Maintainer.
2908 echo -n "Maintainer : " ; read anser
2909 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2910 # Web site.
2911 echo -n "Web site : " ; read anser
2912 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2913 echo ""
2914 # Wget URL.
2915 echo "Wget URL to download source tarball."
2916 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2917 echo -n "Wget url : " ; read anser
2918 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2919 # Ask for a stuff dir.
2920 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2921 if [ "$anser" = "y" ]; then
2922 echo -n "Creating the stuff directory..."
2923 mkdir stuff && status
2924 fi
2925 # Ask for a description file.
2926 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2927 if [ "$anser" = "y" ]; then
2928 echo -n "Creating the description.txt file..."
2929 echo "" > description.txt && status
2930 fi
2931 echo "================================================================================"
2932 echo ""
2933 fi
2934 ;;
2935 remove)
2936 # Remove a package from the wok.
2938 get_tazwok_config
2939 check_for_package_on_cmdline
2940 echo ""
2941 echo -n "Please confirm deletion (y/N) : "; read anser
2942 if [ "$anser" = "y" ]; then
2943 echo -n "Removing $PACKAGE..."
2944 rm -rf $WOK/$PACKAGE && status
2945 echo ""
2946 fi
2947 ;;
2948 update-wok)
2949 # Pull and update a Hg wok.
2950 get_options_list="local"
2951 get_tazwok_config
2952 source_lib report
2953 report start
2954 clean_wok=$LOCAL_REPOSITORY/clean-wok
2955 cd $clean_wok
2956 if ! [ "$local" ]; then
2957 if [ "$WOK_UPDATE_METHOD" = hg ]; then
2958 if ! [ -f "$INSTALLED/mercurial/receipt" ]; then
2960 # Auto-install only if we are in a cook chroot.
2961 if [ -x /usr/bin/clean-chroot ]; then
2962 tazpkg get-install mercurial
2963 else
2964 echo "" >&2
2965 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
2966 echo "">&2
2967 exit 1
2968 fi
2969 fi
2971 report step "Getting wok changes using hg"
2972 if [ -d .hg ]; then
2973 hg pull -u || exit 1
2974 else
2975 hg clone $HG_WOK . || exit 1
2976 fi
2977 report end-step
2978 [ -x /usr/bin/clean-chroot ] && clean-chroot
2979 else
2980 report step "Getting wok changes using tarball"
2981 { mkdir .tmp && cd .tmp
2982 wget "$TARBALL_WOK" &&
2983 case $TARBALL_WOK in
2984 *bz2) tar xjf *.bz2 -C wok; rm *.bz2;;
2985 *lzma) unlzma -c *.lzma | tar xf - -C wok; rm *.lzma ;;
2986 *gz) tar xzf *.gz -C wok; rm*.gz ;;
2987 esac &&
2988 rm -r $(ls -d $clean_wok/*) &&
2989 cp -a wok/* $clean_wok &&
2990 cd .. &&
2991 rm -r .tmp
2992 } || { echo "That's not cool: it fails!" >&2
2993 report end-step
2994 exit 1; }
2995 report end-step
2996 fi
2997 fi
2998 report step "Appending changes to wok"
3000 # Handle removed files/dir.
3001 cd $WOK
3002 for dir in *; do
3003 [ -d "$clean_wok/$dir" ] || rm -rf $dir
3004 done
3005 for file in */receipt */description.txt; do
3006 [ -f "$clean_wok/$file" ] || rm -rf $file
3007 done
3008 for i in $(find */stuff 2>/dev/null); do
3009 [ -e "$clean_wok/$i" ] || rm -rf $i
3010 done
3012 cp -a $clean_wok/* $WOK
3013 report end-step
3014 ;;
3015 maintainers)
3016 get_tazwok_config
3017 echo ""
3018 echo "List of maintainers for: $WOK"
3019 echo "================================================================================"
3020 touch /tmp/slitaz-maintainers
3021 for pkg in $WOK/*
3022 do
3023 . $pkg/receipt
3024 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
3025 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
3026 echo "$MAINTAINER"
3027 fi
3028 done
3029 echo "================================================================================"
3030 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
3031 echo ""
3032 # Remove tmp files
3033 rm -f /tmp/slitaz-maintainers
3034 ;;
3035 maintained-by)
3036 # Search for packages maintained by a contributor.
3037 get_tazwok_config
3038 if [ ! -n "$2" ]; then
3039 echo "Specify a name or email of a maintainer." >&2
3040 exit 1
3041 fi
3042 echo "Maintainer packages"
3043 echo "================================================================================"
3044 for pkg in $WOK/*
3045 do
3046 . $pkg/receipt
3047 if echo "$MAINTAINER" | fgrep -q "$2"; then
3048 echo "$PACKAGE"
3049 packages=$(($PACKAGEs+1))
3050 fi
3051 done
3052 echo "================================================================================"
3053 echo "Packages maintained by $2: $PACKAGEs"
3054 echo ""
3055 ;;
3056 tags)
3057 get_tazwok_config
3058 echo -e "\n\033[1mTags list :\033[0m"
3059 horizontal_line
3060 cd $WOK
3061 for i in */receipt; do
3062 unset TAGS
3063 source $i
3064 for t in $TAGS; do
3065 grep -q ^$t$ $tmp/tags && continue
3066 echo $t | tee -a $tmp/tags
3067 done
3068 done
3069 horizontal_line
3070 echo "$(wc -l $tmp/tags | cut -f1 -d ' ') tags listed."
3071 ;;
3072 check-src)
3073 # Verify if upstream package is still available.
3075 get_tazwok_config
3076 check_for_package_on_cmdline
3077 check_for_receipt
3078 source_receipt
3079 check_src()
3081 for url in $@; do
3082 busybox wget -s $url 2>/dev/null && break
3083 done
3085 if [ "$WGET_URL" ];then
3086 echo -n "$PACKAGE : "
3087 check_src $WGET_URL
3088 status
3089 else
3090 echo "No tarball to check for $PACKAGE"
3091 fi
3092 ;;
3093 gen-src)
3094 get_tazwok_config
3095 if [ "$2" ]; then
3096 if [ -d "$2" ]; then
3097 src_repository=$2
3098 else
3099 echo -e "\nUnable to find directory : $2\n" >&2
3100 exit 1
3101 fi
3102 fi
3103 echo -n "Rebuilding sources.list file"
3104 [ $src_repository ] || src_repository="$SOURCES_REPOSITORY"
3105 gen_sources_list $src_repository
3106 status
3107 ;;
3108 get-src)
3109 check_root
3110 get_options_list="target nounpack"
3111 get_tazwok_config
3112 check_for_package_on_cmdline
3113 check_for_receipt
3114 source_receipt
3115 if [ "$WGET_URL" ];then
3116 source_lib report
3117 report start
3118 check_for_tarball
3119 else
3120 echo "No tarball to download for $PACKAGE"
3121 fi
3122 ;;
3123 check-commit)
3124 check_root
3125 get_options_list="missing forced"
3126 get_tazwok_config
3127 source_lib report
3128 report start
3129 if [ "$forced" ]; then
3130 rm -f $WOK/*/md5
3131 unset forced
3132 fi
3133 if [ "$missing" ]; then
3134 pkg=$(ls -1 $WOK)
3135 else
3136 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3137 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3138 } | sort -u)"
3139 fi
3140 cooklist=$PACKAGES_REPOSITORY/cooklist
3141 gen_cook_list
3142 ;;
3143 cook-commit)
3144 check_root
3145 get_options_list="missing forced"
3146 get_tazwok_config
3147 source_lib report
3148 report start
3149 if [ "$forced" ]; then
3150 rm -f $WOK/*/md5
3151 unset forced
3152 fi
3153 if [ "$missing" ]; then
3154 pkg=$(ls -1 $WOK)
3155 else
3156 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3157 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3158 } | sort -u)"
3159 fi
3160 cooklist=$PACKAGES_REPOSITORY/cooklist
3161 gen_cook_list
3162 cook_list
3163 ;;
3164 cook-all)
3165 check_root
3166 get_options_list="forced missing"
3167 get_tazwok_config
3168 source_lib report
3169 report start
3170 if [ "$missing" ]; then
3171 pkg=$(ls -1 $WOK)
3172 else
3173 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
3174 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
3175 } | sort -u)"
3176 fi
3177 cooklist=$PACKAGES_REPOSITORY/cooklist
3178 gen_cook_list
3179 cook_list
3180 ;;
3181 gen-wok-db)
3182 check_root
3183 get_tazwok_config
3184 source_lib report
3185 report start
3186 gen_wok_db
3187 ;;
3188 report)
3189 get_tazwok_config
3190 cd $PACKAGES_REPOSITORY
3191 if [ "$2" ]; then
3192 case $2 in
3193 commit|cooklist|incoming|broken|blocked)
3194 show="$2"
3195 ;;
3196 *)
3197 echo "usage : tazwok report [commit|cooklist|incoming|broken|blocked]" >&2
3198 exit 1
3199 ;;
3200 esac
3201 else
3202 show="commit cooklist incoming broken blocked"
3203 fi
3204 for i in $show; do
3205 if [ -s $i ]; then
3206 echo ""
3207 echo -e "\033[1m$i\033[0m"
3208 echo "================================================================================"
3209 cat $i
3210 echo "================================================================================"
3211 echo ""
3212 fi
3213 done
3214 ;;
3215 check-incoming)
3216 check_root
3217 get_options_list="forced"
3218 get_tazwok_config
3219 source_lib report
3220 report start
3221 [ -f $LOCAL_RESOSITORY/incoming ] && rm [ -f $LOCAL_REPOSITORY/incoming ]
3222 report step "Checking $INCOMING_REPOSITORY"
3223 report open-bloc
3224 [ -f $LOCAL_REPOSITORY/log/incoming.html ] && rm $LOCAL_REPOSITORY/log/incoming.html
3225 report sublog $LOCAL_REPOSITORY/log/incoming.html
3226 echo "incoming" > $LOCAL_REPOSITORY/log/package
3227 check_for_incoming
3228 report end-sublog
3229 report close-bloc
3230 ;;
3231 configure-chroot)
3232 check_root
3233 get_tazwok_config
3234 if [ -f /usr/bin/tazchroot ]; then
3235 cd $LOCAL_REPOSITORY
3236 configure_tazchroot
3237 else
3238 echo "The package tazchroot needs to be installed" >&2
3239 exit 1
3240 fi
3241 ;;
3242 chroot)
3243 check_root
3244 get_tazwok_config
3245 # Merge this and the other chroot function ?.
3246 if [ -f /usr/bin/tazchroot ]; then
3247 cd $LOCAL_REPOSITORY
3248 [ ! -f tazchroot.conf ] && configure_tazchroot
3249 tazchroot
3250 else
3251 echo "The package tazchroot needs to be installed" >&2
3252 exit 1
3253 fi
3254 ;;
3255 cook-toolchain)
3256 check_root
3257 get_tazwok_config
3258 echo -n "" > $PACKAGES_REPOSITORY/broken
3259 if [ -f /usr/bin/tazchroot ]; then
3260 cd $LOCAL_REPOSITORY
3261 [ ! -f tazchroot.conf ] && configure_tazchroot
3262 tazchroot cook-toolchain
3263 # Buggy : chroot can be elsewhere.
3264 rm -r $LOCAL_REPOSITORY/chroot
3265 # /!\ to be written :
3266 # next rm chroot and plan cook-all by pushing all packages
3267 # in cooklist.
3268 else
3269 echo "The package tazchroot needs to be installed" >&2
3270 exit 1
3271 fi
3272 ;;
3273 webserver)
3274 check_root
3275 get_tazwok_config
3276 if [ "$ARG" = on ]; then
3277 if [ "$WEBSERVER" ] && [ -f "$WEBSERVER/repositories.list" ] && \
3278 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3279 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3280 exit 1
3281 fi
3282 if ! [ -f $LOCAL_REPOSITORY/tazchroot.conf ]; then
3283 tazwok configure-chroot ${undigest:+--undigest=$undigest} --SLITAZ_VERSION=$SLITAZ_VERSION --SLITAZ_DIR=$SLITAZ_DIR
3284 fi
3285 for pkg in php lighttpd; do
3286 [ -d $INSTALLED/$pkg ] || missing="$missing $pkg"
3287 done
3288 if [ "$missing" ]; then
3289 echo "You need to install these packages to start webserver: $missing." >&2
3290 exit 1
3291 fi
3292 if [ ! -f "$LOCAL_REPOSITORY/tazwok.conf" ]; then
3293 echo "Copying /etc/slitaz/tazwok.conf to $LOCAL_REPOSITORY/tazwok.conf: webserver is configured repository-by-repository."
3294 cp /etc/slitaz/tazwok.conf $LOCAL_REPOSITORY
3295 fi
3296 if ! [ "$WEBSERVER" ]; then
3297 echo -n "Where to store php pages (default: /var/www/vhosts/bb)? "
3298 read WEBSERVER
3299 [ "$WEBSERVER" ] || WEBSERVER="/var/www/vhosts/bb"
3300 fi
3301 if [ -f "$WEBSERVER/repositories.list" ] && \
3302 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
3303 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
3304 exit 1
3305 fi
3306 mkdir -p $WEBSERVER
3307 echo "${undigest:-$SLITAZ_VERSION}" >> $WEBSERVER/repositories.list
3308 for file in index.php log.php download.php; do
3309 [ -f "$WEBSERVER/$file" ] || ln -s /usr/share/slitaz/web-bb/$file $WEBSERVER
3310 done
3311 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3312 ln -s $dir $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3313 done
3314 source $LOCAL_REPOSITORY/tazchroot.conf
3315 echo "<?php
3317 // Web interface configuration
3319 \$version=\"${undigest:-$SLITAZ_VERSION}\";
3320 \$chroot=\"$chroot_dir\";
3321 \$lockfile=\"\$chroot/proc/1/status\";
3322 \$db_dir=\"$PACKAGES_REPOSITORY\";
3323 \$log_dir=\"$LOCAL_REPOSITORY/log\";
3324 \$packages=\"$PACKAGES_REPOSITORY\";
3325 \$incoming=\"$INCOMING_REPOSITORY\";
3326 \$wok=\"$WOK\";
3328 ?>" > $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3329 [ -L "$WEBSERVER/web" ] || ln -s /usr/share/slitaz/web $WEBSERVER
3330 echo "WEBSERVER=\"$WEBSERVER\"" >> $LOCAL_REPOSITORY/tazwok.conf
3331 if [ -L "$WEBSERVER/conf.php" ]; then
3332 echo "Do you want to make ${undigest:-$SLITAZ_VERSION} the default page (y/N) ? "
3333 read answer
3334 if [ "$answer" = y ]; then
3335 rm $WEBSERVER/conf.php
3336 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3337 fi
3338 else
3339 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
3340 fi
3341 elif [ "$ARG" = off ]; then
3342 if ! [ "$WEBSERVER" ]; then
3343 echo "No webserver running for ${undigest:-$SLITAZ_VERSION}" >&2
3344 exit 1
3345 fi
3346 sed '/^WEBSERVER/d' -i $LOCAL_REPOSITORY/tazwok.conf
3347 sed "/^${undigest:-$SLITAZ_VERSION}$/d" -i $WEBSERVER/repositories.list
3348 rm $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
3349 for dir in $PACKAGES_REPOSITORY $INCOMING_REPOSITORY; do
3350 rm $WEBSERVER/${undigest:-$SLITAZ_VERSION}-${dir##*/}
3351 done
3352 if ! [ -s "$WEBSERVER/repositories.list" ]; then
3353 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"
3354 rm $WEBSERVER/conf.php
3355 elif [ "$(readlink $WEBSERVER/conf.php)" = "$WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php" ]; then
3356 echo "${undigest:-$SLITAZ_VERSION} was the default version to use; switched to : $(sed 1!d $WEBSERVER/repositories.list)"
3357 rm $WEBSERVER/conf.php
3358 ln -s $WEBSERVER/conf-$(sed 1!d $WEBSERVER/repositories.list).php $WEBSERVER/conf.php
3359 fi
3360 else
3361 echo "Usage: tazwok webserver on/off" >&2
3362 exit 1
3363 fi
3364 ;;
3365 block)
3366 # Add a pkg name to the list of blocked packages.
3367 get_tazwok_config
3368 check_root
3369 check_for_package_on_cmdline
3370 if ! [ -f $WOK/$PACKAGE/receipt ]; then
3371 echo "Can't find $PACKAGE in wok." >&2
3372 echo ""
3373 exit 1
3374 fi
3375 echo ""
3376 if grep -qs "^$PACKAGE$" $PACKAGES_REPOSITORY/blocked; then
3377 echo "$PACKAGE is already in the blocked packages list." >&2
3378 echo ""
3379 exit 1
3380 else
3381 echo -n "Adding $PACKAGE to : $PACKAGES_REPOSITORY/blocked... "
3382 echo "$PACKAGE" >> $PACKAGES_REPOSITORY/blocked
3383 status
3384 if grep -q "^$PACKAGE$" $PACKAGES_REPOSITORY/cooklist; then
3385 echo -n "Removing $PACKAGE from : $PACKAGES_REPOSITORY/cooklist... "
3386 sed -i /"^$PACKAGE$"/d $PACKAGES_REPOSITORY/cooklist
3387 status
3388 fi
3389 fi
3390 echo "" ;;
3391 unblock)
3392 # Remove a pkg name from the list of blocked packages.
3393 get_tazwok_config
3394 check_root
3395 check_for_package_on_cmdline
3396 if ! [ -f $WOK/$PACKAGE/receipt ]; then
3397 echo "Can't find $PACKAGE in wok." >&2
3398 echo ""
3399 exit 1
3400 fi
3401 echo ""
3402 if grep -qs "^$PACKAGE$" $PACKAGES_REPOSITORY/blocked; then
3403 echo -n "Removing $PACKAGE from : $PACKAGES_REPOSITORY/blocked... "
3404 sed -i /"^$PACKAGE$"/d $PACKAGES_REPOSITORY/blocked
3405 sed -i '/^$/d' $PACKAGES_REPOSITORY/blocked
3406 status
3407 else
3408 echo "$PACKAGE is not in the blocked packages list." >&2
3409 echo ""
3410 exit 1
3411 fi
3412 echo "" ;;
3413 usage|*)
3414 # Print usage also for all unknown commands.
3416 usage
3417 ;;
3418 esac
3420 report stop 2>/dev/null
3421 exit 0