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 () returning strings = {
52 for f in ocaml* %other-packages; do
53 [ -f $f/%branch/$f.spec ] && echo "$f"
56 let source-packages = wrap ("*built-in-koji", get-source-packages ())
58 # Main goal: Rebuild all packages.
59 goal all = : source-packages ;
61 # Check if the source package has been built in Koji.
62 tactic *built-in-koji (pkg) = {
63 cd %fedora-dir/%pkg/%branch
67 # Packages which are ignored are treated as if they were rebuilt already.
69 if [ %pkg = "$p" ]; then exit 0; fi
72 # If the specfile doesn't have the magic string then the
73 # package definitely needs to be rebuilt.
74 grep -sq %rebuild-name $specfile || exit 99
76 # Else we must check Koji itself.
77 # Koji sends some messages to stderr.
79 buildinfo=$($koji buildinfo $nvr 2>&1 ||:)
81 # No build at all, needs rebuild.
82 echo "$buildinfo" | grep -sq "No such build" && exit 99
84 # Exists a build, find out what state it is in.
85 state=$(echo "$buildinfo" | grep ^State: | awk '{print $2}')
86 taskid=$(echo "$buildinfo" | grep ^Task: | awk '{print $2}')
90 # Complete so we don't need to rebuild.
93 # Failed builds must be examined and fixed manually.
96 # Cancel the build, we will resubmit it.
97 $koji cancel $taskid ||:
103 # Don't know what happened there, so fail.
108 *built-in-koji ("%pkg") : wrap ("*built-in-koji", source-dependencies (pkg)) {
109 cd %fedora-dir/%pkg/%branch
114 # We have to wait for the dependencies to become available
115 # before we can start the new build.
117 nvr=$($koji --quiet latest-build %side-tag $p | awk '{print $1}')
118 $koji wait-repo %side-tag --build=$nvr
121 # Make sure the local directory is up to date.
122 # This should also fail if there are local changes, which
123 # would need to be corrected/integrated by hand.
126 # If the specfile doesn't have the magic string then add
128 if ! grep -sq %rebuild-name $specfile; then
129 rpmdev-bumpspec -c "- "%rebuild-name *.spec
131 rpmdev-bumpspec -c "- Bump release and rebuild." *.spec
135 $fedpkg build --target %side-tag
138 # Get the source package names for a particular package.
139 # Note this is not merely the BuildRequires, since those are
140 # the binary packages. Also this will only find packages
141 # which are in the list of source-packages.
142 pure function source-dependencies (pkg) returning strings = @{
143 specfile=%fedora-dir/%pkg/%branch/%pkg.spec
145 echo Calculating dependencies of %pkg >&2
147 for r in $(rpmspec -q --buildrequires $specfile 2>/dev/null |
148 awk '{print $1}'); do
149 # Now we examine each *other* source package to see
150 # if any will create this dependency when they build.
151 for p in %source-packages; do
152 if [ "$p" != %pkg ] && \
153 rpmspec -q --provides %fedora-dir/$p/%branch/$p.spec 2>/dev/null |