Ignore some packages which failed to build on riscv64.
[fedora-ocaml-rebuild.git] / Goalfile
1 # See README.
2
3 let fedora-dir = "%HOME/d/fedora"
4
5 let branch = "master"
6 let side-tag = "f32-ocaml"
7 #let koji = "koji"
8 let koji = "koji -p riscv64"
9 #let fedpkg = "fedpkg"
10 let fedpkg = "fedpkg --user-config %HOME/d/fedora-ocaml-rebuild/fedpkg-user-config"
11
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"
15
16 # Packages that are blocked.  Any dependent packages are also blocked
17 # automatically.
18 # XXX Not implemented, use ignore for now.
19 #let blocked = [ "ocaml-camlp4" ]
20
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
25     "ocaml-camlp4",
26     "cduce",
27     "guestfs-browser",
28     "ocaml-bin-prot",
29     "ocaml-bisect",
30     "ocaml-bitstring",
31     "ocaml-deriving",
32     "ocaml-json-static",
33     "ocaml-mikmatch",
34     "ocaml-openin",
35     "ocaml-pa-monad",
36     "ocaml-pgocaml",
37     "ocaml-sexplib",
38     "ocaml-type-conv",
39     "ocamldsort",
40
41     # These ones failed to build on riscv64, ignore them for now.
42     "apron", "plplot", "ocaml-ulex"
43 ]
44
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",
50     "why3", "z3",
51     "flocq" # no OCaml code, but needs to be rebuilt after Coq
52 ]
53 pure function get-source-packages () returning strings = {
54     cd %fedora-dir
55     for f in ocaml* %other-packages; do
56         [ -f $f/%branch/$f.spec ] && echo "$f"
57     done
58 }
59 let source-packages = wrap ("*built-in-koji", get-source-packages ())
60
61 # Main goal: Rebuild all packages.
62 goal all = : source-packages ;
63
64 # Check if the source package has been built in Koji.
65 tactic *built-in-koji (pkg) = {
66     cd %fedora-dir/%pkg/%branch
67     koji=%koji
68     specfile=%pkg.spec
69
70     # Packages which are ignored are treated as if they were rebuilt already.
71     for p in %ignored; do
72         if [ %pkg = "$p" ]; then exit 0; fi
73     done
74
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
78
79     # Else we must check Koji itself.
80     # Koji sends some messages to stderr.
81     nvr=$(fedpkg verrel)
82     buildinfo=$($koji buildinfo $nvr 2>&1 ||:)
83
84     # No build at all, needs rebuild.
85     echo "$buildinfo" | grep -sq "No such build" && exit 99
86
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}')
90
91     case "$state" in
92     COMPLETE)
93         # Complete so we don't need to rebuild.
94         exit 0 ;;
95     FAILED)
96         # Failed builds must be examined and fixed manually.
97         exit 1 ;;
98     BUILDING)
99         # Cancel the build, we will resubmit it.
100         $koji cancel $taskid ||:
101         exit 99 ;;
102     CANCELED|DELETED)
103         # Do a rebuild.
104         exit 99 ;;
105     esac
106     # Don't know what happened there, so fail.
107     exit 1
108 }
109
110 goal rebuild (pkg) =
111 *built-in-koji ("%pkg") : wrap ("*built-in-koji", source-dependencies (pkg)) {
112     cd %fedora-dir/%pkg/%branch
113     fedpkg=%fedpkg
114     koji=%koji
115     specfile=%pkg.spec
116
117     # We have to wait for the dependencies to become available
118     # before we can start the new build.
119     for p in %<; do
120         nvr=$($koji --quiet latest-build %side-tag $p | awk '{print $1}')
121         $koji wait-repo %side-tag --build=$nvr
122     done
123
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.
127     git pull
128
129     # If the specfile doesn't have the magic string then add
130     # that now.
131     if ! grep -sq %rebuild-name $specfile; then
132         rpmdev-bumpspec -c "- "%rebuild-name *.spec
133     else
134         rpmdev-bumpspec -c "- Bump release and rebuild." *.spec
135     fi
136     $fedpkg commit -c
137     $fedpkg push
138     $fedpkg build --target %side-tag
139 }
140
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
147
148     echo Calculating dependencies of %pkg >&2
149
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 |
157                  awk '{print $1}' |
158                  grep -sq "^$r\$"
159              then
160                  echo "$p"
161             fi
162         done
163     done
164 }