-
Notifications
You must be signed in to change notification settings - Fork 13
/
generate_module_lists.sh
executable file
·239 lines (214 loc) · 7.61 KB
/
generate_module_lists.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#!/bin/bash
# Created by argbash-init v2.4.0
# ARG_OPTIONAL_SINGLE([module],[],[Which module are we generating data on?],[base-runtime])
# ARG_OPTIONAL_SINGLE([version],[],[The Fedora release number],[25])
# ARG_OPTIONAL_SINGLE([milestone],[],[The Fedora release milestone],[GA])
# ARG_OPTIONAL_REPEATED([arch],[],[Which CPU architecture(s)?],[])
# ARG_OPTIONAL_SINGLE([repo-path],[],[The base path for repositories],[./repo])
# ARG_OPTIONAL_SINGLE([data-path],[],[The base path for processed data],[./data])
# ARG_HELP([Script to produce the dependency data files for modules])
# ARGBASH_GO()
# needed because of Argbash --> m4_ignore([
### START OF CODE GENERATED BY Argbash v2.4.0 one line above ###
# Argbash is a bash code generator used to get arguments parsing right.
# Argbash is FREE SOFTWARE, see https://argbash.io for more info
die()
{
local _ret=$2
test -n "$_ret" || _ret=1
test "$_PRINT_HELP" = yes && print_help >&2
echo "$1" >&2
exit ${_ret}
}
begins_with_short_option()
{
local first_option all_short_options
all_short_options='h'
first_option="${1:0:1}"
test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0
}
# THE DEFAULTS INITIALIZATION - OPTIONALS
_arg_module="base-runtime"
_arg_version="25"
_arg_milestone="GA"
_arg_arch=()
_arg_repo_path="./repo"
_arg_data_path="./data"
print_help ()
{
echo "Script to produce the dependency data files for modules"
printf 'Usage: %s [--module <arg>] [--version <arg>] [--milestone <arg>] [--arch <arg>] [--repo-path <arg>] [--data-path <arg>] [-h|--help]\n' "$0"
printf "\t%s\n" "--module: Which module are we generating data on? (default: '"base-runtime"')"
printf "\t%s\n" "--version: The Fedora release number (default: '"25"')"
printf "\t%s\n" "--milestone: The Fedora release milestone (default: '"GA"')"
printf "\t%s\n" "--arch: Which CPU architecture(s)? (empty by default)"
printf "\t%s\n" "--repo-path: The base path for repositories (default: '"./repo"')"
printf "\t%s\n" "--data-path: The base path for processed data (default: '"./data"')"
printf "\t%s\n" "-h,--help: Prints help"
}
# THE PARSING ITSELF
while test $# -gt 0
do
_key="$1"
case "$_key" in
--module|--module=*)
_val="${_key##--module=}"
if test "$_val" = "$_key"
then
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_val="$2"
shift
fi
_arg_module="$_val"
;;
--version|--version=*)
_val="${_key##--version=}"
if test "$_val" = "$_key"
then
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_val="$2"
shift
fi
_arg_version="$_val"
;;
--milestone|--milestone=*)
_val="${_key##--milestone=}"
if test "$_val" = "$_key"
then
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_val="$2"
shift
fi
_arg_milestone="$_val"
;;
--arch|--arch=*)
_val="${_key##--arch=}"
if test "$_val" = "$_key"
then
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_val="$2"
shift
fi
_arg_arch+=("$_val")
;;
--repo-path|--repo-path=*)
_val="${_key##--repo-path=}"
if test "$_val" = "$_key"
then
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_val="$2"
shift
fi
_arg_repo_path="$_val"
;;
--data-path|--data-path=*)
_val="${_key##--data-path=}"
if test "$_val" = "$_key"
then
test $# -lt 2 && die "Missing value for the optional argument '$_key'." 1
_val="$2"
shift
fi
_arg_data_path="$_val"
;;
-h*|--help)
print_help
exit 0
;;
*)
_PRINT_HELP=yes die "FATAL ERROR: Got an unexpected argument '$1'" 1
;;
esac
shift
done
# OTHER STUFF GENERATED BY Argbash
### END OF CODE GENERATED BY Argbash (sortof) ### ])
# [ <-- needed because of Argbash
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
module=$_arg_module
version=$_arg_version
milestone=$_arg_milestone
if [ $version == "Rawhide" ]; then
# backwards-compatible
version="rawhide"
fi
repocfg="$(readlink -f $_arg_repo_path)/Fedora-$version-$milestone-repos.cfg"
if [ $milestone == "GA" ]; then
moduleroot="$(readlink -f $_arg_data_path)/Fedora/$version/$module"
else
moduleroot="$(readlink -f $_arg_data_path)/Fedora/${version}_${milestone}/$module"
fi
for arch in ${_arg_arch[@]}; do
modulearchroot=$moduleroot/$arch
mkdir -p $modulearchroot
pkgfile="$modulearchroot/toplevel-binary-packages.txt"
hintsfile="$modulearchroot/hints.txt"
basearch=$($SCRIPT_DIR/get_basearch $arch)
hints=""
while read hint; do
hints+="--hint $hint "
done < $hintsfile
# Clear any existing file, if present
> $modulearchroot/runtime-binary-packages-full.txt
> $modulearchroot/runtime-binary-packages-short.txt
> $modulearchroot/runtime-source-packages-full.txt
> $modulearchroot/runtime-source-packages-short.txt
> $modulearchroot/selfhosting-binary-packages-full.txt
> $modulearchroot/selfhosting-binary-packages-short.txt
> $modulearchroot/selfhosting-source-packages-full.txt
> $modulearchroot/selfhosting-source-packages-short.txt
# Depchase the binary and source packages for the runtime
echo "Processing runtime for $module / $arch"
cat $pkgfile |
xargs depchase -a $arch -c $repocfg resolve $hints > $modulearchroot/depchase-runtime-failures.txt
RC=$?
if [ $RC -ne 0 ]; then
echo "Depchase failures encountered on $module / $arch runtime:"
cat $modulearchroot/depchase-runtime-failures.txt
continue
fi
> $modulearchroot/runtime-binary-packages-full.txt
> $modulearchroot/runtime-source-packages-full.txt
> $modulearchroot/runtime-binary-packages-short.txt
> $modulearchroot/runtime-source-packages-short.txt
cat $modulearchroot/depchase-runtime-failures.txt |
while IFS= read -r nevra; do
[[ "$nevra" == *.src || "$nevra" == *.nosrc ]] && type_="source" || type_="binary"
name=${nevra%-*-*}
echo "$nevra" >> $modulearchroot/runtime-$type_-packages-full.txt
echo "$name" >> $modulearchroot/runtime-$type_-packages-short.txt
done
rm -f $modulearchroot/depchase-runtime-failures.txt
# Depchase the binary and source packages for the self-hosting set
echo "Processing self-hosting for $module / $arch"
cat $pkgfile |
xargs depchase -a $arch -c $repocfg resolve --selfhost $hints > $modulearchroot/depchase-selfhosting-failures.txt
RC=$?
if [ $RC -ne 0 ]; then
echo "Depchase failures encountered on $module / $arch self-hosting:"
cat $modulearchroot/depchase-selfhosting-failures.txt
continue
fi
> $modulearchroot/selfhosting-binary-packages-full.txt
> $modulearchroot/selfhosting-source-packages-full.txt
> $modulearchroot/selfhosting-binary-packages-short.txt
> $modulearchroot/selfhosting-source-packages-short.txt
cat $modulearchroot/depchase-selfhosting-failures.txt |
while IFS= read -r nevra; do
[[ "$nevra" == *.src || "$nevra" == *.nosrc ]] && type_="source" || type_="binary"
name=${nevra%-*-*}
echo "$nevra" >> $modulearchroot/selfhosting-$type_-packages-full.txt
echo "$name" >> $modulearchroot/selfhosting-$type_-packages-short.txt
done
rm -f $modulearchroot/depchase-selfhosting-failures.txt
LC_SAVED=$LC_ALL
export LC_ALL=C
for f in $modulearchroot/{runtime,selfhosting}-{binary,source}-packages-short.txt; do
sort -u $f -o $f
done
for f in $modulearchroot/{runtime,selfhosting}-{binary,source}-packages-full.txt; do
cat $f | rpmdev-sort > $f.new && mv -f $f.new $f
done
export LC_ALL=$LC_SAVED
done
# ] <-- needed because of Argbash