Add support for liveimg-squashfs
This patch adds support to build squashfs images which are compatible to anaconda's liveimg directive and dracuts liveimg feature. The feature is pretty simple, as it just reuses the raw diskimage, and strips the disklabel, to retrieve the plain filesystem image. Two open issues: - Stripping the disk label is a pretty hack - Database schema upgrade is missing Signed-off-by: Fabian Deutsch <fabiand@fedoraproject.org>
This commit is contained in:
parent
2a292308de
commit
4729adc5f9
4 changed files with 39 additions and 3 deletions
|
|
@ -3066,7 +3066,7 @@ class BaseImageTask(OzImageTask):
|
|||
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 @@ class BaseImageTask(OzImageTask):
|
|||
"""
|
||||
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 @@ class BaseImageTask(OzImageTask):
|
|||
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 = ['/usr/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', '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 @@ class BaseImageTask(OzImageTask):
|
|||
# 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
|
||||
|
|
|
|||
3
cli/koji
3
cli/koji
|
|
@ -5353,7 +5353,8 @@ def handle_image_build(options, session, args):
|
|||
"""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")
|
||||
|
|
|
|||
|
|
@ -769,6 +769,7 @@ insert into archivetypes (name, description, extensions) values ('shell', 'Shell
|
|||
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
|
||||
|
|
|
|||
|
|
@ -75,6 +75,7 @@ License: LGPLv2 and GPLv2+
|
|||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue