as we publish the raw files on the mirrors we want to be able to request
xz compressed versions of theraw image.
Signed-off-by: Dennis Gilmore <dennis(a)ausil.us>
---
builder/kojid | 25 ++++++++++++++++++++++++-
cli/koji | 4 ++--
docs/schema-upgrade-1.9-next.sql | 9 +++++++++
docs/schema.sql | 1 +
4 files changed, 36 insertions(+), 3 deletions(-)
create mode 100644 docs/schema-upgrade-1.9-next.sql
diff --git a/builder/kojid b/builder/kojid
index 14309bb..34c62d8 100755
--- a/builder/kojid
+++ b/builder/kojid
@@ -2737,7 +2737,7 @@ class BaseImageTask(OzImageTask):
we have to do this. rhevm-ova requires rhevm, but if the user did not
request it, we should not pass it back up.
"""
- supported = ('raw', 'vmdk', 'qcow', 'qcow2', 'vdi', 'rhevm-ova', 'vsphere-ova', 'docker')
+ supported = ('raw', 'raw-xz', 'vmdk', 'qcow', 'qcow2', 'vdi', 'rhevm-ova', 'vsphere-ova', 'docker')
for f in formats:
if f not in supported:
raise koji.ApplianceError('Invalid format: %s' % f)
@@ -2863,6 +2863,27 @@ class BaseImageTask(OzImageTask):
base.base_image.parameters['libvirt_xml'])
images[format] = {'image': newimg, 'libvirt': lxml}
+ # xz compress the raw disk image if asked for
+ for format in ('raw-xz',):
+ if format not in self.formats:
+ continue
+ newimg = os.path.join(self.workdir, imgname + 'raw.xz')
+ rawimg = os.path.join(self.workdir, imgname + 'raw')
+ cmd = ['/bin/cp', base.base_image.data, rawimg]
+ conlog = os.path.join(self.workdir,
+ 'xz-cp-%s-%s.log' % (format, arch))
+ log_output(self.session, cmd[0], cmd, conlog,
+ self.getUploadDir(), logerror=1)
+ cmd = ['/usr/bin/xz', '-z', rawimg]
+ conlog = os.path.join(self.workdir,
+ 'xz-%s-%s.log' % (format, arch))
+ log_output(self.session, cmd[0], cmd, conlog,
+ self.getUploadDir(), logerror=1)
+ lxml = self.fixImageXML(format, imgname,
+ 'libvirt-%s-%s.xml' % (format, arch),
+ base.base_image.parameters['libvirt_xml'])
+ images[format] = {'image': newimg, 'libvirt': lxml}
+
return images
def handler(self, name, version, release, arch, target_info, build_tag, repo_info, inst_tree, opts=None):
@@ -2954,6 +2975,8 @@ class BaseImageTask(OzImageTask):
newname = imgname + '.' + format.replace('-', '.')
elif format == 'docker':
newname = imgname + '.' + 'tar.gz'
+ elif format == 'raw-xz':
+ newname = imgname + '.' + 'raw.xz'
else:
newname = imgname + '.' + format
if format != 'docker':
diff --git a/cli/koji b/cli/koji
index 504b4ba..1ba273f 100755
--- a/cli/koji
+++ b/cli/koji
@@ -4981,7 +4981,7 @@ def handle_spin_appliance(options, session, args):
help=_("Set the number of virtual cpus in the appliance, " +
"default is 1"))
parser.add_option("--format", metavar="DISK_FORMAT", default='raw',
- help=_("Disk format, default is raw. Other options are qcow, " +
+ help=_("Disk format, default is raw. Other options are raw-xz, qcow, " +
"qcow2, and vmx."))
(task_options, args) = parser.parse_args(args)
@@ -4998,7 +4998,7 @@ def handle_spin_appliance(options, session, args):
def handle_image_build(options, session, args):
"""Create a disk image given an install tree"""
formats = ('vmdk', 'qcow', 'qcow2', 'vdi', 'rhevm-ova', 'vsphere-ova',
- 'docker')
+ 'docker', 'raw-xz')
usage = _("usage: %prog image-build [options] <name> <version> " +
"<target> <install-tree-url> <arch> [<arch>...]")
usage += _("\n %prog image-build --config FILE")
diff --git a/docs/schema-upgrade-1.9-next.sql b/docs/schema-upgrade-1.9-next.sql
new file mode 100644
index 0000000..7d45e91
--- /dev/null
+++ b/docs/schema-upgrade-1.9-next.sql
@@ -0,0 +1,9 @@
+-- schema migration from version 1.9 to next
+-- note: this update will require additional steps, please see the migration doc
+
+BEGIN;
+
+-- new archive types
+insert into archivetypes (name, description, extensions) values ('raw-xz', 'xz compressed raw disk image', 'raw.xz');
+
+COMMIT;
diff --git a/docs/schema.sql b/docs/schema.sql
index 56418c9..91bcfd2 100644
--- a/docs/schema.sql
+++ b/docs/schema.sql
@@ -713,6 +713,7 @@ insert into archivetypes (name, description, extensions) values ('pdb', 'Windows
insert into archivetypes (name, description, extensions) values ('oem', 'Windows driver oem file', 'oem');
insert into archivetypes (name, description, extensions) values ('iso', 'CD/DVD Image', 'iso');
insert into archivetypes (name, description, extensions) values ('raw', 'Raw disk image', 'raw');
+insert into archivetypes (name, description, extensions) values ('raw-xz', 'xz compressed raw disk image', 'raw.xz');
insert into archivetypes (name, description, extensions) values ('qcow', 'QCOW image', 'qcow');
insert into archivetypes (name, description, extensions) values ('qcow2', 'QCOW2 image', 'qcow2');
insert into archivetypes (name, description, extensions) values ('vmdk', 'vSphere image', 'vmdk');
--
2.0.0