cookutils view lib/libcookorder.sh @ rev 586

cook: Add loglimit function.
author Christopher Rogers <slaxemulator@gmail.com>
date Fri Feb 08 03:25:37 2013 +0000 (2013-02-08)
parents f78d194e7f13
children
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 # sort and uniq files.list so it will be smaller
1016 cat files.list | sort | uniq > files.list.sort
1017 cp -a files.list.sort files.list
1018 # Dont log this because lzma always output errors.
1019 lzma e files.list files.list.lzma
1020 rm -f files.list
1021 [ -f packages.equiv ] || touch packages.equiv
1024 # get packages info
1025 get_packages_info()
1027 # If there's no taz folder in the wok, extract info from the
1028 # package.
1029 get_pkg_files $pkg
1030 unset_receipt
1031 . $pkg_files_dir/receipt
1033 #[ "$COMMAND" = "check-incoming" ] && gettext -e "Getting data from ${PACKAGE} \n"
1035 cat >> $pkg_repository/packages.txt << _EOT_
1036 $PACKAGE
1037 $VERSION$EXTRAVERSION
1038 $SHORT_DESC
1039 _EOT_
1040 if [ "$PACKED_SIZE" ]; then
1041 cat >> $pkg_repository/packages.txt << _EOT_
1042 $PACKED_SIZE ($UNPACKED_SIZE installed)
1044 _EOT_
1045 else
1046 echo "" >> $pkg_repository/packages.txt
1047 fi
1049 # Packages.desc is used by Tazpkgbox <tree>.
1050 echo "$PACKAGE | $VERSION$EXTRAVERSION | $SHORT_DESC | $CATEGORY | $WEB_SITE" >> $pkg_repository/packages.desc
1052 # Packages.equiv is used by tazpkg install to check depends.
1053 for i in $PROVIDE; do
1054 DEST=""
1055 echo $i | fgrep -q : && DEST="${i#*:}:"
1056 if grep -qs ^${i%:*}= $pkg_repository/packages.equiv; then
1057 sed -i "s/^${i%:*}=/${i%:*}=$DEST$PACKAGE /" $pkg_repository/packages.equiv
1058 else
1059 echo "${i%:*}=$DEST$PACKAGE" >> $pkg_repository/packages.equiv
1060 fi
1061 done
1063 if [ -f files.list ]; then
1064 { echo "$PACKAGE"; cat files.list; } | awk '
1065 BEGIN { name="" } { if (name == "") name=$0; else printf("%s: %s\n",name,$0); }' >> $pkg_repository/files.list
1066 fi
1068 if [ -f library.list ]; then
1069 sed "/^$PACKAGE\t/d" -i $pkg_repository/libraries.txt
1070 cat library.list >> $pkg_repository/libraries.txt
1071 fi
1073 cd .. && rm -r "$pkg_files_dir"
1075 cd $pkg_repository
1076 echo $(basename ${pkg%.tazpkg}) >> packages.list
1077 $CHECKSUM $(basename $pkg) >> packages.$SUM
1078 $get_packages_info_extracmd
1081 # gen packages database
1082 gen_packages_db()
1084 [ "$pkg_repository" ] || pkg_repository=$PKGS
1085 cd $pkg_repository
1086 gettext -e "Generating packages lists: $pkg_repository\n"
1087 gettext -e "Removing old files\n"
1088 for file in files.list.lzma packages.list packages.txt \
1089 packages.desc packages.equiv packages.$SUM; do
1090 [ -f $file ] && rm $file
1091 done
1092 touch files.list
1093 [ -f libraries.txt ] && rm -f libraries.txt
1094 if [ "$pkg_repository" == "$INCOMING" ]; then
1095 if [ -f "$PKGS/libraries.txt" ]; then
1096 cp -a $PKGS/libraries.txt $INCOMING/libraries.txt
1097 fi
1098 fi
1099 touch libraries.txt
1100 touch depends.txt
1101 touch wanted.txt
1103 packages_db_start
1104 unset_receipt
1105 gettext -e "Reading data from all packages\n"
1106 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1107 get_packages_info
1108 done
1109 packages_db_end
1112 # update package database
1113 update_packages_db()
1115 [ "$pkg_repository" ] || pkg_repository=$PKGS
1116 cd $pkg_repository
1117 for file in packages.list packages.equiv packages.$SUM \
1118 packages.desc packages.txt; do
1119 if [ ! -f "$file" ]; then
1120 gen_packages_db
1121 return
1122 fi
1123 done
1124 if [ -f files.list.lzma ]; then
1125 lzma d files.list.lzma files.list
1126 else
1127 gen_packages_db
1128 return
1129 fi
1130 gettext -e "Updating packages lists: $pkg_repository\n"
1131 echo ""
1132 packages_db_start
1134 # Look for removed/update packages.
1135 touch stamp -r packages.list
1136 for PACKAGE in $(grep ^[0-9,a-z,A-Z] packages.txt); do
1137 pkg="$pkg_repository/$(grep -m1 ^$PACKAGE- packages.list).tazpkg"
1138 if [ ! -f "$pkg" ]; then
1139 erase_package_info
1140 else
1141 if [ "$pkg" -nt "stamp" ]; then
1142 updated_pkg="$updated_pkg
1143 $PACKAGE $pkg"
1144 elif [ ! -f $WOK/$PACKAGE/receipt ] && \
1145 [ "$COMMAND" = check-incoming -o "$pkg_repository" = "$INCOMING" ]; then
1146 erase_package_info
1147 gettext -e "Removing $PACKAGE from $pkg_repository.\n"
1148 rm $pkg
1149 if [ "$pkg_repository" = "$INCOMING_REPOSITORY" ]; then
1150 [ -d $WOK/$PACKAGE ] && rm -r $WOK/$PACKAGE
1151 sed "/^$PACKAGE\t/d" -i $wan_db $dep_db
1152 for i in $fullco $cookorder $cooklist $commits $blocked $broken; do
1153 sed "/^$PACKAGE$/d" -i $i
1154 done
1155 [ -f $LOGS/$pkg.log ] && rm -f $LOGS/$pkg.log
1156 if [ "$(sed 1!d $fullco)" != "#PlanSort" ]; then
1157 sed 1i"#PlanSort" -i $fullco
1158 regen_cooklist=yes
1159 fi
1160 else
1161 echo "$PACKAGE" >> $CACHE/removed
1162 sed -n '1,10p' -i $CACHE/removed
1163 fi
1164 fi
1165 fi
1166 done
1167 rm stamp
1168 echo "$updated_pkg" | sed 1d | while read PACKAGE pkg; do
1169 erase_package_info
1170 get_packages_info
1171 done
1172 unset updated_pkg
1174 # Look for new packages.
1175 for pkg in $(echo $pkg_repository/*.tazpkg | fgrep -v '*'); do
1176 if ! fgrep -q " ${pkg##*/}" packages.$SUM; then
1177 get_packages_info
1178 fi
1179 done
1180 packages_db_end
1183 # make package database
1184 # $1 = incoming/packages or the folder of the package repo
1185 pkgdb()
1187 case "$1" in
1188 incoming)
1189 PKGSDB="incoming" ;;
1190 packages)
1191 PKGSDB="packages" ;;
1192 *)
1193 [ "$1" ] && PKGSDB="$1"
1194 [ ! -d "$PKGSDB" ] && \
1195 gettext -e "\nPackages directory doesn't exist\n\n" && exit 1 ;;
1196 esac
1197 time=$(date +%s)
1198 echo "cook:pkgdb" > $command
1199 echo "Cook pkgdb: Creating all packages lists" | log
1200 echo ""
1201 gettext "Creating lists for: "; echo "$PKGSDB"
1202 separator
1203 gettext "Cook pkgdb started: "; date "+%Y-%m-%d %H:%M"
1204 if [ "$PKGSDB" = packages ]; then
1205 # Packages package db
1206 pkg_repository=$PKGS && gen_packages_db
1207 nb=$(ls $PKGS/*.tazpkg | wc -l)
1208 time=$(($(date +%s) - $time))
1209 echo -e "Packages: $nb - Time: ${time}s\n"
1210 elif [ "$PKGSDB" = incoming ]; then
1211 # Incoming package db
1212 pkg_repository=$INCOMING && gen_packages_db
1213 nb=$(ls $INCOMING/*.tazpkg | wc -l)
1214 time=$(($(date +%s) - $time))
1215 echo -e "Packages: $nb - Time: ${time}s\n"
1216 elif [ -d "$PKGSDB" ]; then
1217 # User path for package db
1218 pkg_repository=$PKGSDB && gen_packages_db
1219 nb=$(ls $PKGSDB/*.tazpkg | wc -l)
1220 time=$(($(date +%s) - $time))
1221 echo -e "Packages: $nb - Time: ${time}s\n"
1222 else
1223 pkg_repository=$PKGS && gen_packages_db
1224 nb=$(ls $PKGS/*.tazpkg | wc -l)
1225 time=$(($(date +%s) - $time))
1226 echo -e "Packages: $nb - Time: ${time}s\n"
1227 pkg_repository=$INCOMING && gen_packages_db
1228 incoming_nb=$(ls $INCOMING/*.tazpkg | wc -l)
1229 time=$(($(date +%s) - $time))
1230 echo -e "Incoming: $incoming_nb - Time: ${time}s\n"
1231 fi
1233 echo "" && rm -f $command
1236 # clean chroot
1237 clean_chroot()
1239 # Remove packages which was not in the chroot at creation time.
1240 if [ -f "$CACHE/chroot-pkgs" ]; then
1241 for pkg in $(ls ${root}${INSTALLED}); do
1242 [ -f ${root}${INSTALLED}/$pkg/receipt ] || continue
1243 [ "$(grep ^$pkg$ $CACHE/chroot-pkgs)" ] || tazpkg remove $pkg --auto --root=$root
1244 done
1246 for pkg in $(ls ${root}${INSTALLED}); do
1247 if [ -d ${root}${INSTALLED}/$pkg -a ! -f ${root}${INSTALLED}/$pkg/receipt ]; then
1248 echo "empty: $pkg"
1249 rm -rf ${root}${INSTALLED}/$pkg
1250 fi
1251 done
1253 for pkg in $(cat $CACHE/chroot-pkgs); do
1254 if [ ! -d ${root}${INSTALLED}/$pkg ]; then
1255 echo "Reinstalling $pkg"
1256 tazpkg get-install $pkg --root=$root --forced
1257 fi
1258 done
1259 fi
1262 # update library database file
1263 update_lib_db()
1265 # Update lib_db
1266 libs=$(for file in $(find * -type f -not -name "*.o" -not -name "*.ko" -not -name "*.a"); do
1267 [ "$(dd if=$file bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ] || continue
1268 LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $PWD/$file
1269 done | { cut -f 1 -d ' ' | tr -d '\t' | sort -u | \
1270 sed -e 's/^linux-gate.so.*$/SLIB/' -e 's~^/lib/ld-.*$~SLIB~' \
1271 -e '/^statically$/d' | tr '\n' ' '; })
1273 if [ "$libs" ]; then
1274 libs=$(echo " $libs" | sed -r 's/( SLIB)+ / /g')
1275 echo -e "$PACKAGE\t$libs" >> $lib_db
1276 sort -o $lib_db $lib_db
1277 echo -e "$PACKAGE\t$libs" >> library.list
1278 sort -o library.list library.list
1279 fi
1280 unset libs
1283 # Check for a specified file list on cmdline.
1284 check_for_list()
1286 if [ ! "$LIST" ]; then
1287 echo -e "\nPlease specify the path to the list of packages to cook.\n" >&2
1288 exit 1
1289 elif ! [ -f "$LIST" ]; then
1290 echo -e "\nUnable to find $LIST packages list.\n" >&2
1291 exit 1
1292 elif ! [ -s "$LIST" ]; then
1293 echo -e "\nList is empty.\n" >&2
1294 exit 1
1295 fi
1298 # get $PACKAGE wanted and depends info into wanted.txt and depends.txt files
1299 get_packages_info_main()
1301 erase_package_info_main
1302 [ "$WANTED" ] && echo -e "$PACKAGE\t$WANTED" >> wanted.txt
1303 echo -e "$PACKAGE\t "$DEPENDS" \t "$BUILD_DEPENDS" " >> depends.txt
1306 # erase $PACKAGE line in wanted.txt and depends.txt
1307 erase_package_info_main()
1309 for i in wanted.txt depends.txt; do
1310 [ -f $i ] || continue
1311 sed "/^$PACKAGE\t/d" -i $i
1312 done