wok-6.x rev 6100

tazbb/sort_cook_list: awk fix
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Aug 31 15:19:29 2010 +0200 (2010-08-31)
parents 5070045e141c
children 276344234dd6
files tazbb/stuff/tazbb
line diff
     1.1 --- a/tazbb/stuff/tazbb	Tue Aug 31 11:22:25 2010 +0200
     1.2 +++ b/tazbb/stuff/tazbb	Tue Aug 31 15:19:29 2010 +0200
     1.3 @@ -441,32 +441,31 @@
     1.4  			MISSING="$MISSING $i"
     1.5  		done
     1.6  		echo ""
     1.7 -	done | awk '
     1.8 -function show(name)
     1.9 -{
    1.10 -	print name;
    1.11 -	got[name]++;
    1.12 -	if (revdepcnt[name] > 0)
    1.13 -		for (i = split(revdep[name], pkg, " "); i > 0; i--)
    1.14 -			if (--depcnt[pkg[i]] == 0) show(pkg[i]);
    1.15 -}
    1.16 -
    1.17 -{
    1.18 -	if ($2 == "") show($1);
    1.19 -	else {
    1.20 -		depcnt[$1] = NF - 1;
    1.21 -		unres = unres " " $1;
    1.22 -		for (i = 2; i <= NF; i++) {
    1.23 -			if (got[$i] > 0) continue;
    1.24 -			revdepcnt[$i]++;
    1.25 -			revdep[$i] = revdep[$i] " " $1;
    1.26 +	done | awk '{ deps[$1] = $0; }
    1.27 +END {
    1.28 +	while (1) {
    1.29 +		skipped = 0;
    1.30 +		done = 0;
    1.31 +		for (entry in deps) {
    1.32 +			for (i = split(deps[entry], pkg, " "); i > 1; i--)
    1.33 +				if (deps[pkg[i]] != "") break;
    1.34 +			if (i == 1) {
    1.35 +				print pkg[1];
    1.36 +				deps[pkg[1]] = "";
    1.37 +				done++;
    1.38 +			}
    1.39 +			else if (i > 1) skipped++;
    1.40 +		}
    1.41 +		if (skipped == 0) break;
    1.42 +		if (done == 0) { # cross deps !!
    1.43 +			for (entry in deps) {
    1.44 +				if (split(deps[entry], pkg, " ") > 1)
    1.45 +					print pkg[1];
    1.46 +			}
    1.47 +			break;
    1.48  		}
    1.49  	}
    1.50  }
    1.51 -END {
    1.52 -	for (i = split(unres, pkg, " "); i > 0; i--)
    1.53 -		if (depcnt[pkg[i]] > 0) print pkg[i];
    1.54 -}
    1.55  '
    1.56  }
    1.57