From 2682f6a7441fe2b549f19d5453e9f8c785305bc2 Mon Sep 17 00:00:00 2001 From: Carlo Landmeter Date: Wed, 27 Jun 2018 12:55:19 +0000 Subject: use images from offical mirror Do not generate images locally but instead generate signatures locally and use images from offical mirror. - generate ipxe boot script from template - add option to start sshd with firstboot - add version information when selecting branch - verify netboot releases with gpg signature - added ncopa.asc gpg public key --- build.lua | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 build.lua (limited to 'build.lua') diff --git a/build.lua b/build.lua new file mode 100755 index 0000000..c509502 --- /dev/null +++ b/build.lua @@ -0,0 +1,51 @@ +#!/usr/bin/lua5.3 + +local yaml = require("lyaml") +local http = require("socket.http") +local pfile = require("pl.file") +local ppath = require("pl.path") +local lustache = require("lustache") + +local cf = yaml.load(pfile.read("config.yaml")) +cf.releases = {} +local info = {} + +function get_release_info(release, arch) + local url = ("%s/%s/releases/%s/latest-releases.yaml"):format( + cf.mirror, release, arch) + local body, code = http.request(url) + if not body then error(code) end + + local res = yaml.load(body) + for k,v in ipairs(res) do + if v.flavor == "alpine-netboot" then return v end + end +end + +for _,branch in ipairs(cf.branches) do + for _,arch in ipairs(cf.archs) do + info = get_release_info(branch, arch) + if info then + if ppath.exists(("/var/www/localhost/htdocs/sigs/%s/%s/%s"):format( + info.branch, info.arch, info.version)) then + print(("Skipping: %s/%s/%s"):format( + info.branch, info.arch, info.version)) + else + info.origin_branch = branch + print(("Processing: %s/%s/%s"):format( + info.branch, info.arch, info.version)) + os.execute(("./sign_images.sh \"%s\" \"%s\" \"%s\""):format( + info.branch, info.arch, info.version)) + end + end + end + if branch == cf.default.branch then + cf.default.branch = info.branch + cf.default.version = info.version + end + table.insert(cf.releases, { branch=info.branch, version=info.version }) +end + +local tpl = pfile.read(cf.tpl) +print("Updating ipxe script: "..cf.ipxe) +pfile.write(cf.ipxe, lustache:render(tpl, cf)) -- cgit v1.2.3