From 58dfcf5ca341096fd41f94d43237227fb0f0d563 Mon Sep 17 00:00:00 2001 From: Natalia Serrano Date: Thu, 17 Oct 2024 17:49:13 +0200 Subject: [PATCH] refs #975 postprocess the generated initrd --- Dockerfile | 2 +- chroot-tasks.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7e0169a..1c4e92a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,7 +33,7 @@ RUN git clone -c http.sslVerify=false --branch ${OPENGNSYS_BRANCH} https://ognpr git --git-dir /tmp/ogrepo/.git log --date format:r%Y%m%d --format=%ad -1 >/tmp/opengnsys/oglive_builder/gitrelease && \ rm -rf /tmp/ogrepo/ -#RUN echo 0 ## development: invalidate docker cache at this point, so that the 'COPY' below actually copies files +## if we place the ogagent.deb and the ogbrowser.deb in the cwd, then this 'COPY .' copies them to the image COPY . /tmp/opengnsys/oglive_builder/ RUN cp /tmp/opengnsys/oglive_builder/schroot.conf /tmp/opengnsys/oglive_builder/mount-defaults /etc/schroot/ && echo '' >/etc/schroot/default/nssdatabases && rm -f /etc/schroot/setup.d/*chrootname diff --git a/chroot-tasks.py b/chroot-tasks.py index 55995f7..ab80ae0 100755 --- a/chroot-tasks.py +++ b/chroot-tasks.py @@ -108,10 +108,23 @@ def boottoolsInitrdGenerate (osrelease): os.unlink (f) shutil.copy ('/bin/busybox', '/usr/lib/initramfs-tools/bin') + initrd_img = f'/tmp/initrd.img-{osrelease}' + os.chdir ('/tmp') - utils.run (['mkinitramfs', '-o', f'/tmp/initrd.img-{osrelease}', osrelease]) + utils.run (['mkinitramfs', '-o', initrd_img, osrelease]) shutil.copy (f'/boot/vmlinuz-{osrelease}', '/tmp/') + ## turn cpio-with-prepended-stuff into a regular cpio, see #975 + utils.run (['unmkinitramfs', initrd_img, 'undone']) + os.mkdir ('undone/merged') + subprocess.run (['rsync -aH undone/early/* undone/main/* undone/merged/'], shell=True) + shutil.rmtree ('undone/early') + shutil.rmtree ('undone/main') + os.chdir ('undone/merged/') + subprocess.run ([f'find . |cpio -H newc -oa >{initrd_img}'], shell=True) + os.chdir ('/tmp') + shutil.rmtree ('undone') + if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument ('--osarch', help='OS architecture', action='store', required=True)