diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-10-01 17:01:02 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-10-01 17:01:02 +0200 |
commit | 8bb9d760b54f103fe1c6be67fde307666b81b789 (patch) | |
tree | 297da8f42c8aa0d377a2db677d29ee16be198908 /rep-update | |
parent | 8253c613c49dd2c1aaac424ed932dffa52c494a9 (diff) |
Add rep-{update,test,publish} scripts
Diffstat (limited to 'rep-update')
-rwxr-xr-x | rep-update | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/rep-update b/rep-update new file mode 100755 index 0000000..cb40441 --- /dev/null +++ b/rep-update @@ -0,0 +1,84 @@ +#! /usr/bin/env bash + +# Update (or create) bpkg 'packages' files in repository. +# +# Usage: update [-t <toolchain>] [-e <subdir>] <dir> [<bpkg-options>] +# +# This script runs the rep-create command for every first-level subdirectory +# of <dir> that doesn't start with '.' and contains the 'repositories' file, +# unless <dir> itself contains 'repositories'. +# +# -e <subdir> +# Exclude the specified sub-directory. Currently only one directory can +# be excluded. +# +# -t <toolchain> +# Specify the build2 toolchain install/stage directory. The script will +# use <toolchain>/bin/bpkd instead of just bpkg. +# + +trap 'exit 1' ERR +set -o errtrace # Trap in functions. + +function info () { echo "$*" 1>&2; } +function error () { info "$*"; exit 1; } + +dir= +toolchain= +exclude= + +while [ $# -gt 0 ]; do + case $1 in + -e) + shift + exclude=${1%/} + shift + ;; + -t) + shift + toolchain=${1%/} + shift + ;; + *) + dir=${1%/} + shift + break + ;; + esac +done + +if [ -z "$dir" ]; then + error "usage: $0 [-t <toolchain>] <dir> [<bpkg-options>]" +fi + +if [ -z "$toolchain" ]; then + bpkg="bpkg" +else + bpkg="$toolchain/bin/bpkg" + if [ ! -x $bpkg ]; then + error "$bpkg does not exist or is not executable" + fi +fi + +if [ -f "$dir/repositories" ]; then + sub=$dir +else + sub=`find $dir -mindepth 1 -maxdepth 1 -type d -name '[^.]*'` + + if [ -z "$sub" ]; then + error "no 'repositories' file or subdirectories in $dir/" + fi +fi + +for d in $sub; do + if [ `basename $d` = "$exclude" ]; then + echo "skipping excluded $d/" 1>&2 + continue + fi + + if [ -f "$d/repositories" ]; then + $bpkg rep-create "$@" $d + else + echo "no 'repositories' file in $d/, skipping" 1>&2 + fi +done |