update buildroot - work in progress development
[cmdllinux.git] / buildroot / _pkg_tmp / _#remove3.sh
blob7d93803613025dfda8da3f80d78911f8ec9ae406
1 #set +e
4 #rem="eudev"
5 rem="zlib eudev"
6 #[ -z "$1" ] && exit 1
7 #rem="$@"
9 #check if package exists
10 cd .local
11 echo -n > ../.rem_cache.tmp1
12 echo -n > ../.rem_cache.tmp2
13 echo -n > ../.rem_cache.tmp1.sort
14 echo -n > ../.rem_cache.tmp2.sort
15 #echo "Getting dependencies..."
16 LS=`ls */depends`
17 while true; do
18 if test -s ../.rem_cache.tmp1.sort; then
19 cp ../.rem_cache.tmp1.sort ../.rem_cache.tmp1
20 for i in `cut -d / -f 1 ../.rem_cache.tmp1.sort | sort -u`; do
21 echo "$LS" | xargs grep "^$i$" >> ../.rem_cache.tmp1
22 done
23 sort -u ../.rem_cache.tmp1 > ../.rem_cache.tmp1.sort
24 else
25 for i in $rem; do
26 echo "$LS" | xargs grep "^$i$" >> ../.rem_cache.tmp1
27 done
28 if ! test -s ../.rem_cache.tmp1; then
29 no_deps_to_remove=1
30 break
32 sort -u ../.rem_cache.tmp1 > ../.rem_cache.tmp1.sort
34 if cmp ../.rem_cache.tmp1.sort ../.rem_cache.tmp2.sort > /dev/null 2>&1; then
35 break
36 else
37 cp ../.rem_cache.tmp1.sort ../.rem_cache.tmp2.sort
39 done
40 ###remove collected
41 ###remove selected
42 cd ..
45 OPKG=
46 DEPP=
47 while read line; do
48 PKG=${line%%/*}
49 DEP=${line##*:}
50 if [ "$OPKG" != "$PKG" ]; then
51 if [ -z "$OPKG" ]; then
52 DEPP="$DEP"
53 else
54 echo "$OPKG/depends:$DEPP"
55 DEPP="$DEP"
57 OPKG="$PKG"
58 else
59 [ -z "$DEPP" ] && DEPP="$DEP" || DEPP="$DEPP $DEP"
61 done < .rem_cache.tmp1.sort > .rem_cache.tmp1.sort4
62 echo "$PKG/depends:$DEPP" >> .rem_cache.tmp1.sort4
65 cut -d / -f 1 .rem_cache.tmp1.sort | sort -u > .rem_cache.tmp1.sort1
66 cut -d : -f 2 .rem_cache.tmp1.sort | sort -u > .rem_cache.tmp1.sort2
67 cat .rem_cache.tmp1.sort1 .rem_cache.tmp1.sort2 | sort -u > .rem_cache.tmp1.sort3
68 DIFF=`comm -13 --nocheck-order .rem_cache.tmp1.sort1 .rem_cache.tmp1.sort3`
69 for i in $DIFF; do
70 echo "$i/depends:" >> .rem_cache.tmp1.sort4
71 done
74 num=0
75 declare -g -a list
76 while read line; do
77 list[$num]="$line"
78 let num++
79 done < .rem_cache.tmp1.sort4
81 processed=
82 orig_maxindex=$(( ${#list[@]} - 1 ))
83 num=0
84 while (( ${#list[@]} != 0 )); do
86 if [[ -z "${list[$num]}" ]]; then
87 [[ "$num" -lt "$orig_maxindex" ]] && num=$(( "$num" + 1 )) || num=0
88 continue
90 name="${list[$num]%%/*}"
91 depends="${list[$num]#*:}"
92 deperror=
93 for i in $depends; do
94 [[ "$name" == "$i" ]] && echo "$i----$i----$i"
95 if ! echo "$processed" | grep -q "^$i$"; then
96 deperror=1
97 break
99 done
100 if [[ -z "$deperror" ]]; then
101 [[ -z "$processed" ]] && processed="$name" || processed=`echo -ne "$processed\n$name"`
102 unset list[$num]
105 [[ "$num" -lt "$orig_maxindex" ]] && num=$(( $num + 1 )) || num=0
106 done
108 reverse=`echo "$processed" | tac`
110 echo "$reverse"
111 #exit 0