3 let fedora-dir = "%HOME/d/fedora"
6 let side-tag = "f32-build-side-18015"
8 #let koji = "koji -p riscv64"
10 #let fedpkg = "fedpkg --user-config %HOME/d/fedora-ocaml-rebuild/fedpkg-user-config"
12 # The magic string that must appear in %changelog when the
13 # package has been rebuilt.
14 let rebuild-name = "OCaml 4.10.0+beta1 rebuild."
16 # Packages that are blocked. Any dependent packages are also blocked
18 # XXX Not implemented, use ignore for now.
19 #let blocked = [ "ocaml-camlp4" ]
21 # Packages that are ignored, which means they are treated as if
22 # they have been rebuilt.
23 let ignored = [ "ocaml-srpm-macros", "ocaml",
24 # These ones are only needed because blocked is not working
42 # All OCaml-related source package names
43 let other-packages = [
44 "alt-ergo", "apron", "brltty", "coccinelle", "coq",
45 "frama-c", "gappalib-coq", "graphviz", "hevea", "hivex",
46 "libguestfs", "libnbd", "nbdkit", "opam", "plplot",
47 "virt-top", "virt-v2v", "why3", "z3",
48 # no OCaml code, but needs to be rebuilt after Coq
51 pure function get-source-packages () returning strings = {
53 for f in ocaml* %other-packages; do
54 [ -f $f/%branch/$f.spec ] && echo "$f"
57 let source-packages = wrap ("*koji-built", get-source-packages ())
59 # Main goal: Rebuild all packages.
60 goal all = : source-packages ;
62 # Check if the source package has been built in Koji.
63 tactic *koji-built (pkg) = {
64 cd %fedora-dir/%pkg/%branch
68 # Packages which are ignored are treated as if they were rebuilt already.
70 if [ %pkg = "$p" ]; then exit 0; fi
73 # If the specfile doesn't have the magic string then the
74 # package definitely needs to be rebuilt.
75 grep -sq %rebuild-name $specfile || exit 99
77 # Else we must check Koji itself.
78 # Koji sends some messages to stderr.
80 buildinfo=$($koji buildinfo $nvr 2>&1 ||:)
82 # No build at all, needs rebuild.
83 echo "$buildinfo" | grep -sq "No such build" && exit 99
85 # Exists a build, find out what state it is in.
86 state=$(echo "$buildinfo" | grep ^State: | awk '{print $2}')
87 taskid=$(echo "$buildinfo" | grep ^Task: | awk '{print $2}')
91 # Complete so we don't need to rebuild.
94 # Failed builds must be examined and fixed manually.
97 # Cancel the build, we will resubmit it.
98 $koji cancel $taskid ||:
104 # Don't know what happened there, so fail.
109 *koji-built ("%pkg") : wrap ("*koji-built", source-dependencies (pkg)) {
110 cd %fedora-dir/%pkg/%branch
115 # We have to wait for the dependencies to become available
116 # before we can start the new build.
118 nvr=$($koji --quiet latest-build %side-tag $p | awk '{print $1}')
119 $koji wait-repo %side-tag --build=$nvr
122 # Make sure the local directory is up to date.
123 # This should also fail if there are local changes, which
124 # would need to be corrected/integrated by hand.
127 # If the specfile doesn't have the magic string then add
129 if ! grep -sq %rebuild-name $specfile; then
130 rpmdev-bumpspec -c "- "%rebuild-name *.spec
132 rpmdev-bumpspec -c "- Bump release and rebuild." *.spec
136 $fedpkg build --target %side-tag
139 # Get the source package names for a particular package.
140 # Note this is not merely the BuildRequires, since those are
141 # the binary packages. Also this will only find packages
142 # which are in the list of source-packages.
143 pure function source-dependencies (pkg) returning strings = @{
144 specfile=%fedora-dir/%pkg/%branch/%pkg.spec
146 echo Calculating dependencies of %pkg >&2
148 for r in $(rpmspec -q --buildrequires $specfile 2>/dev/null |
149 awk '{print $1}'); do
150 # Now we examine each *other* source package to see
151 # if any will create this dependency when they build.
152 for p in %source-packages; do
153 if [ "$p" != %pkg ] && \
154 rpmspec -q --provides %fedora-dir/$p/%branch/$p.spec 2>/dev/null |