[gnome-games/wip/exalm/pin] tools: Add pin-libretro-commits.sh
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/pin] tools: Add pin-libretro-commits.sh
- Date: Sat, 9 Mar 2019 17:34:30 +0000 (UTC)
commit 468705b44656dbb2e0bb55dc16c7ae011bda4734
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Sat Mar 9 22:27:13 2019 +0500
tools: Add pin-libretro-commits.sh
This will help with preparing 3.32.0 manifest.
We have comments in json files, so most json libraries reject the files.
Hence use a dirty regex-based approach.
Fixes #81
tools/pin-libretro-commits.sh | 49 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
---
diff --git a/tools/pin-libretro-commits.sh b/tools/pin-libretro-commits.sh
new file mode 100755
index 00000000..d429bc40
--- /dev/null
+++ b/tools/pin-libretro-commits.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+
+CORES_DIR="../flatpak/libretro-cores"
+
+# A script pinning down commits of all libretro cores to be used before doing
+# a stable release.
+
+cd $CORES_DIR
+
+for F in *.json; do
+ echo "Processing $F"
+
+ LINE_NUMBER=$(grep -Pn '\"type\"\s*:\s*\"git\"' $F | grep -Po '^\d+')
+
+ if [[ "$LINE_NUMBER" == "" ]]; then
+ echo "Cannot find line containing git source"
+ exit 1
+ fi
+
+ # If one of the next 2 lines contains "commit" word in quotes, assume it's already pinned and skip it
+ sed -n "$((LINE_NUMBER+2)),$((LINE_NUMBER+3))p" $F | grep '\"commit\"' > /dev/null
+ if [[ "$?" == "0" ]]; then
+ echo 'Already pinned, skipping'
+ echo
+ continue
+ fi
+
+ # Find every substring between two quotes, take the last one
+ URL=`sed -n "$((LINE_NUMBER+1))p" $F | grep -Po '(?<=\")[^"]*(?=\")' | tail -n1`
+ BRANCH='master'
+
+ # Check for "branch" word on the next line. If it's present, get the branch the same way
+ # as url and use it instead of master
+ sed -n "$((LINE_NUMBER+2))p" $F | grep '\"branch\"' > /dev/null
+ if [[ "$?" == "0" ]]; then
+ BRANCH=`sed -n "$((LINE_NUMBER+2))p" $F | grep -Po '(?<=\")[^"]*(?=\")' | tail -n1`
+ LINE_NUMBER=$((LINE_NUMBER+1))
+ fi
+
+ echo "Found git source: $URL $BRANCH"
+
+ COMMIT=$(git ls-remote $URL $BRANCH | grep -Po '^\w+')
+ echo "Pinning to $COMMIT"
+
+ # Add a comma on the last line, and append "commit": "$COMMIT" after that
+ sed -i "$((LINE_NUMBER+1))s/$/,/; $((LINE_NUMBER+1)) a \ \"commit\": \"$COMMIT\"" $F
+
+ echo
+done
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]