From 0d28b9e09c4f1042be08f87402048f6b3a5ec1f0 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Mon, 28 Mar 2016 17:20:49 -0700 Subject: [PATCH] livemedia-creator: Use correct suffix on default image names (#1318958) When an image name hasn't been passed, and the compression type is something other than xz, the default image name should use the user specified compression suffix. Resolves: rhbz#1318958 (cherry picked from commit f753a064b8601cbe9b7cd210b866a902ba4793e7) --- src/sbin/livemedia-creator | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/sbin/livemedia-creator b/src/sbin/livemedia-creator index a12cb48c..6ec7106f 100755 --- a/src/sbin/livemedia-creator +++ b/src/sbin/livemedia-creator @@ -964,6 +964,22 @@ def setup_logging(opts): log.setLevel(logging.DEBUG) pylorax_log.setLevel(logging.DEBUG) + +def default_image_name(compression, basename): + """ Return a default image name with the correct suffix for the compression type. + + :param str compression: Compression type + :param str basename: Base filename + :returns: basename with compression suffix + + If the compression is unknown it defaults to xz + """ + SUFFIXES = {"xz": ".xz", "gzip": ".gz", "bzip2": ".bz2", "lzma": ".lzma"} + return basename + SUFFIXES.get(compression, ".xz") + + +def main(): + sh = logging.StreamHandler() sh.setLevel(logging.INFO) fmt = logging.Formatter("%(asctime)s: %(message)s") @@ -1213,7 +1229,7 @@ if __name__ == '__main__': opts.fs_label = "AMI" elif opts.make_tar: if not opts.image_name: - opts.image_name = "root.tar.xz" + opts.image_name = default_image_name(opts.compression, "root.tar") if opts.compression == "xz" and not opts.compress_args: opts.compress_args = ["-9"]