tazwok view tazwok @ rev 240

Update usage; automatically fill wok_db when looking for depends
author Antoine Bodin <gokhlayeh@slitaz.org>
date Thu Feb 10 23:13:52 2011 +0100 (2011-02-10)
parents f631650e0925
children c49dfdbcab2b
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=3.9.0
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 check Check every receipt for common errors.
37 check-log Check the process log file of a package.
38 check-depends* Check every receipt for DEPENDS - doesn't scan ELF files.
39 check-src Check upstream tarball for package in the wok.
40 search Search for a package in the wok by pattern or name.
41 compile Configure and build a package using the receipt rules.
42 genpkg Generate a suitable package for Tazpkg with the rules.
43 cook Compile and generate a package directly.
44 cook-list Cook all packages specified in the list by order.
45 cook-commit Cook all modified receipts.
46 cook-all Cook all packages excepted toolchain.
47 cook-toolchain Cook the toolchain packages.
48 gen-cooklist Generate a sorted cooklist using packages or list.
49 sort-cooklist Sort the cooklist given in argument.
50 get-src Download the tarball of the package given in argument.
51 clean Clean all generated files in the package tree.
52 new-tree Prepare a new package tree and receipt (--interactive).
53 gen-list (Re-)Generate a packages list for a repository.
54 check-list Update packages lists for a repository.
55 gen-wok-db (Re-)Generate wok lists with depends and wanted datas.
56 gen-clean-wok Generate a clean wok in a dir.
57 clean-wok Clean entirely the wok.
58 remove Remove a package from the wok.
59 webserver Enable/disable webserver on localhost.
60 hgup Pull and update a wok under Hg.
61 maintainers List all maintainers in the wok.
62 maintained-by List packages maintained by a contributor.\n
64 You can use `basename $0` command --help to list avaible options.
65 \033[1mImportant - *: \033[0m Commands which need a rewrite."
66 }
68 # This function display an error message without returning any error code.
69 # It also log the message in source package's warnings.txt; this file can be
70 # used on an eventual package page on website to display cooking warnings.
71 tazwok_warning()
72 {
73 echo -e "tazwok: $1" >&2
74 echo -e "$1" >> $WOK/${WANTED:-$PACKAGE}/warning.txt
75 return
76 }
78 ########################################################################
79 # TAZWOK VARIABLES & INITIAL CONFIGURATION
80 ########################
82 get_tazwok_config()
83 {
84 # Get configuration file.
85 get_config
87 # Define & get options.
88 get_options_list="$get_options_list SLITAZ_DIR SLITAZ_VERSION undigest"
89 get_options
91 if [ "$undigest" ]; then
92 LOCAL_REPOSITORY=$SLITAZ_DIR/$undigest
93 else
94 LOCAL_REPOSITORY=$SLITAZ_DIR/$SLITAZ_VERSION
95 fi
97 if ! [ "$save_dir" ]; then
98 if [ -f $LOCAL_REPOSITORY/tazwok.conf ] || [ -f $LOCAL_REPOSITORY/slitaz.conf ]; then
99 save_dir=$LOCAL_REPOSITORY
100 [ -f $LOCAL_REPOSITORY/slitaz.conf ] && source $LOCAL_REPOSITORY/slitaz.conf
101 cd $save_dir
102 get_tazwok_config
103 unset save_dir
104 return
105 fi
106 fi
108 # The path to the most important files/dir used by Tazwok.
109 PACKAGES_REPOSITORY=$LOCAL_REPOSITORY/packages
110 WOK=$LOCAL_REPOSITORY/wok
111 INCOMING_REPOSITORY=$LOCAL_REPOSITORY/packages-incoming
112 SOURCES_REPOSITORY=$LOCAL_REPOSITORY/src
113 set_common_path
115 # /!\ This part needs some changes.
116 # Basically, get theses files from the net if they are missing.
117 dep_db=$INCOMING_REPOSITORY/wok-depends.txt
118 wan_db=$INCOMING_REPOSITORY/wok-wanted.txt
119 [ -f $dep_db ] || touch $dep_db
120 [ -f $wan_db ] || touch $wan_db
121 [ -f $PACKAGES_REPOSITORY/cookorder.txt ] || touch $PACKAGES_REPOSITORY/cookorder.txt
123 # Check commons directories, create them if user is root.
124 if test $(id -u) = 0 ; then
125 check_dir $WOK || chmod 777 $WOK
126 check_dir $PACKAGES_REPOSITORY
127 check_dir $SOURCES_REPOSITORY
128 check_dir $INCOMING_REPOSITORY
129 check_dir $LOCAL_REPOSITORY/log
130 fi
132 # Some files are needed by tazwok in PACKAGES_REPOSITORY. Create
133 # them if they are missing.
134 for file in broken blocked commit incoming cooklist; do
135 [ ! -f $PACKAGES_REPOSITORY/$file ] && touch $PACKAGES_REPOSITORY/$file
136 done
138 # Limit memory usage.
139 ulimit -v $(awk '/MemTotal/ { print int(($2*80)/100) }' < /proc/meminfo)
140 }
142 # Used in several functions.
143 set_common_path()
144 {
145 # The receipt is used to compile the source code and
146 # generate suitable packages for Tazpkg.
147 RECEIPT="$WOK/$PACKAGE/receipt"
149 # The path to the process log file.
150 LOG="$WOK/$PACKAGE/process.log"
151 }
153 ########################################################################
154 # TAZWOK CHECK FUNCTIONS
155 ########################
157 # Check for a package name on cmdline.
158 check_for_package_on_cmdline()
159 {
160 if [ ! "$PACKAGE" ]; then
161 echo -e "\nYou must specify a package name on the command line." >&2
162 echo -e "Example : tazwok $COMMAND package\n" >&2
163 exit 1
164 fi
165 }
167 # Check for the receipt of a package used to cook.
168 check_for_receipt()
169 {
170 if [ ! -f "$RECEIPT" ]; then
171 echo -e "\nUnable to find the receipt : $RECEIPT\n" >&2
172 exit 1
173 fi
174 }
176 # Check for a specified file list on cmdline.
177 check_for_list()
178 {
179 if [ ! "$LIST" ]; then
180 echo -e "\nPlease specify the path to the list of packages to cook.\n" >&2
181 exit 1
182 fi
184 # Check if the list of packages exists.
185 if [ -f "$LIST" ]; then
186 LIST=`cat $LIST`
187 else
188 echo -e "\nUnable to find $LIST packages list.\n" >&2
189 exit 1
190 fi
192 if [ ! "$LIST" ]; then
193 echo -e "\nList is empty.\n" >&2
194 exit 1
195 fi
196 }
198 check_for_pkg_in_wok()
199 {
200 [ -f $WOK/$PACKAGE/receipt ] && return
201 if [ "$undigest" ]; then
202 [ -f "$SLITAZ_VERSION/wok/$PACKAGE/receipt" ] && return 1
203 grep -q ^$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages/packages.txt && return 1
204 fi
205 echo "Can't find $PACKAGE in wok or mirror" >&2
206 return 2
207 }
209 ########################################################################
210 # TAZWOK CORE FUNCTIONS
211 ########################
213 remove_src()
214 {
215 [ "$WANTED" ] && return
216 look_for_cookopt !remove_src && return
217 if [ ! -d $WOK/$PACKAGE/install ] && [ "$src" ] && [ -d "$src/_pkg" ]; then
218 check_for_var_modification _pkg src || return
219 mv "$src/_pkg" $WOK/$PACKAGE/install
220 fi
222 # Don't remove sources if a package use src variable in his
223 # genpkg_rules: it maybe need something inside.
224 for i in $PACKAGE $(look_for_rwanted); do
225 sed -n '/^genpkg_rules\(\)/','/}/'p $WOK/$i/receipt | \
226 fgrep -q '$src' && tazwok_warning "Sources will not be removed \
227 because $i use \$src in his receipt." && return
228 done
230 report step "Removing sources directory"
231 rm -fr "$src"
232 report end-step
233 }
235 # Check $COOK_OPT; usage : get_cookopt particular_opt
236 # Return error if not founded
237 # Return args if the opt is in the format opt=arg1:arg2:etc
238 look_for_cookopt()
239 {
240 for arg in $COOK_OPT; do
241 case $arg in
242 $1=*)
243 arg=${arg#$1=}
244 while [ "$arg" ]; do
245 echo "${arg%%:*}"
246 [ "${arg/:}" = "$arg" ] && return
247 arg=${arg#*:}
248 done
249 ;;
250 $1)
251 return
252 ;;
253 esac
254 done
255 return 1
256 }
258 # Check for the wanted package if specified in WANTED
259 # receipt variable. Set the $src/$_pkg variable to help compile
260 # and generate packages.
261 check_for_wanted()
262 {
263 if [ "$WANTED" ]; then
264 report "Checking for the wanted package"
265 if [ ! -d "$WOK/$WANTED" ]; then
266 report exit "\nWanted package is missing in the work directory.\n"
267 fi
269 # Checking for buildtree of Wanted package
270 if [ ! -d "$WOK/$WANTED/taz" ]; then
271 echo -e "\n\nSource files of wanted package is missing in the work directory."
272 echo -n "Would you like to build the missing package (y/N) ? " ; read anser
273 if [ "$anser" == "y" ]; then
274 tazwok cook $WANTED
275 else
276 report exit "\nWanted package source tree is missing in the work directory.\n"
277 fi
278 fi
279 report end-step
281 # Set wanted src path.
282 set_src_path && set_pkg_path
284 fi
285 }
287 # Check for build dependencies, notify user and install if specified.
288 check_for_build_depends()
289 {
290 [ "$WANTED" ] && return
291 [ "$CATEGORY" = meta ] && ! fgrep -q compile_rules $RECEIPT && return
292 report step "Looking for build dependencies"
294 # Keep the list of previously installed build_depends then compare
295 # it with new build_depends to know what to install and what to
296 # what to remove.
297 plan_remove=" $MISSING_PACKAGE $remove_later "
298 [ ! "${plan_remove// }" ] && unset plan_remove
299 unset MISSING_PACKAGE remove_later
300 rwanted=$(look_for_rwanted)
302 for pkg in $(scan $PACKAGE --look_for=bdep --with_dev | \
303 fgrep -v $(for i in $(look_for_rwanted) $PACKAGE; do echo " -e $i"; done))
304 do
306 # Delay the removing of previous cook depends if they are needed
307 # for next cook too.
308 if [ ! -d "$INSTALLED/$pkg" ] ; then
309 MISSING_PACKAGE="$MISSING_PACKAGE $pkg"
310 fi
311 if [ "$plan_remove" != "${plan_remove/ $pkg }" ]; then
312 plan_remove="${plan_remove/ $pkg / }"
313 remove_later="$remove_later $pkg"
314 fi
315 if grep -q ^$pkg$ $PACKAGES_REPOSITORY/broken; then
316 broken="$broken$pkg "
317 fi
318 done
320 # Don't cook if a depend is broken.
321 if [ "$broken" ]; then
322 MISSING_PACKAGE=$plan_remove
323 echo "Can't cook $PACKAGE because broken depend(s) : $broken" >&2
324 unset plan_remove broken
326 # Set report step to failed.
327 report_return_code=1
328 report end-step
329 return 1
330 fi
331 if [ "$MISSING_PACKAGE" ]; then
332 install_missing()
333 {
334 echo "Installing missing packages : $MISSING_PACKAGE"
335 for pkg in $MISSING_PACKAGE; do
336 [ -d "$INSTALLED/$pkg" ] || tazpkg get-install $pkg
337 done
338 }
339 if [ "$auto_install" = yes ]; then
340 install_missing
341 else
342 echo "================================================================================"
343 for pkg in $MISSING_PACKAGE
344 do
345 echo "Missing : $pkg"
346 done
347 echo "================================================================================"
348 echo "You can continue, exit or install missing dependencies."
349 echo -n "Install, continue or exit (install/y/N) ? "; read answer
350 case $answer in
351 install)
352 install_missing ;;
353 y|yes)
354 unset MISSING_PACKAGE;;
355 *)
356 report stop
357 exit 0 ;;
358 esac
359 fi
360 fi
361 report end-step
362 remove_build_depends $plan_remove
363 unset plan_remove
364 }
366 remove_build_depends()
367 {
368 [ "$1" ] || return
369 report step "Removing previous build dependencies"
370 echo "Removing theses packages : $@"
371 for pkg in $@; do
372 [ -d "$INSTALLED/$pkg" ] && tazpkg remove $pkg --auto
373 done
374 report end-step
375 }
377 # Check if we can use the new way to handle tarball
378 # or if we keep the previous method by check for
379 # _pkg=/src= in receipt and reverse-wanted.
380 check_for_var_modification()
381 {
382 for var in $@; do
383 for pkg in $PACKAGE $(look_for_wanted) $(look_for_rwanted); do
384 [ -f $WOK/$pkg/receipt ] || continue
385 fgrep -q "$var=" $WOK/$pkg/receipt && return 1
386 done
387 done
389 # Tweak to make if; then...; fi function working with this one.
390 echo -n ""
391 }
393 set_src_path()
394 {
395 if check_for_var_modification src _pkg; then
396 src=$WOK/${WANTED:-$PACKAGE}/${WANTED:-$PACKAGE}-$VERSION
397 else
398 src=$WOK/${WANTED:-$PACKAGE}/${SOURCE:-${WANTED:-$PACKAGE}}-$VERSION
399 fi
400 }
402 set_pkg_path()
403 {
404 if [ -d $WOK/${WANTED:-$PACKAGE}/install ] ; then
405 _pkg=$WOK/${WANTED:-$PACKAGE}/install
406 else
407 _pkg=$src/_pkg
408 fi
409 }
411 # Output $VERSION-$EXTRAVERSION using packages.txt
412 get_pkg_version()
413 {
414 [ "$PACKAGE" ] || return
415 grep -m1 -A1 -sh ^$PACKAGE$ $1/packages.txt | tail -1 | sed 's/ *//'
416 }
418 remove_previous_tarball()
419 {
420 [ "$prev_VERSION" ] || return
421 if [ "$VERSION" != "$prev_VERSION" ]; then
422 rm -f $SOURCES_REPOSITORY/$PACKAGE-$prev_VERSION.tar.lzma
423 fi
424 }
426 remove_previous_package()
427 {
428 [ "$prev_VERSION" ] || return
429 if [ "$VERSION$EXTRAVERSION" != "$prev_VERSION" ]; then
430 rm -f $1/$PACKAGE-$prev_VERSION.tazpkg
431 fi
432 return
433 }
435 # Check for src tarball and wget if needed.
436 check_for_tarball()
437 {
438 if [ "$WGET_URL" ]; then
439 report step "Checking for source tarball"
441 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
442 [ ! -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] ; then
443 cd $SOURCES_REPOSITORY
444 download $WGET_URL
446 # If source tarball is unreachable, try to find it on SliTaz
447 # mirror.
448 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
449 report step "Download failed, try with mirror copy... "
450 if [ "$SOURCE" ]; then
451 download http://mirror.slitaz.org/sources/packages/${SOURCE:0:1}/$SOURCE-$VERSION.tar.lzma
452 else
453 download http://mirror.slitaz.org/sources/packages/${PACKAGE:0:1}/$PACKAGE-$VERSION.tar.lzma
454 fi
455 fi
456 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ] && \
457 [ ! -f "$SOURCES_REPOSITORY/$PACKAGE-$VERSION.tar.lzma" ]; then
458 report step "Download failed, try with mirror copy (again)... "
459 file=$(basename $WGET_URL)
460 download http://mirror.slitaz.org/sources/packages/${file:0:1}/$file
461 fi
463 # Exit if download failed to avoid errors.
464 if [ ! -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
465 echo -e "\nDownload failed, exiting. Please check WGET_URL variable.\n" >&2
466 report end-step
467 return 1
468 fi
469 fi
470 fi
471 report end-step
473 if [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ] && [ "$nounpack" ]; then
474 return
475 fi
477 # Untaring source if necessary. We don't need to extract source if
478 # the package is built with a wanted source package.
479 if [ "$WANTED" ]; then
480 return
481 fi
483 report step "Untaring source tarball"
484 if [ "$target" ]; then
485 src="$target"
486 else
487 set_src_path
488 fi
490 # Log process.
491 echo "untaring source tarball" >> $LOG
493 tmp_src=$WOK/$PACKAGE/tmp-src-$$
494 mkdir $tmp_src
495 if [ -f "$SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma" ]; then
496 lzma d $SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma -so | \
497 tar xf - -C $tmp_src
498 elif [ -f "$SOURCES_REPOSITORY/$TARBALL" ]; then
499 case "$TARBALL" in
500 *zip|*xpi) { cd $tmp_src; unzip -o $SOURCES_REPOSITORY/$TARBALL; };;
501 *bz2) tar xjf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
502 *tar) tar xf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
503 *lzma) unlzma -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
504 *xz) unxz -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
505 *Z) uncompress -c $SOURCES_REPOSITORY/$TARBALL | tar xf - -C $tmp_src;;
506 *) tar xzf $SOURCES_REPOSITORY/$TARBALL -C $tmp_src;;
507 esac || return 1
509 # Check if uncompressed tarball is in a root dir or not.
510 if [ "$(ls -A $tmp_src | wc -l)" -gt 1 ]; then
511 if check_for_var_modification src _pkg; then
512 mv $tmp_src $tmp_src-1
513 mkdir $tmp_src
514 mv $tmp_src-1 $tmp_src/${SOURCE:-$PACKAGE}-$VERSION
515 else
516 mv $tmp_src/* $WOK/$PACKAGE
517 repack_src=no
518 rm -r $tmp_src
519 fi
520 fi
522 if [ "$repack_src" = yes ]; then
523 report step "Repacking sources in .tar.lzma format"
524 cd $tmp_src
525 tar -c * | lzma e $SOURCES_REPOSITORY/${SOURCE:-$PACKAGE}-$VERSION.tar.lzma -si
526 rm $SOURCES_REPOSITORY/$TARBALL
527 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
529 # Remove previous tarball if it's not used either by
530 # incoming and legacy packages.
531 [ "$prev_VERSION" != "$(get_pkg_version $PACKAGES_REPOSITORY)" ] && \
532 remove_previous_tarball
533 fi
534 fi
535 if [ "$nounpack" ]; then
536 [ -d "$tmp_src" ] && rm -r $tmp_src
537 return
538 fi
540 if [ ! -d "$src" ]; then
541 if [ -d "$tmp_src" ]; then
542 if ! check_for_var_modification src _pkg; then
543 src="${src%/*}/$(ls $tmp_src)"
544 fi
545 mv $(echo $tmp_src/*) "$src"
546 rm -r $tmp_src
548 # Permissions settings.
549 chown -R root.root "$src"
550 fi
551 report end-step
552 else
553 echo "There's already something at $src. Abord." >&2
554 fi
555 }
557 # Log and execute compile_rules function if it exists, to configure and
558 # make the package if it exists.
559 check_for_compile_rules()
560 {
561 if grep -q ^compile_rules $RECEIPT; then
562 echo "executing compile_rules" >> $LOG
563 report step "Executing compile_rules"
564 cd $WOK/$PACKAGE
565 rm -f /tmp/config.site
567 # Free some RAM by cleaning cache if option is enabled.
568 freeram=$(free | fgrep '/+ buffers' | tr -s ' ' | cut -f 4 -d ' ')
570 # Disable -pipe in CFLAGS/CXXFLAGS if less than 512Mb of free
571 # RAM are available.
572 if [ "$freeram" -lt 524288 ] && [ "$CFLAGS" != "${CFLAGS/-pipe}" -o \
573 "$CXXFLAGS" != "${CXXFLAGS/-pipe}" ]; then
574 tazwok_warning "Disabling -pipe compile flag because only ${freeram}b of RAM are available."
575 CFLAGS="${CFLAGS/-pipe}"
576 CXXFLAGS="${CXXFLAGS/-pipe}"
577 fi
578 unset freeram
580 # Set cook environnement variables.
581 [ "$src" ] || set_src_path
582 [ "$DESTDIR" ] || DESTDIR="$WOK/$PACKAGE/install"
583 [ "$CONFIG_SITE" ] || CONFIG_SITE=/etc/config.site
584 export CFLAGS CXXFLAGS MAKEFLAGS DESTDIR BUILD_HOST \
585 CONFIG_SITE default_prefix \
586 default_datarootdir default_datadir default_localedir \
587 default_infodir default_mandir default_build default_host
588 local LC_ALL=POSIX LANG=POSIX
589 compile_rules
591 # Check if config.site has been used.
592 # /!\ disabled since it screw the return_code of the step.
593 #if [ -f /tmp/config.site ]; then
594 # rm /tmp/config.site
595 #else
596 # tazwok_warning "config.site hasn't been used during \
597 #configuration process."
598 #fi
600 report end-step
601 fi
602 }
604 # Check for loop in deps tree. /!\ can be removed
605 check_for_deps_loop()
606 {
607 local list
608 local pkg
609 local deps
610 pkg=$1
611 shift
612 [ -n "$1" ] || return
613 list=""
615 # Filter out already processed deps
616 for i in $@; do
617 case " $ALL_DEPS" in
618 *\ $i\ *);;
619 *) list="$list $i";;
620 esac
621 done
622 ALL_DEPS="$ALL_DEPS$list "
623 for i in $list; do
624 [ -f $i/receipt ] || continue
625 deps="$(DEPENDS=""; . $i/receipt; echo $DEPENDS)"
626 case " $deps " in
627 *\ $pkg\ *) echo -e "$MSG $i"; MSG="";;
628 *) check_for_deps_loop $pkg $deps;;
629 esac
630 done
631 }
633 download()
634 {
635 for file in $@; do
636 wget -q $file && break
637 done
638 }
640 # Regenerate every package that wants a PACKAGE compiled
641 refresh_packages_from_compile()
642 {
643 # make tazwok genpkg happy
644 mkdir $WOK/$PACKAGE/taz
646 # Cook rwanted in default or specied order
647 genlist=" $(look_for_rwanted | tr '\n' ' ') "
648 for i in $(look_for_cookopt genpkg | tac); do
649 [ "${genlist/ $i }" = "$genlist" ] && continue
650 genlist=" $i${genlist/ $i / }"
651 done
652 if [ "$genlist" ]; then
653 local PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
654 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
655 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
656 src _pkg DESTDIR CONFIG_SITE RECEIPT LOG
657 for PACKAGE in $genlist; do
658 set_common_path
659 gen_package
660 done
661 fi
662 }
664 # Copy all generic files (locale, pixmaps, .desktop). We use standard paths,
665 # so some packages need to copy these files with the receipt and genpkg_rules.
666 # This function is executed by gen_package when 'tazwok genpkg'.
667 copy_generic_files()
668 {
669 # In most cases, locales are in $_pkg/usr/share/locale so we copy files
670 # using generic variables and $LOCALE from Tazwok config file.
671 if [ "$LOCALE" ]; then
672 if [ -d "$_pkg/usr/share/locale" ]; then
673 for i in $LOCALE
674 do
675 if [ -d "$_pkg/usr/share/locale/$i" ]; then
676 mkdir -p $fs/usr/share/locale
677 cp -a $_pkg/usr/share/locale/$i $fs/usr/share/locale
678 fi
679 done
680 fi
681 fi
683 # Pixmaps (PNG or/and XPM only). Some icons/images can be added through
684 # genpkg_rules and generic copy can be disabled with GENERIC_PIXMAPS="no"
685 # in pkg receipt.
686 if [ "$GENERIC_PIXMAPS" != "no" ]; then
687 if [ -d "$_pkg/usr/share/pixmaps" ]; then
688 mkdir -p $fs/usr/share/pixmaps
689 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.png \
690 $fs/usr/share/pixmaps 2>/dev/null
691 cp -a $_pkg/usr/share/pixmaps/$PACKAGE.xpm \
692 $fs/usr/share/pixmaps 2>/dev/null
693 fi
695 # Custom or homemade PNG pixmap can be in stuff.
696 if [ -f "stuff/$PACKAGE.png" ]; then
697 mkdir -p $fs/usr/share/pixmaps
698 cp -a stuff/$PACKAGE.png $fs/usr/share/pixmaps
699 fi
700 fi
702 # Desktop entry (.desktop).
703 if [ -d "$_pkg/usr/share/applications" ]; then
704 cp -a $_pkg/usr/share/applications $fs/usr/share
705 fi
707 # Homemade desktop file(s) can be in stuff.
708 if [ -d "stuff/applications" ]; then
709 mkdir -p $fs/usr/share
710 cp -a stuff/applications $fs/usr/share
711 fi
712 if [ -f "stuff/$PACKAGE.desktop" ]; then
713 mkdir -p $fs/usr/share/applications
714 cp -a stuff/$PACKAGE.desktop $fs/usr/share/applications
715 fi
716 }
718 # Find and strip : --strip-all (-s) or --strip-debug on static libs.
719 strip_package()
720 {
721 report step "Executing strip on all files"
723 # Binaries.
724 for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games
725 do
726 if [ -d "$dir" ]; then
727 find $dir -type f -exec strip -s '{}' 2>/dev/null \;
728 fi
729 done
731 # Libraries.
732 find $fs -name "*.so*" -exec strip -s '{}' 2>/dev/null \;
733 find $fs -name "*.a" -exec strip --strip-debug '{}' 2>/dev/null \;
734 report end-step
735 }
737 # Remove .pyc and .pyo files from packages
738 py_compiled_files_remove()
739 {
740 report step "Removing all .pyc and .pyo files from package ..."
741 find $fs -type f -name "*.pyc" -delete 2>/dev/null
742 find $fs -type f -name "*.pyo" -delete 2>/dev/null
743 report end-step
744 }
746 # Check FSH in a slitaz package (Path: /:/usr)
747 check_fsh()
748 {
749 cd $WOK/$PACKAGE/taz/*/fs
750 [ -n "$FSH" ] || FSH="bin boot dev etc home init lib media mnt proc \
751 root sbin share sys tmp usr var vz usr/bin usr/games usr/include usr/lib \
752 usr/local usr/sbin usr/share usr/src"
753 for i in `ls -d * usr/* 2>/dev/null`
754 do
755 if ! echo $FSH | fgrep -q $i; then
756 echo "Wrong path: /$i" >&2
757 error=1
758 fi
759 done
760 if [ "$error" = "1" ]; then
761 cat << _EOT_
763 Package will install files in a non standard directory and won't be generated.
764 You may have a wrong copy path in genpkg_rules or need to add some options to
765 configure in compile_rules. Some valid options for SliTaz (Linux FSH):
767 --prefix=/usr
768 --sysconfdir=/etc
769 --libexecdir=/usr/lib/(pkgname)
770 --localstatedir=/var
771 --mandir=/usr/share/man
772 --infodir=/usr/share/info
774 For more information please read SliTaz docs and run: ./configure --help
775 ================================================================================
776 $PACKAGE package generation aborted.
778 _EOT_
780 # Dont generate a corrupted package.
781 cd $WOK/$PACKAGE && rm -rf taz
782 report exit
783 fi
784 }
786 gen_cookmd5()
787 {
788 # md5sum of cooking stuff make tazwok able to check for changes
789 # without hg.
790 cd $WOK/$PACKAGE
791 md5sum receipt > md5
792 [ -f description.txt ] && md5sum description.txt >> md5
793 if [ -d stuff ]; then
794 find stuff | while read file; do
795 md5sum $file >> md5
796 done
797 fi
798 }
800 # Create a package tree and build the gziped cpio archive
801 # to make a SliTaz (.tazpkg) package.
802 gen_package()
803 {
804 check_root
805 check_for_package_on_cmdline
806 check_for_receipt
807 EXTRAVERSION=""
808 . $RECEIPT
810 # May compute VERSION
811 if grep -q ^get_version $RECEIPT; then
812 get_version
813 fi
814 check_for_wanted
815 cd $WOK/$PACKAGE
817 # Remove old Tazwok package files.
818 [ -d "taz" ] && rm -rf taz
820 # Create the package tree and set useful variables.
821 mkdir -p taz/$PACKAGE-$VERSION/fs
822 fs=taz/$PACKAGE-$VERSION/fs
824 # Set $src for standard package and $_pkg variables.
825 set_src_path && set_pkg_path
827 # Execute genpkg_rules, check package and copy generic files to build
828 # the package.
829 report step "Building $PACKAGE with the receipt"
830 report open-bloc
831 if grep -q ^genpkg_rules $RECEIPT; then
833 # Log process.
834 echo "executing genpkg_rules" >> $LOG
835 report step "Executing genpkg_rules"
836 genpkg_rules
837 report end-step
838 check_fsh
839 cd $WOK/$PACKAGE
841 # Skip generic files for packages with a WANTED variable
842 # (dev and splited pkgs).
843 if [ ! "$WANTED" ]; then
844 copy_generic_files
845 fi
846 look_for_cookopt !strip || strip_package
847 py_compiled_files_remove
848 else
849 echo "No package rules to gen $PACKAGE..." >&2
850 report exit
851 fi
853 # Copy the receipt and description (if exists) into the binary package tree.
854 cd $WOK/$PACKAGE
855 report step "Copying the receipt"
856 cp receipt taz/$PACKAGE-$VERSION
857 report end-step
858 if grep -q ^get_version $RECEIPT; then
859 report step "Updating version in receipt"
860 sed -i "s/^VERSION=.*/VERSION=\"$VERSION\"/" \
861 taz/$PACKAGE-$VERSION/receipt
862 report end-step
863 fi
864 if [ -f "description.txt" ]; then
865 report step "Copying the description file"
866 cp description.txt taz/$PACKAGE-$VERSION
867 report end-step
868 fi
870 # Generate md5 of cooking stuff to look for commit later.
871 gen_cookmd5
872 echo -e "\n# md5sum of cooking stuff :" >> taz/$PACKAGE-$VERSION/receipt
873 cat md5 | sed 's/^/# /' >> taz/$PACKAGE-$VERSION/receipt
875 # Create the files.list by redirecting find output.
876 report step "Creating the list of files"
877 cd taz/$PACKAGE-$VERSION
878 LAST_FILE=""
879 { find fs -print; echo; } | while read file; do
880 if [ "$LAST_FILE" ]; then
881 case "$file" in
882 $LAST_FILE/*)
883 case "$(ls -ld "$LAST_FILE")" in
884 drwxr-xr-x\ *\ root\ *\ root\ *);;
885 *) echo ${LAST_FILE#fs};;
886 esac;;
887 *) echo ${LAST_FILE#fs};;
888 esac
889 fi
890 LAST_FILE="$file"
891 done > files.list
893 # Next, check if something has changed in lib files.
894 if fgrep -q '.so' files.list; then
895 report step "Look for major/minor update in libraries"
896 for rep in $INCOMING_REPOSITORY $PACKAGES_REPOSITORY \
897 $([ "$undigest" ] && echo SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming && \
898 echo $SLITAZ_DIR/$SLITAZ_VERSION/packages); do
899 prev_VERSION=$(get_pkg_version $rep)
900 [ "$prev_VERSION" ] && pkg_file=$rep/$PACKAGE-$prev_VERSION.tazpkg && break
901 done
902 if [ "$pkg_file" ]; then
903 get_pkg_files $pkg_file
904 cd $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
905 fgrep ".so" files.list | egrep -v "[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*" | \
906 while read lib; do
907 fgrep -q "$lib" $pkg_files_dir/files.list && continue
908 echo "A minor/major update in libraries is detected, planning re-cook of reverse-depends of $PACKAGE."
909 for rdep in $(scan $PACKAGE --look_for=rdep | use_wanted); do
910 [ "$rdep" = "${WANTED:-$PACKAGE}" ] && continue
911 grep -q ^$rdep$ $PACKAGES_REPOSITORY/blocked \
912 $PACKAGES_REPOSITORY/cooklist && continue
913 echo $rdep >> $PACKAGES_REPOSITORY/cooklist
914 done
915 regen_cooklist=yes
916 break
917 done
918 rm -r $pkg_files_dir
919 fi
920 report end-step
921 fi
922 if [ ! "$EXTRAVERSION" ]; then
923 case "$PACKAGE" in
924 linux*);;
925 *) EXTRAVERSION="$(grep '/lib/modules/.*-slitaz/' files.list |\
926 head -1 | sed 's|/lib/modules/\(.*\)-slitaz/.*|_\1|')";;
927 esac
928 fi
929 rm -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg 2> /dev/null
930 report step "Creating md5sum of files"
931 while read file; do
932 [ -L "fs$file" ] && continue
933 [ -f "fs$file" ] || continue
934 md5sum "fs$file" | sed 's/ fs/ /'
935 done < files.list > md5sum
936 report end-step
937 UNPACKED_SIZE=$(du -chs fs receipt files.list md5sum description.txt \
938 2> /dev/null | awk '{ sz=$1 } END { print sz }')
940 # Build cpio archives. Find, cpio and gzip the fs, finish by
941 # removing the fs tree.
942 # Don't log this because compression always output error messages.
943 find fs -print | cpio -o -H newc | case "$PACKAGE-$COMPRESSION" in
944 tazpkg-lzma) gzip > fs.cpio.gz;;
945 *-lzma) lzma e fs.cpio.lzma -si;;
946 *) gzip > fs.cpio.gz;;
947 esac && rm -rf fs
948 PACKED_SIZE=$(du -chs fs.cpio.* receipt files.list md5sum \
949 description.txt 2> /dev/null | awk '{ sz=$1 } END { print sz }')
950 report step "Updating receipt sizes"
951 sed -i '/^PACKED_SIZE/d' receipt
952 sed -i '/^UNPACKED_SIZE/d' receipt
953 sed -i "s/^PACKAGE=/PACKED_SIZE=\"$PACKED_SIZE\"\nUNPACKED_SIZE=\"$UNPACKED_SIZE\"\nPACKAGE=/" receipt
954 sed -i "s/^VERSION=$/VERSION=\"$VERSION\"/" receipt
955 report end-step
956 if [ "$EXTRAVERSION" ]; then
957 report step "Updating receipt EXTRAVERSION"
958 sed -i s/^EXTRAVERSION.*$// receipt
959 sed -i "s/^VERSION=/EXTRAVERSION=\"$EXTRAVERSION\"\nVERSION=/" receipt
960 fi
961 prev_VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
962 remove_previous_package $INCOMING_REPOSITORY
963 report step "Creating full cpio archive"
964 find . -print | cpio -o -H newc > $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
966 # Restore package tree in case we want to browse it.
967 report step "Restoring original package tree"
968 { zcat fs.cpio.gz 2> /dev/null || unlzma -c fs.cpio.lzma; } | cpio --quiet -id
969 rm fs.cpio.* && cd ..
971 # Log process.
972 echo "$PACKAGE-$VERSION$EXTRAVERSION.tazpkg (done)" >> $LOG
973 report close-bloc
974 echo "Package $PACKAGE ($VERSION$EXTRAVERSION) generated."
975 echo "Size : `du -sh $INCOMING_REPOSITORY/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg`"
976 echo ""
978 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/broken
979 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/commit
980 sed "/^$PACKAGE$/d" -i $PACKAGES_REPOSITORY/cooklist
981 }
983 ########################################################################
984 # This section contains functions used by several other functions
985 # bellow.
986 ########################
988 # Look for receipt/files.list in wok. If they can't be found, get them
989 # from package. Accept one argument : absolute path to package.
990 get_pkg_files()
991 {
992 pkg_files_dir=$tmp/$(basename ${1%.tazpkg})
993 mkdir -p $pkg_files_dir && \
994 cd $pkg_files_dir && \
995 cpio --quiet -idm receipt < $1 && \
996 cpio --quiet -idm files.list < $1
997 }
999 ########################################################################
1000 # This section contains functions to generate packages databases.
1001 ########################
1004 gen_packages_db()
1006 # pkg_repository can be $PACKAGES_REPOSITORY or $INCOMING_REPOSITORY.
1007 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1008 cd $pkg_repository
1009 report step "Generating packages lists: $pkg_repository"
1010 report open-bloc
1011 report step "Removing old files"
1012 for file in files.list.lzma packages.list packages.txt \
1013 packages.desc packages.equiv packages.md5; do
1014 [ -f $file ] && rm $file
1015 done
1016 touch files.list
1018 packages_db_start
1019 unset RECEIPT
1020 report step "Reading datas from all packages"
1021 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1022 get_packages_info
1023 done
1024 report end-step
1025 packages_db_end
1026 report close-bloc
1029 update_packages_db()
1031 [ "$pkg_repository" ] || pkg_repository=$PACKAGES_REPOSITORY
1032 cd $pkg_repository
1033 for file in packages.list packages.equiv packages.md5 packages.desc \
1034 packages.txt; do
1035 if [ ! -f "$file" ]; then
1036 gen_packages_db
1037 return
1038 fi
1039 done
1040 if [ -f files.list.lzma ]; then
1041 lzma d files.list.lzma files.list
1042 else
1043 gen_packages_db
1044 fi
1045 report step "Updating packages lists: $pkg_repository"
1046 packages_db_start
1048 # Look for removed/update packages.
1049 for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
1050 pkg="$pkg_repository/$(grep -m1 ^$PACKAGE- packages.list).tazpkg"
1051 if ! [ -f "$pkg" ]; then
1052 erase_package_info
1053 else
1054 if [ "$pkg" -nt "packages.list" ]; then
1055 updated_pkg="$updated_pkg
1056 $PACKAGE $pkg"
1057 fi
1058 fi
1059 done
1060 echo "$updated_pkg" | sed 1d | while read PACKAGE pkg; do
1061 erase_package_info
1062 get_packages_info
1063 done
1064 unset updated_pkg
1066 # Look for new packages.
1067 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1068 if ! fgrep -q " ${pkg##*/}" $pkg_repository/packages.md5; then
1069 get_packages_info
1070 fi
1071 done
1072 report end-step
1073 packages_db_end
1076 packages_db_start()
1078 if [ ! -s packages.txt ]; then
1079 echo "# SliTaz GNU/Linux - Packages list
1081 # Packages : unknow
1082 # Date : $(date +%Y-%m-%d\ \%H:%M:%S)
1084 " > packages.txt
1085 else
1086 sed -e 's/^# Packages :.*/# Packages : unknow/' \
1087 -e "s/# Date :.*/# Date : $(date +%Y-%m-%d\ \%H:%M:%S)/" \
1088 -i packages.txt
1089 fi
1091 # Needed in some case as tazwok define RECEIPT at configuration time
1092 # in this particular case it can broke the script.
1093 unset RECEIPT
1096 erase_package_info()
1098 cd $pkg_repository
1099 sed "/^$PACKAGE$/,/^$/d" -i packages.txt
1100 sed "/^$PACKAGE /d" -i packages.desc
1101 sed -e "s/=$PACKAGE /= /" -e "s/ $PACKAGE / /" -e "s/ $PACKAGE$//" \
1102 -e "/=$PACKAGE$/d" -e "s/=[0-9,a-z,A-Z]:$PACKAGE /= /" \
1103 -e "s/ [0-9,a-z,A-Z]:$PACKAGE / /" -e "s/ [0-9,a-z,A-Z]:$PACKAGE$/ /" \
1104 -e "/=[0-9,a-z,A-Z]:$PACKAGE$/d" \
1105 -i packages.equiv
1106 sed "/^$PACKAGE:/d" -i files.list
1107 sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
1108 sed "/ $(basename $pkg)$/d" -i packages.md5
1111 get_packages_info()
1113 # If there's no taz folder in the wok, extract infos from the
1114 # package.
1115 get_pkg_files $pkg
1116 source_receipt
1117 echo "Getting datas from $PACKAGE"
1119 cat >> $pkg_repository/packages.txt << _EOT_
1120 $PACKAGE
1121 $VERSION$EXTRAVERSION
1122 $SHORT_DESC
1123 _EOT_
1124 if [ "$PACKED_SIZE" ]; then
1125 cat >> $pkg_repository/packages.txt << _EOT_
1126 $PACKED_SIZE ($UNPACKED_SIZE installed)
1128 _EOT_
1129 else
1130 echo "" >> $pkg_repository/packages.txt
1131 fi
1133 # Packages.desc is used by Tazpkgbox <tree>.
1134 echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
1136 # Packages.equiv is used by tazpkg install to check depends
1137 for i in $PROVIDE; do
1138 DEST=""
1139 echo $i | fgrep -q : && DEST="${i#*:}:"
1140 if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
1141 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
1142 else
1143 echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
1144 fi
1145 done
1147 if [ -f files.list ]; then
1148 { echo "$PACKAGE"; cat files.list; } | awk '
1149 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
1150 fi
1152 cd .. && rm -r "$pkg_files_dir"
1154 cd $pkg_repository
1155 echo $(basename ${pkg%.tazpkg}) >> packages.list
1156 [ ! "$package_md5" ] && package_md5=$(md5sum $(basename $pkg))
1157 echo "$package_md5" >> packages.md5
1158 unset package_md5
1161 source_receipt()
1163 unset PACKAGE SOURCE VERSION EXTRAVERSION CATEGORY SHORT_DESC \
1164 MAINTAINER WEB_SITE WGET_URL DEPENDS BUILD_DEPENDS WANTED \
1165 PACKED_SIZE UNPACKED_SIZE COOK_OPT PROVIDE CONFIG_FILES TAGS \
1166 src _pkg DESTDIR CONFIG_SITE
1167 . ${RECEIPT:-$PWD/receipt}
1170 packages_db_end()
1172 cd $pkg_repository
1173 pkgs=$(wc -l packages.list | sed 's/ .*//')
1174 sed "s/# Packages : .*/# Packages : $pkgs/" -i packages.txt
1176 # If lists was updated it's generally needed to sort them well.
1177 if ! sort -c packages.list 2> /dev/null; then
1178 report step "Sorting packages lists"
1179 for file in packages.list packages.desc packages.equiv; do
1180 [ -f $file ] || continue
1181 sort -o $file $file
1182 done
1183 report end-step
1184 fi
1186 # Dont log this because lzma always output error.
1187 lzma e files.list files.list.lzma
1188 rm -f files.list
1189 [ -f packages.equiv ] || touch packages.equiv
1192 ########################################################################
1193 # This section contains functions to generate wok database.
1194 ########################
1196 gen_wok_db()
1198 report step "Generating wok database"
1199 report open-bloc
1200 report step "Removing old files"
1201 for file in $wan_db $dep_db $PACKAGES_REPOSITORY/cookorder.txt; do
1202 [ -f $file ] && rm $file
1203 done
1204 report step "Generating wok-wanted.txt"
1205 gen_wan_db
1206 report step "Generating wok-depends.txt"
1207 for PACKAGE in $(cut -f1 -d '|' $PACKAGES_REPOSITORY/packages.desc \
1208 $INCOMING_REPOSITORY/packages.desc | sort -u); do
1209 RECEIPT=$WOK/$PACKAGE/receipt
1210 if [ -s $RECEIPT ]; then
1211 source_receipt
1212 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
1213 fi
1214 done
1215 sort_db
1216 report close-bloc
1219 gen_wan_db()
1221 for RECEIPT in $(fgrep -l WANTED $WOK/*/receipt); do
1222 WANTED=
1223 source $RECEIPT
1224 [ "$WANTED" ] || continue
1225 echo -e $PACKAGE"\t"$WANTED >> $tmp/wan_db
1226 done
1227 if ! [ -f $wan_db ] || [ "$(diff -q $tmp/wan_db $wan_db)" ]; then
1228 mv -f $tmp/wan_db $wan_db
1229 plan_regen_cookorder=yes
1230 else
1231 rm $tmp/wan_db
1232 fi
1235 update_wan_db()
1237 local PACKAGE
1238 for RECEIPT in $(fgrep WANTED $WOK/*/receipt | \
1239 fgrep $PACKAGE | cut -f1 -d ':'); do
1240 WANTED=
1241 source $RECEIPT
1242 [ "$WANTED" ] || continue
1243 wan_info=$(echo -e $PACKAGE"\t"$WANTED)
1244 [ "$wan_info" = "$(grep -m1 ^$PACKAGE$'\t' $wan_db 2>/dev/null)" ] && return
1245 sed "/^$PACKAGE\t/d" -i $wan_db
1246 echo "$wan_info" >> $wan_db
1247 plan_regen_cookorder=yes
1248 plan_sort_wandb=yes
1249 done
1252 update_dep_db()
1254 dep_info=$(echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ')
1255 [ "$dep_info" = "$(grep -m1 ^$PACKAGE$'\t' $dep_db 2>/dev/null)" ] && return
1256 sed "/^$PACKAGE\t/d" -i $dep_db
1257 echo "$dep_info" >> $dep_db
1258 plan_regen_cookorder=yes
1259 plan_sort_depdb=yes
1262 sort_db()
1264 report step "Generating cookorder.txt"
1265 cat $dep_db | sed 's/ \t / /' | while read PACKAGE BUILD_DEPENDS; do
1266 grep -q ^$PACKAGE$'\t' $wan_db && continue
1268 # Replace each BUILD_DEPENDS with a WANTED package by it's
1269 # WANTED package.
1270 replace_by_wanted()
1272 for p in $BUILD_DEPENDS; do
1273 if grep -q ^$p$'\t' $wan_db; then
1274 echo -n $(grep ^$p$'\t' $wan_db | cut -f 2)' '
1275 else
1276 echo -n $p' '
1277 fi
1278 done | tr ' ' '\n' | sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' '
1280 echo -e $PACKAGE"\t $(replace_by_wanted) "
1281 done > $tmp/db
1282 while [ -s "$tmp/db" ]; do
1283 status=start
1284 for pkg in $(cut -f 1 $tmp/db); do
1285 if ! fgrep -q ' '$pkg' ' $tmp/db; then
1286 echo $pkg >> $tmp/cookorder
1287 sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
1288 status=proceed
1289 fi
1290 done
1291 if [ "$status" = start ]; then
1292 cp -f $tmp/db /tmp/remain-depends.txt
1293 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
1294 for blocked in $(cut -f 1 $tmp/db); do
1295 echo "$blocked" >> $PACKAGES_REPOSITORY/blocked
1296 done
1297 break
1298 fi
1299 done
1300 [ -s $tmp/cookorder ] || touch $tmp/cookorder
1302 # The toolchain packages are moved in first position.
1303 grep $(for pkg in `scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
1304 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
1305 $tmp/cookorder | tac > $PACKAGES_REPOSITORY/cookorder.txt
1306 for pkg in $(cat $PACKAGES_REPOSITORY/cookorder.txt); do
1307 sed "/^$pkg$/d" -i $tmp/cookorder
1308 done
1310 tac $tmp/cookorder >> $PACKAGES_REPOSITORY/cookorder.txt
1311 unset plan_regen_cookorder
1312 report end-step
1315 ########################################################################
1316 # SCAN CORE
1317 ########################
1318 # Include various scan core-functions. It's not intended to be used
1319 # directly : prefer scan wrappers in next section.
1321 look_for_dep()
1323 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1324 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
1325 | cut -f 2
1326 else
1327 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1328 cut -f 2
1329 fi
1332 look_for_bdep()
1334 look_for_all
1337 look_for_all()
1339 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1340 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
1341 | cut -f 2,3 | sed 's/ / /'
1342 else
1343 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-depends.txt | \
1344 cut -f 2,3 | sed 's/ / /'
1345 fi
1348 look_for_rdep()
1350 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | cut -f 1
1351 if [ "$undigest" ]; then
1352 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt | cut -f 1); do
1353 if [ ! -f "WOK$/$rdep/receipt" ]; then
1354 echo "$rdep"
1355 fi
1356 done
1357 fi
1360 look_for_rbdep()
1362 fgrep ' '$PACKAGE' ' $INCOMING_REPOSITORY/wok-depends.txt | \
1363 cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
1364 if [ "$undigest" ]; then
1365 for rdep in $(fgrep ' '$PACKAGE' ' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-depends.txt \
1366 | cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1); do
1367 if [ ! -f "WOK$/$rdep/receipt" ]; then
1368 echo "$rdep"
1369 fi
1370 done
1371 fi
1374 # Return WANTED if it exists.
1375 look_for_wanted()
1377 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1378 grep ^$PACKAGE$'\t' $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-wanted.txt | cut -f 2
1379 else
1380 grep ^$PACKAGE$'\t' $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 2
1381 fi
1384 # Return packages which wants PACKAGE.
1385 look_for_rwanted()
1387 grep $'\t'$PACKAGE$ $INCOMING_REPOSITORY/wok-wanted.txt | cut -f 1
1388 if [ "$undigest" ]; then
1389 for rwanted in $(grep $'\t'$PACKAGE$ $SLITAZ_DIR/$SLITAZ_VERSION/packages-incoming/wok-wanted.txt | cut -f 1); do
1390 if [ ! -f "$WOK/$rwanted/receipt" ]; then
1391 echo "$rwanted"
1392 fi
1393 done
1394 fi
1397 look_for_dev()
1399 WANTED=$(look_for_wanted)
1400 if [ "$WANTED" ]; then
1401 if [ "$undigest" ] && [ ! -f "$WOK/$WANTED/receipt" ]; then
1402 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$WANTED-dev/receipt" ] && echo $WANTED-dev
1403 else
1404 [ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
1405 fi
1406 fi
1407 if [ "$undigest" ] && [ ! -f "$WOK/$PACKAGE/receipt" ]; then
1408 [ -f "$SLITAZ_DIR/$SLITAZ_VERSION/wok/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1409 else
1410 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
1411 fi
1414 with_dev()
1416 for PACKAGE in $(cat); do
1417 echo $PACKAGE
1418 look_for_dev
1419 done
1422 with_wanted()
1424 for PACKAGE in $(cat); do
1425 echo $PACKAGE
1426 look_for_wanted
1427 done
1430 use_wanted()
1432 for input in $(cat); do
1433 { grep ^$input$'\t' $wan_db || echo $input
1434 } | sed 's/.*\t//'
1435 done
1438 ########################################################################
1439 # SCAN
1440 ########################
1441 # Use wok-wanted.txt and wok-depeds.txt to scan depends.
1442 # Option in command line (must be first arg) :
1443 # --look_for=bdep/rbdep - Look for depends or reverse depends.
1444 # --with_dev - Add development packages (*-dev) in the result.
1445 # --with_wanted - Add package+reverse wanted in the result.
1446 # --with_args - Include packages in argument in the result.
1448 scan()
1450 # Get packages in argument.
1451 local PACKAGE WANTED pkg_list=
1452 for arg in $@; do
1453 [ "$arg" = "${arg#--}" ] || continue
1454 pkg_list="$pkg_list $arg"
1455 done
1457 # Get options.
1458 [ "$pkg_list" ] || return
1459 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
1460 get_options_list="look_for with_dev with_wanted with_args cooklist use_wanted"
1461 get_options
1463 # Cooklist is a special case where we need to modify a little
1464 # scan behavior
1465 if [ "$cooklist" ]; then
1466 gen_wan_db
1467 look_for=all && with_args=yes && with_dev= && with_wanted=
1468 filter=use_wanted
1469 append_to_dep()
1471 check_for_commit && echo $PACKAGE >> $tmp/dep
1473 else
1474 append_to_dep()
1476 echo $PACKAGE >> $tmp/dep
1478 # If requested packages are not in dep_db, partial generation of this db is needed.
1479 for p in $pkg_list; do
1480 grep -q ^$p$'\t' $dep_db && continue
1481 [ -d "$WOK/$p" ] || continue
1482 plan_check_for_missing=yes
1483 check_for_missing
1484 done
1485 if [ "$plan_check_for_missing" ]; then
1486 append_to_dep()
1488 if ! grep -q ^$PACKAGE$'\t' $dep_db; then
1489 check_for_missing && echo $PACKAGE >> $tmp/dep
1490 else
1491 echo $PACKAGE >> $tmp/dep
1492 fi
1494 check_db_status=yes
1495 unset plan_check_for_missing
1496 fi
1497 fi
1499 [ "$with_dev" ] && filter=with_dev
1500 [ "$with_wanted" ] && filter=with_wanted
1501 if [ "$filter" ]; then
1502 pkg_list=$(echo $pkg_list | $filter)
1503 scan_pkg()
1505 look_for_$look_for | $filter
1507 else
1508 scan_pkg()
1510 look_for_$look_for
1512 fi
1513 touch $tmp/dep
1514 for PACKAGE in $pkg_list; do
1515 [ "$with_args" ] && append_to_dep
1516 scan_pkg
1517 done | tr ' ' '\n' | sort -u > $tmp/list
1518 [ "$look_for" = bdep ] && look_for=dep
1519 while [ -s $tmp/list ]; do
1520 PACKAGE=$(sed 1!d $tmp/list)
1521 sed 1d -i $tmp/list
1522 append_to_dep
1523 for pkg in $(scan_pkg); do
1524 if ! grep -q ^$pkg$ $tmp/list $tmp/dep; then
1525 echo $pkg >> $tmp/list
1526 fi
1527 done
1528 done
1529 if [ "$cooklist" ]; then
1530 mv $tmp/dep $tmp/cooklist
1531 else
1532 cat $tmp/dep | sort -u
1533 fi
1534 rm -f $tmp/dep $tmp/list
1535 if [ "$check_db_status" ]; then
1536 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
1537 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
1538 if [ "$plan_regen_cookorder" ]; then
1539 grep -q "^#" $PACKAGES_REPOSITORY/cookorder.txt || \
1540 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
1541 fi
1542 fi
1545 ########################################################################
1546 # This section contains functions to check package repository and
1547 # find which packages to cook.
1548 ########################
1550 check_for_missing()
1552 local PACKAGE
1553 if ! check_for_pkg_in_wok; then
1554 [ "$?" = 2 ] && return 1
1555 return
1556 fi
1557 source_receipt
1558 PACKAGE=${WANTED:-$PACKAGE}
1559 update_wan_db
1560 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
1561 RECEIPT=$WOK/$PACKAGE/receipt
1562 source_receipt
1563 update_dep_db
1564 done
1567 check_for_commit()
1569 if ! check_for_pkg_in_wok; then
1570 [ "$?" = 2 ] && return 1
1571 return
1572 fi
1573 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
1574 RECEIPT=$WOK/$PACKAGE/receipt
1575 source_receipt
1577 # We use md5 of cooking stuff in the packaged receipt to check
1578 # commit. We look consecutively in 3 different locations :
1579 # - in the wok/PACKAGE/taz/* folder
1580 # - in the receipt in the package in incoming repository
1581 # - in the receipt in the package in packages repository
1582 # If md5sum match, there's no commit.
1583 check_for_commit_using_md5sum()
1585 if [ ! -f $WOK/$PACKAGE/md5 ]; then
1586 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
1587 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
1588 cd $WOK/$PACKAGE
1589 fi
1591 if [ -s md5 ]; then
1592 if md5sum -cs md5; then
1594 # If md5sum check if ok, check for new/missing files in
1595 # cooking stuff.
1596 for file in $([ -f receipt ] && echo receipt; \
1597 [ -f description.txt ] && echo description.txt; \
1598 [ -d stuff ] && find stuff); do
1599 if ! fgrep -q " $file" md5; then
1600 set_commited
1601 fi
1602 done
1603 else
1604 set_commited
1605 fi
1606 else
1607 set_commited
1608 fi
1610 set_commited()
1612 ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/commit &&
1613 echo $PACKAGE >> $PACKAGES_REPOSITORY/commit
1614 gen_cookmd5
1615 update_dep_db
1617 taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*')
1618 if [ -f $WOK/$PACKAGE/md5 ]; then
1619 cd $WOK/$PACKAGE
1620 check_for_commit_using_md5sum
1621 elif [ "$taz_dir" ]; then
1622 cd $taz_dir
1623 check_for_commit_using_md5sum
1624 else
1625 pkg=$(echo $INCOMING_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1626 [ "$pkg" ] || pkg=$(echo $PACKAGES_REPOSITORY/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
1627 if [ "$pkg" ]; then
1628 get_pkg_files $pkg
1629 check_for_commit_using_md5sum
1630 rm -r $pkg_files_dir
1631 else
1632 set_commited
1633 fi
1634 fi
1635 [ "$forced" ] || echo $PACKAGE >> $tmp/checked
1636 done
1637 return
1640 gen_cook_list()
1642 report step "Scanning wok"
1643 if [ "$pkg" ]; then
1644 scan $pkg --cooklist
1645 else
1646 scan `cat $cooklist` --cooklist
1647 fi
1648 report end-step
1650 [ -s $tmp/checked ] || [ -s $tmp/cooklist ] || return
1651 if [ "$(sed 1!d $PACKAGES_REPOSITORY/cookorder.txt)" = "#PlanSort" ]; then
1652 sed 1d -i $PACKAGES_REPOSITORY/cookorder.txt
1653 plan_regen_cookorder=yes
1654 fi
1656 # Core toolchain should not be cooked unless cook-toolchain is used.
1657 if ! [ -f /etc/config.site.tmptoolchain ] ; then
1658 for PACKAGE in $(scan gcc --look_for=all --with_args --with_wanted); do
1659 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/blocked || \
1660 echo $PACKAGE >> $PACKAGES_REPOSITORY/blocked
1661 done
1662 fi
1664 if [ -s $PACKAGES_REPOSITORY/commit ]; then
1665 cd $PACKAGES_REPOSITORY
1666 for PACKAGE in $(cat commit); do
1667 WANTED="$(look_for_wanted)"
1668 if [ "$WANTED" ]; then
1669 grep -q ^$WANTED$ broken cooklist blocked commit && continue
1670 fi
1671 grep -q ^$PACKAGE$ blocked cooklist && continue
1672 echo $PACKAGE >> cooklist
1673 done
1674 fi
1675 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
1676 [ "$plan_regen_cookorder" ] && sort_db
1677 sort_cooklist
1680 sort_cooklist()
1682 report step "Sorting cooklist"
1683 if [ -f "$tmp/checked" ]; then
1684 rm -f $tmp/cooklist
1685 cat $tmp/checked | while read PACKAGE; do
1686 grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/cooklist && \
1687 echo $PACKAGE >> $tmp/cooklist
1688 done
1689 elif ! [ "$COMMAND" = gen-cooklist ]; then
1690 cat $PACKAGES_REPOSITORY/blocked | while read PACKAGE; do
1691 sed "/^$PACKAGE/d" -i $tmp/cooklist
1692 done
1693 fi
1695 for PACKAGE in $(cat $tmp/cooklist); do
1696 WANTED="$(look_for_wanted)"
1697 [ "$WANTED" ] || continue
1698 if grep -q ^$WANTED$ $PACKAGES_REPOSITORY/broken $tmp/cooklist; then
1699 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1700 elif [ ! -d $WOK/$WANTED/install ]; then
1701 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1702 echo $WANTED >> $tmp/cooklist
1703 fi
1704 done
1706 # Use cookorder.txt to sort cooklist.
1707 if [ -s $tmp/cooklist ]; then
1708 cat $PACKAGES_REPOSITORY/cookorder.txt | while read PACKAGE; do
1709 if grep -q ^$PACKAGE$ $tmp/cooklist; then
1710 sed "/^$PACKAGE$/d" -i $tmp/cooklist
1711 echo $PACKAGE >> $tmp/cooklist.tmp
1712 fi
1713 done
1715 # Remaining packages in cooklist are thoses without compile_rules.
1716 # They can be cooked first in any order.
1717 if [ -f $tmp/cooklist.tmp ]; then
1718 cat $tmp/cooklist.tmp >> $tmp/cooklist
1719 rm $tmp/cooklist.tmp
1720 fi
1722 cat $tmp/cooklist
1723 [ "$cooklist" = "$PACKAGES_REPOSITORY/cooklist" ] && \
1724 cat $tmp/cooklist > $cooklist
1725 fi
1727 report end-step
1730 check_for_incoming()
1732 [ -s $INCOMING_REPOSITORY/packages.desc ] || {
1733 echo "No packages in $INCOMING_REPOSITORY."
1734 return; }
1735 if [ -s $PACKAGES_REPOSITORY/broken ]; then
1736 echo "Don't move incoming packages to main repository because theses ones are broken:
1737 $(cat $PACKAGES_REPOSITORY/broken)" >&2
1738 return
1739 fi
1740 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1741 echo "Don't move incoming packages to main repository because some of them need to be cooked:
1742 $(cat $PACKAGES_REPOSITORY/cooklist)" >&2
1743 return
1744 fi
1745 pkg="$(cut -f 1 -d '|' $INCOMING_REPOSITORY/packages.desc)"
1746 if ! [ "$forced" ]; then
1747 cooklist=$PACKAGES_REPOSITORY/cooklist
1748 gen_cook_list
1749 if [ -s $PACKAGES_REPOSITORY/cooklist ]; then
1750 echo "Don't move incoming packages to main repository because some of them need to be cooked." >&2
1751 return
1752 fi
1753 fi
1754 report step "Moving incoming packages to main repository"
1755 unset EXTRAVERSION
1756 for PACKAGE in $pkg; do
1757 prev_VERSION=$(get_pkg_version $PACKAGES_REPOSITORY)
1758 VERSION=$(get_pkg_version $INCOMING_REPOSITORY)
1759 remove_previous_package $PACKAGES_REPOSITORY
1760 remove_previous_tarball
1761 echo "Moving $PACKAGE..."
1762 mv -f $INCOMING_REPOSITORY/$PACKAGE-$VERSION.tazpkg $PACKAGES_REPOSITORY
1763 touch $PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg
1764 done
1765 report end-step
1766 for file in packages.list packages.equiv packages.md5 packages.desc \
1767 packages.txt; do
1768 echo -n "" > $INCOMING_REPOSITORY/$file
1769 done
1770 rm -r $INCOMING_REPOSITORY/files.list.lzma
1771 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
1774 ########################################################################
1775 # TAZWOK MAIN FUNCTIONS
1776 ########################
1778 clean()
1780 cd $WOK/$PACKAGE
1781 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
1782 -e ^stuff$ || return
1784 report step "Cleaning $PACKAGE"
1785 # Check for clean_wok function.
1786 if grep -q ^clean_wok $RECEIPT; then
1787 clean_wok
1788 fi
1789 # Clean should only have a receipt, stuff and optional desc.
1790 for f in `ls .`
1791 do
1792 case $f in
1793 receipt|stuff|description.txt)
1794 continue ;;
1795 *)
1796 echo "Removing: $f"
1797 rm -rf $f
1798 esac
1799 done
1800 report end-step
1803 # Configure and make a package with the receipt.
1804 compile_package()
1806 check_for_package_on_cmdline
1808 # Include the receipt to get all needed variables and functions
1809 # and cd into the work directory to start the work.
1810 check_for_receipt
1811 source_receipt
1813 # Log the package name and date.
1814 echo "date `date +%Y%m%d\ \%H:%M:%S`" >> $LOG
1815 echo "package $PACKAGE (compile)" >> $LOG
1817 # Set wanted $src variable to help compiling.
1818 [ ! "$src" ] && set_src_path
1819 check_for_build_depends || return 1
1820 check_for_wanted
1821 unset target
1822 check_for_tarball && check_for_compile_rules
1825 # Cook command also include all features to manage lists which keep
1826 # track of wok/packages state.
1827 cook()
1829 cook_code=
1830 set_common_path
1831 check_for_receipt
1832 source_receipt
1834 # Define log path and start report.
1835 [ -f $LOCAL_REPOSITORY/log/$PACKAGE.html ] && rm $LOCAL_REPOSITORY/log/$PACKAGE.html
1836 report sublog $LOCAL_REPOSITORY/log/$PACKAGE.html
1837 report step "Cooking $PACKAGE"
1838 report open-bloc
1840 clean $PACKAGE
1841 [ -s $tmp/cooklist ] && sed "/^$PACKAGE$/d" -i $tmp/cooklist
1843 if compile_package; then
1844 remove_src
1845 refresh_packages_from_compile
1846 gen_package
1848 # Update packages-incoming repository.
1849 store_pkgname=$PACKAGE
1850 pkg_repository=$INCOMING_REPOSITORY
1851 update_packages_db
1853 PACKAGE=$store_pkgname
1854 unset store_pkgname
1856 # Upgrade to cooked packages if it was previously installed.
1857 report step "Look for package(s) to upgrade"
1858 for pkg in $(look_for_rwanted) $PACKAGE; do
1859 if [ -d $INSTALLED/$pkg ]; then
1860 tazpkg get-install $pkg --forced
1861 fi
1862 done
1863 report end-step
1864 else
1866 # Set package as broken.
1867 if ! grep -q ^$PACKAGE$ $PACKAGES_REPOSITORY/broken; then
1868 echo $PACKAGE >> $PACKAGES_REPOSITORY/broken
1869 fi
1870 gen_cookmd5
1871 cook_code=1
1872 fi
1874 # Remove build_depends in cook mode (if in cooklist, it's done when
1875 # checking build_depends of next package and we remove only unneeded
1876 # packages to keep chroot minimal and gain some time).
1877 if [ "$COMMAND" = cook ]; then
1878 remove_build_depends $MISSING_PACKAGE
1879 [ -x /usr/bin/clean-chroot ] && clean-chroot
1880 fi
1882 # Regen the cooklist if it was planned and command is not cook.
1883 [ "$regen_cooklist" ] && unset regen_cooklist && \
1884 [ "$COMMAND" != cook ] && sort_cooklist
1886 # Some hacks to set the bloc & function status as failed if cook was
1887 # failed.
1888 report_return_code=$cook_code
1889 report close-bloc
1890 report end-sublog
1891 return $cook_code
1894 cook_list()
1896 if [ -s $tmp/cooklist ]; then
1897 if [ -f /usr/bin/tazchroot ]; then
1898 # Note : options -main variables- are automatically keeped by
1899 # the sub-applications tazchroot/tazwok; as well as report data.
1900 cd $LOCAL_REPOSITORY
1901 [ ! -f tazchroot.conf ] && configure_tazchroot
1902 tazchroot tazwok cook-list --SLITAZ_DIR=$SLITAZ_DIR --SLITAZ_VERSION=$SLITAZ_VERSION ${undigest:+ --undigest=$undigest}
1903 return
1904 fi
1905 while [ -s $tmp/cooklist ]; do
1906 PACKAGE=$(sed 1!d $tmp/cooklist)
1907 cook
1908 done
1909 remove_build_depends $MISSING_PACKAGE $remove_later
1910 [ -x /usr/bin/clean-chroot ] && clean-chroot
1911 else
1912 echo "Nothing to cook."
1913 return
1914 fi
1917 configure_tazchroot()
1919 cat > $LOCAL_REPOSITORY/tazchroot.conf << EOF
1920 # Tazchroot configuration file - created by tazwok.
1922 # Default chroot path
1923 SLITAZ_DIR=$SLITAZ_DIR
1924 SLITAZ_VERSION=$SLITAZ_VERSION
1925 $( [ "$undigest" ] && echo "undigest=$undigest" )
1926 LOCAL_REPOSITORY=$SLITAZ_DIR/$(if [ "$undigest" ]; then echo '$undigest'; else echo '$SLITAZ_VERSION'; fi)
1927 chroot_dir=\$LOCAL_REPOSITORY/chroot
1929 # Default scripts path (theses scripts are added in the
1930 # $chroot_dir/usr/bin and can be called with tazchroot script)
1931 script_dir=/var/lib/tazchroot
1933 # List of directories to mount.
1934 list_dir="$(for dir in packages wok src packages-incoming log flavors iso; do echo $LOCAL_REPOSITORY/$dir; done)
1935 $SLITAZ_LOG$( [ "$undigest" ] && echo -e "\n$SLITAZ_DIR/$SLITAZ_VERSION/packages" )"
1937 create_chroot()
1939 mkdir -p \$chroot_dir
1940 for pkg in \$(tazwok build-depends toolchain --SLITAZ_DIR=\$SLITAZ_DIR --SLITAZ_VERSION=\$SLITAZ_VERSION${undigest:+ --undigest=\$undigest}); do
1941 tazpkg get-install \$pkg --root="\$chroot_dir"
1942 done
1944 # Store list of installed packages needed by cleanchroot.
1945 ls -1 \$chroot_dir/\$INSTALLED > \$chroot_dir/\$LOCALSTATE/chroot-pkgs
1947 sed -e "s~^SLITAZ_DIR=.*~SLITAZ_DIR=\$SLITAZ_DIR~" \\
1948 -e "s/^SLITAZ_VERSION=.*/SLITAZ_VERSION=\$SLITAZ_VERSION/" \\
1949 -i \$chroot_dir/etc/slitaz/slitaz.conf
1950 $( [ "$undigest" ] && echo ' echo "undigest='"$undigest"'" >> $chroot_dir/etc/slitaz/tazwok.conf')
1951 sed 's/LC_ALL/LC_ALL=POSIX/' -i \$chroot_dir/etc/profile
1954 mount_chroot()
1956 cp -a /etc/resolv.conf \$chroot_dir/etc/resolv.conf
1957 echo "\$LOCAL_REPOSITORY/packages" > \$chroot_dir\$LOCALSTATE/mirror
1958 mkdir -p \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming
1959 echo "\$LOCAL_REPOSITORY/packages-incoming" > \$chroot_dir\$LOCALSTATE/undigest/\${LOCAL_REPOSITORY##*/}-incoming/mirror
1960 $( [ "$undigest" ] && echo ' mkdir -p $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION
1961 echo "$SLITAZ_DIR/$SLITAZ_VERSION/packages" > $chroot_dir$LOCALSTATE/undigest/$SLITAZ_VERSION/mirror' )
1962 echo -e "\${LOCAL_REPOSITORY##*/}-incoming\nmain" > \$chroot_dir\$LOCALSTATE/priority
1963 mount -t proc proc \$chroot_dir/proc
1964 mount -t sysfs sysfs \$chroot_dir/sys
1965 mount -t devpts devpts \$chroot_dir/dev/pts
1966 mount -t tmpfs shm \$chroot_dir/dev/shm
1967 for dir in \$list_dir; do
1968 mkdir -p \$dir \$chroot_dir\$dir
1969 mount \$dir \$chroot_dir\$dir
1970 done
1973 umount_chroot()
1975 for dir in \$list_dir; do
1976 umount \$chroot_dir\$dir
1977 done
1978 umount \$chroot_dir/dev/shm
1979 umount \$chroot_dir/dev/pts
1980 umount \$chroot_dir/sys
1981 umount \$chroot_dir/proc
1983 EOF
1986 ########################################################################
1987 ######################### END OF NEW FUNCTIONS #########################
1988 ########################################################################
1990 # List packages providing a virtual package
1991 whoprovide()
1993 local i;
1994 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
1995 . $i
1996 case " $PROVIDE " in
1997 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
1998 esac
1999 done
2002 ########################################################################
2003 # TAZWOK COMMANDS
2004 ########################
2006 case "$COMMAND" in
2007 stats)
2008 # Tazwok general statistics from the wok config file.
2010 get_tazwok_config
2011 echo -e "\n\033[1mTazwok configuration statistics\033[0m
2012 ================================================================================
2013 Wok directory : $WOK
2014 Packages repository : $PACKAGES_REPOSITORY
2015 Incoming repository : $INCOMING_REPOSITORY
2016 Sources repository : $SOURCES_REPOSITORY
2017 Log directory : $LOCAL_REPOSITORY/log
2018 Packages in the wok : `ls -1 $WOK | wc -l`
2019 Cooked packages : `ls -1 $PACKAGES_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2020 Incoming packages : `ls -1 $INCOMING_REPOSITORY/*.tazpkg 2>/dev/null | wc -l`
2021 ================================================================================\n"
2022 ;;
2023 edit)
2024 get_tazwok_config
2025 check_for_package_on_cmdline
2026 check_for_receipt
2027 $EDITOR $WOK/$PACKAGE/receipt
2028 ;;
2029 build-depends)
2030 # List dependencies to rebuild wok, or only a package
2031 get_tazwok_config
2032 report(){ : ; }
2033 if [ "$PACKAGE" = toolchain-cooklist ]; then
2034 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
2035 --cooklist
2036 elif [ ! "$PACKAGE" ] || [ "$PACKAGE" = toolchain ]; then
2037 scan "$SLITAZ_TOOLCHAIN $SLITAZ_TOOLCHAIN_EXTRA" \
2038 --look_for=dep --with_dev --with_args
2039 else
2040 check_for_package_on_cmdline
2041 scan $PACKAGE --look_for=bdep --with_dev
2042 fi
2043 ;;
2044 gen-cooklist)
2045 check_root
2046 get_options_list="pkg"
2047 get_tazwok_config
2048 report(){ : ; }
2049 if ! [ "$pkg" ]; then
2050 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2051 fi
2052 forced=yes
2053 gen_cook_list
2054 ;;
2055 check-depends)
2056 # Check package depends /!\
2057 get_tazwok_config
2058 echo ""
2059 echo -e "\033[1mCheck every receipt for DEPENDS - doesn't scan ELF files\033[0m
2060 ================================================================================"
2061 TMPDIR=/tmp/tazwok$$
2062 DEFAULT_DEPENDS="glibc-base gcc-lib-base"
2064 # Build ALL_DEPENDS variable
2065 scan_dep()
2067 local i
2068 ALL_DEPENDS="$ALL_DEPENDS$PACKAGE "
2069 for i in $DEPENDS $SUGGESTED ; do
2070 case " $ALL_DEPENDS " in
2071 *\ $i\ *) continue;;
2072 esac
2073 [ -d $WOK/$i ] || {
2074 ALL_DEPENDS="$ALL_DEPENDS$i "
2075 continue
2077 DEPENDS=""
2078 SUGGESTED=""
2079 . $WOK/$i/receipt
2080 scan_dep
2081 done
2084 # Check for ELF file
2085 is_elf()
2087 [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" \
2088 = "ELF" ]
2091 # Print shared library dependencies
2092 ldd()
2094 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null
2097 mkdir $TMPDIR
2098 cd $TMPDIR
2099 for i in $LOCALSTATE/files.list.lzma \
2100 $LOCALSTATE/undigest/*/files.list.lzma ; do
2101 [ -f $i ] && lzma d $i -so >> files.list
2102 done
2103 for pkg in $PACKAGES_REPOSITORY/*.tazpkg ; do
2104 tazpkg extract $pkg > /dev/null 2>&1
2105 . */receipt
2106 ALL_DEPENDS="$DEFAULT_DEPENDS "
2107 scan_dep
2108 find */fs -type f | while read file ; do
2109 is_elf $file || continue
2110 case "$file" in
2111 *.o|*.ko|*.ko.gz) continue;;
2112 esac
2113 ldd $file | while read lib rem; do
2114 case "$lib" in
2115 statically|linux-gate.so*|ld-*.so|*/ld-*.so)
2116 continue;;
2117 esac
2118 for dep in $(fgrep $lib files.list | cut -d: -f1); do
2119 case " $ALL_DEPENDS " in
2120 *\ $dep\ *) continue 2;;
2121 esac
2122 for vdep in $(fgrep $dep $LOCALSTATE/packages.equiv | cut -d= -f1); do
2123 case " $ALL_DEPENDS " in
2124 *\ $vdep\ *) continue 3;;
2125 esac
2126 done
2127 done
2128 [ -n "$dep" ] || dep="UNKNOWN"
2129 echo "$(basename $pkg): ${file#*fs} depends on package $dep for the shared library $lib"
2130 done
2131 done
2132 rm -rf */
2133 done
2134 cd /tmp
2135 rm -rf $TMPDIR
2136 ;;
2137 check)
2138 # Check wok consistency
2139 get_tazwok_config
2140 echo ""
2141 echo -e "\033[1mWok and packages checking\033[0m
2142 ================================================================================"
2143 cd $WOK
2144 for pkg in $(ls)
2145 do
2146 [ -f $pkg/receipt ] || continue
2147 RECEIPT= $pkg/receipt
2148 source_receipt
2149 [ "$PACKAGE" = "$pkg" ] || echo "Package $PACKAGE should be $pkg" >&2
2150 [ -n "$VERSION" ] || echo "Package $PACKAGE has no VERSION" >&2
2151 [ -n "$PACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded PACKED_SIZE" >&2
2152 [ -n "$UNPACKED_SIZE" ] && echo "Package $PACKAGE has hardcoded UNPACKED_SIZE" >&2
2153 [ -n "$EXTRAVERSION" ] && echo "Package $PACKAGE has hardcoded EXTRAVERSION" >&2
2154 if [ -n "$WANTED" ]; then
2155 if [ ! -f $WANTED/receipt ]; then
2156 echo "Package $PACKAGE wants unknown $WANTED package" >&2
2157 else
2158 BASEVERSION=$(. $WANTED/receipt ; echo $VERSION)
2159 if [ "$VERSION" = "$WANTED" ]; then
2160 # BASEVERSION is computed in receipt
2161 fgrep -q '_pkg=' $pkg/receipt &&
2162 BASEVERSION=$VERSION
2163 fi
2164 if [ "$VERSION" != "$BASEVERSION" ]; then
2165 echo "Package $PACKAGE ($VERSION) wants $WANTED ($BASEVERSION)" >&2
2166 fi
2167 fi
2168 fi
2170 if [ -n "$CATEGORY" ]; then
2171 case " $(echo $CATEGORIES) " in
2172 *\ $CATEGORY\ *);;
2173 *) echo "Package $PACKAGE has an invalid CATEGORY" >&2;;
2174 esac
2175 else
2176 echo"Package $PACKAGE has no CATEGORY" >&2
2177 fi
2178 [ -n "$SHORT_DESC" ] || echo "Package $PACKAGE has no SHORT_DESC" >&2
2179 [ -n "$MAINTAINER" ] || echo "Package $PACKAGE has no MAINTAINER" >&2
2180 case "$WGET_URL" in
2181 ftp*|http*) busybox wget -s $WGET_URL 2> /dev/null ||
2182 echo "Package $PACKAGE has a wrong WGET_URL" >&2;;
2183 '') ;;
2184 *) echo "Package $PACKAGE has an invalid WGET_URL" >&2;;
2185 esac
2186 case "$WEB_SITE" in
2187 ftp*|http*);;
2188 '') echo "Package $PACKAGE has no WEB_SITE" >&2;;
2189 *) echo "Package $PACKAGE has an invalid WEB_SITE" >&2;;
2190 esac
2191 case "$MAINTAINER" in
2192 *\<*|*\>*) echo "Package $PACKAGE has an invalid MAINTAINER: $MAINTAINER" >&2;;
2193 esac
2194 case "$MAINTAINER" in
2195 *@*);;
2196 *) echo "Package $PACKAGE MAINTAINER is not an email address" >&2;;
2197 esac
2198 MSG="Missing dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2199 for i in $DEPENDS; do
2200 [ -d $i ] && continue
2201 [ -n "$(whoprovide $i)" ] && continue
2202 echo -e "$MSG $i"
2203 MSG=""
2204 done
2205 MSG="Missing build dependencies for $PACKAGE $VERSION$EXTRAVERSION :\n" >&2
2206 for i in $BUILD_DEPENDS; do
2207 [ -d $i ] && continue
2208 [ -n "$(whoprovide $i)" ] && continue
2209 echo -e "$MSG $i"
2210 MSG=""
2211 done
2212 MSG="Dependencies loop between $PACKAGE and :\n"
2213 ALL_DEPS=""
2214 check_for_deps_loop $PACKAGE $DEPENDS
2215 [ -d $WOK/$pkg/taz ] && for i in $BUILD_DEPENDS; do
2216 [ $WOK/$pkg/taz -nt $INSTALLED/$i/files.list ] && continue
2217 echo "$pkg should be rebuilt after $i installation"
2218 done
2219 done
2220 ;;
2221 list)
2222 # List packages in wok directory. User can specify a category.
2224 get_tazwok_config
2225 if [ "$2" = "category" ]; then
2226 echo -e "\033[1m\nPackages categories :\033[0m $CATEGORIES\n"
2227 exit 0
2228 fi
2229 # Check for an asked category.
2230 if [ -n "$2" ]; then
2231 ASKED_CATEGORY=$2
2232 echo ""
2233 echo -e "\033[1mPackages in category :\033[0m $ASKED_CATEGORY"
2234 echo "================================================================================"
2235 for pkg in $WOK/*
2236 do
2237 [ ! -f $pkg/receipt ] && continue
2238 . $pkg/receipt
2239 if [ "$CATEGORY" == "$ASKED_CATEGORY" ]; then
2240 echo -n "$PACKAGE"
2241 echo -e "\033[28G $VERSION"
2242 packages=$(($packages+1))
2243 fi
2244 done
2245 echo "================================================================================"
2246 echo -e "$packages packages in category $ASKED_CATEGORY.\n"
2247 else
2248 # By default list all packages and version.
2249 echo ""
2250 echo -e "\033[1mList of packages in the wok\033[0m"
2251 echo "================================================================================"
2252 for pkg in $WOK/*
2253 do
2254 [ ! -f $pkg/receipt ] && continue
2255 . $pkg/receipt
2256 echo -n "$PACKAGE"
2257 echo -en "\033[28G $VERSION"
2258 echo -e "\033[42G $CATEGORY"
2259 packages=$(($packages+1))
2260 done
2261 echo "================================================================================"
2262 echo -e "$packages packages available in the wok.\n"
2263 fi
2264 ;;
2265 info)
2266 # Information about a package.
2268 get_tazwok_config
2269 check_for_package_on_cmdline
2270 check_for_receipt
2271 . $WOK/$PACKAGE/receipt
2272 echo ""
2273 echo -e "\033[1mTazwok package information\033[0m
2274 ================================================================================
2275 Package : $PACKAGE
2276 Version : $VERSION
2277 Category : $CATEGORY
2278 Short desc : $SHORT_DESC
2279 Maintainer : $MAINTAINER"
2280 if [ ! "$WEB_SITE" = "" ]; then
2281 echo "Web site : $WEB_SITE"
2282 fi
2283 if [ ! "$DEPENDS" = "" ]; then
2284 echo "Depends : $DEPENDS"
2285 fi
2286 if [ ! "$WANTED" = "" ]; then
2287 echo "Wanted src : $WANTED"
2288 fi
2289 echo "================================================================================"
2290 echo ""
2291 ;;
2292 check-log)
2293 # We just cat the file log to view process info.
2295 get_tazwok_config
2296 if [ ! -f "$LOG" ]; then
2297 echo -e "\nNo process log found. The package is probably not cooked.\n" >&2
2298 exit 1
2299 else
2300 echo ""
2301 echo -e "\033[1mPackage process log for :\033[0m $PACKAGE"
2302 echo "================================================================================"
2303 cat $LOG
2304 echo "================================================================================"
2305 echo ""
2306 if [ -s "$WOK/$PACKAGE/warning.txt" ]; then
2307 echo -e "\033[1mCook warning(s) for :\033[0m $PACKAGE"
2308 echo "================================================================================"
2309 cat "$WOK/$PACKAGE/warning.txt"
2310 echo "================================================================================"
2311 echo ""
2312 fi
2313 fi
2314 ;;
2315 search)
2316 # Search for a package by pattern or name.
2318 get_tazwok_config
2319 if [ -z "$2" ]; then
2320 echo -e "\nPlease specify a pattern or a package name to search." >&2
2321 echo -e "Example : 'tazwok search gcc'.\n" >&2
2322 exit 1
2323 fi
2324 echo ""
2325 echo -e "\033[1mSearch result for :\033[0m $2"
2326 echo "================================================================================"
2327 list=`ls -1 $WOK | fgrep $2`
2328 for pkg in $list
2329 do
2330 . $WOK/$pkg/receipt
2331 echo -n "$PACKAGE "
2332 echo -en "\033[24G $VERSION"
2333 echo -e "\033[42G $CATEGORY"
2334 packages=$(($PACKAGEs+1))
2335 done
2336 echo "================================================================================"
2337 echo "$packages packages found for : $2"
2338 echo ""
2339 ;;
2340 compile)
2341 # Configure and make a package with the receipt.
2343 get_tazwok_config
2344 source_lib report
2345 report start
2346 compile_package
2347 ;;
2348 genpkg)
2349 # Generate a package.
2351 get_tazwok_config
2352 source_lib report
2353 report start
2354 gen_package
2355 ;;
2356 cook)
2357 # Compile and generate a package. Just execute tazwok with
2358 # the good commands.
2360 check_root
2361 get_tazwok_config
2362 source_lib report
2363 report start
2364 update_wan_db
2365 check_for_commit
2366 [ "$plan_sort_depdb" ] && sort -o $dep_db $dep_db && unset plan_sort_depdb
2367 [ "$plan_sort_wandb" ] && sort -o $wan_db $wan_db && unset plan_sort_wandb
2368 if [ "$plan_regen_cookorder" ]; then
2369 grep -q "^#" $PACKAGES_REPOSITORY/cookorder.txt || \
2370 sed 1i"#PlanSort" -i $PACKAGES_REPOSITORY/cookorder.txt
2371 fi
2372 cook
2373 ;;
2374 sort-cooklist)
2375 if [ ! "$LIST" ]; then
2376 echo "Usage : tazwok sort-cooklist cooklist" >&2\
2377 exit 1
2378 fi
2379 get_tazwok_config
2380 source_lib report
2381 report start
2382 cooklist=$LIST
2383 sort_cooklist
2384 cp -af $tmp/cooklist $cooklist
2385 ;;
2386 cook-list)
2387 # Cook all packages listed in a file or in default cooklist.
2388 check_root
2389 get_options_list="pkg forced"
2390 get_tazwok_config
2391 source_lib report
2392 report start
2393 if ! [ "$pkg" ]; then
2394 cooklist=${LIST:-$PACKAGES_REPOSITORY/cooklist}
2395 fi
2396 gen_cook_list
2397 cook_list
2398 ;;
2399 clean)
2400 # Clean up a package work directory + thoses which want it.
2402 get_tazwok_config
2403 check_for_package_on_cmdline
2404 check_for_receipt
2405 source_lib report
2406 report start
2407 . $RECEIPT
2408 clean
2409 ;;
2410 gen-clean-wok)
2411 # Generate a clean wok from the current wok by copying all receipts
2412 # and stuff directory.
2414 get_tazwok_config
2415 source_lib report
2416 report start
2417 if [ -z "$ARG" ]; then
2418 echo -e "\nPlease specify the destination for the new clean wok.\n" >&2
2419 exit 1
2420 else
2421 dest=$ARG
2422 mkdir -p $dest
2423 fi
2424 report step "Creating clean wok in : $dest"
2425 for pkg in `ls -1 $WOK`
2426 do
2427 mkdir -p $dest/$pkg
2428 cp -a $WOK/$pkg/receipt $dest/$pkg
2429 [ -f $WOK/$pkg/description.txt ] && \
2430 cp -a $WOK/$pkg/description.txt $dest/$pkg
2431 if [ -d "$WOK/$pkg/stuff" ]; then
2432 cp -a $WOK/$pkg/stuff $dest/$pkg
2433 fi
2434 done
2435 [ -d $WOK/.hg ] && cp -a $WOK/.hg $dest
2436 report end-step
2437 echo "Packages cleaned : `ls -1 $dest | wc -l`"
2438 echo ""
2439 ;;
2440 clean-wok)
2441 # Clean all packages in the work directory
2443 get_tazwok_config
2444 source_lib report
2445 report start
2446 report step "Cleaning wok"
2447 report open-bloc
2448 for PACKAGE in `ls -1 $WOK`
2449 do
2450 set_common_path
2451 source_receipt
2452 clean
2453 done
2454 report close-bloc
2455 echo "`ls -1 $WOK | wc -l` packages cleaned."
2456 ;;
2457 gen-list)
2458 get_tazwok_config
2459 if [ "$2" ]; then
2460 if [ -d "$2" ]; then
2461 pkg_repository=$2
2462 else
2463 echo -e "\nUnable to find directory : $2\n" >&2
2464 exit 1
2465 fi
2466 fi
2468 source_lib report
2469 report start
2470 if [ "$pkg_repository" ]; then
2471 gen_packages_db
2472 else
2473 pkg_repository=$PACKAGES_REPOSITORY && gen_packages_db
2474 pkg_repository=$INCOMING_REPOSITORY && gen_packages_db
2475 fi
2476 ;;
2477 check-list)
2478 # The directory to move into by default is the repository,
2479 # if $2 is not empty cd into $2.
2481 get_tazwok_config
2482 if [ "$2" ]; then
2483 if [ -d "$2" ]; then
2484 pkg_repository=$2
2485 else
2486 echo -e "\nUnable to find directory : $2\n" >&2
2487 exit 1
2488 fi
2489 fi
2491 source_lib report
2492 report start
2493 if [ "$pkg_repository" ]; then
2494 update_packages_db
2495 else
2496 pkg_repository=$PACKAGES_REPOSITORY && update_packages_db
2497 pkg_repository=$INCOMING_REPOSITORY && update_packages_db
2498 fi
2499 ;;
2500 new-tree)
2501 # Just create a few directories and generate an empty receipt to prepare
2502 # the creation of a new package.
2504 get_tazwok_config
2505 check_for_package_on_cmdline
2506 if [ -d $WOK/$PACKAGE ]; then
2507 echo -e "\n$PACKAGE package tree already exists.\n" >&2
2508 exit 1
2509 fi
2510 echo "Creating : $WOK/$PACKAGE"
2511 mkdir $WOK/$PACKAGE
2512 cd $WOK/$PACKAGE
2513 echo -n "Preparing the receipt..."
2515 # Default receipt begin.
2517 echo "# SliTaz package receipt." > receipt
2518 echo "" >> receipt
2519 echo "PACKAGE=\"$PACKAGE\"" >> receipt
2520 # Finish the empty receipt.
2521 cat >> receipt << "EOF"
2522 VERSION=""
2523 CATEGORY=""
2524 SHORT_DESC=""
2525 MAINTAINER=""
2526 DEPENDS=""
2527 TARBALL="$PACKAGE-$VERSION.tar.gz"
2528 WEB_SITE=""
2529 WGET_URL=""
2531 # Rules to configure and make the package.
2532 compile_rules()
2534 cd $src
2535 ./configure && make && make install
2538 # Rules to gen a SliTaz package suitable for Tazpkg.
2539 genpkg_rules()
2541 mkdir -p $fs/usr
2542 cp -a $_pkg/usr/bin $fs/usr
2545 EOF
2547 # Default receipt end.
2549 status
2550 # Interactive mode, asking and seding.
2551 if [ "$3" = "--interactive" ]; then
2552 echo "Entering into interactive mode..."
2553 echo "================================================================================"
2554 echo "Package : $PACKAGE"
2555 # Version.
2556 echo -n "Version : " ; read anser
2557 sed -i s/'VERSION=\"\"'/"VERSION=\"$anser\""/ receipt
2558 # Category.
2559 echo -n "Category : " ; read anser
2560 sed -i s/'CATEGORY=\"\"'/"CATEGORY=\"$anser\""/ receipt
2561 # Short description.
2562 echo -n "Short desc : " ; read anser
2563 sed -i s/'SHORT_DESC=\"\"'/"SHORT_DESC=\"$anser\""/ receipt
2564 # Maintainer.
2565 echo -n "Maintainer : " ; read anser
2566 sed -i s/'MAINTAINER=\"\"'/"MAINTAINER=\"$anser\""/ receipt
2567 # Web site.
2568 echo -n "Web site : " ; read anser
2569 sed -i s#'WEB_SITE=\"\"'#"WEB_SITE=\"$anser\""# receipt
2570 echo ""
2571 # Wget URL.
2572 echo "Wget URL to download source tarball."
2573 echo "Example : \$GNU_MIRROR/\$PACKAGE/\$TARBALL"
2574 echo -n "Wget url : " ; read anser
2575 sed -i s#'WGET_URL=\"\"'#"WGET_URL=\"$anser\""# receipt
2576 # Ask for a stuff dir.
2577 echo -n "Do you need a stuff directory ? (y/N) : " ; read anser
2578 if [ "$anser" = "y" ]; then
2579 echo -n "Creating the stuff directory..."
2580 mkdir stuff && status
2581 fi
2582 # Ask for a description file.
2583 echo -n "Are you going to write a description ? (y/N) : " ; read anser
2584 if [ "$anser" = "y" ]; then
2585 echo -n "Creating the description.txt file..."
2586 echo "" > description.txt && status
2587 fi
2588 echo "================================================================================"
2589 echo ""
2590 fi
2591 ;;
2592 remove)
2593 # Remove a package from the wok.
2595 get_tazwok_config
2596 check_for_package_on_cmdline
2597 echo ""
2598 echo -n "Please confirm deletion (y/N) : "; read anser
2599 if [ "$anser" = "y" ]; then
2600 echo -n "Removing $PACKAGE..."
2601 rm -rf $WOK/$PACKAGE && status
2602 echo ""
2603 fi
2604 ;;
2605 hgup)
2606 # Pull and update a Hg wok.
2607 get_tazwok_config
2608 if ls -l $WOK/.hg/hgrc | fgrep -q "root"; then
2609 check_root
2610 fi
2611 cd $WOK
2612 hg pull && hg update
2613 ;;
2614 maintainers)
2615 get_tazwok_config
2616 echo ""
2617 echo "List of maintainers for: $WOK"
2618 echo "================================================================================"
2619 touch /tmp/slitaz-maintainers
2620 for pkg in $WOK/*
2621 do
2622 . $pkg/receipt
2623 if ! fgrep -q "$MAINTAINER" /tmp/slitaz-maintainers; then
2624 echo "$MAINTAINER" >> /tmp/slitaz-maintainers
2625 echo "$MAINTAINER"
2626 fi
2627 done
2628 echo "================================================================================"
2629 echo "Maintainers: `cat /tmp/slitaz-maintainers | wc -l`"
2630 echo ""
2631 # Remove tmp files
2632 rm -f /tmp/slitaz-maintainers
2633 ;;
2634 maintained-by)
2635 # Search for packages maintained by a contributor.
2636 get_tazwok_config
2637 if [ ! -n "$2" ]; then
2638 echo "Specify a name or email of a maintainer." >&2
2639 exit 1
2640 fi
2641 echo "Maintainer packages"
2642 echo "================================================================================"
2643 for pkg in $WOK/*
2644 do
2645 . $pkg/receipt
2646 if echo "$MAINTAINER" | fgrep -q "$2"; then
2647 echo "$PACKAGE"
2648 packages=$(($PACKAGEs+1))
2649 fi
2650 done
2651 echo "================================================================================"
2652 echo "Packages maintained by $2: $PACKAGEs"
2653 echo ""
2654 ;;
2655 check-src)
2656 # Verify if upstream package is still available
2658 get_tazwok_config
2659 check_for_package_on_cmdline
2660 check_for_receipt
2661 source_receipt
2662 check_src()
2664 for url in $@; do
2665 busybox wget -s $url 2>/dev/null && break
2666 done
2668 if [ "$WGET_URL" ];then
2669 echo -n "$PACKAGE : "
2670 check_src $WGET_URL
2671 status
2672 else
2673 echo "No tarball to check for $PACKAGE"
2674 fi
2675 ;;
2676 get-src)
2677 check_root
2678 get_options_list="target nounpack"
2679 get_tazwok_config
2680 check_for_package_on_cmdline
2681 check_for_receipt
2682 source_receipt
2683 if [ "$WGET_URL" ];then
2684 source_lib report
2685 report start
2686 check_for_tarball
2687 else
2688 echo "No tarball to download for $PACKAGE"
2689 fi
2690 ;;
2691 check-commit)
2692 check_root
2693 get_options_list="missing forced"
2694 get_tazwok_config
2695 source_lib report
2696 report start
2697 if [ "$forced" ]; then
2698 rm -f $WOK/*/md5
2699 unset forced
2700 fi
2701 if [ "$missing" ]; then
2702 pkg=$(ls -1 $WOK)
2703 else
2704 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2705 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2706 } | sort -u)"
2707 fi
2708 cooklist=$PACKAGES_REPOSITORY/cooklist
2709 gen_cook_list
2710 ;;
2711 cook-commit)
2712 check_root
2713 get_options_list="missing forced"
2714 get_tazwok_config
2715 source_lib report
2716 report start
2717 if [ "$forced" ]; then
2718 rm -f $WOK/*/md5
2719 unset forced
2720 fi
2721 if [ "$missing" ]; then
2722 pkg=$(ls -1 $WOK)
2723 else
2724 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2725 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2726 } | sort -u)"
2727 fi
2728 cooklist=$PACKAGES_REPOSITORY/cooklist
2729 gen_cook_list
2730 cook_list
2731 ;;
2732 cook-all)
2733 check_root
2734 get_options_list="forced missing"
2735 get_tazwok_config
2736 source_lib report
2737 report start
2738 if [ "$missing" ]; then
2739 pkg=$(ls -1 $WOK)
2740 else
2741 pkg="$({ grep ^[a-zA-Z0-9] $PACKAGES_REPOSITORY/packages.txt
2742 grep ^[a-zA-Z0-9] $INCOMING_REPOSITORY/packages.txt
2743 } | sort -u)"
2744 fi
2745 cooklist=$PACKAGES_REPOSITORY/cooklist
2746 gen_cook_list
2747 cook_list
2748 ;;
2749 gen-wok-db)
2750 check_root
2751 get_tazwok_config
2752 source_lib report
2753 report start
2754 gen_wok_db
2755 ;;
2756 report)
2757 check_root
2758 get_tazwok_config
2759 cd $PACKAGES_REPOSITORY
2760 if [ "$2" ]; then
2761 case $2 in
2762 commit|cooklist|incoming|broken|blocked)
2763 show="$2"
2764 ;;
2765 *)
2766 echo "usage : tazwok report [commit|cooklist|incoming|broken|blocked]" >&2
2767 exit 1
2768 ;;
2769 esac
2770 else
2771 show="commit cooklist incoming broken blocked"
2772 fi
2773 for i in $show; do
2774 if [ -s $i ]; then
2775 echo ""
2776 echo -e "\033[1m$i\033[0m"
2777 echo "================================================================================"
2778 cat $i
2779 echo "================================================================================"
2780 echo ""
2781 fi
2782 done
2783 ;;
2784 check-incoming)
2785 check_root
2786 get_options_list="forced"
2787 get_tazwok_config
2788 source_lib report
2789 report start
2790 check_for_incoming
2791 ;;
2792 configure-chroot)
2793 check_root
2794 get_tazwok_config
2795 if [ -f /usr/bin/tazchroot ]; then
2796 cd $LOCAL_REPOSITORY
2797 configure_tazchroot
2798 else
2799 echo "The packages tazchroot need to be installed" >&2
2800 exit 1
2801 fi
2802 ;;
2803 chroot)
2804 check_root
2805 get_tazwok_config
2806 # Merge this and the other chroot function ?.
2807 if [ -f /usr/bin/tazchroot ]; then
2808 cd $LOCAL_REPOSITORY
2809 [ ! -f tazchroot.conf ] && configure_tazchroot
2810 tazchroot
2811 else
2812 echo "The packages tazchroot need to be installed" >&2
2813 exit 1
2814 fi
2815 ;;
2816 cook-toolchain)
2817 check_root
2818 get_tazwok_config
2819 echo -n "" > $PACKAGES_REPOSITORY/broken
2820 if [ -f /usr/bin/tazchroot ]; then
2821 cd $LOCAL_REPOSITORY
2822 [ ! -f tazchroot.conf ] && configure_tazchroot
2823 tazchroot cook-toolchain
2824 # Buggy : chroot can be elsewhere.
2825 rm -r $LOCAL_REPOSITORY/chroot
2826 # /!\ to be writed :
2827 # next rm chroot and plan cook-all by pushing all packages
2828 # in cooklist.
2829 else
2830 echo "The packages tazchroot need to be installed" >&2
2831 exit 1
2832 fi
2833 ;;
2834 webserver)
2835 check_root
2836 get_tazwok_config
2837 if [ "$ARG" = on ]; then
2838 if [ "$WEBSERVER" ] && [ -f "$WEBSERVER/repositories.list" ] && \
2839 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
2840 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
2841 exit 1
2842 fi
2843 if ! [ -f $LOCAL_REPOSITORY/tazchroot.conf ]; then
2844 tazwok configure-chroot ${undigest:+--undigest=$undigest} --SLITAZ_VERSION=$SLITAZ_VERSION --SLITAZ_DIR=$SLITAZ_DIR
2845 fi
2846 for pkg in php lighttpd; do
2847 [ -d $INSTALLED/$pkg ] || missing="$missing $pkg"
2848 done
2849 if [ "$missing" ]; then
2850 echo "You need to install those packages to start webserver: $missing." >&2
2851 exit 1
2852 fi
2853 if [ ! -f "$LOCAL_REPOSITORY/tazwok.conf" ]; then
2854 echo "Copying /etc/slitaz/tazwok.conf to $LOCAL_REPOSITORY/tazwok.conf: webserver is configured repository-by-repository."
2855 cp /etc/slitaz/tazwok.conf $LOCAL_REPOSITORY
2856 fi
2857 if ! [ "$WEBSERVER" ]; then
2858 echo -n "Where to store php pages (default: /var/www/vhosts/bb)? "
2859 read WEBSERVER
2860 [ "$WEBSERVER" ] || WEBSERVER="/var/www/vhosts/bb"
2861 fi
2862 if [ -f "$WEBSERVER/repositories.list" ] && \
2863 grep -q ^"${undigest:-$SLITAZ_VERSION}"$ $WEBSERVER/repositories.list; then
2864 echo "Webserver is already enabled at $WEBSERVER for ${undigest:-$SLITAZ_VERSION}." >&2
2865 exit 1
2866 fi
2867 mkdir -p $WEBSERVER
2868 echo "${undigest:-$SLITAZ_VERSION}" >> $WEBSERVER/repositories.list
2869 for file in index.php log.php; do
2870 [ -f "$WEBSERVER/$file" ] || ln -s /usr/share/slitaz/web-bb/$file $WEBSERVER
2871 done
2872 source $LOCAL_REPOSITORY/tazchroot.conf
2873 echo "<?php
2875 // Web interface configuration
2877 \$version=\"${undigest:-$SLITAZ_VERSION}\";
2878 \$chroot=\"$chroot_dir\";
2879 \$lockfile=\"\$chroot/proc/1\";
2880 \$db_dir=\"$PACKAGES_REPOSITORY\";
2881 \$log_dir=\"$LOCAL_REPOSITORY/log\";
2882 \$packages=\"$PACKAGES_REPOSITORY\";
2883 \$incoming=\"$INCOMING_REPOSITORY\";
2885 ?>" > $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
2886 [ -L "$WEBSERVER/web" ] || ln -s /usr/share/slitaz/web $WEBSERVER
2887 echo "WEBSERVER=\"$WEBSERVER\"" >> $LOCAL_REPOSITORY/tazwok.conf
2888 if [ -L "$WEBSERVER/conf.php" ]; then
2889 echo "Do yo want to make ${undigest:-$SLITAZ_VERSION} the default page (y/N) ? "
2890 read answer
2891 if [ "$answer" = y ]; then
2892 rm $WEBSERVER/conf.php
2893 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
2894 fi
2895 else
2896 ln -s $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php $WEBSERVER/conf.php
2897 fi
2898 elif [ "$ARG" = off ]; then
2899 if ! [ "$WEBSERVER" ]; then
2900 echo "No webserver running for ${undigest:-$SLITAZ_VERSION}" >&2
2901 exit 1
2902 fi
2903 sed '/^WEBSERVER/d' -i $LOCAL_REPOSITORY/tazwok.conf
2904 sed "/^${undigest:-$SLITAZ_VERSION}$/d" -i $WEBSERVER/repositories.list
2905 rm $WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php
2906 if ! [ -s "$WEBSERVER/repositories.list" ]; then
2907 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"
2908 rm $WEBSERVER/conf.php
2909 elif [ "$(readlink $WEBSERVER/conf.php)" = "$WEBSERVER/conf-${undigest:-$SLITAZ_VERSION}.php" ]; then
2910 echo "${undigest:-$SLITAZ_VERSION} was the default version to use; switched to : $(sed 1!d $WEBSERVER/repositories.list)"
2911 rm $WEBSERVER/conf.php
2912 ln -s $WEBSERVER/conf-$(sed 1!d $WEBSERVER/repositories.list).php $WEBSERVER/conf.php
2913 fi
2914 else
2915 echo "Usage: tazwok webserver on/off" >&2
2916 exit 1
2917 fi
2918 ;;
2919 usage|*)
2920 # Print usage also for all unknown commands.
2922 usage
2923 ;;
2924 esac
2926 report stop 2>/dev/null || exit 0