Fix gen_flatpak_manifest
This commit is contained in:
@@ -92,7 +92,7 @@ jobs:
|
||||
- name: Create the flatpak manifest
|
||||
run: |
|
||||
git config --global --add safe.directory $(pwd)
|
||||
tools/gen_flatpak_manifest.sh --git https://github.com/${{github.repository}}.git > io.github.wivrn.wivrn.yml
|
||||
tools/gen_flatpak_manifest.py --git https://github.com/${{github.repository}}.git > io.github.wivrn.wivrn.yml
|
||||
|
||||
# TODO: replace with version > v6.3 when it's released
|
||||
- uses: flatpak/flatpak-github-actions/flatpak-builder@b8be6bc0ede43cb3a2cc55895654312b14f84a0d
|
||||
@@ -507,7 +507,7 @@ jobs:
|
||||
git reset --hard upstream/master
|
||||
|
||||
git config --global --add safe.directory $(pwd)
|
||||
../wivrn/tools/gen_flatpak_manifest.sh --git https://github.com/${{github.repository}}.git > io.github.wivrn.wivrn.yml
|
||||
../wivrn/tools/gen_flatpak_manifest.py --git https://github.com/${{github.repository}}.git > io.github.wivrn.wivrn.yml
|
||||
|
||||
git checkout -b $WIVRN_TAG
|
||||
git add io.github.wivrn.wivrn.yml
|
||||
|
||||
Executable
+79
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
TEMPLATE = "flatpak/io.github.wivrn.wivrn.yml.in"
|
||||
|
||||
|
||||
class CMakeFile:
|
||||
def __init__(self, filename: str):
|
||||
self.entries = {}
|
||||
with open(filename) as f:
|
||||
data = f.read()
|
||||
for match in re.findall("FetchContent_Declare\\(([^)]*)\\)", data):
|
||||
words = [word for word
|
||||
in match.replace("\n", " ").split(" ")
|
||||
if word]
|
||||
self.entries[words[0]] = words[1:]
|
||||
|
||||
def get(self, target: str, key: str) -> str:
|
||||
entry = self.entries[target]
|
||||
index = entry.index(key)
|
||||
return entry[index + 1]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--git")
|
||||
parser.add_argument("--gitlocal", action="store_true")
|
||||
parser.add_argument("--dir", action="store_true")
|
||||
|
||||
args = parser.parse_args()
|
||||
if not (args.git or args.dir):
|
||||
args.gitlocal = True
|
||||
|
||||
root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
cmake = CMakeFile(os.path.join(root, "CMakeLists.txt"))
|
||||
with open(os.path.join(root, TEMPLATE)) as f:
|
||||
template = f.read()
|
||||
|
||||
monado_commit = cmake.get("monado", "GIT_TAG")
|
||||
boostpfr_url = cmake.get("boostpfr", "URL")
|
||||
boostpfr_sha256 = cmake.get("boostpfr", "URL_HASH").split("=")[-1]
|
||||
|
||||
try:
|
||||
git_commit = subprocess.check_output(
|
||||
["git", "describe", "--exact-match", "--tags"]
|
||||
).decode().strip()
|
||||
except subprocess.CalledProcessError:
|
||||
git_commit = subprocess.check_output(
|
||||
["git", "rev-parse", "HEAD"]
|
||||
).decode().strip()
|
||||
git_desc = subprocess.check_output(
|
||||
["git", "describe", "--tags", "--always"]
|
||||
).decode().strip()
|
||||
|
||||
if args.git or args.gitlocal:
|
||||
template = template.replace("WIVRN_SRC1", "type: git")
|
||||
if args.git:
|
||||
template = template.replace("WIVRN_SRC2", f"url: {args.git}")
|
||||
else:
|
||||
template = template.replace("WIVRN_SRC2", f"url: {root}")
|
||||
template = template.replace("WIVRN_SRC3", f"tag: {git_commit}")
|
||||
else:
|
||||
template = template.replace("WIVRN_SRC1", "type: dir")
|
||||
template = template.replace("WIVRN_SRC2", f"path: {root}")
|
||||
template = template.replace("WIVRN_SRC3", "")
|
||||
|
||||
template = template.replace("WIVRN_GIT_DESC", git_desc)
|
||||
template = template.replace("WIVRN_GIT_COMMIT", git_commit)
|
||||
|
||||
template = template.replace("BOOSTPFR_URL", boostpfr_url)
|
||||
template = template.replace("BOOSTPFR_SHA256", boostpfr_sha256)
|
||||
template = template.replace("MONADO_COMMIT", monado_commit)
|
||||
|
||||
print(template)
|
||||
@@ -1,66 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
WIVRN_SRC_TYPE=gitlocal
|
||||
|
||||
while [ ! -z "$1" ]
|
||||
do
|
||||
case "$1" in
|
||||
"--git")
|
||||
WIVRN_SRC_TYPE=git
|
||||
shift
|
||||
WIVRN_SRC2="url: $1"
|
||||
;;
|
||||
"--gitlocal")
|
||||
WIVRN_SRC_TYPE=gitlocal
|
||||
;;
|
||||
"--dir")
|
||||
WIVRN_SRC_TYPE=dir
|
||||
;;
|
||||
esac
|
||||
|
||||
shift
|
||||
done
|
||||
|
||||
cd $(dirname $0)
|
||||
|
||||
GIT_TAG=$(git describe --exact-match --tags 2>/dev/null || true)
|
||||
GIT_SHA=$(git rev-parse HEAD)
|
||||
GIT_COMMIT=$(git describe --exact-match --tags 2>/dev/null || git rev-parse HEAD)
|
||||
GIT_DESC=$(git describe --tags --always)
|
||||
|
||||
MONADO_COMMIT=$(grep -zo "FetchContent_Declare(monado[^)]*)" ../CMakeLists.txt | sed -ze "s/^.*GIT_TAG *\([^ )]*\).*$/\1/" | tr -d '\0')
|
||||
BOOSTPFR_URL=$(grep -zo "FetchContent_Declare(boostpfr[^)]*)" ../CMakeLists.txt | sed -ze "s/^.*URL *\([^ )]*\).*$/\1/" | tr -d '\0')
|
||||
BOOSTPFR_SHA256=$(curl --silent --location $BOOSTPFR_URL | sha256sum | cut -f1 -d' ')
|
||||
|
||||
if [ $WIVRN_SRC_TYPE = git ]
|
||||
then
|
||||
WIVRN_SRC1="type: git"
|
||||
WIVRN_SRC3="tag: ${GIT_COMMIT}"
|
||||
elif [ $WIVRN_SRC_TYPE = gitlocal ]
|
||||
then
|
||||
WIVRN_SRC1="type: git"
|
||||
WIVRN_SRC2="url: "$(realpath $(pwd)/..)
|
||||
WIVRN_SRC3="tag: ${GIT_COMMIT}"
|
||||
else
|
||||
WIVRN_SRC1="type: dir"
|
||||
WIVRN_SRC2="path: "$(realpath $(pwd)/..)
|
||||
WIVRN_SRC3=""
|
||||
fi
|
||||
|
||||
echo "Git commit: $GIT_COMMIT" >&2
|
||||
echo "Git tag: $GIT_DESC" >&2
|
||||
echo "Monado commit: $MONADO_COMMIT" >&2
|
||||
echo "Boost.PFR URL: $BOOSTPFR_URL" >&2
|
||||
echo "Boost.PFR SHA256: $BOOSTPFR_SHA256" >&2
|
||||
|
||||
cat ../flatpak/io.github.wivrn.wivrn.yml.in | sed \
|
||||
-e s,WIVRN_SRC1,"$WIVRN_SRC1", \
|
||||
-e s,WIVRN_SRC2,"$WIVRN_SRC2", \
|
||||
-e s,WIVRN_SRC3,"$WIVRN_SRC3", \
|
||||
-e s,WIVRN_GIT_DESC,$GIT_DESC, \
|
||||
-e s,WIVRN_GIT_COMMIT,$GIT_COMMIT, \
|
||||
-e s,BOOSTPFR_URL,$BOOSTPFR_URL, \
|
||||
-e s,BOOSTPFR_SHA256,$BOOSTPFR_SHA256, \
|
||||
-e s,MONADO_COMMIT,$MONADO_COMMIT,
|
||||
Reference in New Issue
Block a user