third_party: Add a script to update waf
authorAndreas Schneider <asn@samba.org>
Thu, 26 Aug 2021 12:52:14 +0000 (14:52 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 2 Sep 2021 20:30:31 +0000 (20:30 +0000)
    ./third_party/waf/update.sh

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
third_party/update.sh
third_party/waf/update.sh [new file with mode: 0755]

index a510e8a70426e0b2f154011af9f481d10b7aa901..2945699187444b81ce6b44563814ae48384069c5 100755 (executable)
@@ -23,9 +23,4 @@ hg clone https://bitbucket.org/micktwomey/pyiso8601 "$WORKDIR/pyiso8601"
 rm -rf "$WORKDIR/pyiso8601/.hg"
 rsync -avz --delete "$WORKDIR/pyiso8601/" "$THIRD_PARTY_DIR/pyiso8601/"
 
-echo "Updating waf..."
-git clone git://git.samba.org/third_party/waf.waf15/ "$WORKDIR/waf"
-rm -rf "$WORKDIR/waf/.git"
-rsync -C -avz --delete "$WORKDIR/waf/" "$THIRD_PARTY_DIR/waf/"
-
 rm -rf "$WORKDIR"
diff --git a/third_party/waf/update.sh b/third_party/waf/update.sh
new file mode 100755 (executable)
index 0000000..16bda84
--- /dev/null
@@ -0,0 +1,79 @@
+#!/bin/bash
+
+if [[ $# -lt 1 ]]; then
+    echo "Usage: update.sh VERSION"
+    exit 1
+fi
+
+WAF_VERSION="${1}"
+WAF_GIT="https://gitlab.com/ita1024/waf.git"
+WAF_UPDATE_SCRIPT="$(readlink -f "$0")"
+WAF_SAMBA_DIR="$(dirname "${WAF_UPDATE_SCRIPT}")"
+WAF_TMPDIR=$(mktemp --tmpdir -d waf-XXXXXXXX)
+
+echo "VERSION:       ${WAF_VERSION}"
+echo "GIT URL:       ${WAF_GIT}"
+echo "WAF SAMBA DIR: ${WAF_SAMBA_DIR}"
+echo "WAF TMP DIR:    ${WAF_TMPDIR}"
+
+cleanup_tmpdir() {
+    popd 2>/dev/null || true
+    rm -rf "$WAF_TMPDIR"
+}
+trap cleanup_tmpdir SIGINT
+
+cleanup_and_exit() {
+    cleanup_tmpdir
+    if test "$1" = 0 -o -z "$1" ; then
+        exit 0
+    else
+        exit "$1"
+    fi
+}
+
+# Checkout the git tree
+mkdir -p "${WAF_TMPDIR}"
+pushd "${WAF_TMPDIR}" || cleanup_and_exit 1
+
+git clone "${WAF_GIT}"
+ret=$?
+if [ $ret -ne 0 ]; then
+    echo "ERROR: Failed to clone repository"
+    cleanup_and_exit 1
+fi
+
+
+pushd waf || cleanup_and_exit 1
+git checkout -b "waf-${WAF_VERSION}" "waf-${WAF_VERSION}"
+ret=$?
+if [ $ret -ne 0 ]; then
+    echo "ERROR: Failed to checkout waf-${WAF_VERSION} repository"
+    cleanup_and_exit 1
+fi
+popd || cleanup_and_exit 1
+
+popd || cleanup_and_exit 1
+
+# Update waflib
+pushd "${WAF_SAMBA_DIR}" || cleanup_and_exit 1
+pwd
+
+rm -rf waflib/
+rsync -av "${WAF_TMPDIR}/waf/waflib" .
+ret=$?
+if [ $ret -ne 0 ]; then
+    echo "ERROR: Failed copy waflib"
+    cleanup_and_exit 1
+fi
+chmod -x waflib/Context.py
+
+git add waflib
+
+popd || cleanup_and_exit 1
+
+echo
+echo "Now please change VERSION in buildtools/bin/waf and"
+echo "Context.HEXVERSION in buildtools/wafsamba/wafsamba.py"
+echo
+
+cleanup_and_exit 0