aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua M. Boniface <joshua@boniface.me>2024-02-03 16:08:08 -0500
committerJoshua M. Boniface <joshua@boniface.me>2024-02-03 16:08:18 -0500
commitd3e2aa39cc31d2d8053f4122cad0062f1aa93ba1 (patch)
tree02d634f81c21058224ea0024b87b233eee3b3d0c
parentAdd submodules (diff)
downloadjellyfin-packaging-d3e2aa39cc31d2d8053f4122cad0062f1aa93ba1.tar.gz
jellyfin-packaging-d3e2aa39cc31d2d8053f4122cad0062f1aa93ba1.tar.bz2
jellyfin-packaging-d3e2aa39cc31d2d8053f4122cad0062f1aa93ba1.zip
Add submodule checkout tool
-rwxr-xr-xcheckout.py54
-rw-r--r--requirements.txt1
2 files changed, 55 insertions, 0 deletions
diff --git a/checkout.py b/checkout.py
new file mode 100755
index 0000000..c491fd5
--- /dev/null
+++ b/checkout.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+
+# checkout.py - Checkout submodules for a build (checkout a given tag or head)
+#
+# Part of the Jellyfin CI system
+###############################################################################
+
+import os.path
+from subprocess import run, PIPE
+import sys
+
+from git import Repo
+
+try:
+ target_release = sys.argv[1]
+except IndexError:
+ target_release = "master"
+
+print(f"Preparing targets for {target_release}")
+
+# Determine top level directory of this repository ("jellyfin-packaging")
+revparse = run(["git", "rev-parse", "--show-toplevel"], stdout=PIPE)
+revparse_dir = revparse.stdout.decode().strip()
+
+# Prepare repo object for this repository
+this_repo = Repo(revparse_dir)
+
+# Update all the submodules
+this_repo.submodule_update(recursive=True)
+
+# Prepare a dictionary form of the submodules so we can reference them by name
+submodules = dict()
+for submodule in this_repo.submodules:
+ submodules[submodule.name] = submodule.module()
+
+# Validate that the provided tag is valid; if not, fall back to "master"
+if target_release != "master":
+ if (
+ target_release not in submodules["jellyfin-server"].tags or
+ target_release not in submodules["jellyfin-web"].tags
+ ):
+ print(f"WARNING: Provided tag {target_release} is not a valid tag for both jellyfin-server and jellyfin-web; using master instead")
+ target_release = "master"
+
+for submodule in submodules.keys():
+ if target_release == "master":
+ target_head = "refs/heads/master"
+ else:
+ target_head = f"refs/tags/{target_release}"
+ # Checkout the given head and reset the working tree
+ submodules[submodule].head.reference = target_head
+ submodules[submodule].head.reset(index=True, working_tree=True)
+
+print(f"Successfully checked out submodules to ref {target_release}")
diff --git a/requirements.txt b/requirements.txt
new file mode 100644
index 0000000..5664e30
--- /dev/null
+++ b/requirements.txt
@@ -0,0 +1 @@
+git
bgstack15