summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2023-04-29 10:22:39 +0300
committerLars Wirzenius <liw@liw.fi>2023-04-29 10:22:39 +0300
commitff4132f761052412a2f740fbd7ecf99d8a443b50 (patch)
treed95e51aa32a761fc5b0f50d9ad7a2666f6f0783e
parent5668d9ca59b40b4654f9d15ae70af5ba270eda4c (diff)
downloadvmdb2-ff4132f761052412a2f740fbd7ecf99d8a443b50.tar.gz
feat(check-one): allow user to override the debootstrap release
This means we don't need to have different files for different Debian releases, where they only differ in the debootstrap target. Sponsored-by: author
-rwxr-xr-x[-rw-r--r--]check-one19
1 files changed, 18 insertions, 1 deletions
diff --git a/check-one b/check-one
index 6d97841..ef21fa1 100644..100755
--- a/check-one
+++ b/check-one
@@ -4,6 +4,7 @@ import argparse
import os
import subprocess
import sys
+import tempfile
import yaml
@@ -12,12 +13,18 @@ class Config:
p = argparse.ArgumentParser()
p.add_argument("--vmdb", action="store")
p.add_argument("--tarball-directory", action="store", default=".")
+ p.add_argument("--debian-release", action="store")
args = p.parse_args()
self.tarball_directory = args.tarball_directory
self.vmdb_filename = args.vmdb
self.vmdb = yaml.safe_load(open(self.vmdb_filename))
+ if args.debian_release is not None:
+ for item in self.vmdb["steps"]:
+ if "debootstrap" in item:
+ item["debootstrap"] = args.debian_release
+
def debootstrap_release(self):
for item in self.vmdb["steps"]:
if "debootstrap" in item:
@@ -48,8 +55,16 @@ class Config:
tarball = f"{self.debootstrap_release()}_{self.arch()}.tar.gz"
return os.path.join(self.tarball_directory, tarball)
+ def write_vmdb(self, filename):
+ with open(filename, "w") as f:
+ yaml.safe_dump(self.vmdb, stream=f, indent=4)
+
def run_vmdb2(config):
+ fd, vmdb = tempfile.mkstemp(dir=config.tarball_directory, suffix=".vmdb")
+ config.write_vmdb(vmdb)
+ os.close(fd)
+
argv = [
"./vmdb2",
"--rootfs-tarball",
@@ -59,10 +74,12 @@ def run_vmdb2(config):
config.log(),
"--output",
config.image(),
- config.vmdb_filename,
+ vmdb,
]
subprocess.run(argv, check=True)
+ os.remove(vmdb)
+
def main():
config = Config()