tazwok view tazwok @ rev 518

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