tazwok view tazwok @ rev 496

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