tazwok view tazwok @ rev 488

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