@@ -119,6 +119,22 @@ os.mkdir(tmpisoisolinux)
119
119
initrd_ignition_padding = 256 * 1024
120
120
121
121
122
+ def generate_initramfs_stampfile (tmpdir , destpath , stampname ):
123
+ # Create a compressed CPIO archive that can be appended to an initramfs,
124
+ # with a single empty file. This is used to differentiate between
125
+ # types of initramfs.
126
+ with tempfile .TemporaryDirectory (prefix = 'initramfs' , dir = tmpdir ) as tmproot :
127
+ stamppath = os .path .join (tmproot , stampname )
128
+ os .makedirs (os .path .dirname (stamppath ), exist_ok = True )
129
+ open (stamppath , 'w' ).close ()
130
+ run_verbose (['cpio' , '-o' , '-H' , 'newc' , '-R' , 'root:root' ,
131
+ '--quiet' , '--reproducible' , '--force-local' ,
132
+ '-D' , tmproot , '-O' , destpath + '.tmp' ],
133
+ input = stampname .encode ())
134
+ run_verbose (['gzip' , destpath + '.tmp' ])
135
+ os .rename (destpath + '.tmp.gz' , destpath )
136
+
137
+
122
138
def generate_iso ():
123
139
# convention for kernel and initramfs names
124
140
kernel_img = 'vmlinuz'
@@ -150,22 +166,14 @@ def generate_iso():
150
166
os .chmod (os .path .join (tmpisoimages , file ), 0o755 )
151
167
152
168
initramfs = os .path .join (tmpisoimages , 'initramfs.img' )
153
- live_initramfs_cpio = None
169
+ initramfs_cpio_ext = None
154
170
if is_live :
155
171
# This stamp file denotes we're in a "live" initramfs
156
- live_initramfs_cpio = os .path .join (tmpdir , 'live-stamp-initramfs' )
157
- with tempfile .TemporaryDirectory (prefix = 'live-initramfs' , dir = tmpdir ) as livetmpd :
158
- live_initramfs_stamp_path = 'etc/coreos-live-initramfs'
159
- live_initramfs_stamp = os .path .join (livetmpd , live_initramfs_stamp_path )
160
- os .makedirs (os .path .dirname (live_initramfs_stamp ), exist_ok = True )
161
- with open (live_initramfs_stamp , 'w' ) as f :
162
- pass
163
- run_verbose (['cpio' , '-o' , '-H' , 'newc' , '-R' , 'root:root' ,
164
- '--quiet' , '--reproducible' , '--force-local' ,
165
- '-D' , livetmpd , '-O' , live_initramfs_cpio ],
166
- input = live_initramfs_stamp_path .encode ())
167
- run_verbose (['gzip' , live_initramfs_cpio ])
168
- live_initramfs_cpio = live_initramfs_cpio + '.gz'
172
+ initramfs_cpio_ext = os .path .join (tmpdir , 'live-stamp-initramfs' )
173
+ generate_initramfs_stampfile (tmpdir , initramfs_cpio_ext , 'etc/coreos-live-initramfs' )
174
+ elif image_type == 'installer' :
175
+ initramfs_cpio_ext = os .path .join (tmpdir , 'legacy-stamp-initramfs' )
176
+ generate_initramfs_stampfile (tmpdir , initramfs_cpio_ext , 'etc/coreos-legacy-installer-initramfs' )
169
177
if is_fulliso :
170
178
tmp_initramfs = os .path .join (tmpdir , 'initramfs' )
171
179
@@ -186,7 +194,7 @@ def generate_iso():
186
194
with open (tmp_initramfs , 'wb' ) as fdst :
187
195
with open (initramfs , 'rb' ) as fsrc :
188
196
shutil .copyfileobj (fsrc , fdst )
189
- with open (live_initramfs_cpio , 'rb' ) as fsrc :
197
+ with open (initramfs_cpio_ext , 'rb' ) as fsrc :
190
198
shutil .copyfileobj (fsrc , fdst )
191
199
fdst .write (bytes (initrd_ignition_padding ))
192
200
os .rename (tmp_initramfs , initramfs )
@@ -211,13 +219,22 @@ def generate_iso():
211
219
with open (tmp_initramfs , 'wb' ) as fdst :
212
220
with open (initramfs , 'rb' ) as fsrc :
213
221
shutil .copyfileobj (fsrc , fdst )
214
- with open (live_initramfs_cpio , 'rb' ) as fsrc :
222
+ with open (initramfs_cpio_ext , 'rb' ) as fsrc :
215
223
shutil .copyfileobj (fsrc , fdst )
216
224
with open (tmp_cpio + '.gz' , 'rb' ) as fsrc :
217
225
shutil .copyfileobj (fsrc , fdst )
218
226
fdst .write (bytes (initrd_ignition_padding ))
219
227
os .rename (tmp_initramfs , initramfs )
220
228
os .unlink (tmp_squashfs )
229
+ elif image_type == 'installer' :
230
+ tmp_initramfs = os .path .join (tmpdir , 'initramfs' )
231
+ # And this one just includes the stamp file
232
+ with open (tmp_initramfs , 'wb' ) as fdst :
233
+ with open (initramfs , 'rb' ) as fsrc :
234
+ shutil .copyfileobj (fsrc , fdst )
235
+ with open (initramfs_cpio_ext , 'rb' ) as fsrc :
236
+ shutil .copyfileobj (fsrc , fdst )
237
+ os .rename (tmp_initramfs , initramfs )
221
238
222
239
# Read and filter kernel arguments for substituting into ISO bootloader
223
240
result = run_verbose (['/usr/lib/coreos-assembler/gf-get-kargs' ,
0 commit comments