0426d0c5878e — John Mulligan 4 years ago
container: container build based on new home repo

Support git / github by default in the build & test container.  Still allow
basic hg functions as I'm going to keep using hg (as a wrapper over git).
2 files changed, 33 insertions(+), 10 deletions(-)

M tests/container/Containerfile
M tests/container/build.sh
M tests/container/Containerfile +1 -0
@@ 2,6 2,7 @@ FROM fedora
 
 RUN yum install \
     -y --setopt=install_weak_deps=False \
+    git \
     mercurial \
     python-pip \
     python-pip-wheel \

          
M tests/container/build.sh +32 -10
@@ 1,23 1,45 @@ 
-#!/bin/sh
+#!/bin/bash
+
+set -e
 
 python=python3
-url="https://hg.sr.ht/~phlogistonjohn/sambacc"
-
-mkdir -p /var/tmp/build/
+url="https://github.com/phlogistonjohn/sambacc"
 bdir="/var/tmp/build/sambacc"
 
-if [ -d "$bdir" ] && hg --cwd "$bdir" log -r. ; then
+checked_out() {
+    local d="$1"
+    # allow manual clones with either git or hg
+    [[ -d "$d" && ( -d "$d/.git" || -d "$d/.hg" ) ]]
+}
+
+clone() {
+    # if the script is doing the cloning we default to git
+    # as obnoxxx has peer-pressured me into it
+    git clone "$1" "$2"
+}
+
+update() {
+    local d="$1"
+    local node="$2"
+    if [[ -d "$d/.hg" ]]; then
+        hg update --check "${node}"
+    else
+        git checkout "${node}"
+    fi
+}
+
+mkdir -p /var/tmp/build/ || true
+if checked_out "${bdir}" ; then
     echo "repo already checked out"
 else
-    hg clone "$url" "$bdir"
+    clone "$url" "${bdir}"
 fi
 
-set -e
-cd "$bdir"
+cd "${bdir}"
 
 if [ "$1" ]; then
-    # a revision id was specified on the cli
-    hg update --check "$1"
+    # a tag or revision id was specified on the cli
+    update "${bdir}" "$1"
 fi
 
 # Allow the tests to use customized passwd file contents in order