@@ -29,6 +29,8 @@ IGNITION_IMG_SIZE = 256 * 1024
29
29
# Size of the file used to embed miniso data.
30
30
MINISO_DATA_FILE_SIZE = 16 * 1024
31
31
32
+ COSA_OSBUILD_LIVEISO = os .getenv ("COSA_OSBUILD_LIVEISO" , "" )
33
+
32
34
live_exclude_kargs = set ([
33
35
'$ignition_firstboot' , # unsubstituted variable in grub config
34
36
'console' , # no serial console by default on ISO
@@ -97,12 +99,39 @@ name_version = f'{base_name}-{args.build}'
97
99
# to shorten this more intelligently, otherwise we truncate the
98
100
# version which may impede uniqueness.
99
101
volid = name_version [0 :32 ]
102
+ build_path = os .path .abspath (f"{ builddir } /{ base_name } -{ args .build } " )
100
103
kernel_name = f'{ base_name } -{ args .build } -live-kernel-{ basearch } '
101
104
initramfs_name = f'{ base_name } -{ args .build } -live-initramfs.{ basearch } .img'
102
105
rootfs_name = f'{ base_name } -{ args .build } -live-rootfs.{ basearch } .img'
103
106
kernel_file = os .path .join (builddir , kernel_name )
104
107
initramfs_file = os .path .join (builddir , initramfs_name )
105
108
rootfs_file = os .path .join (builddir , rootfs_name )
109
+
110
+ if COSA_OSBUILD_LIVEISO != "" :
111
+ data = {
112
+ "buildid" : args .build ,
113
+ "imgid" : iso_name ,
114
+ "ostree-commit" : buildmeta_commit ,
115
+ "container-imgref" : "" ,
116
+ "deploy-via-container" : "" ,
117
+ "osname" : base_name ,
118
+ "ostree-ref" : args .build ,
119
+ "ostree-container" : f"{ build_path } -ostree.{ basearch } .ociarchive" ,
120
+ "metal-filename" : f"{ build_path } -metal.{ basearch } .raw" ,
121
+ "metal4k-filename" : f"{ build_path } -metal4k.{ basearch } .raw" ,
122
+ "ostree-repo" : repo ,
123
+ "extra-kargs-string" : "mitigations=auto,nosmt" ,
124
+ "image-type" : "live-iso" ,
125
+ "cloud-image-size" : "10240" ,
126
+ "metal-image-size" : "2405" ,
127
+ "squashfs-compression" : squashfs_compression ,
128
+ "rootfs-size" : 0 ,
129
+ "live-efiboot-img-size" : 16
130
+ }
131
+
132
+ image_for_disk_json = "runvm.json"
133
+ with open (image_for_disk_json , 'w' ) as file :
134
+ json .dump (data , file , indent = 4 )
106
135
# The kernel requires that uncompressed cpio archives appended to an initrd
107
136
# start on a 4-byte boundary. If there's misalignment, it stops unpacking
108
137
# and says:
@@ -119,6 +148,35 @@ def align_initrd_for_uncompressed_append(destf):
119
148
destf .write (b'\0 ' * (4 - offset % 4 ))
120
149
121
150
151
+ def update_buildmeta ():
152
+ buildmeta ['images' ].update ({
153
+ 'live-iso' : {
154
+ 'path' : iso_name ,
155
+ 'sha256' : sha256sum_file (tmpisofile ),
156
+ 'skip-compression' : True ,
157
+ }
158
+ })
159
+ buildmeta ['images' ].update ({
160
+ 'live-kernel' : {
161
+ 'path' : kernel_name ,
162
+ 'sha256' : sha256sum_file (kernel_file ),
163
+ 'skip-compression' : True ,
164
+ },
165
+ 'live-initramfs' : {
166
+ 'path' : initramfs_name ,
167
+ 'sha256' : sha256sum_file (initramfs_file ),
168
+ 'skip-compression' : True ,
169
+ },
170
+ 'live-rootfs' : {
171
+ 'path' : rootfs_name ,
172
+ 'sha256' : sha256sum_file (rootfs_file ),
173
+ 'skip-compression' : True ,
174
+ }
175
+ })
176
+ buildmeta .write (artifact_name = 'live' )
177
+ print (f"Updated: { buildmeta_path } " )
178
+
179
+
122
180
# Return OS features table for features.json, which is read by
123
181
# coreos-installer {iso|pxe} customize
124
182
def get_os_features ():
@@ -798,7 +856,24 @@ with open(build_semaphore, 'w') as f:
798
856
f .write (f"{ time .time_ns ()} " )
799
857
800
858
try :
801
- generate_iso ()
859
+ if COSA_OSBUILD_LIVEISO == "" :
860
+ generate_iso ()
861
+ else :
862
+ command = [
863
+ "/usr/bin/cosa" , "supermin-run" ,
864
+ "--cache" , "/usr/lib/coreos-assembler/runvm-osbuild" ,
865
+ "--config" ,
866
+ image_for_disk_json ,
867
+ "--mpp" ,
868
+ f"/usr/lib/coreos-assembler/osbuild-manifests/coreos.osbuild.{ basearch } .mpp.yaml" ,
869
+ "--filepath" ,
870
+ tmpisofile
871
+ ]
872
+ subprocess .run (command )
873
+ update_buildmeta ()
874
+ # Extract live artifacts from ISO. OSBUILD does not support an output with multiple files
875
+ command = ["coreos-installer" , "iso" , "extract" , "pxe" , tmpisofile ]
876
+ subprocess .run (command )
802
877
finally :
803
878
if os .path .exists (build_semaphore ):
804
879
os .unlink (build_semaphore )
0 commit comments