Permalink
Browse files

OS-4690 joyent#428 imgadm xz compression support for images

  • Loading branch information...
xen0l authored and trentm committed Mar 24, 2015
1 parent 0187807 commit f2cb5fe1338f59e63a5f95a395823f817fc390c9
View
@@ -53,7 +53,7 @@ var DEFAULT_SOURCE = {type: 'imgapi', url: 'https://images.joyent.com'};
var DB_DIR = '/var/imgadm';
var VALID_COMPRESSIONS = ['none', 'bzip2', 'gzip'];
var VALID_COMPRESSIONS = ['none', 'bzip2', 'gzip', 'xz'];
var VALID_SOURCE_TYPES = ['imgapi', 'dsapi', 'docker'];
View
@@ -2605,6 +2605,9 @@ IMGADM.prototype._installZfsImage = function _installZfsImage(ctx, cb) {
} else if (compression === 'gzip') {
uncompressor = spawn('/usr/bin/gzip', ['-cdfq']);
numToFinish++;
} else if (compression === 'xz') {
uncompressor = spawn('/usr/bin/xz', ['-cdfq']);
numToFinish++;
} else {
assert.equal(compression, 'none',
format('image %s file compression: %s', uuid, compression));
@@ -3808,6 +3811,10 @@ IMGADM.prototype.createImage = function createImage(options, callback) {
compressor = spawn('/usr/bin/gzip', ['-cfq']);
imageInfo.filePath += '.gz';
numToFinish++;
} else if (compression === 'xz') {
compressor = spawn('/usr/bin/xz', ['-cfq']);
imageInfo.filePath += '.xz';
numToFinish++;
} else {
finish(new errors.UsageError(format(
'unknown compression "%s"', compression)));
View
@@ -354,7 +354,7 @@ UUID.
then "PATH.imgmanifest" and "PATH.zfs[.EXT]" are
created.
-c <comp>, --compression=<comp>
One of "none", "gz" or "bzip2" for the compression
One of "none", "gz", "bzip2" or "xz" for the compression
to use on the image file, if any. Default is "none".
-i Build an incremental image (based on the "@final"
snapshot of the source image for the VM).

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -13,7 +13,7 @@
"docker-registry-client": "git://github.com/joyent/node-docker-registry-client.git#765e74c",
"extsprintf": "1.2.0",
"findit": "2.0.0",
"imgmanifest": "git://github.com/joyent/node-imgmanifest.git#91e5d80",
"imgmanifest": "git://github.com/joyent/node-imgmanifest.git#4f80d8c",
"mkdirp": "0.5.0",
"node-uuid": "1.4.1",
"once": "1.3.1",
@@ -179,3 +179,40 @@ test('custom image (incremental, compression=bzip2)', function (t) {
});
});
test('custom image (compression=xz)', function (t) {
var cmd = format('%s/mk-custom-image %s %s/4 xz >%s/mk-custom-image.4.log 2>&1',
TESTDIR, BASE_UUID, WRKDIR, WRKDIR);
exec(cmd, {env: envWithTrace}, function (err, stdout, stderr) {
t.ifError(err, format('error running "%s": %s', cmd, err));
var logfile = WRKDIR + '/try-custom-image.4.log';
var cmd = format('%s/try-custom-image %s/4.imgmanifest %s/4.zfs.xz >%s 2>&1',
TESTDIR, WRKDIR, WRKDIR, logfile);
exec(cmd, function (err) {
t.ifError(err, format('error running "%s": %s', cmd, err));
var output = fs.readFileSync(logfile, 'utf8');
t.ok(output.indexOf('hi from mk-custom-image') !== -1,
format('could not find expected marker in output:\n--\n%s\n--\n',
output));
t.end();
});
});
});
test('custom image (incremental, compression=xz)', function (t) {
var cmd = format('%s/mk-custom-image %s %s/4i xz -i >%s/mk-custom-image.4i.log 2>&1',
TESTDIR, BASE_UUID, WRKDIR, WRKDIR);
exec(cmd, {env: envWithTrace}, function (err, stdout, stderr) {
t.ifError(err, format('error running "%s": %s', cmd, err));
var logfile = WRKDIR + '/try-custom-image.4i.log';
var cmd = format('%s/try-custom-image %s/4i.imgmanifest %s/4i.zfs.xz >%s 2>&1',
TESTDIR, WRKDIR, WRKDIR, logfile);
exec(cmd, function (err) {
t.ifError(err, format('error running "%s": %s', cmd, err));
var output = fs.readFileSync(logfile, 'utf8');
t.ok(output.indexOf('hi from mk-custom-image') !== -1,
format('could not find expected marker in output:\n--\n%s\n--\n',
output));
t.end();
});
});
});

0 comments on commit f2cb5fe

Please sign in to comment.