summaryrefslogtreecommitdiff
path: root/contrib/containers-common/containers-common.sh
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/containers-common/containers-common.sh')
-rwxr-xr-xcontrib/containers-common/containers-common.sh56
1 files changed, 56 insertions, 0 deletions
diff --git a/contrib/containers-common/containers-common.sh b/contrib/containers-common/containers-common.sh
new file mode 100755
index 000000000..9e7b445eb
--- /dev/null
+++ b/contrib/containers-common/containers-common.sh
@@ -0,0 +1,56 @@
+#!/usr/bin/bash -e
+#
+# Script used for downloading man pages and config files from
+# github.com/containers libraries (storage, common, image)
+#
+# Must be run from directory containing input specfile
+#
+
+die() {
+ echo "$(basename $0): $*" >&2
+ exit 1
+}
+
+branchversion() {
+ gomod=$(git rev-parse --show-toplevel)/go.mod
+ v=$(awk -v X=github.com/containers/$1 '$1 ~ X { print $2 }' <$gomod)
+ hash=$(expr "$v" : "v.*-[0-9.]\+-\([0-9a-f]\+\)")
+ if [[ -n "$hash" ]]; then
+ v="$hash"
+ fi
+ echo "$v"
+}
+
+
+SPECFILE=containers-common.spec
+if [[ ! -e $SPECFILE.in ]]; then
+ die "Please run me from the same directory as $SPECFILE.in"
+fi
+
+declare -A moduleversion
+for module in common image storage; do
+ v=$(branchversion $module)
+ if [[ -z "$v" ]]; then
+ die "Could not find version for module '$v'"
+ fi
+ moduleversion[$module]=$v
+done
+
+builddir=containers-common-${moduleversion[common]}
+mkdir -p $builddir
+
+sed -e "s/COMMON_BRANCH/${moduleversion[common]}/g" \
+ -e "s/IMAGE_BRANCH/${moduleversion[image]}/g" \
+ -e "s/STORAGE_BRANCH/${moduleversion[storage]}/g" \
+ <$SPECFILE.in >$builddir/$SPECFILE
+
+cd $builddir
+spectool -fg $SPECFILE
+
+if [[ ! -e storage.conf ]]; then
+ die "spectool did not pull storage.conf"
+fi
+
+echo "Changing storage.conf..."
+sed -i -e 's/^driver.*=.*/driver = "overlay"/' -e 's/^mountopt.*=.*/mountopt = "nodev,metacopy=on"/' \
+ storage.conf