3 let fedora-dir = "%HOME/d/fedora"
6 let side-tag = "f32-ocaml"
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.09.0 for riscv64"
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
41 # These ones failed to build on riscv64, ignore them for now.
42 "apron", "plplot", "ocaml-ulex"
45 # All OCaml-related source package names
46 let other-packages = [
47 "alt-ergo", "apron", "brltty", "coccinelle", "coq",
48 "frama-c", "gappalib-coq", "graphviz", "hevea", "hivex",
49 "libguestfs", "opam", "plplot", "virt-top", "virt-v2v",
51 "flocq" # no OCaml code, but needs to be rebuilt after Coq
53 pure function get-source-packages () returning strings = {
55 for f in ocaml* %other-packages; do
56 [ -f $f/%branch/$f.spec ] && echo "$f"
59 let source-packages = wrap ("*built-in-koji", get-source-packages ())
61 # Main goal: Rebuild all packages.
62 goal all = : source-packages ;
64 # Check if the source package has been built in Koji.
65 tactic *built-in-koji (pkg) = {
66 cd %fedora-dir/%pkg/%branch
70 # Packages which are ignored are treated as if they were rebuilt already.
72 if [ %pkg = "$p" ]; then exit 0; fi
75 # If the specfile doesn't have the magic string then the
76 # package definitely needs to be rebuilt.
77 grep -sq %rebuild-name $specfile || exit 99
79 # Else we must check Koji itself.
80 # Koji sends some messages to stderr.
82 buildinfo=$($koji buildinfo $nvr 2>&1 ||:)
84 # No build at all, needs rebuild.
85 echo "$buildinfo" | grep -sq "No such build" && exit 99
87 # Exists a build, find out what state it is in.
88 state=$(echo "$buildinfo" | grep ^State: | awk '{print $2}')
89 taskid=$(echo "$buildinfo" | grep ^Task: | awk '{print $2}')
93 # Complete so we don't need to rebuild.
96 # Failed builds must be examined and fixed manually.
99 # Cancel the build, we will resubmit it.
100 $koji cancel $taskid ||:
106 # Don't know what happened there, so fail.
111 *built-in-koji ("%pkg") : wrap ("*built-in-koji", source-dependencies (pkg)) {
112 cd %fedora-dir/%pkg/%branch
117 # We have to wait for the dependencies to become available
118 # before we can start the new build.
120 nvr=$($koji --quiet latest-build %side-tag $p | awk '{print $1}')
121 $koji wait-repo %side-tag --build=$nvr
124 # Make sure the local directory is up to date.
125 # This should also fail if there are local changes, which
126 # would need to be corrected/integrated by hand.
129 # If the specfile doesn't have the magic string then add
131 if ! grep -sq %rebuild-name $specfile; then
132 rpmdev-bumpspec -c "- "%rebuild-name *.spec
134 rpmdev-bumpspec -c "- Bump release and rebuild." *.spec
138 $fedpkg build --target %side-tag
141 # Get the source package names for a particular package.
142 # Note this is not merely the BuildRequires, since those are
143 # the binary packages. Also this will only find packages
144 # which are in the list of source-packages.
145 pure function source-dependencies (pkg) returning strings = @{
146 specfile=%fedora-dir/%pkg/%branch/%pkg.spec
148 echo Calculating dependencies of %pkg >&2
150 for r in $(rpmspec -q --buildrequires $specfile 2>/dev/null |
151 awk '{print $1}'); do
152 # Now we examine each *other* source package to see
153 # if any will create this dependency when they build.
154 for p in %source-packages; do
155 if [ "$p" != %pkg ] && \
156 rpmspec -q --provides %fedora-dir/$p/%branch/$p.spec 2>/dev/null |