<p>osmith has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/c/osmo-ci/+/26622">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">contrib/obs-mirror: import<br><br>Import scripts from OS#4862 to have them properly versioned. We use this<br>to replicate Osmocom related packages from OBS to:<br>https://download.osmocom.org/obs-mirror<br><br>Put it in contrib/, because it doesn't need to get installed to the<br>jenkins nodes (as it would happen with everything in scripts/).<br><br>Related: OS#4862<br>Change-Id: I3f47cddbcee6c9b85fde77a039dcd5b54dd89f2d<br>---<br>A contrib/obs-mirror/README<br>A contrib/obs-mirror/obs-mirror-include.txt<br>A contrib/obs-mirror/obs-mirror.sh<br>A contrib/obs-mirror/rm-old-nightly-archives.sh<br>A contrib/obs-mirror/test-include-list.sh<br>5 files changed, 99 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-ci refs/changes/22/26622/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/contrib/obs-mirror/README b/contrib/obs-mirror/README</span><br><span>new file mode 100644</span><br><span>index 0000000..4cab14b</span><br><span>--- /dev/null</span><br><span>+++ b/contrib/obs-mirror/README</span><br><span>@@ -0,0 +1,7 @@</span><br><span style="color: hsl(120, 100%, 40%);">+The scripts in this directory are used to create an archive of Osmocom related</span><br><span style="color: hsl(120, 100%, 40%);">+packages from OBS, at: https://downloads.osmocom.org/obs-mirror/</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+There is no mechanism in place to deploy updated scripts after updating them</span><br><span style="color: hsl(120, 100%, 40%);">+here in osmo-ci.git, so this must be done manually.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+See OS#4862 for more information.</span><br><span>diff --git a/contrib/obs-mirror/obs-mirror-include.txt b/contrib/obs-mirror/obs-mirror-include.txt</span><br><span>new file mode 100644</span><br><span>index 0000000..037ce3f</span><br><span>--- /dev/null</span><br><span>+++ b/contrib/obs-mirror/obs-mirror-include.txt</span><br><span>@@ -0,0 +1,9 @@</span><br><span style="color: hsl(120, 100%, 40%);">+latest/CentOS_8</span><br><span style="color: hsl(120, 100%, 40%);">+latest/Debian_10</span><br><span style="color: hsl(120, 100%, 40%);">+latest/Raspbian_10</span><br><span style="color: hsl(120, 100%, 40%);">+latest/xUbuntu_21.04</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+nightly/CentOS_8</span><br><span style="color: hsl(120, 100%, 40%);">+nightly/Debian_10</span><br><span style="color: hsl(120, 100%, 40%);">+nightly/Raspbian_10</span><br><span style="color: hsl(120, 100%, 40%);">+nightly/xUbuntu_21.04</span><br><span>diff --git a/contrib/obs-mirror/obs-mirror.sh b/contrib/obs-mirror/obs-mirror.sh</span><br><span>new file mode 100755</span><br><span>index 0000000..76317c4</span><br><span>--- /dev/null</span><br><span>+++ b/contrib/obs-mirror/obs-mirror.sh</span><br><span>@@ -0,0 +1,40 @@</span><br><span style="color: hsl(120, 100%, 40%);">+#!/bin/bash</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# Mirror script to create a local archive of the OBS packages in the network:osmocom</span><br><span style="color: hsl(120, 100%, 40%);">+# repositories / projects</span><br><span style="color: hsl(120, 100%, 40%);">+#</span><br><span style="color: hsl(120, 100%, 40%);">+# We are using hard-links to perform de-duplication on the local side; only</span><br><span style="color: hsl(120, 100%, 40%);">+# those files that changed compoared to the previous run will be rsync'ed over</span><br><span style="color: hsl(120, 100%, 40%);">+# from the remote side</span><br><span style="color: hsl(120, 100%, 40%);">+#</span><br><span style="color: hsl(120, 100%, 40%);">+# See also: OS#4862</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+set -e -x</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# base directory on the local side</span><br><span style="color: hsl(120, 100%, 40%);">+BASE_DIR="/downloads/obs-mirror/"</span><br><span style="color: hsl(120, 100%, 40%);">+# sync remote where to find the osmocom packages</span><br><span style="color: hsl(120, 100%, 40%);">+REMOTE="rsync.opensuse.org::opensuse-full-really-everything-including-repositories/opensuse/repositories/network:/osmocom:"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+cd "$BASE_DIR"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+RSYNC_ARGS="-av --delete"</span><br><span style="color: hsl(120, 100%, 40%);">+RSYNC_ARGS="$RSYNC_ARGS --files-from /home/pkgmirror/obs-mirror-include.txt --recursive"</span><br><span style="color: hsl(120, 100%, 40%);">+DATE=`date +%Y%m%d-%H%M%S`</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# create output directory</span><br><span style="color: hsl(120, 100%, 40%);">+DIR="$BASE_DIR/$DATE"</span><br><span style="color: hsl(120, 100%, 40%);">+mkdir -p "$DIR"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+PREVIOUS="$BASE_DIR/.previous"</span><br><span style="color: hsl(120, 100%, 40%);">+if [ -d "$PREVIOUS" ]; then</span><br><span style="color: hsl(120, 100%, 40%);">+  RSYNC_ARGS+=" --link-dest=$PREVIOUS"</span><br><span style="color: hsl(120, 100%, 40%);">+fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# finally, perform rsync</span><br><span style="color: hsl(120, 100%, 40%);">+# || true: don't stop here if one of the dirs from the include list does not exist</span><br><span style="color: hsl(120, 100%, 40%);">+rsync $RSYNC_ARGS "$REMOTE"/ "$DIR"/ || true</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# update '.previous' for the next run</span><br><span style="color: hsl(120, 100%, 40%);">+rm -f "$PREVIOUS"</span><br><span style="color: hsl(120, 100%, 40%);">+ln -sf "$DATE" "$PREVIOUS"</span><br><span>diff --git a/contrib/obs-mirror/rm-old-nightly-archives.sh b/contrib/obs-mirror/rm-old-nightly-archives.sh</span><br><span>new file mode 100755</span><br><span>index 0000000..3a5f276</span><br><span>--- /dev/null</span><br><span>+++ b/contrib/obs-mirror/rm-old-nightly-archives.sh</span><br><span>@@ -0,0 +1,31 @@</span><br><span style="color: hsl(120, 100%, 40%);">+#!/bin/sh -e</span><br><span style="color: hsl(120, 100%, 40%);">+# Remove nightly archives older than one month (OS#4862)</span><br><span style="color: hsl(120, 100%, 40%);">+DRY=0</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+# Get removal date in seconds since epoch and display it</span><br><span style="color: hsl(120, 100%, 40%);">+DATE_RM_SEC=$(expr $(date +%s) - 3600 \* 24 \* 32)</span><br><span style="color: hsl(120, 100%, 40%);">+DATE_RM_STR=$(date -d "@$DATE_RM_SEC" +"%Y-%m-%d")</span><br><span style="color: hsl(120, 100%, 40%);">+echo "Removing nightly archives from $DATE_RM_STR and older"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+cd /downloads/obs-mirror</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+for i in */nightly; do</span><br><span style="color: hsl(120, 100%, 40%);">+        # "Last modified" isn't set to the date of the dir name for some</span><br><span style="color: hsl(120, 100%, 40%);">+        # archives, so parse the date from the dir name instead</span><br><span style="color: hsl(120, 100%, 40%);">+        DATE_DIR="$(basename "$(dirname "$i")")"  # e.g. "20210604-002301"</span><br><span style="color: hsl(120, 100%, 40%);">+        DATE_DIR_SEC="$(date -d "$(echo "$DATE_DIR" | cut -d "-" -f 1)" +%s)"</span><br><span style="color: hsl(120, 100%, 40%);">+        if [ -z "$DATE_DIR_SEC" ]; then</span><br><span style="color: hsl(120, 100%, 40%);">+                echo "ERROR: $i: failed to parse date from dir name"</span><br><span style="color: hsl(120, 100%, 40%);">+                continue</span><br><span style="color: hsl(120, 100%, 40%);">+        fi</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        if [ "$DATE_DIR_SEC" -lt "$DATE_RM_SEC" ]; then</span><br><span style="color: hsl(120, 100%, 40%);">+                DATE_DIR_STR="$(date -d "@$DATE_DIR_SEC" +"%Y-%m-%d")"</span><br><span style="color: hsl(120, 100%, 40%);">+                echo "Removing $i ($DATE_DIR_STR)..."</span><br><span style="color: hsl(120, 100%, 40%);">+                if [ "$DRY" = 0 ]; then</span><br><span style="color: hsl(120, 100%, 40%);">+                        rm -r "$i"</span><br><span style="color: hsl(120, 100%, 40%);">+                fi</span><br><span style="color: hsl(120, 100%, 40%);">+        fi</span><br><span style="color: hsl(120, 100%, 40%);">+done</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+echo "Done"</span><br><span>diff --git a/contrib/obs-mirror/test-include-list.sh b/contrib/obs-mirror/test-include-list.sh</span><br><span>new file mode 100755</span><br><span>index 0000000..6766403</span><br><span>--- /dev/null</span><br><span>+++ b/contrib/obs-mirror/test-include-list.sh</span><br><span>@@ -0,0 +1,12 @@</span><br><span style="color: hsl(120, 100%, 40%);">+#!/bin/sh -ex</span><br><span style="color: hsl(120, 100%, 40%);">+BASE_DIR="/downloads/obs-mirror/"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+cd "$BASE_DIR"</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+rsync \</span><br><span style="color: hsl(120, 100%, 40%);">+        -a \</span><br><span style="color: hsl(120, 100%, 40%);">+        --list-only \</span><br><span style="color: hsl(120, 100%, 40%);">+        --files-from /home/pkgmirror/obs-mirror-include.txt \</span><br><span style="color: hsl(120, 100%, 40%);">+        --recursive \</span><br><span style="color: hsl(120, 100%, 40%);">+        "$(realpath .previous)"/ \</span><br><span style="color: hsl(120, 100%, 40%);">+        new-backup-dir/</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/c/osmo-ci/+/26622">change 26622</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/c/osmo-ci/+/26622"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-ci </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-Change-Id: I3f47cddbcee6c9b85fde77a039dcd5b54dd89f2d </div>
<div style="display:none"> Gerrit-Change-Number: 26622 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: osmith <osmith@sysmocom.de> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>