Obviously those kinds of changes can deeply alter your ability to distribute the ISO and have implications above the technical stuff. You should probably avoid spreading customized distribution or at least check for yourself what you can do and what cannot. Nevertheless, customizing ISO can really speed up some of your installation and, for that reason, is worth understanding.
Building a dummy packageThe goal here is to add a RPM to the regular Oracle Linux 7 ISO. To make it brief, it uses the simplest RPM you can probably create from the specification below:
cat dummy.spec Summary: A dummy package Name: dummy Version: 1.0 Release: 1 License: GPLv2 Group: System Environment/Base BuildArch: noarch %description A dummy package %filesYou should be able to create the associated RPM with the
rpmbuild -bb dummy.spec Processing files: dummy-1.0-1.noarch Provides: dummy = 1.0-1 Requires(rpmlib): rpmlib(FileDigests) <= [...] <= 3.0.4-1 Checking for unpackaged file(s): check-files dummy-1.0-1.x86_64 Wrote: /root/rpmbuild/RPMS/noarch/dummy-1.0-1.noarch.rpm Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.bR2LDH + umask 022 + cd /root/rpmbuild/BUILD + /usr/bin/rm -rf /root/rpmbuild/BUILDROOT/dummy-1.0-1.x86_64 + exit 0
Adding the RPM to the ISOTo rebuild the ISO, you should extract it in a regular directory as described in the first part of this article. We use a directory named
OL7for it. Once done, adding a RPM to an Oracle Linux 7 distribution only requires to add it to the
cp -p /root/rpmbuild/RPMS/noarch/dummy-1.0-1.noarch.rpm OL7/Packages/.
Rebuilding the RepositoryThe
createrepocommand is used to rebuild the repository index from the RPMs. Before you proceed, keep a copy of the
comps-Server.xmlfile. It contains the description of the various types of installation as well as their associated groups and packages.
cd OL7 cp repodata/*-comps-Server.xml comps.xmlRebuilding the repository requires to list the RPM and to run the
find Packages -iname "*.rpm"|sort > rpms.lst createrepo -o . -i rpms.lst . rm rpms.lst
Customizing the comps.xml FileTo link the RPM installation to an existing type of installation or to create new types of installation, the
comps-Server.xmlfile needs to be adapted. In this example, the dummy package is simply added to the
CoreGroup. To proceed, the red line below has simply be added to the package list:
<group> <id>core</id> <name>Core</name> ... <packagelist> ... <packagereq type="default">dummy</packagereq>Once the file changed, it can be added back to the
repodatadirectory with a prefix that is its SHA256 checksum:
cp comps.xml \ repodata/`sha256sum comps.xml|cut -d' ' -f1`-comps-Server.xml gzip comps.xml export SIG=`sha256sum comps.xml.gz|cut -d' ' -f1` mv comps.xml.gz repodata/$SIG-comps-Server.xml.gz
Opposite to Oracle Linux 6, OL7 doesn't allow to select a single RPM from the installer. That's why learning to edit this file, including adding news types of installation or addons is so useful...
Referencing files in repomd.xmlTo finish with the customization, the file and its compressed counterpart should be referenced in the
repodata/repomd.xmlfile. Check the size, creation time and name of the files with the command below:
cd repodata ls -l --time-style=+%s *comps-Server.xml* -rw-r--r--. 1 root root 632976 1406309424 1fee86c5fdabac0aa1609cf27e7a75fbbf6bec94602a3dda9b2e69a3056f215d-comps-Server.xml -rw-r--r--. 1 root root 137762 1406309422 7943914c495c230c524d38caf65d364d25d04005782a98afbce3bbd9ec64d042-comps-Server.xml.gzAdapt and add the 2 sections below to the repomd.xml file:
<data type="group"> <checksum type="sha256">1fee86c5fdabac0aa1609cf27e7a75fbbf6bec94602a3dda9b2e69a3056f215d</checksum> <location href="repodata/1fee86c5fdabac0aa1609cf27e7a75fbbf6bec94602a3dda9b2e69a3056f215d-comps-Server.xml"/> <timestamp>1406309424</timestamp> <size>632976</size> </data> <data type="group_gz"> <checksum type="sha256">7943914c495c230c524d38caf65d364d25d04005782a98afbce3bbd9ec64d042</checksum> <open-checksum type="sha256">1fee86c5fdabac0aa1609cf27e7a75fbbf6bec94602a3dda9b2e69a3056f215d</open-checksum> <location href="repodata/7943914c495c230c524d38caf65d364d25d04005782a98afbce3bbd9ec64d042-comps-Server.xml.gz"/> <timestamp>1406309422</timestamp> <size>137762</size> </data>
Recreating the ISOThe ISO can simply be recreated with
implantisomd5as already described
mkisofs -r -T -J -V "OL-7.0 Server.x86_64" \ -b isolinux/isolinux.bin \ -c isolinux/boot.cat \ -no-emul-boot -boot-load-size 4 \ -boot-info-table \ -o OracleLinux7.iso OL7/ implantisomd5 OracleLinux7.iso
Testing the ISOLast but not least, the ISO must be tested. That's where Virtualbox comes to help.
Customizing ISO can be very useful to speed-up installation you don't want to automate with kickstart. It makes easy to upgrade Oracle Linux DVD with the latest Kernel and updates. As you've probably already figured out its also very easy to add any file or program...
To learn more about the subject of this post, we may want to read: How to use and edit comps.xml for package groups.