X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=fedora.ml;h=6575dbfa00bc127f7df1e48f05b754363ab452f8;hb=4b474a524994c85339b5f50b5d8df734a8efae96;hp=edc9cfd08a3d949ebd0e4ea110a5f4e31e9d346b;hpb=ece68a0d845a02388127bb5a68698ce92690894f;p=goaljobs-goals.git diff --git a/fedora.ml b/fedora.ml index edc9cfd..6575dbf 100644 --- a/fedora.ml +++ b/fedora.ml @@ -73,6 +73,14 @@ let contains_substring substr str = * resists automation: RHBZ#760924. *) +(* XXX koji_build_state verrel: If you do a build and it fails, then + * do another build without bumping the release field, 'koji buildinfo' + * seems to always return the failed build, at least until the second + * build completes. This means the code below fails. Unclear how it + * can be fixed, but best to always bump the release to avoid the + * problem. + *) + (* Get build state. *) let rec koji_build_state verrel = fst (koji_build_state_task verrel) @@ -90,34 +98,36 @@ and koji_build_state_task = else ( let out = shout "timeout 120 koji buildinfo %s 2>&1 ||:" verrel in if no_such_build out then - failwith (sprintf "koji_build_state_task: %s: no such build" verrel); - let state = - try - let subs = Pcre.exec ~rex:state out in - match Pcre.get_substring subs 1 with - | "BUILDING" -> `Building - | "COMPLETE" -> `Complete - | "DELETED" -> `Deleted - | "FAILED" -> `Failed - | "CANCELED" -> `Canceled - | sub -> - failwith (sprintf "koji_build_state_task: %s: unknown build state '%s'" - verrel sub) - with - Not_found -> - failwith (sprintf "koji_build_state_task: %s: no build state found" - verrel) in - let task = - try - let subs = Pcre.exec ~rex:task_id out in - Some (int_of_string (Pcre.get_substring subs 1)) - with - Not_found -> None in - - if state == `Complete then - memory_set key "1"; - - state, task + `No_such_build, None + else ( + let state = + try + let subs = Pcre.exec ~rex:state out in + match Pcre.get_substring subs 1 with + | "BUILDING" -> `Building + | "COMPLETE" -> `Complete + | "DELETED" -> `Deleted + | "FAILED" -> `Failed + | "CANCELED" -> `Canceled + | sub -> + failwith (sprintf "koji_build_state_task: %s: unknown build state '%s'" + verrel sub) + with + Not_found -> + failwith (sprintf "koji_build_state_task: %s: no build state found" + verrel) in + let task = + try + let subs = Pcre.exec ~rex:task_id out in + Some (int_of_string (Pcre.get_substring subs 1)) + with + Not_found -> None in + + if state == `Complete then + memory_set key "1"; + + state, task + ) ) (* Perform a Koji build and wait until it finishes. If it fails, @@ -134,10 +144,15 @@ let koji_build = let out = shout " cd %s - fedpkg build%s 2>&1 ||: + fedpkg build%s 2>&1 " repodir (if not wait then " --nowait" else "") in - if wait then ( + if not wait then ( + (* Just check the task was created. *) + if not (Pcre.pmatch ~rex:created_task out) then ( + failwith "fedpkg build: build failed to start" + ) + ) else ( let task_id = try let subs = Pcre.exec ~rex:created_task out in @@ -153,7 +168,6 @@ let koji_build = else if completed_successfully out then () else if failed out then ( - eprintf "%s\n%!" out; failwith "koji build failed" ) else