tazwok view tazwok @ rev 362

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