summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordd <dd@wx.tnyzeq.icu>2025-11-30 08:25:56 +0100
committerdd <dd@wx.tnyzeq.icu>2025-11-30 08:25:56 +0100
commitb25fdc4c0984cbeadaf9a707e5f935f577ee903a (patch)
tree7b5a95e78a047adac46398ecbc7d78a9f8f17fa4
parent160262f0056c6ada035c515c9ead03f8856ec56f (diff)
downloadvyos-jenkins-b25fdc4c0984cbeadaf9a707e5f935f577ee903a.tar.gz
vyos-jenkins-b25fdc4c0984cbeadaf9a707e5f935f577ee903a.zip
added detection if apt key is present when local apt mirror is used to avoid confusing error condition
-rwxr-xr-xnew/image_builder.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/new/image_builder.py b/new/image_builder.py
index a81694f..b7c7219 100755
--- a/new/image_builder.py
+++ b/new/image_builder.py
@@ -62,6 +62,22 @@ class ImageBuilder:
ensure_directories()
def build(self):
+ local_apt_key_path = os.path.join(apt_dir, "apt.gpg.key")
+ if self.vyos_mirror == "local":
+ if os.path.exists(local_apt_key_path):
+ if os.path.isdir(local_apt_key_path):
+ os.rmdir(local_apt_key_path)
+
+ if not os.path.exists(local_apt_key_path):
+ self.terminal_title.set("ERROR")
+ logging.error(
+ "Something went wrong, the APT key is missing (%s),"
+ " this can happen if package-builder.py wasn't run before image-builder.py,"
+ " or if the build files are corrupted,"
+ " either way you need to run package-builder.py and then image-builder.py" % local_apt_key_path
+ )
+ exit(1)
+
self.terminal_title.set("Preparation...")
begin = monotonic()
if self.vyos_mirror == "local":
@@ -121,10 +137,9 @@ class ImageBuilder:
if self.vyos_mirror == "local":
# TODO: remove me, yet another temporary hack until vyos-build if fixed
# --custom-apt-key is broken since https://github.com/vyos/vyos-build/commit/9ed7a29ebb77c36ee555c2818b728a7e6b160322
- apt_key_path = os.path.join(apt_dir, "apt.gpg.key")
with open(os.path.join(git.repo_path, "scripts/image-build/defaults.py"), "r+") as file:
contents = file.read()
- with open(apt_key_path, "rb") as key_file:
+ with open(local_apt_key_path, "rb") as key_file:
encoded_key = base64.b64encode(key_file.read()).decode("utf-8")
contents = re.sub(
r"('custom_apt_keys'):.*\[[^]]*]",
@@ -180,8 +195,7 @@ class ImageBuilder:
extra_mounts = []
if self.vyos_mirror == "local":
- apt_key_path = os.path.join(apt_dir, "apt.gpg.key")
- extra_mounts.append((apt_key_path, "/opt/apt.gpg.key"))
+ extra_mounts.append((local_apt_key_path, "/opt/apt.gpg.key"))
self.terminal_title.set("Building '%s' image..." % self.branch)