summaryrefslogtreecommitdiff
path: root/stage-pkg
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-05-05 14:26:14 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-05-05 14:26:14 +0200
commitb22f2f86d4a7166b7098fc82944a198e6ad63748 (patch)
tree5e52471866323e253d3d53a07a24710ccc8273d6 /stage-pkg
parent56c433b914d65ccf9b9c53a78562452475353e8d (diff)
Updates for 0.5.0 release0.5.0
Diffstat (limited to 'stage-pkg')
-rwxr-xr-xstage-pkg122
1 files changed, 122 insertions, 0 deletions
diff --git a/stage-pkg b/stage-pkg
new file mode 100755
index 0000000..02b3e96
--- /dev/null
+++ b/stage-pkg
@@ -0,0 +1,122 @@
+#! /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 regenerating only without publishing the repository.
+#
+# -q
+# Publish packages into the queue instead of staging.
+#
+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; }
+
+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=
+group=
+dirs=()
+
+while [ $# -gt 0 ]; do
+ case $1 in
+ -c)
+ clean=true
+ shift
+ ;;
+ -d)
+ dist_only=true
+ shift
+ ;;
+ -g)
+ gen_only=true
+ shift
+ ;;
+ -q)
+ repo_name="CPPGET.ORG/QUEUE"
+ repo_dir="cppget.org/repository/1/queue"
+ repo_host1="cppget.org:/var/bpkg/1/queue"
+ repo_host2="queue.cppget.org:/var/bpkg/1/queue"
+ shift
+ ;;
+ *)
+ if [ -z "$group" ]; then
+ group="$1"
+ else
+ dirs+=("${1%/}")
+ fi
+ shift
+ ;;
+ esac
+done
+
+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)"
+
+ mkdir -p "$o"
+
+ # Clean up old packages.
+ #
+ if [ -n "$clean" ]; then
+ rm -f "$o/$b"-*
+ fi
+
+ b "dist($2-default/)" "config.dist.archives=$owd/$o/tar.gz"
+}
+
+for d in "${dirs[@]}"; do
+ dist "$group" "$d"
+done
+
+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/" \
+ --openssl-option -engine --openssl-option pkcs11 \
+ --openssl-option -keyform --openssl-option engine \
+ --key "label_SIGN key"
+
+if [ -n "$gen_only" ]; then
+ exit 0
+fi
+
+# Sync repository.
+#
+etc/rep-publish "$repo_dir/" "$repo_host1/" $rsync_ops
+
+if [ -n "$repo_host2" ]; then
+ etc/rep-publish "$repo_dir/" "$repo_host2/" $rsync_ops
+fi