blob: fe876c6db1e826e74cbccc3a730556bbaa786aa9 (
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
#! /usr/bin/env bash
# Stage or queue one or more projects from the same group.
#
# -c
# Cleanup (remove) previous versions.
#
# -d
# Distribute only without regenerating or publishing the repository.
#
# -g
# Distribute and regenerate only without publishing the repository.
# In this mode of no packages is specified, then just regenerate.
#
# -p
# Publish only without distributing and regenerating the repository.
#
# -q
# Put packages into the queue instead of staging. Implies -d.
#
# -Q
# Put packages into staging queue instead of staging.
#
# --min-bpkg-version <ver>
#
# Pass --min-bpkg-version to bpkg-rep-create.
#
usage="usage: etc/stage-pkg [<options>] <group> <dir>..."
rsync_ops="--progress"
owd=`pwd`
trap "{ cd $owd; exit 1; }" ERR
set -o errtrace # Trap in functions.
function info () { echo "$*" 1>&2; }
function error () { info "$*"; exit 1; }
# Make sure the build2 tools are runnable.
#
b --version >/dev/null
bpkg --version >/dev/null
bdep --version >/dev/null
repo_name="STAGE.BUILD2.ORG"
repo_dir="staging/repository/1"
repo_host1="stage.build2.org:/var/bpkg/1"
repo_host2=
clean=
dist_only=
gen_only=
pub_only=
group=
dirs=()
rep_create_ops=()
while [ $# -gt 0 ]; do
case $1 in
-c)
clean=true
shift
;;
-d)
dist_only=true
shift
;;
-g)
gen_only=true
shift
;;
-p)
pub_only=true
shift
;;
-q)
#repo_name="CPPGET.ORG/QUEUE"
repo_dir="cppget.org/queue/1/alpha"
#repo_host1="cppget.org:/var/bpkg/1/queue"
#repo_host2="queue.cppget.org:/var/bpkg/1/queue"
dist_only=true
shift
;;
-Q)
repo_name="QUEUE.STAGE.BUILD2.ORG"
repo_dir="staging/queue/1"
repo_host1="stage.build2.org:/var/bpkg/queue/1"
shift
;;
--min-bpkg-version)
shift
rep_create_ops+=(--min-bpkg-version "$1")
shift
;;
*)
if [ -z "$group" ]; then
group="$1"
else
dirs+=("${1%/}")
fi
shift
;;
esac
done
if [ -z "$pub_only" ]; then
# In the -g mode skip distributing if no packages are specified.
#
if [ -z "$gen_only" -o -n "$group" ]; then
if [ -z "$group" -o "${#dirs[@]}" -eq 0 ]; then
error "$usage"
fi
mkdir -p /tmp/dist
# Dist individual packages into the repository.
#
function dist() # <group> <dir>
{
local o="$repo_dir/$1"
local b="$(basename $2)"
local d="$2-default"
# If *-default/ exists, use that (old style out of tree configuration).
# Otherwise, use the source directory itself (new style forwarded
# configuration).
#
if ! test -d "$d"; then
d="$2"
if ! test -d "$d"; then
error "neither $2-default nor $2 exist"
fi
fi
mkdir -p "$o"
# Clean up old packages.
#
if [ -n "$clean" ]; then
rm -f "$o/$b"-*
fi
b "dist($d/)" config.dist.root=/tmp/dist "config.dist.archives=$owd/$o/tar.gz"
}
for d in "${dirs[@]}"; do
dist "$group" "$d"
done
fi
if [ -n "$dist_only" ]; then
exit 0
fi
# Regenerate the repository.
#
info "Insert $repo_name signing key and press Enter"
read
etc/rep-update "$repo_dir/" "${rep_create_ops[@]}" \
--openssl-option -engine --openssl-option pkcs11 \
--openssl-option -keyform --openssl-option engine \
--key "label_SIGN key"
if [ -n "$gen_only" ]; then
exit 0
fi
fi # !pub_only
# Sync repository.
#
info "Press Enter to start package upload"
read
etc/rep-publish "$repo_dir/" "$repo_host1/" $rsync_ops
if [ -n "$repo_host2" ]; then
etc/rep-publish "$repo_dir/" "$repo_host2/" $rsync_ops
fi
|