From 9ba304d74b10c133cf1db257ac4687a53d718536 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Mon, 19 Oct 2015 15:27:56 -0700 Subject: [PATCH] Add selinux switch to mktar Sometimes you don't want to include the selinux xattrs in the tar (eg. bsdtar has problems extracting them). They are still included by default, but pass selinux=False to remove '--selinux --acls --xattrs' from the tar cmdline. --- src/pylorax/imgutils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pylorax/imgutils.py b/src/pylorax/imgutils.py index 2a48517b..114e0de3 100644 --- a/src/pylorax/imgutils.py +++ b/src/pylorax/imgutils.py @@ -80,10 +80,13 @@ def mkcpio(rootdir, outfile, compression="xz", compressargs=None): return compress(["cpio", "--null", "--quiet", "-H", "newc", "-o"], rootdir, outfile, compression, compressargs) -def mktar(rootdir, outfile, compression="xz", compressargs=None): +def mktar(rootdir, outfile, compression="xz", compressargs=None, selinux=True): compressargs = compressargs or ["-9"] - return compress(["tar", "--no-recursion", "--selinux", "--acls", "--xattrs", "-cf-", "--null", "-T-"], - rootdir, outfile, compression, compressargs) + tar_cmd = ["tar", "--no-recursion"] + if selinux: + tar_cmd += ["--selinux", "--acls", "--xattrs"] + tar_cmd += ["-cf-", "--null", "-T-"] + return compress(tar_cmd, rootdir, outfile, compression, compressargs) def mksquashfs(rootdir, outfile, compression="default", compressargs=None): '''Make a squashfs image containing the given rootdir.'''