tazwok view tazwok @ rev 536

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