blob: a269e6bc7167f0718add53dad449e64126739d27 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# file : brep/handler/ci/ci.bash.in
# copyright : Copyright (c) 2014-2019 Code Synthesis Ltd
# license : MIT; see accompanying LICENSE file
# Utility functions useful for implementing CI request handlers.
if [ "$brep_handler_ci" ]; then
return 0
else
brep_handler_ci=true
fi
@import brep/handler/handler@
# Serialize the CI result manifest to stdout and exit the (sub-)shell with the
# zero status.
#
reference= # Should be assigned by the handler when becomes available.
function exit_with_manifest () # <status> <message>
{
trace_func "$@"
local sts="$1"
local msg="$2"
manifest_serializer_start
manifest_serialize "" "1" # Start of manifest.
manifest_serialize "status" "$sts"
manifest_serialize "message" "$msg"
if [ -n "$reference" ]; then
manifest_serialize "reference" "$reference"
elif [ "$sts" == "200" ]; then
error "no reference for code $sts"
fi
manifest_serializer_finish
run exit 0
}
# Dump the repositories.manifest and packages.manifest files into the
# specified directory by running bpkg-rep-info command for the specified
# repository and using the specified fetch timeout (in seconds).
#
function dump_repository_manifests () # <repo-url> <dir> <timeout>
{
local url="$1"
local dir="$2"
local tmo="$3"
# Note that due to the --manifest option only known manifest values are
# allowed.
#
if ! run_silent bpkg rep-info --fetch-timeout "$tmo" --manifest \
--repositories --repositories-file "$dir/repositories.manifest" \
--packages --packages-file "$dir/packages.manifest" "$url"; then
# Perform the sanity check to make sure that bpkg is runnable.
#
if ! run bpkg --version >/dev/null; then
error "unable to run bpkg"
fi
exit_with_manifest 422 "unable to fetch repository information (run 'bpkg rep-info $url' for details)"
fi
}
|