libguestfs: Do f20 releases by hand.
[goaljobs-goals.git] / libguestfs_fedora.ml
1 (* Handle Fedora builds of libguestfs. *)
2
3 open Goaljobs
4
5 open Printf
6
7 open Config
8 open Fedora
9 open Git
10 open Libguestfs
11
12 (* Enable debugging. *)
13 let () =
14   Unix.putenv "LIBGUESTFS_DEBUG" "1";
15   Unix.putenv "LIBGUESTFS_TRACE" "1"
16
17 (* Log program output. *)
18 let from = "rjones@redhat.com"
19 let to_ = "rjones@redhat.com"
20
21 let package = "libguestfs"
22
23 (* How branches in libguestfs upstream map to branches in Fedora. *)
24 let branches = [
25   "1.23-development", "master";    (* Rawhide follows development. *)
26   (* f20 is being done by hand until 1.24 is released. *)
27   "1.22-stable", "f19";            (* F19 follows 1.22. *)
28   "1.20-stable", "f18";            (* F18 follows 1.20. *)
29 ]
30
31 (* Goal: Latest website version has been built in every branch. *)
32 let rec goal all () =
33   List.iter (
34     fun (wbranch, fbranch) ->
35       match website_latest_version wbranch with
36       | None -> ()
37       | Some version ->
38         require (fedora_built version fbranch)
39   ) branches
40
41 (* Goal: Fedora has a successful build of 'version' on 'branch'. *)
42 and fedora_built version branch =
43   let specfile = fedora_specfile package branch in
44
45   target (file_contains_string specfile version.version &&
46             koji_build_state (fedora_verrel package branch) == `Complete);
47
48   require (sources_uploaded version branch);
49   require (specfile_pushed version branch);
50
51   koji_build ~wait:true package branch
52
53 and sources_uploaded version branch =
54   let repodir = fedora_repo package branch in
55   let sources = repodir // "sources" in
56   let key = sprintf "libguestfs_fedora_sources_uploaded_%s" version.version in
57
58   target (file_contains_string sources version.version &&
59             memory_exists key);
60   onrun (fun () -> memory_set key "1");
61
62   require (repodir_up_to_date repodir);
63
64   sh "
65     cd %s
66     fedpkg new-sources %s/%s
67   " repodir libguestfs_website_repo version.urlpath
68
69 and specfile_updated version branch =
70   let repodir = fedora_repo package branch in
71   let specfile = fedora_specfile package branch in
72
73   target (file_contains_string specfile version.version);
74
75   require (repodir_up_to_date repodir);
76
77   (* Hairy specfile editing. *)
78   sh "
79     cd %s
80     email=\"Richard W.M. Jones <rjones@redhat.com>\"
81     date=`date +\"%%a %%b %%d %%Y\"`
82     cp libguestfs.spec libguestfs.spec.old
83     sed < libguestfs.spec.old \\
84     -e \"s/^Version:.*/Version:       %s/\" \\
85     -e \"s/^Release:.*/Release:       1%%{?dist}/\" \\
86     -e \"/^%%changelog/a \\
87 * $date $email - 1:%s-1\\\\n\\
88 - New upstream version %s.\\\\n\\
89 \" > libguestfs.spec
90     rm libguestfs.spec.old
91   " repodir version.version version.version version.version
92
93 and specfile_committed version branch =
94   let repodir = fedora_repo package branch in
95   let key = sprintf "libguestfs_fedora_specfile_committed_%s" version.version in
96
97   target (memory_exists key);
98   onrun (fun () -> memory_set key "1");
99
100   require (specfile_updated version branch);
101
102   sh "
103     cd %s
104     fedpkg commit -c
105   " repodir
106
107 and specfile_pushed version branch =
108   let repodir = fedora_repo package branch in
109   let key = sprintf "libguestfs_fedora_specfile_pushed_%s" version.version in
110
111   target (memory_exists key);
112   onrun (fun () -> memory_set key "1");
113
114   require (repodir_up_to_date repodir);
115   require (specfile_committed version branch);
116
117   sh "
118     cd %s
119     fedpkg push
120   " repodir
121
122 and repodir_up_to_date repodir =
123   sh "
124     cd %s
125     git fetch
126   " repodir;
127   if not (git_has_local_changes repodir) then
128     sh "
129       cd %s
130       git pull --rebase
131     " repodir