tazwok view tazwok @ rev 499

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