Merge pull request #43 from wesbarnett/fix/firstsnap
Fix installation error
This commit is contained in:
commit
95ad2669f6
5 changed files with 23 additions and 70 deletions
|
|
@ -1,28 +0,0 @@
|
||||||
# snap-pac
|
|
||||||
# https://github.com/wesbarnett/snap-pac
|
|
||||||
# Copyright (C) 2016, 2017, 2018 James W. Barnett
|
|
||||||
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
|
|
||||||
# You should have received a copy of the GNU General Public License along
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
|
|
||||||
[Trigger]
|
|
||||||
Operation = Remove
|
|
||||||
Type = Package
|
|
||||||
Target = snap-pac
|
|
||||||
|
|
||||||
[Action]
|
|
||||||
Description = You are removing snap-pac. No post transaction snapshots will be taken.
|
|
||||||
Depends = snap-pac
|
|
||||||
When = PreTransaction
|
|
||||||
Exec = /usr/bin/bash -c "rm -f /tmp/snap-pac-pre_*"
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
# snap-pac
|
|
||||||
# https://github.com/wesbarnett/snap-pac
|
|
||||||
# Copyright (C) 2016, 2017, 2018 James W. Barnett
|
|
||||||
|
|
||||||
# This program is free software; you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation; either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
|
|
||||||
# You should have received a copy of the GNU General Public License along
|
|
||||||
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
||||||
|
|
||||||
[Trigger]
|
|
||||||
Operation = Install
|
|
||||||
Type = Package
|
|
||||||
Target = snap-pac
|
|
||||||
|
|
||||||
[Action]
|
|
||||||
Description = You are installing snap-pac, so no post transaction snapshots will be taken.
|
|
||||||
Depends = snap-pac
|
|
||||||
When = PostTransaction
|
|
||||||
Exec = /usr/bin/true
|
|
||||||
|
|
@ -38,7 +38,6 @@ class SnapperCmd:
|
||||||
self.cmd.append("--no-dbus")
|
self.cmd.append("--no-dbus")
|
||||||
self.cmd.extend([
|
self.cmd.extend([
|
||||||
f"--config {config} create",
|
f"--config {config} create",
|
||||||
f"--type {snapshot_type}",
|
|
||||||
f"--cleanup-algorithm {cleanup_algorithm}",
|
f"--cleanup-algorithm {cleanup_algorithm}",
|
||||||
"--print-number"
|
"--print-number"
|
||||||
])
|
])
|
||||||
|
|
@ -50,7 +49,11 @@ class SnapperCmd:
|
||||||
if pre_number is not None:
|
if pre_number is not None:
|
||||||
self.cmd.append(f"--pre-number {pre_number}")
|
self.cmd.append(f"--pre-number {pre_number}")
|
||||||
else:
|
else:
|
||||||
raise ValueError("snapshot type specified as 'post' but no pre snapshot number passed.")
|
logging.debug("snapshot type specified as 'post' but no pre snapshot number, "
|
||||||
|
"so setting snapshot type to 'single'. If installing "
|
||||||
|
"snap-pac this is normal.")
|
||||||
|
snapshot_type = "single"
|
||||||
|
self.cmd.append(f"--type {snapshot_type}")
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
return os.popen(self.__str__()).read().rstrip("\n")
|
return os.popen(self.__str__()).read().rstrip("\n")
|
||||||
|
|
@ -148,7 +151,9 @@ class Prefile:
|
||||||
try:
|
try:
|
||||||
pre_number = self.file.read_text()
|
pre_number = self.file.read_text()
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
raise FileNotFoundError(f"prefile {self.file} not found. Ensure you have run the pre snapshot first.")
|
pre_number = None
|
||||||
|
logging.debug(f"prefile {self.file} not found. Ensure you have run the pre snapshot first. "
|
||||||
|
"If installing snap-pac this is normal.")
|
||||||
else:
|
else:
|
||||||
self.file.unlink()
|
self.file.unlink()
|
||||||
return pre_number
|
return pre_number
|
||||||
|
|
|
||||||
|
|
@ -10,27 +10,32 @@ from scripts.snap_pac import check_skip, ConfigProcessor, get_snapper_configs, P
|
||||||
@pytest.mark.parametrize("snapper_cmd, actual_cmd", [
|
@pytest.mark.parametrize("snapper_cmd, actual_cmd", [
|
||||||
(
|
(
|
||||||
SnapperCmd("root", "pre", "number", "foo"),
|
SnapperCmd("root", "pre", "number", "foo"),
|
||||||
"snapper --config root create --type pre --cleanup-algorithm number --print-number --description \"foo\""
|
"snapper --config root create --cleanup-algorithm number --print-number --description \"foo\" --type pre"
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
SnapperCmd("root", "post", "number", "bar", False, 1234),
|
SnapperCmd("root", "post", "number", "bar", False, 1234),
|
||||||
"snapper --config root create --type post --cleanup-algorithm number --print-number"
|
"snapper --config root create --cleanup-algorithm number --print-number"
|
||||||
" --description \"bar\" --pre-number 1234"
|
" --description \"bar\" --pre-number 1234 --type post"
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
SnapperCmd("root", "post", "number", "bar", True, 1234),
|
SnapperCmd("root", "post", "number", "bar", True, 1234),
|
||||||
"snapper --no-dbus --config root create --type post --cleanup-algorithm number --print-number"
|
"snapper --no-dbus --config root create --cleanup-algorithm number --print-number"
|
||||||
" --description \"bar\" --pre-number 1234"
|
" --description \"bar\" --pre-number 1234 --type post"
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
SnapperCmd("root", "post", "number", "bar", False, 1234, "important=yes"),
|
SnapperCmd("root", "post", "number", "bar", False, 1234, "important=yes"),
|
||||||
"snapper --config root create --type post --cleanup-algorithm number --print-number"
|
"snapper --config root create --cleanup-algorithm number --print-number"
|
||||||
" --description \"bar\" --userdata \"important=yes\" --pre-number 1234"
|
" --description \"bar\" --userdata \"important=yes\" --pre-number 1234 --type post"
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
SnapperCmd("root", "post", "number", "bar", False, 1234, "foo=bar,important=yes"),
|
SnapperCmd("root", "post", "number", "bar", False, 1234, "foo=bar,important=yes"),
|
||||||
"snapper --config root create --type post --cleanup-algorithm number --print-number"
|
"snapper --config root create --cleanup-algorithm number --print-number"
|
||||||
" --description \"bar\" --userdata \"foo=bar,important=yes\" --pre-number 1234"
|
" --description \"bar\" --userdata \"foo=bar,important=yes\" --pre-number 1234 --type post"
|
||||||
|
),
|
||||||
|
(
|
||||||
|
SnapperCmd("root", "post", "number", "bar", False, None, "foo=bar,important=yes"),
|
||||||
|
"snapper --config root create --cleanup-algorithm number --print-number"
|
||||||
|
" --description \"bar\" --userdata \"foo=bar,important=yes\" --type single"
|
||||||
)
|
)
|
||||||
])
|
])
|
||||||
def test_snapper_cmd(snapper_cmd, actual_cmd):
|
def test_snapper_cmd(snapper_cmd, actual_cmd):
|
||||||
|
|
@ -114,5 +119,4 @@ def test_prefile_read():
|
||||||
|
|
||||||
def test_no_prefile():
|
def test_no_prefile():
|
||||||
prefile = Prefile("foo-pre-file-not-found", "post")
|
prefile = Prefile("foo-pre-file-not-found", "post")
|
||||||
with pytest.raises(FileNotFoundError):
|
assert prefile.read() is None
|
||||||
prefile.read()
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue