Remove tar option "--overwrite" when extracting archives

The tar option "--overwrite" is in confict with "--unlink-first"
when extracting archives.

freezer-agent occurs error "Restore error: /usr/local/bin/tar:
'--overwrite' cannot be used with '--unlink-first'"
when GNU tar 1.29 is being used.

--overwrite: No matter what the file timestamp is, replace it with
             the archive version. Notice, that replacing means
             unlinking old file and creating a new one in its stead.
--unlink-first: Same as --overwrite, the only difference being that
                --unlink-first tries to unlink file before opening
                (even if it does not exist), while --overwrite
                unlinks it only after opening it returns EEXIST.
from http://lists.gnu.org/archive/html/bug-tar/2005-05/msg00056.html

Change-Id: I2423c27c2d522a1dbf9270f9a81fc99c68c4845e
Closes-Bug: #1609704
This commit is contained in:
shangzhong.zhu 2016-08-05 11:49:36 +08:00
parent 4277d4a4f3
commit 6f1b051292
2 changed files with 3 additions and 3 deletions

View File

@ -112,7 +112,7 @@ class TarCommandRestoreBuilder(object):
DRY_RUN_TEMPLATE = '{0} {1} --incremental --list ' \
'--ignore-zeros --warning=none'
UNIX_TEMPLATE = '{0} {1} --incremental --extract --unlink-first ' \
'--ignore-zeros --warning=none --overwrite --directory {2}'
'--ignore-zeros --warning=none --directory {2}'
OPENSSL_DEC = "{openssl_path} enc -d -aes-256-cfb -pass file:{file}"
def __init__(self, restore_path, compression_algo, is_windows,

View File

@ -78,7 +78,7 @@ class TestTarCommandRestoreBuilder(unittest.TestCase):
self.assertEquals(
self.builder.build(),
"gnutar -z --incremental --extract --unlink-first --ignore-zeros "
"--warning=none --overwrite --directory restore_path")
"--warning=none --directory restore_path")
def test_dry_run(self):
self.builder.set_dry_run()
@ -92,7 +92,7 @@ class TestTarCommandRestoreBuilder(unittest.TestCase):
self.builder.build(),
"openssl enc -d -aes-256-cfb -pass file:encrypt_pass_file | gnutar "
"-z --incremental --extract --unlink-first --ignore-zeros"
" --warning=none --overwrite --directory restore_path")
" --warning=none --directory restore_path")
def test_all_args_windows(self):
self.builder = tar_builders.TarCommandRestoreBuilder(