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 let blocked = [ "ocaml-camlp4" ]
20 # Packages that are ignored, which means they are treated as if
21 # they have been rebuilt.
22 #let ignored = [ "ocaml-srpm-macros", "ocaml" ]
23 let ignored = [ "ocaml-srpm-macros" ]
25 # All OCaml-related source package names
26 let other-packages = [
27 "alt-ergo", "apron", "brltty", "coccinelle", "coq",
28 "frama-c", "gappalib-coq", "graphviz", "hevea", "hivex",
29 "libguestfs", "opam", "plplot", "virt-top", "virt-v2v",
31 "flocq" # no OCaml code, but needs to be rebuilt after Coq
33 pure function get-source-packages () = {
36 for f in ocaml* %other-packages; do
37 [ -f $f/%branch/$f.spec ] && echo "*built-in-koji(\"$f\"),"
41 let source-packages = get-source-packages ()
43 # Main goal: Rebuild all packages.
44 goal all = : source-packages ;
46 # Check if the source package has been built in Koji.
47 tactic *built-in-koji (pkg) = {
48 cd %fedora-dir/%pkg/%branch
52 # Packages which are ignored are treated as if they were rebuilt already.
54 if [ %pkg = "$p" ]; then exit 0; fi
57 # If the specfile doesn't have the magic string then the
58 # package definitely needs to be rebuilt.
59 grep -sq %rebuild-name $specfile || exit 99
61 # Else we must check Koji itself.
62 # Koji sends some messages to stderr.
64 buildinfo=$($koji buildinfo $nvr 2>&1 ||:)
66 # No build at all, needs rebuild.
67 echo "$buildinfo" | grep -sq "No such build" && exit 99
69 # Exists a build, find out what state it is in.
70 state=$(echo "$buildinfo" | grep ^State: | awk '{print $2}')
71 taskid=$(echo "$buildinfo" | grep ^Task: | awk '{print $2}')
75 # Complete so we don't need to rebuild.
78 # Failed builds must be examined and fixed manually.
81 # Cancel the build, we will resubmit it.
82 $koji cancel $taskid ||:
88 # Don't know what happened there, so fail.
93 *built-in-koji ("%pkg") : source-dependencies (pkg) {
94 cd %fedora-dir/%pkg/%branch
99 # We have to wait for the dependencies to become available
100 # before we can start the new build.
102 nvr=$($koji --quiet latest-build %side-tag $p | awk '{print $1}')
103 $koji wait-repo %side-tag --build=$nvr
106 # If the specfile doesn't have the magic string then add
108 if ! grep -sq %rebuild-name $specfile; then
109 rpmdev-bumpspec -c "- "%rebuild-name *.spec
111 rpmdev-bumpspec -c "- Bump release and rebuild." *.spec
115 $fedpkg build --target %side-tag
118 # Get the source package names for a particular package.
119 # Note this is not merely the BuildRequires, since those are
120 # the binary packages. Also this will only find packages
121 # which are in the list of source-packages.
122 pure function source-dependencies (pkg) = @{
123 specfile=%fedora-dir/%pkg/%branch/%pkg.spec
125 echo -n Dependencies of %pkg: >&2
128 for r in $(rpmspec -q --buildrequires $specfile 2>/dev/null |
129 awk '{print $1}'); do
130 # Now we examine each *other* source package to see
131 # if any will create this dependency when they build.
132 for p in %source-packages; do
133 if [ "$p" != %pkg ] && \
134 rpmspec -q --provides %fedora-dir/$p/%branch/$p.spec 2>/dev/null |
138 echo "*built-in-koji(\"$p\"),"