[PATCH 1/3 rhel7-branch] Update templates to use installimg for product and updates

Radek Vykydal rvykydal at redhat.com
Tue Jun 16 12:35:58 UTC 2015


From: "Brian C. Lane" <bcl at redhat.com>

With these templates if a package has installed files in
/usr/share/lorax/product or /usr/share/lorax/updates/ they will be used
to create product.img and/or updates.img which will be included in the
images/ directory of the iso and of the final output tree.

These can be used to customize the installation environment or provide
updates. See README.product for current documentation.

Related: rhbz#1202278
---
 README.product                 | 18 ++++++++++++++++++
 lorax.spec                     |  2 +-
 share/aarch64.tmpl             | 12 +++++++++++-
 share/live/ppc.tmpl            | 12 +++++++++++-
 share/live/x86.tmpl            | 12 +++++++++++-
 share/ppc.tmpl                 | 13 ++++++++++++-
 share/runtime-postinstall.tmpl |  3 +++
 share/x86.tmpl                 | 12 +++++++++++-
 8 files changed, 78 insertions(+), 6 deletions(-)
 create mode 100644 README.product

diff --git a/README.product b/README.product
new file mode 100644
index 0000000..ec6e516
--- /dev/null
+++ b/README.product
@@ -0,0 +1,18 @@
+Lorax now supports creation of product.img and updates.img as part of the build
+process. This is implemented using the installimg command which will take the
+contents of a directory and create a compressed archive from it. The x86, ppc,
+ppc64le and aarch64 templates all look for /usr/share/lorax/product/ and
+/usr/share/lorax/updates/ directories while creating the final install tree. If
+there are files in those directories lorax will create images/product.img
+and/or images/updates.img
+
+These archives are just like an anaconda updates image -- they are copied over
+the top of the filesystem at boot time so that you can drop in files to add to
+or replace anything on the filesystem.
+
+Anaconda has several places that it looks for updates, the one for product.img
+is in /run/install/product.  For example, to add an installclass to Anaconda
+you would put your custom class here:
+
+/usr/share/lorax/product/run/install/product/pyanaconda/installclasses/custom.py
+
diff --git a/lorax.spec b/lorax.spec
index fbd9b13..9d3f4e4 100644
--- a/lorax.spec
+++ b/lorax.spec
@@ -84,7 +84,7 @@ make DESTDIR=$RPM_BUILD_ROOT mandir=%{_mandir} install
 
 %files
 %defattr(-,root,root,-)
-%doc COPYING AUTHORS README.livemedia-creator
+%doc COPYING AUTHORS README.livemedia-creator README.product
 %doc docs/*ks
 %{python_sitelib}/pylorax
 %{python_sitelib}/*.egg-info
diff --git a/share/aarch64.tmpl b/share/aarch64.tmpl
index be5871c..09d5a06 100644
--- a/share/aarch64.tmpl
+++ b/share/aarch64.tmpl
@@ -4,6 +4,7 @@ configdir="tmp/config_files/aarch64"
 PXEBOOTDIR="images/pxeboot"
 KERNELDIR=PXEBOOTDIR
 LIVEDIR="LiveOS"
+LORAXDIR="usr/share/lorax/"
 %>
 
 mkdir ${LIVEDIR}
@@ -36,11 +37,20 @@ mkdir ${KERNELDIR}
     %>
     <%include file="efi.tmpl" args="configdir=configdir, KERNELDIR=KERNELDIR, efiarch=efiarch, isolabel=isolabel"/>
 
+    # Create optional product.img and updates.img
+    <% imggraft=""; images=["product", "updates"] %>
+    %for img in images:
+        %if exists("%s/%s/" % (LORAXDIR, img)):
+            installimg ${LORAXDIR}/${img}/ images/${img}.img
+            <% imggraft += " images/{0}.img={1}/images/{0}.img".format(img, outroot) %>
+        %endif
+    %endfor
+
     ## make boot.iso
     runcmd mkisofs -o ${outroot}/images/boot.iso \
            ${efiargs} -R -J -V '${isolabel}' -T -graft-points \
            ${KERNELDIR}=${outroot}/${KERNELDIR} \
            ${LIVEDIR}=${outroot}/${LIVEDIR} \
-           ${efigraft}
+           ${efigraft} ${imggraft}
     treeinfo images-${basearch} boot.iso images/boot.iso
 %endif
diff --git a/share/live/ppc.tmpl b/share/live/ppc.tmpl
index 80c0383..af6373e 100644
--- a/share/live/ppc.tmpl
+++ b/share/live/ppc.tmpl
@@ -6,6 +6,7 @@ GRUBDIR="boot/grub"
 LIVEDIR="LiveOS"
 MACDIR=BOOTDIR+"/mac"
 NETBOOTDIR="images/netboot"
+LORAXDIR="usr/share/lorax/"
 
 WRAPPER="usr/sbin/wrapper"
 WRAPPER_DATA="usr/"+libdir+"/kernel-wrapper"
@@ -80,6 +81,15 @@ install ${configdir}/magic ${BOOTDIR}
     %endif
 %endfor
 
+# Create optional product.img and updates.img
+<% imggraft=""; images=["product", "updates"] %>
+%for img in images:
+    %if exists("%s/%s/" % (LORAXDIR, img)):
+        installimg ${LORAXDIR}/${img}/ images/${img}.img
+        <% imggraft += " images/{0}.img={1}/images/{0}.img".format(img, outroot) %>
+    %endif
+%endfor
+
 ## make boot.iso
 runcmd mkisofs -o ${outroot}/images/boot.iso -chrp-boot -U \
         ${prepboot} -part -hfs -T -r -l -J \
@@ -91,7 +101,7 @@ runcmd mkisofs -o ${outroot}/images/boot.iso -chrp-boot -U \
         ${BOOTDIR}=${outroot}/${BOOTDIR} \
         ${GRUBDIR}=${outroot}/${GRUBDIR} \
         ${NETBOOTDIR}=${outroot}/${NETBOOTDIR} \
-        ${LIVEDIR}=${outroot}/${LIVEDIR}
+        ${LIVEDIR}=${outroot}/${LIVEDIR} ${imggraft}
 
 %for kernel in kernels:
     treeinfo images-${kernel.arch} boot.iso images/boot.iso
diff --git a/share/live/x86.tmpl b/share/live/x86.tmpl
index a640fee..347d21e 100644
--- a/share/live/x86.tmpl
+++ b/share/live/x86.tmpl
@@ -6,6 +6,7 @@ PXEBOOTDIR="images/pxeboot"
 BOOTDIR="isolinux"
 KERNELDIR=PXEBOOTDIR
 LIVEDIR="LiveOS"
+LORAXDIR="usr/share/lorax/"
 %>
 
 mkdir ${LIVEDIR}
@@ -64,6 +65,15 @@ hardlink ${KERNELDIR}/initrd.img ${BOOTDIR}
     <%include file="efi.tmpl" args="configdir=configdir, KERNELDIR=KERNELDIR, efiarch=efiarch, isolabel=isolabel"/>
 %endif
 
+# Create optional product.img and updates.img
+<% imggraft=""; images=["product", "updates"] %>
+%for img in images:
+    %if exists("%s/%s/" % (LORAXDIR, img)):
+        installimg ${LORAXDIR}/${img}/ images/${img}.img
+        <% imggraft += " images/{0}.img={1}/images/{0}.img".format(img, outroot) %>
+    %endif
+%endfor
+
 ## make boot.iso
 runcmd mkisofs -o ${outroot}/images/boot.iso \
        -b ${BOOTDIR}/isolinux.bin -c ${BOOTDIR}/boot.cat \
@@ -72,6 +82,6 @@ runcmd mkisofs -o ${outroot}/images/boot.iso \
        ${BOOTDIR}=${outroot}/${BOOTDIR} \
        ${KERNELDIR}=${outroot}/${KERNELDIR} \
        ${LIVEDIR}=${outroot}/${LIVEDIR} \
-       ${efigraft}
+       ${efigraft} ${imggraft}
 runcmd isohybrid ${efihybrid} ${outroot}/images/boot.iso
 treeinfo images-${basearch} boot.iso images/boot.iso
diff --git a/share/ppc.tmpl b/share/ppc.tmpl
index 23f4b08..4d13001 100644
--- a/share/ppc.tmpl
+++ b/share/ppc.tmpl
@@ -6,6 +6,7 @@ GRUBDIR="boot/grub"
 LIVEDIR="LiveOS"
 MACDIR=BOOTDIR+"/mac"
 NETBOOTDIR="images/netboot"
+LORAXDIR="usr/share/lorax/"
 
 WRAPPER="usr/sbin/wrapper"
 WRAPPER_DATA="usr/"+libdir+"/kernel-wrapper"
@@ -88,6 +89,15 @@ install ${configdir}/magic ${BOOTDIR}
     %endif
 %endfor
 
+# Create optional product.img and updates.img
+<% imggraft=""; images=["product", "updates"] %>
+%for img in images:
+    %if exists("%s/%s/" % (LORAXDIR, img)):
+        installimg ${LORAXDIR}/${img}/ images/${img}.img
+        <% imggraft += " images/{0}.img={1}/images/{0}.img".format(img, outroot) %>
+    %endif
+%endfor
+
 ## make boot.iso
 runcmd mkisofs -o ${outroot}/images/boot.iso -chrp-boot -U \
         ${prepboot} -part -hfs -T -r -l -J \
@@ -99,7 +109,8 @@ runcmd mkisofs -o ${outroot}/images/boot.iso -chrp-boot -U \
         ${BOOTDIR}=${outroot}/${BOOTDIR} \
         ${GRUBDIR}=${outroot}/${GRUBDIR} \
         ${NETBOOTDIR}=${outroot}/${NETBOOTDIR} \
-        ${LIVEDIR}=${outroot}/${LIVEDIR}
+        ${LIVEDIR}=${outroot}/${LIVEDIR} ${imggraft}
+
 
 %for kernel in kernels:
     treeinfo images-${kernel.arch} boot.iso images/boot.iso
diff --git a/share/runtime-postinstall.tmpl b/share/runtime-postinstall.tmpl
index ef39563..300adb7 100644
--- a/share/runtime-postinstall.tmpl
+++ b/share/runtime-postinstall.tmpl
@@ -125,4 +125,7 @@ remove etc/lvm/cache
 remove etc/lvm/lvm.conf
 append etc/lvm/lvm.conf "global {\n\tuse_lvmetad = 1\n}\n"
 
+mkdir usr/share/lorax/product/run/install/product/pyanaconda/installclasses/
+append usr/share/lorax/product/run/install/product/pyanaconda/installclasses/custom.py "import logging\nlog = logging.getLogger('anaconda')\nlog.info('bcl was here')\n"
+
 ## TODO: we could run prelink here if we wanted?
diff --git a/share/x86.tmpl b/share/x86.tmpl
index 82c0ed8..9d03400 100644
--- a/share/x86.tmpl
+++ b/share/x86.tmpl
@@ -6,6 +6,7 @@ PXEBOOTDIR="images/pxeboot"
 BOOTDIR="isolinux"
 KERNELDIR=PXEBOOTDIR
 LIVEDIR="LiveOS"
+LORAXDIR="usr/share/lorax/"
 %>
 
 mkdir ${LIVEDIR}
@@ -78,6 +79,15 @@ hardlink ${KERNELDIR}/initrd.img ${BOOTDIR}
     <%include file="efi.tmpl" args="configdir=configdir, KERNELDIR=KERNELDIR, efiarch=efiarch, isolabel=isolabel"/>
 %endif
 
+# Create optional product.img and updates.img
+<% imggraft=""; images=["product", "updates"] %>
+%for img in images:
+    %if exists("%s/%s/" % (LORAXDIR, img)):
+        installimg ${LORAXDIR}/${img}/ images/${img}.img
+        <% imggraft += " images/{0}.img={1}/images/{0}.img".format(img, outroot) %>
+    %endif
+%endfor
+
 ## make boot.iso
 runcmd mkisofs -o ${outroot}/images/boot.iso \
        -b ${BOOTDIR}/isolinux.bin -c ${BOOTDIR}/boot.cat \
@@ -86,6 +96,6 @@ runcmd mkisofs -o ${outroot}/images/boot.iso \
        ${BOOTDIR}=${outroot}/${BOOTDIR} \
        ${KERNELDIR}=${outroot}/${KERNELDIR} \
        ${LIVEDIR}=${outroot}/${LIVEDIR} \
-       ${efigraft}
+       ${efigraft} ${imggraft}
 runcmd isohybrid ${efihybrid} ${outroot}/images/boot.iso
 treeinfo images-${basearch} boot.iso images/boot.iso
-- 
1.9.3



More information about the anaconda-patches mailing list