Last active 1746658351 Unlisted

dch.conf Raw
1#!/bin/sh
2#
3# $FreeBSD: tools/git-release/builds-15.conf 2804 2025-04-21 17:34:35Z cperciva $
4#
5# usage
6# zfs destroy -vrf zroot/releng
7# zfs create -o sync=disabled -o mountpoint=/releng zroot/releng
8# zfs create -o mountpoint=/releng zroot/releng
9# ./thermite.sh -b -d -c dch.conf
10
11. "${__BUILDCONFDIR}/main.conf"
12
13# overrides
14SRC_UPDATE_SKIP=1
15PORTS_UPDATE_SKIP=1
16DOC_UPDATE_SKIP=1
17
18# use local git repositories
19GITROOT="file:///usr"
20GITSRC="src"
21GITDOC="../projects/freebsd/doc"
22GITPORTS="ports"
23
24releasesrc="main"
25heads=15
26stables=
27
28revs="${heads} ${stables}"
29archs="amd64 aarch64"
30types="snap"
31
32x86_kernels="GENERIC"
33kernels="${x86_kernels}"
34
35portsbranch="quarterly"
36srcbranch="${releasesrc}"
37docbranch="main"
38
39# enable merging of OCI images into multi-architectures
40OCI_MERGE=1
41# where to put the merged OCI images
42OCI_DESTDIR="/releng/oci-images"
43# what are the images we need to merge
44oci_images="static dynamic runtime"
45# the architectures are already defined previously
podmanic Raw
1#!/usr/libexec/flua
2
3-- check if we have enough arguments
4if #arg < 3 then
5 print("usage: podmanic <aarch64.txz> <amd64.txz> <manifest> [tags...]")
6 os.exit(1)
7end
8
9function execute_command(command)
10 print("executing: " .. command)
11 local handle = io.popen(command)
12 local result = handle:read("*a")
13 local success, _, code = handle:close()
14 return result:gsub("%s+$", ""), success, code
15end
16
17function import_image(txz_path)
18 print("importing " .. txz_path)
19 local output, success = execute_command("podman load -i=" .. txz_path)
20
21 if not success then
22 print("FATAL: failed to import " .. txz_path)
23 print("command output: " .. output)
24 print("make sure the file exists and is a valid container image")
25 os.exit(1)
26 end
27
28 -- extract the image id from the output
29 -- output format is typically: "Loaded image: localhost/freebsd-static:14.2-stable-amd64"
30 local image_id = output:match("Loaded image: ([^\n]+)")
31
32 if not image_id then
33 -- if still not found, try to list images and find the most recently loaded one
34 print("FATAL: could not determine image id from output")
35 print("command output: " .. output)
36 print("failed to extract image id using pattern matching and fallback method")
37 os.exit(1)
38 end
39
40 print("found image: " .. image_id)
41 return image_id
42end
43
44function create_manifest(manifest_name, image_ids)
45 -- First, try to remove any existing manifest with the same name
46 local rm_cmd = "podman manifest rm " .. manifest_name .. " 2>/dev/null || true"
47 execute_command(rm_cmd)
48
49 -- Create empty manifest
50 local create_cmd = "podman manifest create " .. manifest_name
51 local output, success = execute_command(create_cmd)
52
53 if not success then
54 print("FATAL: Failed to create manifest: " .. output)
55 os.exit(1)
56 end
57
58 -- add each image to the manifest
59 for i, image_id in ipairs(image_ids) do
60 local arch = i == 1 and "arm64" or "amd64"
61 local add_cmd = "podman manifest add --arch " .. arch .. " " .. manifest_name .. " " .. image_id
62 local add_output, add_success = execute_command(add_cmd)
63
64 if not add_success then
65 print("FATAL: failed to add " .. image_id .. " to manifest: " .. add_output)
66 os.exit(1)
67 end
68 end
69
70 print("successfully created manifest: " .. manifest_name)
71 return manifest_name
72end
73
74function apply_tags(manifest_name, tags)
75 for _, tag in ipairs(tags) do
76 local tag_cmd = "podman tag " .. manifest_name .. " " .. tag
77 local output, success = execute_command(tag_cmd)
78
79 if not success then
80 print("ERROR: failed to apply tag " .. tag .. ": " .. output)
81 else
82 print("applied tag: " .. tag)
83
84 -- also push the additional tags if we're pushing to a registry
85 -- if manifest_name:match("^[^/]+%.") or manifest_name:match("^localhost/") then
86 -- local push_tag_cmd = "podman manifest push --all " .. tag .. " " .. tag
87 -- local push_output, push_success = execute_command(push_tag_cmd)
88
89 -- if push_success then
90 -- print("successfully pushed tag: " .. tag)
91 -- else
92 -- print("ERROR: failed to push tag " .. tag .. ": " .. push_output)
93 -- end
94 -- end
95 end
96 end
97end
98
99function export_manifest(manifest_name)
100 local file = manifest_name .. ".oci"
101 -- remove all text up to / from filename, and replace all : with -
102 file = file:gsub("^.+/", "")
103 file = file:gsub(":", "-")
104 local push_cmd = "podman manifest push --all " .. manifest_name .. " oci-archive:" .. file
105 local output, success = execute_command(push_cmd)
106
107 if not success then
108 print("FATAL: failed to push manifest " .. manifest_name .. ": " .. output)
109 print("- make sure you're logged in via podman login")
110 return false
111 end
112
113 print("successfully pushed manifest: " .. manifest_name .. " to " .. file)
114 return true
115end
116
117-- get arguments
118local manifest_name = arg[3]
119local txz_arm64 = arg[1] -- arm64 image
120local txz_amd64 = arg[2] -- amd64 image
121local tags = {}
122
123-- collect additional tags
124for i = 4, #arg do
125 table.insert(tags, arg[i])
126end
127
128print("podmanic is processing:")
129print("- manifest: " .. manifest_name)
130print("- arm64 image: " .. txz_arm64)
131print("- amd64 image: " .. txz_amd64)
132if #tags > 0 then
133 print("- additional tags: " .. table.concat(tags, ", "))
134end
135print("")
136
137-- import images
138local image_arm64 = import_image(txz_arm64)
139local image_amd64 = import_image(txz_amd64)
140
141if not image_arm64 or not image_amd64 then
142 print("FATAL: failed to import one or more images")
143 os.exit(1)
144end
145
146-- create manifest
147local manifest = create_manifest(manifest_name, {image_arm64, image_amd64})
148if not manifest then
149 print("FATAL: failed to create or populate manifest")
150 os.exit(1)
151end
152
153-- apply additional tags
154if #tags > 0 then
155 apply_tags(manifest_name, tags)
156end
157
158-- export manifest
159if not export_manifest(manifest_name) then
160 print("FATAL: failed to publish manifest")
161 os.exit(1)
162end
163
164print("OK: great success")
thermite.sh.diff Raw
1Index: thermite.sh
2===================================================================
3--- thermite.sh (revision 2811)
4+++ thermite.sh (working copy)
5@@ -679,6 +679,33 @@
6 return 0
7 }
8
9+# Merge OCI images into a single image for subsequent upload.
10+merge_oci_images() {
11+ source_config || return 0
12+ info "Merging OCI images into ${OCI_DESTDIR}"
13+
14+ # define paths for aarch64 and amd64 container images to merge
15+ # /releng/15-aarch64-GENERIC-snap/R/ociimages/container-image-$type.txz
16+ # /releng/15-amd64-GENERIC-snap/R/ociimages/container-image-$type.txz
17+ aarch64_path="/${zfs_mount}/${heads}-aarch64-GENERIC-${type}/R/ociimages/container-image"
18+ amd64_path="/${zfs_mount}/${heads}-amd64-GENERIC-${type}/R/ociimages/container-image"
19+
20+ # define destination for merged OCI images, probably should be a dataset
21+ test -d ${OCI_DESTDIR} || mkdir -p ${OCI_DESTDIR}
22+
23+ # podmanic FreeBSD-14.3-PRERELEASE-arm64-aarch64-container-image-$t.txz \
24+ # FreeBSD-14.3-PRERELEASE-amd64-container-image-$t.txz \
25+ # freebsd-$t-14.3-prerelease.oci
26+ for t in ${oci_images}; do
27+ aarch64="${aarch64_path}-${t}.txz"
28+ amd64="${amd64_path}-${t}.txz"
29+ oci="${OCI_DESTDIR}/freebsd-${t}-${heads}"
30+ podmanic $aarch64 $amd64 $oci >> ${logdir}/${_build}.log 2>&1
31+ sha256 ${oci}.oci > ${oci}.oci.sha256 >> ${logdir}/${_build}.log 2>&1
32+ done
33+ return 0
34+}
35+
36 main() {
37 releasesrc="main"
38 export __BUILDCONFDIR="$(dirname $(realpath ${0}))"
39@@ -719,6 +746,10 @@
40 runall ${parallel}build_release
41 wait
42 fi
43+ if [ "$OCI_MERGE" ]; then
44+ merge_oci_images
45+ # TODO bug_colin_to_sign_them
46+ fi
47 if [ "$DOUPLOAD" ]; then
48 runall upload_mount_devfs
49 runall upload_ec2_ami
50