-let koji_build_exists =
- let state_complete = contains_substring "State: COMPLETE" in
- let state_other = contains_substring "State: " in
+
+(* 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)
+
+(* Get build state and task ID. *)
+and koji_build_state_task =
+ let state = Pcre.regexp "State: (\\w+)" in
+ let task_id = Pcre.regexp "Task: (\\d+)" in