cookutils view lib/libcookorder.sh @ rev 551

libmodular.sh: Add some comments.
author Christopher Rogers <slaxemulator@gmail.com>
date Tue Oct 16 16:06:34 2012 +0000 (2012-10-16)
parents ad9af7bfcc78
children 93e95c5212f2
line source
1 #!/bin/sh
3 # Define & create a temporary directory as it's used by report.
4 tmp=/tmp/$(basename $0)-$$
5 mkdir -p $tmp
7 log_command="$0 $@"
9 ########################################################################
10 # EXIT FUNCTIONS
11 ########################
12 # run_on_exit commands are executed when apps exit (whatever the reason)
13 # run_on_kill commands are executed only when apps are killed (or Ctrl+C)
14 # Note : one command per line in the variable.
15 run_on_exit="rm -rf $tmp"
16 run_on_kill=""
17 trap run_on_exit EXIT
18 trap run_on_kill INT KILL
20 run_on_exit()
21 {
22 echo "$run_on_exit" | while read c; do
23 run_on_exit=$(echo "$run_on_exit" | sed 1d)
24 $c
25 done
26 trap - EXIT
27 exit
28 }
30 run_on_kill()
31 {
32 echo "$run_on_kill" | while read c; do
33 run_on_kill=$(echo "$run_on_kill" | sed 1d)
34 $c
35 done
36 trap - INT KILL
37 run_on_exit
38 }
40 # List packages providing a virtual package.
41 whoprovide()
42 {
43 local i;
44 for i in $(fgrep -l PROVIDE $WOK/*/receipt); do
45 . $i
46 case " $PROVIDE " in
47 *\ $1\ *|*\ $1:*) echo $(basename $(dirname $i));;
48 esac
49 done
50 }
52 # Be sure package exists in wok.
53 check_pkg_in_wok() {
54 [ -f $receipt ] && return
55 [ -f $WOK/$(whoprovide $PACKAGE)/receipt ] && return 1
56 gettext -e "\nUnable to find package in the wok:"
57 echo -e " $pkg\n" && exit 1
58 }
60 # rsync wok-hg with wok
61 rsync_wok() {
62 if [ -d "$WOKHG" ]; then
63 echo "Updating build wok"
64 rsync -r -t -l -u --force -v -D -E --delete --exclude-from "/usr/share/cook/exclude.txt" $WOKHG/ $WOK/ | \
65 sed '/^$/'d
66 for i in $(ls $WOK); do
67 [ ! -f $WOKHG/$i/receipt ] || continue
68 if [ -d $WOK/$i ]; then
69 echo "Deleting $i"
70 rm -rf $WOK/$i
71 fi
72 done
73 fi
74 }
76 # Store -- options in a variable.
77 # Test phase.
78 # Need to add something to filter options and report errors in case option is not
79 # listed and used by the command.
80 get_options()
81 {
82 if echo "$log_command" | fgrep -q ' '--help; then
83 echo "Available options for $(echo `basename "$log_command"` | cut -d ' ' -f 1,2) : $get_options_list"
84 exit 0
85 fi
86 for get_option in $(echo "$log_command" | tr ' ' '\n' | grep ^-- | sed 's/^--//'); do
87 if [ "${get_options_list/${get_option%%=*}}" = "$get_options_list" ]; then
88 echo "Option ${get_option%%=*} is incorrect, valid options are : $get_options_list". >&2
89 exit 1
90 fi
91 if [ "$get_option" = "${get_option/=}" ]; then
92 export $get_option=yes
93 export opts="$opts --$get_option"
94 else
95 export $get_option
96 export opts="$opts --$get_option"
97 fi
98 done
99 }
101 # gen_wan_db is to make the wanted.txt
102 gen_wan_db()
103 {
104 local receipt
105 [ -f $wan_db ] && rm $wan_db
106 for receipt in $(grep -l ^WANTED= $WOK/*/receipt); do
107 unset WANTED DEPENDS
108 [ -f $receipt ] || continue
109 source $receipt
110 [ "$WANTED" ] || continue
111 echo -e $PACKAGE"\t"$WANTED >> $wan_db
112 done
113 if [ "$wan_db" = "$INCOMING/wanted.txt" ]; then
114 cp -a $wan_db $PKGS/wanted.txt
115 fi
116 }
118 # gen_dep_db is to make the depends.txt
119 gen_dep_db()
120 {
121 local pkg receipt
122 [ -f $dep_db ] && rm $dep_db
123 for pkg in $(ls $WOK); do
124 unset DEPENDS BUILD_DEPENDS
125 receipt=$WOK/$pkg/receipt
126 if [ -f $receipt ]; then
127 source $receipt
128 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
129 fi
130 done
131 if [ "$dep_db" = "$INCOMING/depends.txt" ]; then
132 cp -a $dep_db $PKGS/depends.txt
133 fi
134 }
136 # gen_wok_db is to create the wok cooklist database
137 # This helps create the wanted.txt, depends.txt and fullco.txt
138 gen_wok_db()
139 {
140 echo "Generating wok database"
141 echo "Removing old files"
142 for file in $wan_db $dep_db $fullco; do
143 [ -f $file ] && rm $file
144 done
145 echo "Generating $(basename $wan_db)"
146 gen_wan_db
147 echo "Generating $(basename $dep_db)"
148 gen_dep_db
149 echo "Generating $(basename $fullco)"
150 sort_db
151 }
153 # look for $PACKAGE in $dep_db
154 look_for_dep()
155 {
156 grep -m1 ^$PACKAGE$'\t' $dep_db | \
157 cut -f 2
158 }
160 # look for all $PACKAGE depends and build depends in $dep_db
161 look_for_all()
162 {
163 grep -m1 ^$PACKAGE$'\t' $dep_db | \
164 cut -f 2,3 | sed 's/ / /'
165 }
167 # same as look_for_all function
168 look_for_bdep()
169 {
170 look_for_all
171 }
173 # reverse depend look up
174 look_for_rdep()
175 {
176 fgrep ' '$PACKAGE' ' $dep_db | cut -f 1
177 }
179 # reverse build depend look up
180 look_for_rbdep()
181 {
182 fgrep ' '$PACKAGE' ' $dep_db | \
183 cut -f 1,3 | fgrep ' '$PACKAGE' ' | cut -f 1
184 }
186 # look for wanted $PACKAGE in wanted.txt
187 look_for_wanted()
188 {
189 grep -m1 ^$PACKAGE$'\t' $wan_db | cut -f 2
190 }
192 # look for reverse wanted $PACKAGE in wanted.txt
193 look_for_rwanted()
194 {
195 for rwanted in $(grep $'\t'$PACKAGE$ $wan_db | cut -f 1); do
196 if [ -f "$WOK/$rwanted/receipt" ]; then
197 echo "$rwanted"
198 fi
199 done
200 }
202 # look for -dev $WANTED packages in wanted.txt
203 look_for_dev()
204 {
205 WANTED=$(look_for_wanted)
206 if [ "$WANTED" ]; then
207 [ -f "$WOK/$WANTED-dev/receipt" ] && echo $WANTED-dev
208 fi
209 [ -f "$WOK/$PACKAGE-dev/receipt" ] && echo $PACKAGE-dev
210 }
212 # make list with $PACKAGE and $PACKAGE-dev
213 with_dev()
214 {
215 for PACKAGE in $(cat); do
216 echo $PACKAGE
217 look_for_dev
218 done
219 }
221 # make list with $PACKAGE and all its wanted receipt
222 with_wanted()
223 {
224 for PACKAGE in $(cat); do
225 echo $PACKAGE
226 look_for_wanted
227 done
228 }
230 use_wanted()
231 {
232 for input in $(cat); do
233 { grep ^$input$'\t' $wan_db || echo $input
234 }
235 done | sed 's/.*\t//'
236 }
238 # We use md5 of cooking stuff in the packaged receipt to check
239 # commit. We look consecutively in 3 different locations :
240 # - in the wok/PACKAGE/taz/* folder
241 # - in the receipt in the package in incoming repository
242 # - in the receipt in the package in packages repository
243 # If md5sums match, there's no commit.
244 check_for_commit_using_md5sum()
245 {
246 if [ ! -f $WOK/$PACKAGE/md5 ]; then
247 sed -n '/# md5sum of cooking stuff :/,$p' receipt | \
248 sed -e 1d -e 's/^# //' > $WOK/$PACKAGE/md5
249 cd $WOK/$PACKAGE
250 fi
252 if [ -s md5 ]; then
253 if md5sum -cs md5; then
254 # If md5sum check if ok, check for new/missing files in
255 # cooking stuff.
256 for file in $([ -f receipt ] && echo receipt; \
257 [ -f description.txt ] && echo description.txt; \
258 [ -d stuff ] && find stuff); do
259 if ! fgrep -q " $file" md5; then
260 set_commited
261 fi
262 done
263 else
264 set_commited
265 fi
266 else
267 set_commited
268 fi
269 }
271 # add changed md5sum receipts to $commits
272 set_commited()
273 {
274 grep -q ^$PACKAGE$ $commits || echo $PACKAGE >> $commits
275 gen_cookmd5
276 update_dep_db
277 }
279 # gen md5 files for receipt and stuff files
280 gen_cookmd5()
281 {
282 # md5sum of cooking stuff make tazwok able to check for changes
283 # without hg.
284 md5sum $WOK/$PACKAGE/receipt > $WOK/$PACKAGE/md5
285 [ -f $WOK/$PACKAGE/description.txt ] && md5sum $WOK/$PACKAGE/description.txt >> $WOK/$PACKAGE/md5
286 if [ -d $WOK/$PACKAGE/stuff ]; then
287 find $WOK/$PACKAGE/stuff -type f | while read file; do
288 md5sum $file >> $WOK/$PACKAGE/md5
289 done
290 fi
291 sed -i "s|$WOK/$PACKAGE/||g" $WOK/$PACKAGE/md5
292 }
294 check_for_commit()
295 {
296 if ! check_pkg_in_wok; then
297 [ "$?" = 2 ] && return 1
298 return
299 fi
300 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
301 RECEIPT=$WOK/$PACKAGE/receipt
302 unset_receipt
303 [ -f $RECEIPT ] || continue
304 source $RECEIPT
306 taz_dir=$(echo $WOK/$PACKAGE/taz/$PACKAGE-* | fgrep -v '*')
307 if [ -f $WOK/$PACKAGE/md5 ]; then
308 cd $WOK/$PACKAGE
309 check_for_commit_using_md5sum
310 elif [ "$taz_dir" ]; then
311 cd $taz_dir
312 check_for_commit_using_md5sum
313 else
314 pkgfile=$(echo $INCOMING/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
315 [ "$pkgfile" ] || pkgfile=$(echo $PKGS/$PACKAGE-$VERSION*.tazpkg | fgrep -v '*')
316 if [ "$pkgfile" ]; then
317 get_pkg_files $pkgfile
318 check_for_commit_using_md5sum
319 rm -r $pkg_files_dir
320 else
321 set_commited
322 fi
323 fi
324 [ "$forced" ] || echo $PACKAGE >> $tmp/checked
325 unset pkgfile
326 done
327 }
329 ########################################################################
330 # SCAN
331 ########################
332 # Use wanted.txt and depeds.txt to scan depends.
333 # Option in command line (must be first arg) :
334 # --look_for=bdep/rbdep - Look for depends or reverse depends.
335 # --with_dev - Add development packages (*-dev) in the result.
336 # --with_wanted - Add package+reverse wanted in the result.
337 # --with_args - Include packages in argument in the result.
339 scan()
340 {
341 # Get packages in argument.
342 local PACKAGE=$PACKAGE WANTED=$WANTED pkg_list=
343 for arg in $@; do
344 [ "$arg" = "${arg#--}" ] || continue
345 pkg_list="$pkg_list $arg"
346 done
348 # Get options.
349 [ "$pkg_list" ] || return
350 local cooklist= look_for= with_dev= with_wanted= with_args= log_command="$0 $@" \
351 get_options_list="look_for with_dev with_wanted with_args cooklist use_wanted"
352 get_options
354 # Get db md5 to be able to check for changes latter.
355 db_md5=$(md5sum $dep_db $wan_db)
357 # Cooklist is a special case where we need to modify a little
358 # scan behavior
359 if [ "$cooklist" ]; then
360 gen_wan_db
361 look_for=all && with_args=yes && with_dev= && with_wanted=
362 filter=use_wanted
363 if [ "$COMMAND" = gen-cooklist ]; then
364 for PACKAGE in $pkg_list; do
365 grep -q ^$PACKAGE$'\t' $dep_db && continue
366 [ -d "$WOK/$p" ] || continue
367 check_for_missing
368 done
369 append_to_dep()
370 {
371 if grep -q ^$PACKAGE$'\t' $dep_db; then
372 echo $PACKAGE >> $tmp/dep
373 else
374 check_for_missing && echo $PACKAGE >> $tmp/dep
375 fi
376 }
377 else
378 append_to_dep()
379 {
380 check_for_commit && echo $PACKAGE >> $tmp/dep
381 }
382 fi
383 else
384 append_to_dep()
385 {
386 echo $PACKAGE >> $tmp/dep
387 }
388 # If requested packages are not in dep_db, partial generation of this db is needed.
389 for PACKAGE in $pkg_list; do
390 grep -q ^$PACKAGE$'\t' $dep_db && continue
391 [ -d "$WOK/$p" ] || continue
392 plan_check_for_missing=yes
393 check_for_missing
394 done
395 if [ "$plan_check_for_missing" ]; then
396 append_to_dep()
397 {
398 if grep -q ^$PACKAGE$'\t' $dep_db; then
399 echo $PACKAGE >> $tmp/dep
400 else
401 check_for_missing && echo $PACKAGE >> $tmp/dep
402 fi
403 }
404 unset plan_check_for_missing
405 fi
406 fi
408 [ "$with_dev" ] && filter=with_dev
409 [ "$with_wanted" ] && filter=with_wanted
410 if [ "$filter" ]; then
411 pkg_list=$(echo $pkg_list | $filter | sort -u)
412 scan_pkg()
413 {
414 look_for_$look_for | $filter
415 }
416 else
417 scan_pkg()
418 {
419 look_for_$look_for
420 }
421 fi
422 touch $tmp/dep
423 for PACKAGE in $pkg_list; do
424 [ "$with_args" ] && append_to_dep
425 scan_pkg
426 done | tr ' ' '\n' | sort -u > $tmp/list
427 [ "$look_for" = bdep ] && look_for=dep
428 while [ -s $tmp/list ]; do
429 PACKAGE=$(sed 1!d $tmp/list)
430 sed 1d -i $tmp/list
431 append_to_dep
432 for pkg in $(scan_pkg); do
433 grep -q ^$pkg$ $tmp/list $tmp/dep || echo $pkg >> $tmp/list
434 done
435 done
436 if [ "$cooklist" ]; then
437 mv $tmp/dep $tmp/cooklist
438 else
439 cat $tmp/dep | sort -u
440 fi
441 rm -f $tmp/dep $tmp/list
442 sort -o $dep_db $dep_db
443 sort -o $wan_db $wan_db
444 if [ "$db_md5" != "$(md5sum $dep_db $wan_db)" ]; then
445 grep -q "^#" $fullco || sed 1i"#PlanSort" -i $fullco
446 fi
447 }
449 # update wanted.txt database
450 update_wan_db()
451 {
452 local PACKAGE=$PACKAGE
453 wanted_list=$(fgrep WANTED=\"$PACKAGE\" $WOK/*/receipt | cut -f1 -d ':')
454 grep $'\t'$PACKAGE$ $wan_db | cut -f 1 | while read wan; do
455 echo "$wanted_list" | fgrep -q $WOK/$wan/receipt && continue
456 sed "/^$wan\t/d" -i $wan_db
457 done
458 for RECEIPT in $wanted_list; do
459 unset WANTED PACKAGE
460 [ -f $RECEIPT ] || continue
461 source $RECEIPT
462 [ "$WANTED" ] || continue
463 sed "/^$PACKAGE\t/d" -i $wan_db
464 echo -e $PACKAGE"\t"$WANTED >> $wan_db
465 done
466 unset wanted_list
467 }
469 # update depends.txt file
470 update_dep_db()
471 {
472 sed "/^$PACKAGE\t/d" -i $dep_db
473 echo -e $PACKAGE"\t "$DEPENDS" \t "$BUILD_DEPENDS' ' >> $dep_db
474 }
476 # create sorted fullco.txt file
477 sort_db()
478 {
479 #echo "Generating full cookorder (fullco)"
480 sed 's/ \t / /' $dep_db | while read PACKAGE BUILD_DEPENDS; do
481 grep -q ^$PACKAGE$'\t' $wan_db && continue
483 # Replace each BUILD_DEPENDS with a WANTED package by it's
484 # WANTED package.
485 echo -e $PACKAGE"\t $(echo $BUILD_DEPENDS | use_wanted | \
486 sort -u | sed "/^$PACKAGE$/d" | tr '\n' ' ') "
487 done > $tmp/db
488 while [ -s "$tmp/db" ]; do
489 status=start
490 for pkg in $(cut -f 1 $tmp/db); do
491 if ! fgrep -q ' '$pkg' ' $tmp/db; then
492 echo $pkg >> $tmp/fullco
493 sed -e "/^$pkg\t/d" -e "s/ $pkg / /g" -i $tmp/db
494 status=proceed
495 fi
496 done
497 if [ "$status" = start ]; then
498 cp -f $tmp/db /tmp/remain-depends.txt
499 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
500 for remaining in $(cut -f 1 $tmp/db); do
501 if ! grep -q ^$remaining $blocked; then
502 echo "$remaining" >> $blocked
503 fi
504 done
505 break
506 fi
507 done
508 [ -s $tmp/fullco ] || touch $tmp/fullco
510 # The toolchain packages are moved in first position.
511 grep $(for pkg in `scan "$TOOLCHAIN $TOOLCHAIN_EXTRA" \
512 --look_for=all --with_args`; do echo " -e ^$pkg$"; done) \
513 $tmp/fullco | tac > $fullco
514 for pkg in $(cat $fullco); do
515 sed "/^$pkg$/d" -i $tmp/fullco
516 done
518 tac $tmp/fullco >> $fullco
519 }
521 # check for missing $PACKAGE in wok
522 # used in scan function only
523 check_for_missing()
524 {
525 local PACKAGE=$PACKAGE
526 if ! check_pkg_in_wok; then
527 [ "$?" = 2 ] && return 1
528 return
529 fi
530 RECEIPT=$WOK/$PACKAGE/receipt
531 [ -f $RECEIPT ] || continue
532 source $RECEIPT
533 PACKAGE=${WANTED:-$PACKAGE}
534 update_wan_db
535 for PACKAGE in $(look_for_rwanted) $PACKAGE; do
536 RECEIPT=$WOK/$PACKAGE/receipt
537 [ -f $RECEIPT ] || continue
538 source $RECEIPT
539 update_dep_db
540 done
541 }
543 # look to see if package is missing in
544 # $INCOMING/packages.txt and $PKGS/packages.txt
545 look_for_missing_pkg()
546 {
547 for pkg in $(cat $1); do
548 grep -q ^$pkg$ $INCOMING/packages.txt \
549 $PKGS/packages.txt || \
550 continue
551 echo $pkg
552 done
553 }
555 # Output $VERSION-$EXTRAVERSION using packages.txt
556 get_pkg_version()
557 {
558 [ "$PACKAGE" ] || return
559 grep -m1 -A1 -sh ^$PACKAGE$ $1/packages.txt | tail -1 | sed 's/ *//'
560 }
562 # remove previous package
563 remove_previous_package()
564 {
565 if [ "$prev_VERSION" ] && [ "$VERSION$EXTRAVERSION" != "$prev_VERSION" ]; then
566 rm -f $1/$PACKAGE-$prev_VERSION.tazpkg
567 fi
568 return 0
569 }
571 # create cook list
572 gen_cook_list()
573 {
574 #echo "Scanning wok"
575 if [ "$pkg" ]; then
576 scan $pkg --cooklist
577 elif [ "$LIST" ]; then
578 scan `cat $LIST` --cooklist
579 else
580 scan `cat $cooklist` --cooklist
581 fi
583 [ -s $tmp/checked ] || [ -s $tmp/cooklist ] || return
585 # Core toolchain should not be cooked unless cook-toolchain is used.
586 if [ "$COMMAND" != "toolchain" ] ; then
587 for PACKAGE in $(scan slitaz-toolchain --look_for=all --with_args --with_wanted); do
588 grep -q ^$PACKAGE$ $blocked || \
589 echo $PACKAGE >> $blocked
590 done
591 fi
593 if [ -s $commits ] && [ "$COMMAND" != gen-cooklist ]; then
594 for PACKAGE in $(cat $commits); do
595 WANTED="$(look_for_wanted)"
596 if [ "$WANTED" ]; then
597 grep -q ^$WANTED$ $broken $cooklist $blocked $commits && continue
598 fi
599 grep -q ^$PACKAGE$ $blocked $cooklist && continue
600 echo $PACKAGE >> $cooklist
601 done
602 fi
603 sort_cooklist
604 }
606 # sort cooklist
607 sort_cooklist()
608 {
609 if [ "$(sed 1!d $fullco)" = "#PlanSort" ]; then
610 sed 1d -i $fullco
611 sort_db
612 fi
613 #echo "Generating cooklist"
614 if [ -f "$tmp/checked" ]; then
615 rm -f $tmp/cooklist
616 cat $tmp/checked | while read PACKAGE; do
617 grep -q ^$PACKAGE$ $cooklist && echo $PACKAGE >> $tmp/cooklist
618 done
619 elif ! [ "$COMMAND" = gen-cooklist ]; then
620 cat $blocked | while read PACKAGE; do
621 sed "/^$PACKAGE/d" -i $tmp/cooklist
622 done
623 fi
624 [ -s $tmp/cooklist ] || return
626 #echo "Sorting cooklist"
627 for PACKAGE in $(cat $tmp/cooklist); do
628 WANTED="$(look_for_wanted)"
629 [ "$WANTED" ] || continue
630 if grep -q ^$WANTED$ $broken $tmp/cooklist; then
631 sed "/^$PACKAGE$/d" -i $tmp/cooklist
632 elif [ ! -d $WOK/$WANTED/install ]; then
633 sed "/^$PACKAGE$/d" -i $tmp/cooklist
634 echo $WANTED >> $tmp/cooklist
635 fi
636 done
638 # Use cookorder.txt to sort cooklist.
639 if [ -s $tmp/cooklist ]; then
640 cat $fullco | while read PACKAGE; do
641 if grep -q ^$PACKAGE$ $tmp/cooklist; then
642 sed "/^$PACKAGE$/d" -i $tmp/cooklist
643 echo $PACKAGE >> $tmp/cooklist.tmp
644 fi
645 done
647 # Remaining packages in cooklist are those without compile_rules.
648 # They can be cooked first in any order.
649 if [ -f $tmp/cooklist.tmp ]; then
650 cat $tmp/cooklist.tmp >> $tmp/cooklist
651 rm $tmp/cooklist.tmp
652 fi
654 cat $tmp/cooklist
655 [ "$LIST" ] || cat $tmp/cooklist > $cooklist
656 fi
657 }
659 # Check $COOK_OPT; usage : get_cookopt particular_opt
660 # Return error if not found
661 # Return args if the opt is in the format opt=arg1:arg2:etc
662 look_for_cookopt()
663 {
664 for arg in $COOK_OPT; do
665 case $arg in
666 $1=*)
667 arg=${arg#$1=}
668 while [ "$arg" ]; do
669 echo "${arg%%:*}"
670 [ "${arg/:}" = "$arg" ] && return
671 arg=${arg#*:}
672 done
673 ;;
674 $1)
675 return
676 ;;
677 esac
678 done
679 return 1
680 }
682 # check $INCOMING packages into $PKGS
683 check_for_incoming()
684 {
685 echo "Checking that all packages were cooked OK"
686 [ -s $INCOMING/packages.desc ] || {
687 echo "No packages in $INCOMING."
688 return; }
689 if [ -s $broken ]; then
690 missingpkg=$(look_for_missing_pkg $broken)
691 if [ "$missingpkg" ]; then
692 echo "Don't move incoming packages to main repository because these ones are broken:" >&2
693 echo "$missingpkg"
694 return 1
695 fi
696 fi
697 if [ -s $cooklist ]; then
698 missingpkg=$(look_for_missing_pkg $cooklist)
699 if [ "$missingpkg" ]; then
700 echo "Don't move incoming packages to main repository because these ones need to be cooked:" >&2
701 echo "$missingpkg"
702 return 1
703 fi
704 fi
705 incoming_pkgs="$(cut -f 1 -d '|' $INCOMING/packages.desc)"
706 if ! [ "$forced" ]; then
707 cooklist=$CACHE/cooklist
708 pkg="$incoming_pkgs"
709 gen_cook_list
710 if [ -s $cooklist ]; then
711 missingpkg=$(look_for_missing_pkg $cooklist)
712 if [ "$missingpkg" ]; then
713 echo "Don't move incoming packages to main repository because these ones need to be cooked:" >&2
714 echo "$missingpkg"
715 return 1
716 fi
717 fi
718 fi
720 echo "Moving incoming packages to main repository"
721 unset EXTRAVERSION
722 for PACKAGE in $incoming_pkgs; do
723 prev_VERSION=$(get_pkg_version $PKGS)
724 VERSION=$(get_pkg_version $INCOMING)
725 if [ -f $INCOMING/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg ]; then
726 remove_previous_package $PKGS
727 echo "Moving $PACKAGE..."
728 mv -f $INCOMING/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg $PKGS
729 touch $PKGS/$PACKAGE-${VERSION}${EXTRAVERSION}.tazpkg
730 else
731 echo "$PACKAGE doesn't exist"
732 fi
733 if [ "$AUTO_PURGE_SRC" ]; then
734 previous_tarball=$(grep ^$PACKAGE:main $SRC/sources.list | cut -f2)
735 sed -e "/^$PACKAGE:main/d" \
736 -e "s/^$PACKAGE:incoming/$PACKAGE:main/" \
737 -i $SRC/sources.list
738 if [ "$previous_tarball" ]; then
739 grep -q $'\t'$previous_tarball$ $SRC/sources.list || \
740 rm -f $SRC/$previous_tarball
741 fi
742 fi
743 done
744 for file in packages.list packages.equiv packages.md5 packages.desc \
745 packages.txt; do
746 echo -n "" > $INCOMING/$file
747 done
748 [ -f "$INCOMING/files.list.lzma" ] && rm -r $INCOMING/files.list.lzma
749 pkg_repository=$PKGS && gen_packages_db
751 }
753 # help gen sources.list file from scranch
754 gen_sources_list()
755 {
756 local src_repository=$1
757 [ -f $src_repository/sources.list ] && rm -f $src_repository/sources.list
758 for i in $WOK/*; do
759 unset PACKAGE SOURCE KBASEVER VERSION WGET_URL TARBALL WANTED
760 [ -f $i/receipt ] && source $i/receipt
761 [ "$WGET_URL" ] || continue
762 if grep -q "^$PACKAGE | $VERSION" $PKGS/packages.desc; then
763 main_version="$VERSION"
764 if [ -f $src_repository/${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}.tar.lzma ]; then
765 echo -e "$PACKAGE:main\t${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}.tar.lzma" >> $src_repository/sources.list
766 elif [ -f "$src_repository/$TARBALL" ]; then
767 echo -e "$PACKAGE:main\t$TARBALL" >> $src_repository/sources.list
768 fi
769 else
770 # May not works if package use extraversion.
771 main_version=$(grep -m1 -A1 -sh ^$PACKAGE$ $PKGS/packages.txt | tail -1 | sed 's/ *//')
772 if [ -f $src_repository/${SOURCE:-$PACKAGE}-${KBASEVER:-$main_version}.tar.lzma ]; then
773 echo -e "$PACKAGE:main\t${SOURCE:-$PACKAGE}-${KBASEVER:-$main_version}.tar.lzma" >> $src_repository/sources.list
774 else
775 unset main_version
776 fi
777 fi
778 if [ ! "$main_version" ] || [ $(grep -q "^$PACKAGE | $VERSION" $INCOMING/packages.desc 2>/dev/null) ]; then
779 if [ -f $src_repository/${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}.tar.lzma ]; then
780 echo -e "$PACKAGE:incoming\t${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}.tar.lzma" >> $src_repository/sources.list
781 elif [ -f "$src_repository/$TARBALL" ]; then
782 echo -e "$PACKAGE:incoming\t$TARBALL" >> $src_repository/sources.list
783 fi
784 fi
785 done
786 }
788 # get package files for building libraries.txt, files.list.lzma, and packages.desc
789 get_pkg_files()
790 {
791 pkg_files_dir=/tmp/cook/$(basename ${1%.tazpkg})
792 mkdir -p $pkg_files_dir && \
793 cd $pkg_files_dir && \
794 cpio --quiet -idm receipt < $1 2>/dev/null && \
795 cpio --quiet -idm files.list < $1 2>/dev/null && \
796 cpio --quiet -idm library.list < $1 2>/dev/null
797 }
799 # check .so files
800 check_so_files()
801 {
802 pwd=$(pwd)
803 for rep in $PKGS $INCOMING; do
804 prev_VERSION=$(get_pkg_version $rep)
805 [ "$prev_VERSION" ] && pkg_file=$rep/$PACKAGE-$prev_VERSION.tazpkg && break
806 done
807 if [ "$pkg_file" ]; then
808 gettext -e "Looking for major/minor updates in libraries\n"
809 get_pkg_files $pkg_file
810 if [ -d $WOK/$PACKAGE/taz/$PACKAGE-${VERSION}${EXTRAVERSION} ]; then
811 cd $WOK/$PACKAGE/taz/$PACKAGE-${VERSION}${EXTRAVERSION}
812 else
813 cd $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
814 fi
816 pkg_to_check=$(diff $pkg_files_dir/files.list files.list | \
817 grep '^-/.*\.so' | while read lib; do
818 pkg=$(fgrep " ${lib##*/} " $lib_db | cut -f1)
819 for i in $pkg; do
820 [ -f $WOK/$i/receipt ] || continue
821 wanted=$(grep ^WANTED= $WOK/$i/receipt | cut -d "=" -f2 | sed -e 's/"//g')
822 if [ "$wanted" ]; then
823 echo $wanted
824 else
825 echo $i
826 fi
827 done
828 done | sort -u)
830 if [ "$pkg_to_check" ]; then
831 for rdep in $(scan $PACKAGE --look_for=rdep | use_wanted); do
832 echo "$pkg_to_check" | grep -q ^$rdep$ || continue
833 [ "$rdep" = "${WANTED:-$PACKAGE}" ] && continue
834 grep -q ^$rdep$ $blocked $cooklist && continue
835 echo "Plan to recook $rdep"
836 echo $rdep >> $cooklist
837 regen_cooklist=yes
838 done
839 fi
840 update_lib_db
841 rm -r $pkg_files_dir
842 unset pkg_file pkg_file_dir pkg_to_check
843 cd $pwd
844 else
845 if [ -d $WOK/$PACKAGE/taz/$PACKAGE-${VERSION}${EXTRAVERSION} ]; then
846 cd $WOK/$PACKAGE/taz/$PACKAGE-${VERSION}${EXTRAVERSION}
847 else
848 cd $WOK/$PACKAGE/taz/$PACKAGE-$VERSION
849 fi
850 update_lib_db
851 cd $pwd
852 fi
853 }
855 # check recook reverse depends
856 check_recook_rdeps()
857 {
858 # Recook of reverse-depends if package was broken.
859 if grep -q "^$PACKAGE$" $broken; then
860 echo "Planning a re-try cook of reverse depends"
861 sed "/^$PACKAGE$/d" -i $broken
862 for rdep in $(look_for_rdep); do
863 grep -q "^$rdep$" $broken || continue
864 grep -q "^$rdep$" $cooklist && continue
865 echo "Adding $rdep to the cooklist"
866 echo $rdep >> $cooklist
867 regen_cooklist=t
868 done
869 fi
870 sed "/^$PACKAGE$/d" -i $commits
871 sed "/^$PACKAGE$/d" -i $cooklist
872 }
874 # remove source folder
875 remove_src()
876 {
877 [ "$WANTED" ] && return
878 look_for_cookopt !remove_src && return
880 # Don't remove sources if a package uses src variable in its
881 # genpkg_rules: it maybe needs something inside.
882 for i in $PACKAGE $(look_for_rwanted); do
883 sed -n '/^genpkg_rules\(\)/','/^}/'p $WOK/$i/receipt | \
884 fgrep -q '$src' && gettext -e "Sources will not be removed \
885 because $i uses \$src in its receipt.\n" && return
886 done
888 gettext -e "Removing sources directory"
889 echo ""
890 rm -fr "$src"
891 [ -d $WOK/$PACKAGE/source ] && rm -rf $WOK/$PACKAGE/source
892 }
894 # check for varable modification
895 check_for_var_modification()
896 {
897 for var in $@; do
898 for pkg in $PACKAGE $(look_for_wanted) $(look_for_rwanted); do
899 [ -f $WOK/$pkg/receipt ] || continue
900 fgrep -q "$var=" $WOK/$pkg/receipt && return 1
901 done
902 done
904 # Tweak to make if; then...; fi function working with this one.
905 echo -n ""
906 }
908 # clean $WOK/$PACKAGE folder
909 clean()
910 {
911 cd $WOK/$PACKAGE
912 ls -A $WOK/$PACKAGE | grep -q -v -e ^receipt$ -e ^description.txt$ \
913 -e ^stuff$ || return
915 [ "$COMMAND" = clean-wok ] || echo "Cleaning $PACKAGE"
916 # Check for clean_wok function.
917 if grep -q ^clean_wok $RECEIPT; then
918 clean_wok
919 fi
920 # Clean should only have a receipt, stuff and optionals desc/md5.
921 for f in `ls .`
922 do
923 case $f in
924 receipt|stuff|description.txt|md5)
925 continue ;;
926 *)
927 rm -rf $f ;;
928 esac
929 done
930 }
932 # put $PACKAGE in $broken file if not already there
933 set_pkg_broken()
934 {
935 grep -q ^$PACKAGE$ $broken || echo $PACKAGE >> $broken
937 # Remove pkg from cooklist to avoid re-cook it if no changes happen
938 # in the cook stuff.
939 sed "/^$PACKAGE$/d" -i $cooklist $commits
941 gen_cookmd5
943 # Return 1 to make report know that its mother-function failed.
944 return 1
945 }
947 # Log broken packages.
948 broken() {
949 unset cook_code
950 for PACKAGE in $(look_for_wanted) $PACKAGE; do
951 set_pkg_broken
952 done
953 cook_code=1
954 }
956 # start package database
957 packages_db_start()
958 {
959 if [ ! -s packages.txt ]; then
960 echo "# SliTaz GNU/Linux - Packages list
961 #
962 # Packages : unknown
963 # Date : $(date +%Y-%m-%d\ \%H:%M:%S)
964 #
965 " > packages.txt
966 else
967 sed -e 's/^# Packages :.*/# Packages : unknown/' \
968 -e "s/# Date :.*/# Date : $(date +%Y-%m-%d\ \%H:%M:%S)/" \
969 -i packages.txt
970 fi
972 # If $packages_repository is the main one, configure few functions
973 # to act as they should, without having loop on them (speed-up)
974 if [ "$pkg_repository" = "$PKGS" ]; then
975 erase_package_info_extracmd="erase_package_info_main"
976 get_packages_info_extracmd="get_packages_info_main"
977 fi
978 }
980 # erase previous package info
981 erase_package_info()
982 {
983 cd $pkg_repository
984 sed "/^$PACKAGE$/,/^$/d" -i packages.txt
985 sed "/^$PACKAGE /d" -i packages.desc
986 sed -e "s/=$PACKAGE /= /" -e "s/ $PACKAGE / /" -e "s/ $PACKAGE$//" \
987 -e "/=$PACKAGE$/d" -e "s/=[0-9,a-z,A-Z]:$PACKAGE /= /" \
988 -e "s/ [0-9,a-z,A-Z]:$PACKAGE / /" -e "s/ [0-9,a-z,A-Z]:$PACKAGE$/ /" \
989 -e "/=[0-9,a-z,A-Z]:$PACKAGE$/d" \
990 -i packages.equiv
991 sed "/^$PACKAGE:/d" -i files.list
992 sed "/^$(basename ${pkg%.tazpkg})$/d" -i packages.list
993 sed "/ $(basename $pkg)$/d" -i packages.$SUM
994 $erase_package_info_extracmd
995 }
997 # make the end of the package database
998 packages_db_end()
999 {
1000 cd $pkg_repository
1001 pkgs=$(wc -l packages.list | sed 's/ .*//')
1002 sed "s/# Packages : .*/# Packages : $pkgs/" -i packages.txt
1004 # If lists were updated it's generally needed to sort them well.
1005 echo "Sorting packages lists"
1006 files_list="packages.list packages.desc packages.equiv wanted.txt depends.txt libraries.txt"
1007 for file in $files_list; do
1008 [ -f $file ] || continue
1009 sort -o $file $file
1010 done
1012 $CHECKSUM packages.$SUM | cut -f1 -d' ' > ID
1013 [ -s ID ] || echo null > ID
1015 # Dont log this because lzma always output errors.
1016 lzma e files.list files.list.lzma
1017 rm -f files.list
1018 [ -f packages.equiv ] || touch packages.equiv
1021 # get packages info
1022 get_packages_info()
1024 # If there's no taz folder in the wok, extract info from the
1025 # package.
1026 get_pkg_files $pkg
1027 unset_receipt
1028 . $pkg_files_dir/receipt
1030 #[ "$COMMAND" = "check-incoming" ] && gettext -e "Getting data from ${PACKAGE} \n"
1032 cat >> $pkg_repository/packages.txt << _EOT_
1033 $PACKAGE
1034 $VERSION$EXTRAVERSION
1035 $SHORT_DESC
1036 _EOT_
1037 if [ "$PACKED_SIZE" ]; then
1038 cat >> $pkg_repository/packages.txt << _EOT_
1039 $PACKED_SIZE ($UNPACKED_SIZE installed)
1041 _EOT_
1042 else
1043 echo "" >> $pkg_repository/packages.txt
1044 fi
1046 # Packages.desc is used by Tazpkgbox <tree>.
1047 echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
1049 # Packages.equiv is used by tazpkg install to check depends.
1050 for i in $PROVIDE; do
1051 DEST=""
1052 echo $i | fgrep -q : && DEST="${i#*:}:"
1053 if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
1054 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
1055 else
1056 echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
1057 fi
1058 done
1060 if [ -f files.list ]; then
1061 { echo "$PACKAGE"; cat files.list; } | awk '
1062 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
1063 fi
1065 if [ -f library.list ]; then
1066 sed "/^$PACKAGE\t/d" -i $pkg_repository/libraries.txt
1067 cat library.list >> $pkg_repository/libraries.txt
1068 fi
1070 cd .. && rm -r "$pkg_files_dir"
1072 cd $pkg_repository
1073 echo $(basename ${pkg%.tazpkg}) >> packages.list
1074 $CHECKSUM $(basename $pkg) >> packages.$SUM
1075 $get_packages_info_extracmd
1078 # gen packages database
1079 gen_packages_db()
1081 [ "$pkg_repository" ] || pkg_repository=$PKGS
1082 cd $pkg_repository
1083 gettext -e "Generating packages lists: $pkg_repository\n"
1084 gettext -e "Removing old files\n"
1085 for file in files.list.lzma packages.list packages.txt \
1086 packages.desc packages.equiv packages.$SUM; do
1087 [ -f $file ] && rm $file
1088 done
1089 touch files.list
1090 [ -f libraries.txt ] && rm -f libraries.txt
1091 if [ "$pkg_repository" == "$INCOMING" ]; then
1092 if [ -f "$PKGS/libraries.txt" ]; then
1093 cp -a $PKGS/libraries.txt $INCOMING/libraries.txt
1094 fi
1095 fi
1096 touch libraries.txt
1097 touch depends.txt
1098 touch wanted.txt
1100 packages_db_start
1101 unset_receipt
1102 gettext -e "Reading data from all packages\n"
1103 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1104 get_packages_info
1105 done
1106 packages_db_end
1109 # update package database
1110 update_packages_db()
1112 [ "$pkg_repository" ] || pkg_repository=$PKGS
1113 cd $pkg_repository
1114 for file in packages.list packages.equiv packages.$SUM \
1115 packages.desc packages.txt; do
1116 if [ ! -f "$file" ]; then
1117 gen_packages_db
1118 return
1119 fi
1120 done
1121 if [ -f files.list.lzma ]; then
1122 lzma d files.list.lzma files.list
1123 else
1124 gen_packages_db
1125 return
1126 fi
1127 gettext -e "Updating packages lists: $pkg_repository\n"
1128 echo ""
1129 packages_db_start
1131 # Look for removed/update packages.
1132 touch stamp -r packages.list
1133 for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
1134 pkg="$pkg_repository/$(grep -m1 ^$PACKAGE- packages.list).tazpkg"
1135 if [ ! -f "$pkg" ]; then
1136 erase_package_info
1137 else
1138 if [ "$pkg" -nt "stamp" ]; then
1139 updated_pkg="$updated_pkg
1140 $PACKAGE $pkg"
1141 elif [ ! -f $WOK/$PACKAGE/receipt ] && \
1142 [ "$COMMAND" = check-incoming -o "$pkg_repository" = "$INCOMING" ]; then
1143 erase_package_info
1144 gettext -e "Removing $PACKAGE from $pkg_repository.\n"
1145 rm $pkg
1146 if [ "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
1147 [ -d $WOK/$PACKAGE ] && rm -r $WOK/$PACKAGE
1148 sed "/^$PACKAGE\t/d" -i $wan_db $dep_db
1149 for i in $fullco $cookorder $cooklist $commits $blocked $broken; do
1150 sed "/^$PACKAGE$/d" -i $i
1151 done
1152 [ -f $LOGS/$pkg.log ] && rm -f $LOGS/$pkg.log
1153 if [ "$(sed 1!d $fullco)" != "#PlanSort" ]; then
1154 sed 1i"#PlanSort" -i $fullco
1155 regen_cooklist=yes
1156 fi
1157 else
1158 echo "$PACKAGE" >> $CACHE/removed
1159 sed -n '1,10p' -i $CACHE/removed
1160 fi
1161 fi
1162 fi
1163 done
1164 rm stamp
1165 echo "$updated_pkg" | sed 1d | while read PACKAGE pkg; do
1166 erase_package_info
1167 get_packages_info
1168 done
1169 unset updated_pkg
1171 # Look for new packages.
1172 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1173 if ! fgrep -q " ${pkg##*/}" packages.$SUM; then
1174 get_packages_info
1175 fi
1176 done
1177 packages_db_end
1180 # make package database
1181 # $1 = incoming/packages or the folder of the package repo
1182 pkgdb()
1184 case "$1" in
1185 incoming)
1186 PKGSDB="incoming" ;;
1187 packages)
1188 PKGSDB="packages" ;;
1189 *)
1190 [ "$1" ] && PKGSDB="$1"
1191 [ ! -d "$PKGSDB" ] && \
1192 gettext -e "\nPackages directory doesn't exist\n\n" && exit 1 ;;
1193 esac
1194 time=$(date +%s)
1195 echo "cook:pkgdb" > $command
1196 echo "Cook pkgdb: Creating all packages lists" | log
1197 echo ""
1198 gettext "Creating lists for: "; echo "$PKGSDB"
1199 separator
1200 gettext "Cook pkgdb started: "; date "+%Y-%m-%d %H:%M"
1201 if [ "$PKGSDB" = packages ]; then
1202 # Packages package db
1203 pkg_repository=$PKGS && gen_packages_db
1204 nb=$(ls $PKGS/*.tazpkg | wc -l)
1205 time=$(($(date +%s) - $time))
1206 echo -e "Packages: $nb - Time: ${time}s\n"
1207 elif [ "$PKGSDB" = incoming ]; then
1208 # Incoming package db
1209 pkg_repository=$INCOMING && gen_packages_db
1210 nb=$(ls $INCOMING/*.tazpkg | wc -l)
1211 time=$(($(date +%s) - $time))
1212 echo -e "Packages: $nb - Time: ${time}s\n"
1213 elif [ -d "$PKGSDB" ]; then
1214 # User path for package db
1215 pkg_repository=$PKGSDB && gen_packages_db
1216 nb=$(ls $PKGSDB/*.tazpkg | wc -l)
1217 time=$(($(date +%s) - $time))
1218 echo -e "Packages: $nb - Time: ${time}s\n"
1219 else
1220 pkg_repository=$PKGS && gen_packages_db
1221 nb=$(ls $PKGS/*.tazpkg | wc -l)
1222 time=$(($(date +%s) - $time))
1223 echo -e "Packages: $nb - Time: ${time}s\n"
1224 pkg_repository=$INCOMING && gen_packages_db
1225 incoming_nb=$(ls $INCOMING/*.tazpkg | wc -l)
1226 time=$(($(date +%s) - $time))
1227 echo -e "Incoming: $incoming_nb - Time: ${time}s\n"
1228 fi
1230 echo "" && rm -f $command
1233 # clean chroot
1234 clean_chroot()
1236 # Remove packages which was not in the chroot at creation time.
1237 if [ -f "$CACHE/chroot-pkgs" ]; then
1238 for pkg in $(ls ${root}${INSTALLED}); do
1239 [ -f ${root}${INSTALLED}/$pkg/receipt ] || continue
1240 [ "$(grep ^$pkg$ $CACHE/chroot-pkgs)" ] || tazpkg remove $pkg --auto --root=$root
1241 done
1243 for pkg in $(ls ${root}${INSTALLED}); do
1244 if [ -d ${root}${INSTALLED}/$pkg -a ! -f ${root}${INSTALLED}/$pkg/receipt ]; then
1245 echo "empty: $pkg"
1246 rm -rf ${root}${INSTALLED}/$pkg
1247 fi
1248 done
1250 for pkg in $(cat $CACHE/chroot-pkgs); do
1251 if [ ! -d ${root}${INSTALLED}/$pkg ]; then
1252 echo "Reinstalling $pkg"
1253 tazpkg get-install $pkg --root=$root --forced
1254 fi
1255 done
1256 fi
1259 # update library database file
1260 update_lib_db()
1262 # Update lib_db
1263 libs=$(for file in $(find * -type f -not -name "*.o" -not -name "*.ko" -not -name "*.a"); do
1264 [ "$(dd if=$file bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ] || continue
1265 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $PWD/$file
1266 done | { cut -f 1 -d ' ' | tr -d '\t' | sort -u | \
1267 sed -e 's/^linux-gate.so.*$/SLIB/' -e 's~^/lib/ld-.*$~SLIB~' \
1268 -e '/^statically$/d' | tr '\n' ' '; })
1270 if [ "$libs" ]; then
1271 libs=$(echo " $libs" | sed -r 's/( SLIB)+ / /g')
1272 echo -e "$PACKAGE\t$libs" >> $lib_db
1273 sort -o $lib_db $lib_db
1274 echo -e "$PACKAGE\t$libs" >> library.list
1275 sort -o library.list library.list
1276 fi
1277 unset libs
1280 # Check for a specified file list on cmdline.
1281 check_for_list()
1283 if [ ! "$LIST" ]; then
1284 echo -e "\nPlease specify the path to the list of packages to cook.\n" >&2
1285 exit 1
1286 elif ! [ -f "$LIST" ]; then
1287 echo -e "\nUnable to find $LIST packages list.\n" >&2
1288 exit 1
1289 elif ! [ -s "$LIST" ]; then
1290 echo -e "\nList is empty.\n" >&2
1291 exit 1
1292 fi
1295 # get $PACKAGE wanted and depends info into wanted.txt and depends.txt files
1296 get_packages_info_main()
1298 erase_package_info_main
1299 [ "$WANTED" ] && echo -e "$PACKAGE\t$WANTED" >> wanted.txt
1300 echo -e "$PACKAGE\t "$DEPENDS" \t "$BUILD_DEPENDS" " >> depends.txt
1303 # erase $PACKAGE line in wanted.txt and depends.txt
1304 erase_package_info_main()
1306 for i in wanted.txt depends.txt; do
1307 [ -f $i ] || continue
1308 sed "/^$PACKAGE\t/d" -i $i
1309 done