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
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", "opam", "plplot", "virt-top", "virt-v2v",
48 "flocq" # no OCaml code, but needs to be rebuilt after Coq
50 pure function get-source-packages () = {
53 for f in ocaml* %other-packages; do
54 [ -f $f/%branch/$f.spec ] && echo "*built-in-koji(\"$f\"),"
58 let source-packages = get-source-packages ()
60 # Main goal: Rebuild all packages.
61 goal all = : source-packages ;
63 # Check if the source package has been built in Koji.
64 tactic *built-in-koji (pkg) = {
65 cd %fedora-dir/%pkg/%branch
69 # Packages which are ignored are treated as if they were rebuilt already.
71 if [ %pkg = "$p" ]; then exit 0; fi
74 # If the specfile doesn't have the magic string then the
75 # package definitely needs to be rebuilt.
76 grep -sq %rebuild-name $specfile || exit 99
78 # Else we must check Koji itself.
79 # Koji sends some messages to stderr.
81 buildinfo=$($koji buildinfo $nvr 2>&1 ||:)
83 # No build at all, needs rebuild.
84 echo "$buildinfo" | grep -sq "No such build" && exit 99
86 # Exists a build, find out what state it is in.
87 state=$(echo "$buildinfo" | grep ^State: | awk '{print $2}')
88 taskid=$(echo "$buildinfo" | grep ^Task: | awk '{print $2}')
92 # Complete so we don't need to rebuild.
95 # Failed builds must be examined and fixed manually.
98 # Cancel the build, we will resubmit it.
99 $koji cancel $taskid ||:
105 # Don't know what happened there, so fail.
110 *built-in-koji ("%pkg") : source-dependencies (pkg) {
111 cd %fedora-dir/%pkg/%branch
116 # We have to wait for the dependencies to become available
117 # before we can start the new build.
119 nvr=$($koji --quiet latest-build %side-tag $p | awk '{print $1}')
120 $koji wait-repo %side-tag --build=$nvr
123 # Make sure the local directory is up to date.
124 # This should also fail if there are local changes, which
125 # would need to be corrected/integrated by hand.
128 # If the specfile doesn't have the magic string then add
130 if ! grep -sq %rebuild-name $specfile; then
131 rpmdev-bumpspec -c "- "%rebuild-name *.spec
133 rpmdev-bumpspec -c "- Bump release and rebuild." *.spec
137 $fedpkg build --target %side-tag
140 # Get the source package names for a particular package.
141 # Note this is not merely the BuildRequires, since those are
142 # the binary packages. Also this will only find packages
143 # which are in the list of source-packages.
144 pure function source-dependencies (pkg) = @{
145 specfile=%fedora-dir/%pkg/%branch/%pkg.spec
147 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 |
160 echo "*built-in-koji(\"$p\"),"