3 let fedora-dir = "%HOME/d/fedora"
6 let side-tag = "f32-ocaml"
8 let koji = "koji -p riscv64"
10 # The magic string that must appear in %changelog when the
11 # package has been rebuilt.
12 let rebuild-name = "OCaml 4.09.0 for riscv64"
14 # Packages that are blocked. Any dependent packages are also blocked
16 let blocked = [ "ocaml-camlp4" ]
18 # Packages that are ignored, which means they are treated as if
19 # they have been rebuilt.
20 #let ignored = [ "ocaml-srpm-macros", "ocaml" ]
21 let ignored = [ "ocaml-srpm-macros" ]
23 # All OCaml-related source package names
24 let other-packages = [
25 "alt-ergo", "apron", "brltty", "coccinelle", "coq",
26 "frama-c", "gappalib-coq", "graphviz", "hevea", "hivex",
27 "libguestfs", "opam", "plplot", "virt-top", "virt-v2v",
29 "flocq" # no OCaml code, but needs to be rebuilt after Coq
31 pure function get-source-packages () = {
34 for f in ocaml* %other-packages; do
35 [ -f $f/%branch/$f.spec ] && echo "*built-in-koji(\"$f\"),"
39 let source-packages = get-source-packages ()
41 # Main goal: Rebuild all packages.
42 goal all = : source-packages ;
44 # Check if the source package has been built in Koji.
45 tactic *built-in-koji (pkg) = {
46 cd %fedora-dir/%pkg/%branch
50 # Packages which are ignored are treated as if they were rebuilt already.
52 if [ %pkg = "$p" ]; then exit 0; fi
55 # If the specfile doesn't have the magic string then the
56 # package definitely needs to be rebuilt.
57 grep -sq %rebuild-name $specfile || exit 99
59 # Else we must check Koji itself.
61 buildinfo=$($koji buildinfo $nvr)
63 # No build at all, needs rebuild.
64 echo "$buildinfo" | grep -sq "No such build" && exit 99
66 # Exists a build, find out what state it is in.
67 state=$(echo "$buildinfo" | grep ^State: | awk '{print $2}')
68 taskid=$(echo "$buildinfo" | grep ^Task: | awk '{print $2}')
72 # Complete so we don't need to rebuild.
75 # Failed builds must be examined and fixed manually.
78 # Cancel the build, we will resubmit it.
85 # Don't know what happened there, so fail.
90 *built-in-koji ("%pkg") : source-dependencies (pkg) {
91 cd %fedora-dir/%pkg/%branch
95 # We have to wait for the dependencies to become available
96 # before we can start the new build.
97 for p in $($koji latest-build %< | awk '{print $1}'); do
98 $koji --quiet wait-repo side-tag
101 # If the specfile doesn't have the magic string then add
103 if ! grep -sq %rebuild-name $specfile; then
104 rpmdev-bumpspec -c "- "%rebuild-name *.spec
106 rpmdev-bumpspec -c "- Bump release and rebuild." *.spec
110 if [ "$koji" = "koji" ]; then
113 hash=$(git rev-parse HEAD)
114 $koji build "git+https://src.fedoraproject.org/rpms/"%pkg".git#$hash" %side-tag
119 # Get the source package names for a particular package.
120 # Note this is not merely the BuildRequires, since those are
121 # the binary packages. Also this will only find packages
122 # which are in the list of source-packages.
123 pure function source-dependencies (pkg) = @{
124 specfile=%fedora-dir/%pkg/%branch/%pkg.spec
126 echo -n Dependencies of %pkg: >&2
129 for r in $(rpmspec -q --buildrequires $specfile 2>/dev/null |
130 awk '{print $1}'); do
131 # Now we examine each *other* source package to see
132 # if any will create this dependency when they build.
133 for p in %source-packages; do
134 if [ "$p" != %pkg ] && \
135 rpmspec -q --provides %fedora-dir/$p/%branch/$p.spec 2>/dev/null |
139 echo "*built-in-koji(\"$p\"),"