#53 Add support for liveimg-squashfs
Merged 8 years ago by mikeb. Opened 8 years ago by mikem.
https://github.com/mikem23/koji-playground.git squashfs  into  master

use full path to squashfs-root
Mike McLean • 8 years ago  
use rhel-friendly path for dd
Mike McLean • 8 years ago  
Add support for liveimg-squashfs
Fabian Deutsch • 8 years ago  
builder/kojid
file modified
+35 -2
@@ -3066,7 +3066,7 @@

          Some image formats require others to be processed first, which is why

          we have to do this. raw files in particular may not be kept.

          """

-         supported = ('raw', 'raw-xz', 'vmdk', 'qcow', 'qcow2', 'vdi', 'rhevm-ova', 'vsphere-ova', 'docker', 'vagrant-virtualbox', 'vagrant-libvirt', 'vagrant-vmware-fusion', 'vpc')

+         supported = ('raw', 'raw-xz', 'liveimg-squashfs', 'vmdk', 'qcow', 'qcow2', 'vdi', 'rhevm-ova', 'vsphere-ova', 'docker', 'vagrant-virtualbox', 'vagrant-libvirt', 'vagrant-vmware-fusion', 'vpc')

          for f in formats:

              if f not in supported:

                  raise koji.ApplianceError('Invalid format: %s' % f)
@@ -3092,6 +3092,7 @@

          """

          fcalls = {'raw':   self._buildBase,

                    'raw-xz': self._buildXZ,

+                   'liveimg-squashfs': self._buildSquashfs,

                    'vmdk':  self._buildConvert,

                    'vdi':   self._buildConvert,

                    'qcow':  self._buildConvert,
@@ -3249,6 +3250,37 @@

              logerror=1)

          return {'image': newimg}

  

+     def _buildSquashfs(self, format):

+         """

+         Use squashfs to wrap a raw disk image into liveimg compatible image.

+         This can be used by dracut for booting or anaconda to install.

+ 

+         @args:

+             format - a string representing the image format, "liveimg-squashfs"

+         @returns:

+             a dict with some metadata about the image

+         """

+         newimg = os.path.join(self.workdir, self.imgname + '.squashfs')

+         fsimg = os.path.join(self.workdir, 'squashfs-root/LiveOS/rootfs.img')

+ 

+         os.makedirs(os.path.join(self.workdir, 'squashfs-root/LiveOS'))

+ 

+         cmd = ['/bin/dd', 'conv=sparse', 'bs=1M',

+                'skip=1',  # FIXME Hack to strip the disklabel

+                'if=%s' % self.base_img.base_image.data,

+                'of=%s' % fsimg]

+         conlog = os.path.join(self.workdir,

+             'squashfs-dd-%s-%s.log' % (format, self.arch))

+         log_output(self.session, cmd[0], cmd, conlog, self.getUploadDir(),

+             logerror=1)

+         cmd = ['/usr/sbin/mksquashfs', os.path.join(self.workdir, 'squashfs-root'),

+                newimg, '-comp', 'xz', '-noappend']

+         conlog = os.path.join(self.workdir,

+             'squashfs-mksquashfs-%s-%s.log' % (format, self.arch))

+         log_output(self.session, cmd[0], cmd, conlog, self.getUploadDir(),

+             logerror=1)

+         return {'image': newimg}

+ 

      def _buildOVA(self, format):

          """

          Build an OVA target image. This is a format supported by RHEV and
@@ -3453,7 +3485,8 @@

          # upload the results

          for format in (f for f in self.formats.keys() if self.formats[f]):

              newimg = images[format]['image']

-             if 'ova' in format or format == 'raw-xz':

+             if ('ova' in format or format == 'raw-xz' or

+                     format == 'liveimg-squashfs'):

                  newname = self.imgname + '.' + format.replace('-', '.')

              elif 'vagrant' in format:

                  # This embeds the vagrant target and the ".box" format in the name

cli/koji
file modified
+2 -1
@@ -5353,7 +5353,8 @@

      """Create a disk image given an install tree"""

      formats = ('vmdk', 'qcow', 'qcow2', 'vdi', 'vpc', 'rhevm-ova',

                 'vsphere-ova', 'vagrant-virtualbox', 'vagrant-libvirt',

-                'vagrant-vmware-fusion', 'docker', 'raw-xz')

+                'vagrant-vmware-fusion', 'docker', 'raw-xz',

+                'liveimg-squashfs')

      usage = _("usage: %prog image-build [options] <name> <version> " +

                "<target> <install-tree-url> <arch> [<arch>...]")

      usage += _("\n       %prog image-build --config FILE")

docs/schema.sql
file modified
+1
@@ -769,6 +769,7 @@

  insert into archivetypes (name, description, extensions) values ('rc', 'Resource file', 'rc');

  insert into archivetypes (name, description, extensions) values ('wsdl', 'Web Services Description Language', 'wsdl');

  insert into archivetypes (name, description, extensions) values ('obr', 'OSGi Bundle Repository', 'obr');

+ insert into archivetypes (name, description, extensions) values ('liveimg-squashfs', 'liveimg compatible squashfs image', 'liveimg.squashfs');

  

  

  -- Do we want to enforce a constraint that a build can only generate one

koji.spec
file modified
+1
@@ -75,6 +75,7 @@

  Requires: %{name} = %{version}-%{release}

  Requires: mock >= 0.9.14

  Requires(pre): /usr/sbin/useradd

+ Requires: squashfs-tools

  %if %{use_systemd}

  Requires(post): systemd

  Requires(preun): systemd

no initial comment

Initial patch by Fabian Deutsch, with a few fixes added

Pull-Request has been merged by mikeb

8 years ago