tazwok view tazwok @ rev 505

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