-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathosc-submit-dependencies
More file actions
89 lines (81 loc) · 3.12 KB
/
osc-submit-dependencies
File metadata and controls
89 lines (81 loc) · 3.12 KB
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
#!/bin/bash -e
set -euo pipefail
list_pkgs() {
prj="${1:?"Need project"}"
osc list "$prj"
}
unresolvables_per_pkg() {
echo "# unresolvables_per_pkg"
local prj="${prj:-"home:okurz:try_openqa_leap16"}"
local repo="${repo:-"16.0"}"
local arch="${arch:-"$arch"}"
local pkgs="$(list_pkgs "$prj")"
osc buildinfo "$prj" "$pkg" "$repo" "$arch" | xml_grep --nowrap --text_only error | sed -n "s/nothing provides //gp"
}
unresolvables_in_prj() {
echo "# unresolvables_in_prj"
local prj="${prj:-"home:okurz:try_openqa_leap16"}"
local repo="${repo:-"16.0"}"
local arch="${arch:-"$arch"}"
while read -r pkg; do
echo "## pkg: $pkg"
# this shows all unresolvables, for multiple comma separate messages. And
# for some with exact version which we should strip. Also we should remove
# packages already in this project but unresolved
unresolvables_per_pkg "$prj" "$pkg" "$repo" "$arch"
done <<<$pkgs
}
find_and_submit_dependencies() {
echo "# find_and_submit_dependencies"
local prj="${prj:-"home:okurz:try_openqa_leap16"}"
local repo="${repo:-"16.0"}"
local arch="${arch:-"$arch"}"
local pkgs="$(list_pkgs "$prj")"
local base_prj="${base_prj:-"openSUSE:Factory"}"
unresolvables_in_prj "$prj" "$repo" "$arch" | tee unresolvables
# put each entry on separate line
sed -n -e "s/, /\n/g" -e "s/unresolvable: //p" unresolvables
if ! [ -s unresolvables ]; then
echo "# no more unresolvables found, aborting"
fi
# lookup actual provides from current running system needing zypper and
# assuming that your current working system has same package provides as
# target system
# Alternatively I would suggest to use a Tumbleweed container with podman but
# calling the container fresh every time would mean we would need to
# implicitly refresh the zypper cache everytime so inefficient. One way to
# solve would be spawn the container and keep it running until all tasks are
# done and cleanup on exit
for i in $(sed -n -e "s/, /\n/g" -e "s/unresolvable: //p" unresolvables | sort -u); do
zypper --no-refresh --xmlout se --provides --match-exact "$i" | xml_grep --nowrap solvable | sed -n "s/^.*name=\"\([^\"]*\).*$/\1/p"
done | tee unresolves_provides
for pkg in $(sort -u unresolves_provides); do
# this will throw errors for already existing packages in target as
# well as for sub-packages
osc linkpac "$base_prj" "$pkg" "$prj"
done
}
resolve_dependencies_until_stable() {
local prj="${prj:-"home:okurz:try_openqa_leap16"}"
local repo="${repo:-"16.0"}"
local arch="${arch:-"x86_64"}"
local pkgs="$(list_pkgs "$prj")"
local base_prj="${base_prj:-"openSUSE:Factory"}"
while :; do
unresolvables=$(unresolvables_in_prj "$prj")
if [ -z "$unresolvables" ]; then
break
fi
find_and_submit_dependencies
# TODO
# for debugging only once
break
echo "# Next cycle in 10s …"
sleep 10
done
}
main() {
echo "foo"
resolve_dependencies_until_stable
}
caller 0 > /dev/null || main "$@"