This repository has been archived by the owner on Sep 17, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathresolve.sh
executable file
·130 lines (108 loc) · 5.69 KB
/
resolve.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/bin/sh
source ./config.sh
WHAT="$1"
case "$WHAT" in
buildtime)
modules=$(ls "$topdir/modules" \
| sed \
-e "s/^bootstrap$//g" \
-e "s/^platform$//g")
get_toplevel_pkgs() {
local modulearchroot="$1"
sed -e "s/$/.src/g" < "$modulearchroot/runtime-source-packages-short.txt"
}
;;
runtime)
modules=$(ls "$topdir/modules" \
| sed \
-e "s/^bootstrap$//g" \
-e "s/^platform$//g")
get_toplevel_pkgs() {
local modulearchroot="$1"
cat "$modulearchroot/toplevel-binary-packages.txt"
}
;;
*)
echo "Don't know what to do: '$WHAT'" >&2
exit 1
;;
esac
# Resolve complete dependencies using depchase
resolve_arch() {
local arch="$1"
for module in $modules; do
modulearchroot="$topdir/modules/$module/$arch"
# clear existing files
> $modulearchroot/complete-$WHAT-binary-packages-full.txt
> $modulearchroot/complete-$WHAT-source-packages-full.txt
> $modulearchroot/complete-$WHAT-binary-packages-short.txt
> $modulearchroot/complete-$WHAT-source-packages-short.txt
echo " Processing $WHAT deps of $module for $arch..."
hintsfile="$topdir/hp/$arch/hints.txt"
hints=""
while read hint; do
hints+="--hint $hint "
done < $hintsfile
get_toplevel_pkgs "$modulearchroot" |
xargs depchase -a $arch -c repos.cfg resolve $hints > $modulearchroot/depchase-$WHAT-failures.txt 2> $modulearchroot/depchase-$WHAT-relations.txt
RC=$?
if [ $RC -ne 0 ]; then
echo "Depchase failures encountered for $module on $arch $WHAT:"
cat $modulearchroot/depchase-$WHAT-failures.txt
continue
fi
cat $modulearchroot/depchase-$WHAT-failures.txt |
while IFS= read -r nevra; do
[[ "$nevra" == *.src || "$nevra" == *.nosrc ]] && type_="source" || type_="binary"
name=${nevra%-*-*}
echo "$nevra" >> $modulearchroot/complete-$WHAT-$type_-packages-full.txt
echo "$name" >> $modulearchroot/complete-$WHAT-$type_-packages-short.txt
done
rm -f $modulearchroot/depchase-$WHAT-failures.txt
sort -o $modulearchroot/complete-$WHAT-binary-packages-full.txt $modulearchroot/complete-$WHAT-binary-packages-full.txt
sort -o $modulearchroot/complete-$WHAT-source-packages-full.txt $modulearchroot/complete-$WHAT-source-packages-full.txt
sort -o $modulearchroot/complete-$WHAT-binary-packages-short.txt $modulearchroot/complete-$WHAT-binary-packages-short.txt
sort -o $modulearchroot/complete-$WHAT-source-packages-short.txt $modulearchroot/complete-$WHAT-source-packages-short.txt
done
}
for arch in $(cat arches.txt); do
echo "Starting the resolution of $arch dependencies."
resolve_arch "$arch" &
done
echo "Waiting for jobs to finish..."
wait
echo "Done. Sorting out Platform module dependencies."
# Figuring out the standalone dependencies
for arch in $(cat arches.txt); do
for module in $modules; do
modulearchroot="$topdir/modules/$module/$arch"
# clear existing files
> $modulearchroot/standalone-$WHAT-binary-packages-full.txt
> $modulearchroot/standalone-$WHAT-source-packages-full.txt
> $modulearchroot/standalone-$WHAT-binary-packages-short.txt
> $modulearchroot/standalone-$WHAT-source-packages-short.txt
sort -o "$topdir/hp/$arch/runtime-source-packages-full.txt" "$topdir/hp/$arch/runtime-source-packages-full.txt"
sort -o "$topdir/hp/$arch/runtime-binary-packages-full.txt" "$topdir/hp/$arch/runtime-binary-packages-full.txt"
sort -o "$topdir/hp/$arch/runtime-source-packages-short.txt" "$topdir/hp/$arch/runtime-source-packages-short.txt"
sort -o "$topdir/hp/$arch/runtime-binary-packages-short.txt" "$topdir/hp/$arch/runtime-binary-packages-short.txt"
comm -13 "$topdir/hp/$arch/runtime-binary-packages-full.txt" $modulearchroot/complete-$WHAT-binary-packages-full.txt > $modulearchroot/standalone-$WHAT-binary-packages-full.txt
comm -13 "$topdir/hp/$arch/runtime-source-packages-full.txt" $modulearchroot/complete-$WHAT-source-packages-full.txt > $modulearchroot/standalone-$WHAT-source-packages-full.txt
comm -13 "$topdir/hp/$arch/runtime-binary-packages-short.txt" $modulearchroot/complete-$WHAT-binary-packages-short.txt > $modulearchroot/standalone-$WHAT-binary-packages-short.txt
comm -13 "$topdir/hp/$arch/runtime-source-packages-short.txt" $modulearchroot/complete-$WHAT-source-packages-short.txt > $modulearchroot/standalone-$WHAT-source-packages-short.txt
awk 'NR==FNR{x++} END{ if(x!=FNR){exit 1} }' $modulearchroot/standalone-$WHAT-binary-packages-full.txt $modulearchroot/standalone-$WHAT-binary-packages-short.txt
RC=$?
if [ $RC -ne 0 ]; then
echo " WARNING! Different number of packages between full and short."
echo " $(wc -l $modulearchroot/standalone-$WHAT-binary-packages-short.txt)"
echo " $(wc -l $modulearchroot/standalone-$WHAT-binary-packages-full.txt)"
fi
awk 'NR==FNR{x++} END{ if(x!=FNR){exit 1} }' $modulearchroot/standalone-$WHAT-source-packages-full.txt $modulearchroot/standalone-$WHAT-source-packages-short.txt
RC=$?
if [ $RC -ne 0 ]; then
echo " WARNING! Different number of packages between full and short."
echo " $(wc -l $modulearchroot/standalone-$WHAT-source-packages-short.txt)"
echo " $(wc -l $modulearchroot/standalone-$WHAT-source-packages-full.txt)"
fi
done
done
echo "Success!"