Compare commits

...

433 commits
0.1.1 ... main

Author SHA1 Message Date
ak95
7208cd3f26 fixed README formatting 2024-09-03 17:02:23 -07:00
ak95
e54405822f fixed readme formatting 2024-09-03 17:01:48 -07:00
ak95
74a055dfe6 modified to use a single R/W snapshot 2024-09-03 17:00:45 -07:00
Wes Barnett, PhD
d58d047d2a
Merge pull request #47 from auipga/patch-1
Fix typo
2021-10-04 10:10:42 -04:00
Wes Barnett, PhD
959bf2b102
Merge pull request #48 from kidonng/patch-1
Fix link
2021-10-04 10:10:25 -04:00
Kid
c79d73fdc0
Fix link 2021-06-04 17:31:46 +08:00
Manuel Transfeld
6423f59848
Fix typo 2021-05-30 18:34:39 +02:00
Wes Barnett
6cfaa46fff
update for sphinx change 2021-05-16 19:31:49 -04:00
Wes Barnett
759a2cc84c
update ini file location 2021-05-16 19:20:53 -04:00
Wes Barnett
6dc564314c
install ini file directly 2021-05-16 19:17:00 -04:00
Wes Barnett
fad8cd676c
Merge remote-tracking branch 'origin/main' 2021-05-09 16:58:55 -04:00
Wes Barnett
6ae4bbb810
update Makefile for new version of sphinx 2021-05-09 16:58:25 -04:00
Wes Barnett, PhD
121f744ac6
Merge pull request #46 from dotiful/patch-1
Fix typo
2021-05-09 16:52:40 -04:00
Wes Barnett
f38f7aa9e6
rename hooks, update docs on backupboot example
Closes #45.
2021-05-09 16:51:57 -04:00
Dots Util
b6cb6c0ef7
Fix typo 2021-04-29 15:38:59 +03:00
Wes Barnett
2f39f46ac0
strip newline from return of cmd 2021-04-25 12:03:45 -04:00
Wes Barnett
08af0963d2
strip \n when reading in pre-number 2021-04-25 12:01:53 -04:00
Wes Barnett
d78781f771
debugging 2021-04-25 11:58:14 -04:00
Wes Barnett
1159296a8a
update docs 2021-04-25 11:50:15 -04:00
Wes Barnett
e913d70b95
Revert "rename hook"
This reverts commit 138717d269.
2021-04-15 20:31:56 -04:00
Wes Barnett
2ab106c200
Revert "make it a posttransaction hook"
This reverts commit 9b459dc49d.
2021-04-15 20:31:48 -04:00
Wes Barnett
f4f8fd8a7f
Revert "hook cant run if removed"
This reverts commit 4ebfa0eaa6.
2021-04-15 20:31:40 -04:00
Wes Barnett, PhD
95ad2669f6
Merge pull request #43 from wesbarnett/fix/firstsnap
Fix installation error
2021-04-15 20:28:37 -04:00
Wes Barnett
4ebfa0eaa6
hook cant run if removed 2021-04-15 20:26:10 -04:00
Wes Barnett
9b459dc49d
make it a posttransaction hook 2021-04-15 20:24:33 -04:00
Wes Barnett
138717d269
rename hook 2021-04-15 20:22:55 -04:00
Wes Barnett
abb1e2beb8
rename hook 2021-04-15 20:21:54 -04:00
Wes Barnett
5271109cc4
update logging 2021-04-15 20:20:48 -04:00
Wes Barnett
ecd19a6705
update test 2021-04-15 20:14:24 -04:00
Wes Barnett
e8a8c6c096
allow file to be missing 2021-04-15 20:13:04 -04:00
Wes Barnett
98d4286157
handle missing file 2021-04-15 20:11:42 -04:00
Wes Barnett, PhD
ef889e198e
Merge pull request #42 from wesbarnett/feature/man
Don't track changes in manpage since it is generated
2021-04-15 19:37:02 -04:00
Wes Barnett
3288517395
Don't track changes in manpage since it is generated 2021-04-04 18:11:12 -04:00
Wes Barnett
ea778aa380
update docs 2021-03-28 09:00:01 -04:00
Wes Barnett
3da59ac9d3
Update docs building 2021-03-28 08:56:33 -04:00
Wes Barnett
c01ba154d0
more refactoring 2021-03-27 20:25:45 -04:00
Wes Barnett
53b5a34c18
create Prefile class 2021-03-27 19:59:16 -04:00
Wes Barnett
22751b7d95
Revert "use nametuple"
This reverts commit d81f6f1f6f.
2021-03-27 19:20:21 -04:00
Wes Barnett
38c93b1ad5
Fix ConfigProcessor 2021-03-27 19:20:07 -04:00
Wes Barnett
d81f6f1f6f
use nametuple 2021-03-27 19:05:00 -04:00
Wes Barnett
7734706157
defaults for ConfigProcessor 2021-03-26 21:29:23 -04:00
Wes Barnett
73f683533f
Create CommandParser 2021-03-26 21:22:19 -04:00
Wes Barnett
559a8d7b54
refactor 2021-03-16 19:24:05 -04:00
Wes Barnett
a2704e5eda
fix syntax error 2021-03-16 19:13:31 -04:00
Wes Barnett
2aad72fb1a
save tmpdir in var 2021-03-15 20:33:38 -04:00
Wes Barnett
ec959799b8
update manpage; add docs to Makefile 2021-03-15 08:03:23 -04:00
Wes Barnett
b65cc3d261
Allow file paths to be passed to command line 2021-03-14 20:09:07 -04:00
Wes Barnett
a455240b60
Add command line options for ini and config files 2021-03-14 18:11:13 -04:00
Wes Barnett
573559e250
refactor 2021-03-14 18:04:38 -04:00
Wes Barnett
c0224aed25
update docs 2021-03-14 17:59:56 -04:00
Wes Barnett
0636c02438
add PR template 2021-03-14 10:44:48 -04:00
Wes Barnett
c382fbdbf8
add how to build docs 2021-03-14 10:36:00 -04:00
Wes Barnett
135e5a91d0
update documentation 2021-03-14 10:01:42 -04:00
Wes Barnett
0f86de6ade
Update example config file 2021-03-14 08:38:19 -04:00
Wes Barnett
b66665a35e
more links to docs 2021-03-13 20:17:16 -05:00
Wes Barnett
c7d6f9b88c
notes on tests 2021-03-13 20:13:50 -05:00
Wes Barnett
0c6f8f769e
fix test 2021-03-13 16:10:34 -05:00
Wes Barnett
cb47d1907d
update config file 2021-03-13 16:05:58 -05:00
Wes Barnett
2428ee46ca
fix default userdata 2021-03-13 16:00:34 -05:00
Wes Barnett
da67ac9ac9
add description 2021-03-13 15:37:54 -05:00
Wes Barnett, PhD
d8c8ae9b66
Merge pull request #41 from wesbarnett/feature/important
Add a few scenarios when userdata important=yes is used, update documentation
2021-03-13 14:02:16 -05:00
Wes Barnett
1ef50ddd42
add back manpage 2021-03-13 14:01:23 -05:00
Wes Barnett
292f1713ad
update docs 2021-03-13 13:59:36 -05:00
Wes Barnett
a78e7b6d71
update docs 2021-03-13 13:58:02 -05:00
Wes Barnett
bf541e667d
update docs 2021-03-13 13:45:15 -05:00
Wes Barnett
8ca92a0bb4
Update documentation 2021-03-13 13:33:32 -05:00
Wes Barnett
7eb7081012
Link to new documentation 2021-03-13 12:57:27 -05:00
Wes Barnett
733f915ac0
add list of options 2021-03-13 12:55:27 -05:00
Wes Barnett
9ab0a7833d
Add option to pass any userdata 2021-03-13 12:43:55 -05:00
Wes Barnett
8dfba55e07
Fix missing data in pytest fixture 2021-03-13 07:28:05 -05:00
Wes Barnett
e5ea12d060
fix syntax 2021-03-13 07:18:45 -05:00
Wes Barnett
fad08ebe29
rm print 2021-03-13 07:17:24 -05:00
Wes Barnett
d81070c898
add defaults for important commands and packages 2021-03-13 07:15:18 -05:00
Wes Barnett
287c1eacac
Add options for important=yes userdata
Check if user-specified packages and user-specified commands are in
important lists and if so add userdata important=yes

Fixes #38.
2021-03-13 07:08:40 -05:00
Wes Barnett
796b0f790d
ignore built docs 2021-03-13 05:23:08 -05:00
Wes Barnett
fdda143014
update tests workflow 2021-03-13 05:22:57 -05:00
Wes Barnett
1e6629aa08
add docs to main branch 2021-03-13 05:22:44 -05:00
Wes Barnett
95dce2a22d
add badge for docs 2021-03-11 20:08:05 -05:00
Wes Barnett
081a8bf1f2
Add test to Makefile 2021-03-11 19:41:15 -05:00
Wes Barnett
651ee7402a
update README 2021-02-28 09:24:19 -05:00
Wes Barnett
eeb376a54c
use pathlib 2021-02-27 21:10:22 -05:00
Wes Barnett
edd388092f
rm debug logs 2021-02-27 21:01:07 -05:00
Wes Barnett
5b5643001a
update 2021-02-27 21:00:43 -05:00
Wes Barnett
1716654236
simplify paths with Pathlib 2021-02-27 21:00:38 -05:00
Wes Barnett
de9ef06efa
rm prefile after closed 2021-02-27 20:50:53 -05:00
Wes Barnett
630354ac30
more descriptive vars; rm prefile when done; tests 2021-02-27 20:48:45 -05:00
Wes Barnett
ca9746fd6b
don't use reserved keyword 2021-02-27 20:31:22 -05:00
Wes Barnett
bd0527e003
better arg parsing; better env var parsing 2021-02-27 20:29:37 -05:00
Wes Barnett
830f0fb084
update tests to find script 2021-02-27 09:28:44 -05:00
Wes Barnett
abdecad935
don't print command 2021-02-27 09:24:37 -05:00
Wes Barnett
0a3d49a940
move tests 2021-02-27 09:24:18 -05:00
Wes Barnett, PhD
1ccdebdcb2
Merge pull request #40 from wesbarnett/feature/oop
Feature/oop
2021-02-15 20:37:10 -05:00
Wes Barnett
7e99ee19c3
update tests, linting 2021-02-15 20:34:58 -05:00
Wes Barnett
baf8fce9c6
more tests 2021-02-15 11:55:04 -05:00
Wes Barnett
18ec7c1232
More tests 2021-02-15 11:42:07 -05:00
Wes Barnett
47ca26cdeb
Update tests 2021-02-15 08:45:04 -05:00
Wes Barnett
6be6cab827
Create SnapperCmd class 2021-02-15 08:42:03 -05:00
Wes Barnett
b44d46d6bc
rename workflow 2021-02-14 18:08:19 -05:00
Wes Barnett
1f746a22d9
Update workflow for master branch and add badge 2021-02-14 18:06:55 -05:00
Wes Barnett
bd2f9bb6e1
Update readme about configuration file 2021-02-14 17:59:18 -05:00
Wes Barnett
e6724de4c8
add note that error can be ignored on install 2021-02-14 17:57:24 -05:00
Wes Barnett
da71fe8bb8
Update manpage and comment example configuration 2021-02-14 17:56:14 -05:00
Wes Barnett
57438e11c9
Clearer error 2021-02-14 17:28:35 -05:00
Wes Barnett
0dc86a06ac
Add FileNotFoundError if file containing pre number not found 2021-02-14 17:24:36 -05:00
Wes Barnett
8ceb5ef133
Make tests verbose 2021-02-14 16:50:35 -05:00
Wes Barnett
cfd636401e
add github workflow 2021-02-14 16:49:18 -05:00
Wes Barnett
e5121d4e28
Refactor for unit tests 2021-02-14 16:41:31 -05:00
Wes Barnett
481cb47bd0
Updates, refactoring, logging 2021-02-14 15:40:43 -05:00
Wes Barnett
0aff4920b4
Add SNAP_PAC_SKIP 2021-02-14 13:55:30 -05:00
Wes Barnett
61981ab4f9
Create python version 2021-02-14 13:17:31 -05:00
Wes Barnett
1ff1f66b8d
update copyright 2021-01-30 08:30:33 -05:00
Wes Barnett, PhD
82472f513a
Merge pull request #37 from NicoHood/patch-1
Fix readme name in makefile
2021-01-30 08:29:33 -05:00
NicoHood
6e4d05a4f4
Fix readme name in makefile
Version 2.3.2 did not built because of that name change
2021-01-30 09:40:15 +01:00
Wes Barnett, PhD
2bd088c576 Update issue templates 2021-01-29 22:16:50 -05:00
Wes Barnett, PhD
6e326592c3 Update issue templates 2021-01-29 22:16:03 -05:00
Wes Barnett
0bd23edb67
typo 2021-01-29 20:55:32 -05:00
Wes Barnett
8e0268a1b2
markdown 2021-01-29 20:55:02 -05:00
Wes Barnett
8af8c526bc
Update wording on snapper filters 2021-01-29 20:51:01 -05:00
Wes Barnett, PhD
189fb58044
Merge pull request #35 from GregoryHinton/issue-34 2021-01-23 17:12:52 -05:00
Gregory Hinton
e1a4b527bc Remove LINK_MODULES and KERNEL_PACKAGE declarations 2020-11-24 02:45:54 -08:00
Wes Barnett
a2ba2aa201
Fix bash test with double brackets 2019-03-09 13:25:55 -05:00
Wes Barnett
905ed72380
Detect if PPID is empty and then ignore
Fixes #25.
2019-03-08 14:14:16 -05:00
Wes Barnett
18a26d36e8
Detect if in chroot and disable dbus
Fixes #23.
2019-03-08 14:12:53 -05:00
Wes Barnett
6e6ea87c1b
update fingerprint 2019-03-08 07:37:30 -05:00
Wes Barnett
d97065a2e4
Document pacman hook that symlinks old kernel modules
Fixes #24.
2019-03-07 17:10:10 -05:00
Wes Barnett
5dac095982
Fix env var usage in manpage
See #26.
2019-02-28 15:30:17 -05:00
Wes Barnett
1dabe290b6
Don't symlink linux kernel modules.
Fixes #22, #21, and #19.
2018-08-16 07:17:24 -04:00
Wes Barnett
39dee2be1f
Remove old module symlinks on pre snapshot
Only do this if LINK_MODULES is set to yes. This prevents old symlinks
getting in the way of other packages.

Fixes #21.
2018-08-15 20:06:35 -04:00
James Barnett
42f12d216f
update manual 2018-02-28 15:43:01 -05:00
James Barnett
24891dfce3
don't print broken symlinks 2018-02-28 15:35:26 -05:00
James Barnett
9a796f490b
add new environment variable 2018-02-06 21:22:30 -05:00
James Barnett
561551ba53
use -v to test if var is set and printf 2018-02-06 21:19:14 -05:00
James Barnett
0fb43271be
Merge branch 'maximbaz-add-snap-pac-ignore' 2018-02-06 21:17:04 -05:00
Maxim Baz
4e671baf51
Use -n, rename variable, specify exit code 0 2018-02-04 13:59:08 +01:00
Maxim Baz
8edd181ab7
Allow to occasionally skip snap-pac run 2018-02-04 13:41:24 +01:00
James Barnett
ff3bdf1e2d
really add example configuration files 2018-02-03 07:32:50 -05:00
James Barnett
a868836031
update man page to reflect example configuration files 2018-02-03 07:23:59 -05:00
James Barnett
2112224e9d
add example configuration files 2018-02-03 07:16:37 -05:00
James Barnett
da977e108c
fix manpage 2018-02-02 21:24:20 -05:00
James Barnett
dee6ff6a08
change default desc limit to 72 chars 2018-02-02 21:12:31 -05:00
James Barnett
a0d0a823f1
change default description limit 2018-02-02 21:07:19 -05:00
James Barnett
8d11628592
fix homepage url 2018-02-02 21:06:58 -05:00
James Barnett
d9ce4c5d8e
update man page to reflect #17 2018-02-01 21:04:06 -05:00
James Barnett
ca7bfe6663
List packages in post description instead of pacman command
Fixes #17.
2018-02-01 15:57:01 -05:00
James Barnett
94a78681b7
fix link modules functionality 2018-01-22 12:12:14 -05:00
James Barnett
32cba7c5a3
Merge branch 'modules' 2018-01-20 11:05:28 -05:00
James Barnett
cf160c21f5
update docs 2018-01-19 11:09:04 -05:00
James Barnett
ff5554d304
add option to link kernel modules 2018-01-19 11:06:00 -05:00
James Barnett
7bff82da28
restored package_updated 2018-01-19 11:02:12 -05:00
James Barnett
a94895c9ee
typo, reword 2018-01-19 10:57:48 -05:00
James Barnett
2a33eafc7c
rm extra space 2018-01-18 19:09:42 -05:00
James Barnett
8b738b92f5
happy new year 2018-01-18 19:08:41 -05:00
James Barnett
5db7eb1468
some cleanup 2018-01-18 19:06:37 -05:00
James Barnett
8e1cde3f01
fix setting name 2018-01-18 13:49:35 -05:00
James Barnett
d4813a7fdc
create read_config function 2018-01-18 13:47:44 -05:00
James Barnett
65fdd716e0
change PRE_POST to SNAPSHOT 2018-01-17 21:21:07 -05:00
James Barnett
f9b2c62ab7
unset vars in loop; fix PRE_POST defaults 2018-01-17 21:14:23 -05:00
James Barnett
1d02860306
update manpage 2018-01-17 21:05:35 -05:00
James Barnett
4f5ce6554a
add option to link kernel modules 2018-01-17 20:58:33 -05:00
James Barnett
a60e16f8e1
Merge branch 'master' into modules 2018-01-17 20:57:26 -05:00
James Barnett
d8ef209911
update manpage 2018-01-17 20:49:35 -05:00
James Barnett
9530dd9a1b
Merge branch 'master' of github.com:wesbarnett/snap-pac 2018-01-17 20:33:51 -05:00
James “Wes” Barnett
41919ab4ad
Merge pull request #16 from jonasc/patch-1
Read configuration values from `/etc/snap-pac`
2018-01-18 01:26:48 +00:00
James Barnett
4ec3acfee5
Source settings from /etc/snap-pac and not snapper's files 2018-01-17 18:33:32 -05:00
jonasc
c0f92f1cfb
Read configuration values from /etc/snap-pac
Test whether `/etc/snap-pac` is a readable file and then source it.
Set `DESC_LIMIT` only to the default value of `48` if it was not specified in the sourced file.
2018-01-05 15:22:44 +01:00
James Barnett
f21b4998a4 typo
Signed-off-by: James Barnett <wes@wbarnett.us>
2017-12-17 21:12:30 -05:00
James Barnett
a6e0cd3287
error tracing 2017-05-31 12:59:48 -04:00
James Barnett
1135776e93
more verbose 2017-04-20 09:28:15 -05:00
James Barnett
3a904dac0e
fix typos 2017-04-20 09:22:30 -05:00
James Barnett
311e2d9a75
remove unneeded ETC_DIR 2017-04-20 08:45:42 -05:00
James Barnett
9ebba032da
delete old broken links 2017-04-20 08:45:25 -05:00
James Barnett
e6d48a89ad
remove unused variable 2017-04-20 08:36:29 -05:00
James Barnett
6ad1c1f571
rearrange how package update is detected 2017-04-20 08:36:06 -05:00
James Barnett
76c4151814
initial commit 2017-04-20 08:04:37 -05:00
James Barnett
38c0c29605
undo change 2017-04-18 21:00:52 -05:00
James Barnett
a368582080
notes on kernel branch 2017-04-18 20:49:51 -05:00
James Barnett
7b39fb5d1b
grub file +x 2017-04-18 20:43:54 -05:00
James Barnett
2f7c44ba21
can't link modules until after 2017-04-18 20:34:53 -05:00
James Barnett
edc4e89368
debugging 2017-04-18 20:32:22 -05:00
James Barnett
3bbd2a3152
debugging 2017-04-18 20:29:27 -05:00
James Barnett
9f8816b103
bug with creating directory 2017-04-18 20:28:48 -05:00
James Barnett
a238bd40f5
mark kernel snaps as important 2017-04-18 20:26:36 -05:00
James Barnett
ce7516c681
PACMAN_KEEP_OLD_KERNELS goes in root snapper config 2017-04-18 20:20:02 -05:00
James Barnett
67a89013cd
and 2017-04-18 20:18:26 -05:00
James Barnett
f67d8dab2c
debugging 2017-04-18 20:17:21 -05:00
James Barnett
9a8e7ac65f
debugging 2017-04-18 20:14:24 -05:00
James Barnett
d5d7fe5956
debugging 2017-04-18 20:11:53 -05:00
James Barnett
bc059a3f04
move everything to post snapshot 2017-04-18 20:07:53 -05:00
James Barnett
d3d4a40992
correct etc install directory 2017-04-18 20:02:57 -05:00
James Barnett
4151fcb35c
check if kernel is updated 2017-04-18 20:00:44 -05:00
James Barnett
d92c259b70
initial commit 2017-04-18 19:51:26 -05:00
James Barnett
a2048588af
rm old manpage info 2017-03-25 07:32:06 -05:00
James Barnett
05e10dcff3
split up snapper command to catch errors 2017-03-25 07:30:32 -05:00
James Barnett
335745bd8b
update manpage 2017-03-22 18:17:34 -05:00
James Barnett
325c8f45c3
udpate docs, rm unneeded checks 2017-03-22 18:11:27 -05:00
James Barnett
a54039effe
rm warning cmd (not used); update error fmt 2017-03-21 16:11:23 -05:00
James Barnett
c41c294dba
Get parent of script call (may not be pacman)
Check for pre or post args, since no longer checking command. Update manpage.
2017-03-20 07:54:21 -05:00
James Barnett
613a1a3552
move hook 2017-02-14 13:59:39 -06:00
James Barnett
59eb91c5f8
move warning to hook 2017-02-14 13:57:09 -06:00
James Barnett
1eebf453e0
Remove redundant checks
Just check to see if pacman is running
2017-02-14 13:51:00 -06:00
James Barnett
6efd9d6fc7
Remove check for root
Snapper may not actually require it depending on how the user set it up,
and if this is run from pacman (as it should be), it will always be run
as root
2017-02-14 13:22:18 -06:00
James Barnett
923d232f8e
create set_defaults 2017-02-14 13:22:00 -06:00
James Barnett
9a8c20ce1a
Revert "no need to check for root, since permissions will be checked."
This reverts commit 39bc6ea222.
2017-02-14 13:17:17 -06:00
James Barnett
39bc6ea222
no need to check for root, since permissions will be checked. 2017-02-14 13:16:09 -06:00
James Barnett
89db1fcfe7
sourcing already tests if file exists 2017-02-14 13:13:56 -06:00
James Barnett
29be92e46a
formatting 2017-02-14 13:11:47 -06:00
James Barnett
b14f923a09
Remove test if there are no snapper configs
this is tested at the end of the script already
2017-02-14 13:09:55 -06:00
James Barnett
b5220f2a5d
revert prev change on abort on fail 2017-02-14 12:00:14 -06:00
James Barnett
eabc759750
wording 2017-02-14 11:53:58 -06:00
James Barnett
c8d14e43d5
add back exit 0 2017-02-14 11:51:37 -06:00
James Barnett
267a497f4e
fix pacman abort on fail 2017-02-14 11:49:19 -06:00
James Barnett
123e33e162
update description; use bash for globbing 2017-02-14 11:36:33 -06:00
James Barnett
83e578369d
rm of prefile can be done directly in hook 2017-02-14 11:30:18 -06:00
James Barnett
02770cffc6
prefile not defined in correct location 2017-02-14 11:28:01 -06:00
James Barnett
505d62a80d
most likely is going to be set to no 2017-02-14 11:25:47 -06:00
James Barnett
e9a5cf31af
formatting 2017-02-14 11:21:00 -06:00
James Barnett
ea299e2b8a
more refactoring 2017-02-14 11:13:36 -06:00
James Barnett
1969e5bd15
output format 2017-02-14 11:03:06 -06:00
James Barnett
591a0730c6
some cleanup 2017-02-14 11:01:19 -06:00
James Barnett
e3537fab43
put rm file in correct spot 2017-02-14 09:45:31 -06:00
James Barnett
d162241a1b
set name variable 2017-02-14 09:39:57 -06:00
James Barnett
6105acf78b
why do we need a checkmark?
The number itself tells us it was completed
2017-02-14 09:39:48 -06:00
James Barnett
2edea865b0
removal should be checked first in loop 2017-02-14 09:05:04 -06:00
James Barnett
5011637263
add truncate_description 2017-02-14 09:01:46 -06:00
James Barnett
f7bf18e85c
Code refactoring 2017-02-14 08:42:43 -06:00
James Barnett
51cee6cf6c
Check for utf8 as well as UTF-8 in LANG 2017-02-13 06:17:20 -06:00
James Barnett
d99b2a759f
update README 2017-02-07 07:41:19 -06:00
James Barnett
eee3dec43e
manpage typ 2017-02-04 08:01:34 -06:00
James Barnett
9f8918a30e
fix makefile README 2017-02-04 07:59:31 -06:00
James Barnett
83509c2fe4
update manpage 2017-02-04 07:54:13 -06:00
James Barnett
ffca5484e9
code refactoring 2017-02-04 07:11:35 -06:00
James Barnett
59ea13fd11
update manpage 2017-02-03 20:56:18 -06:00
James Barnett
b6082ceaed
update manpage 2017-02-03 20:48:02 -06:00
James Barnett
2c62cce12c
update manpage 2017-02-03 20:23:23 -06:00
James Barnett
76eff16127
update README 2017-02-03 14:08:46 -06:00
James Barnett
039c0ae70d
update README 2017-02-03 14:07:36 -06:00
James Barnett
730abde329
update README 2017-02-03 14:06:29 -06:00
James Barnett
f2a7e7b189
update README 2017-02-03 13:58:29 -06:00
James Barnett
2478a189d8
add installation method 2017-02-03 13:56:08 -06:00
James Barnett
b97cf5bf04
add man page 2017-02-03 13:54:03 -06:00
James Barnett
03792597b0
update documentation 2017-02-03 11:49:32 -06:00
James Barnett
8f10395a88
no need to list configurations that aren't being snapshotted 2017-02-03 11:45:13 -06:00
James Barnett
e6ec6a7c8f
happy (late) new year 2017-02-03 11:41:10 -06:00
James Barnett
70859e84a2
rm duplicate 2017-02-03 11:04:52 -06:00
James Barnett
b737252a4e
limit description length 2017-02-03 11:04:09 -06:00
James Barnett
5afd92ddfb
info on new warning 2017-02-03 09:44:23 -06:00
James Barnett
42b8a93292
warn if pacman was not found to be running 2017-02-03 09:41:31 -06:00
James Barnett
54df716ec1
make if logic clearer 2017-02-03 09:36:57 -06:00
James Barnett
f0ddb4ee29
update documentation 2017-02-03 09:29:38 -06:00
James Barnett
7d981ff6fd
add removal to main script 2017-02-03 08:42:43 -06:00
James Barnett
439f925abf
warning message formatting
error messge formatting
2017-02-03 08:36:20 -06:00
James Barnett
8ef411732e
use trap for error 2017-02-03 07:54:24 -06:00
James Barnett
c5b822c2dd
add description if pacman was not found to be running 2017-02-03 07:46:58 -06:00
James Barnett
ac28d14ed8
add trap for SIGTERM and SIGINT 2017-02-03 07:46:37 -06:00
James Barnett
7f1e35b20a
use printf 2017-02-03 07:41:16 -06:00
James Barnett
04bf81ab05 update documention since now in community 2016-10-31 08:02:48 -05:00
James Barnett
6594945ecf ensure UTF font is used 2016-10-03 09:09:08 -05:00
James Barnett
01d4af9e3e update 2016-09-18 20:55:58 -05:00
James Barnett
509cfb0540 typo 2016-09-11 14:52:35 -05:00
James Barnett
33d2617bbb note on pacman database being locked 2016-09-11 14:46:49 -05:00
James Barnett
c208cbe7e9 Use "done" instead of checkmark in virtual consoles
Unicode checkmark is not available in virtual console fonts.

Fixes #5.
2016-09-08 08:57:10 -05:00
James Barnett
5b2a17c94b fix link 2016-09-08 08:27:49 -05:00
James Barnett
2bb4081773 add FAQ on non-btrfs /boot partitions 2016-09-08 08:20:59 -05:00
James Barnett
946f0df093 put alternative keyserver in command line 2016-09-01 19:55:23 -05:00
James Barnett
97dfcebeeb improve spacing 2016-09-01 07:31:51 -05:00
James Barnett
9625951a11 update readme 2016-09-01 07:30:22 -05:00
James Barnett
5417160503 update documentation on PACMAN_ABORT_ON_FAIL 2016-08-31 21:03:46 -05:00
James Barnett
47f124dec6 fix hook 2016-08-31 20:56:36 -05:00
James Barnett
9237b519f7 add option to abort pacman transaction on script fail 2016-08-31 20:55:42 -05:00
James Barnett
5ef0091d9b update comment 2016-08-31 20:44:23 -05:00
James Barnett
a7b017b326 fix checkmark 2016-08-31 20:35:15 -05:00
James Barnett
c6e5f06691 make echo use escape code 2016-08-31 20:31:53 -05:00
James Barnett
be873061bd fix script path 2016-08-31 20:30:01 -05:00
James Barnett
a7429f8838 add snap-pac-remove 2016-08-31 20:27:31 -05:00
James Barnett
a34fd38af5 add snap-pac warning hook 2016-08-31 19:43:46 -05:00
James Barnett
71ee66826e Revert "color more output"
Doesn't look good in pacman log.

This reverts commit 43ae966afa.
2016-08-31 16:08:02 -05:00
James Barnett
43ae966afa color more output 2016-08-31 16:05:41 -05:00
James Barnett
1f26d4247f color ERROR and WARNING 2016-08-31 16:00:35 -05:00
James Barnett
ec81615379 update README with new error 2016-08-31 12:43:25 -05:00
James Barnett
797d27521b check if dbus not available (i.e. in chroot) 2016-08-31 12:41:40 -05:00
James Barnett
3a4e052d7b add variable SNAPPER_CONFIG_FILE 2016-08-31 12:02:44 -05:00
James Barnett
47da90f66f get rid of worthless shellcheck 2016-08-31 11:53:11 -05:00
James Barnett
f5b9ce68e1 make default location /usr instead of /usr/local 2016-08-31 11:51:04 -05:00
James Barnett
26e72a4272 updated readme 2016-08-30 16:40:25 -05:00
James Barnett
c29edbc4bd updated readme 2016-08-30 16:39:27 -05:00
James Barnett
9de30a8075 Output each configuration name and snapshot number during transactions 2016-08-30 12:55:18 -05:00
James Barnett
14b9e99d04 show long id for key 2016-08-17 11:14:01 -05:00
James Barnett
53b096836e update 2016-06-25 13:03:50 -05:00
James Barnett
162a2cf60a update 2016-06-25 10:31:21 -05:00
James Barnett
b9e6572092 fix formatting 2016-06-25 09:01:23 -05:00
James Barnett
dd35f89c37 add bitcoin tip 2016-06-25 09:00:38 -05:00
James Barnett
f0e35d5e6f add PGP to troubleshooting 2016-06-10 10:34:44 -05:00
James Barnett
0630806061 fix links 2016-06-10 10:27:45 -05:00
James Barnett
efd9dc781d link test 2016-06-10 10:26:48 -05:00
James Barnett
8cea1d9528 add toc 2016-06-10 10:24:31 -05:00
James Barnett
df0f4549a2 update 2016-06-10 10:21:23 -05:00
James Barnett
6d9cca05fa update readme 2016-06-09 16:18:48 -05:00
James Barnett
a692215033 fix Makefile for shellcheck 2016-06-09 16:15:48 -05:00
James Barnett
4b84410780 reorganize 2016-06-09 16:09:42 -05:00
James Barnett
519be40dc0 update script for shellcheck; update Makefile 2016-06-09 16:07:35 -05:00
James Barnett
67a81829cf update script for shellcheck 2016-06-09 15:57:01 -05:00
James Barnett
eee0134ed2 make clearer 2016-06-09 15:03:04 -05:00
James Barnett
e08a0aca24 typo 2016-06-09 15:02:06 -05:00
James Barnett
a4bf9641ab update PGP section 2016-06-09 15:01:30 -05:00
James Barnett
87913d022c add section on PGP signatures 2016-06-09 08:42:49 -05:00
James Barnett
e945e3ffc3 formatting 2016-05-20 21:56:57 -05:00
James Barnett
06c61fa5b4 add troubleshooting section 2016-05-20 21:55:27 -05:00
James Barnett
fd3780aedb update depends 2016-05-20 08:44:55 -05:00
James Barnett
ae5c332c8a convert install script to Makefile 2016-05-20 08:41:36 -05:00
James Barnett
e981f3c729 move warning 2016-05-08 21:18:55 -05:00
James Barnett
d4cf0fa183 add warnings when no snapshots are taken 2016-05-08 21:16:59 -05:00
James Barnett
ea654087df avoid defaults carrying over 2016-05-08 21:04:44 -05:00
James Barnett
268256123e tidy up 2016-05-08 21:02:28 -05:00
James Barnett
b4fa01786d better bash syntax 2016-05-08 20:30:41 -05:00
James Barnett
7017e68087 update descriptions of hook to be consistent with other hooks 2016-05-08 19:51:01 -05:00
James Barnett
78130b2e06 fix typo 2016-05-08 19:49:56 -05:00
James Barnett
1113b8882c fix post 2016-05-08 19:47:51 -05:00
James Barnett
f503d7a233 fix post command 2016-05-08 19:38:27 -05:00
James Barnett
243d1d6ee9 cleanup 2016-05-08 19:28:24 -05:00
James Barnett
0b2b465b6f rearrange command args 2016-05-08 19:01:54 -05:00
James Barnett
5738263134 update install script 2016-04-27 08:55:33 -05:00
James Barnett
4571e2890b update install script 2016-04-27 08:54:27 -05:00
James Barnett
bef769fd04 update hook names in install script 2016-04-27 08:26:07 -05:00
James Barnett
be35509864 move scripts dir to be consistent with other hooks 2016-04-27 08:22:42 -05:00
James Barnett
525f0602d9 ensure that pre hook is first and post hook is last 2016-04-27 08:22:01 -05:00
James Barnett
01390f4873 grammar 2016-04-26 17:40:38 -05:00
James Barnett
4986dc60ec AUR badges! 2016-04-26 17:35:09 -05:00
James Barnett
adda3341d3 update badges with links 2016-04-26 17:25:15 -05:00
James Barnett
acbdda794f remove abort on fail 2016-04-26 14:42:45 -05:00
James Barnett
ffdd26f055 update 2016-04-26 14:38:46 -05:00
James Barnett
0b724a5fcf fix hooks 2016-04-26 14:37:55 -05:00
James Barnett
44bef72930 remove cleanup hook; change script dir 2016-04-26 14:35:45 -05:00
James Barnett
e7844991a0 use subshell; use /tmp for file 2016-04-26 14:35:02 -05:00
James Barnett
b22224f150 better practice to us find than ls 2016-04-26 12:53:16 -05:00
James Barnett
9c67dcec57 cleanup 2016-04-26 12:34:42 -05:00
James Barnett
9e6a9de678 rearrange a little 2016-04-26 12:08:29 -05:00
James Barnett
fbb7c5ae81 check if root runs script 2016-04-26 12:00:57 -05:00
James Barnett
deb7d862ed fix pre/post description 2016-04-26 11:43:42 -05:00
James Barnett
825bbf89a7 greatly simplify script 2016-04-26 11:31:58 -05:00
James Barnett
2fb18c78f0 check that script is sourced and not run 2016-04-26 11:03:47 -05:00
James Barnett
8a0c325ee2 check that script is run as root 2016-04-26 10:58:29 -05:00
James Barnett
cfda6a90b7 formatting, create argument for reading in configuration based on pre or post 2016-04-26 10:28:59 -05:00
James Barnett
a13a5ab706 make reading configuration a separate function 2016-04-26 10:18:46 -05:00
James Barnett
d5e7860fb3 typo 2016-04-26 10:11:42 -05:00
James Barnett
1467c59874 remove snap-pac.conf from install 2016-04-26 08:30:54 -05:00
James Barnett
088c4a630a use snapper configuration file 2016-04-26 08:23:50 -05:00
James Barnett
769673531a update comment 2016-04-25 19:29:37 -05:00
James Barnett
5187adb9e5 fix hooks 2016-04-25 18:26:51 -05:00
James Barnett
376355538e maintain separate directory for script 2016-04-25 18:25:31 -05:00
James Barnett
5e92c178a3 fix location of pre number 2016-04-25 18:22:42 -05:00
James Barnett
17506c3b43 fix hooks 2016-04-25 18:20:54 -05:00
James Barnett
d392bf411b complete consolidation into one script 2016-04-25 18:19:40 -05:00
James Barnett
8f5989df84 expand 2016-04-25 17:06:38 -05:00
James Barnett
dd4307f6b5 grammar 2016-04-25 17:02:54 -05:00
James Barnett
6d57ff8c16 update 2016-04-25 17:02:11 -05:00
James Barnett
68b92700c9 update install to include main script 2016-04-25 15:26:47 -05:00
James Barnett
f8731f2b38 update clean script 2016-04-25 15:26:02 -05:00
James Barnett
4f25ac388f make main script that is sourced 2016-04-25 15:24:34 -05:00
James Barnett
96b282e4fa make variables read only 2016-04-25 15:16:44 -05:00
James Barnett
cef3d00b01 update README 2016-04-25 14:42:54 -05:00
James Barnett
1cffe0260a remove verbose option 2016-04-25 13:18:38 -05:00
James Barnett
7ad490c283 add verbose option 2016-04-25 13:15:19 -05:00
James Barnett
3a9aaadb1f add comment about defaults 2016-04-25 13:10:46 -05:00
James Barnett
35e62cc8b2 add warning if configuration file is missing 2016-04-25 13:08:07 -05:00
James Barnett
2e364c802f more details on configuration 2016-04-25 12:56:25 -05:00
James Barnett
48469cbbc3 update configuration defaults 2016-04-25 12:51:48 -05:00
James Barnett
34da5c923f fix sed 2016-04-25 12:50:31 -05:00
James Barnett
1c71f3d185 typo 2016-04-25 12:48:31 -05:00
James Barnett
60eed78f0c typo 2016-04-25 12:47:48 -05:00
James Barnett
fbbe552550 fix description defaults 2016-04-25 12:46:21 -05:00
James Barnett
b6f8c322d4 don't show full path of pacman in descriptions 2016-04-25 12:45:24 -05:00
James Barnett
32306e37f8 comment out configuration file, since defaults now set 2016-04-25 12:40:26 -05:00
James Barnett
33efa4484d make sure defaults are set if user removes options 2016-04-25 12:36:37 -05:00
James Barnett
8194b4ac7b put CLEANUP_ALGORITHM in scripts 2016-04-25 12:22:54 -05:00
James Barnett
31a76ca665 hard code removal 2016-04-25 12:21:53 -05:00
James Barnett
a0659fdae0 remove dangerous code 2016-04-25 12:19:24 -05:00
James Barnett
7213a5ad1c make /etc directory 2016-04-25 11:45:06 -05:00
James Barnett
16d26fe55f add configuration file for real 2016-04-25 11:43:52 -05:00
James Barnett
6e12136abc fix typo 2016-04-25 11:42:35 -05:00
James Barnett
976d440616 create basic configuration file 2016-04-25 11:40:34 -05:00
James Barnett
02a37e8289 remove verbose flag 2016-04-25 11:23:13 -05:00
James Barnett
14b4fd127a add variables 2016-04-25 11:22:11 -05:00
James Barnett
c39458f224 update install script 2016-04-25 11:16:17 -05:00
James Barnett
4f6de57707 downloads icon doesn't work 2016-04-25 11:14:20 -05:00
James Barnett
b6f25d7685 add badges 2016-04-25 10:18:14 -05:00
James Barnett
081ed10675 update install script comments 2016-04-25 09:51:40 -05:00
James Barnett
92b1ccc3bb add install script 2016-04-25 09:43:03 -05:00
James Barnett
f5094e5616 fix priority of snap-pac-clean 2016-04-25 09:35:02 -05:00
James Barnett
fcc7763c45 add cleanup hook, in order to get rid of install script 2016-04-25 09:33:42 -05:00
James Barnett
3f8ea86897 remove GRUB hook and script 2016-04-25 09:22:23 -05:00
James Barnett
54eec76bc8 update link to stable release of grub-btrfs 2016-04-24 21:00:56 -05:00
James Barnett
7cdb6ba28e grammer, clarify, rearrange 2016-04-24 08:01:05 -05:00
James Barnett
6bae9c0044 create simple way to add more configurations to take snapshots of 2016-04-23 08:38:38 -05:00
James Barnett
3244efa1f9 fix formatting 2016-04-23 08:24:54 -05:00
James Barnett
1f0b93bbb8 add link to each script 2016-04-23 08:23:16 -05:00
James Barnett
9074bc6237 note on where hooks and scripts live 2016-04-23 07:55:48 -05:00
James Barnett
4e8b0aac98 rename scripts 2016-04-23 07:54:38 -05:00
James Barnett
e6b0a6a6e5 update grub hook 2016-04-23 07:47:10 -05:00
James Barnett
fd4c92de01 update hooks for new script locations 2016-04-23 07:44:05 -05:00
James Barnett
137875b568 comments in scripts; update location of prefile 2016-04-23 07:14:48 -05:00
James Barnett
d3afa0b201 dependeny should be on GRUB, not grub-btrfs-git 2016-04-23 07:02:35 -05:00
James Barnett
4fcff3de03 remove extra space 2016-04-22 21:55:38 -05:00
James Barnett
b96cd99707 add header to each file 2016-04-22 21:52:20 -05:00
James Barnett
bc1050ddfc update README 2016-04-22 21:38:28 -05:00
James Barnett
e7739b0542 update README 2016-04-22 20:31:23 -05:00
James Barnett
c390946261 update README 2016-04-22 20:29:13 -05:00
James Barnett
c310e4f02a update README 2016-04-22 20:27:12 -05:00
James Barnett
ff74d7cb68 update README 2016-04-22 20:11:06 -05:00
James Barnett
fff40e3ec9 formatting 2016-04-22 13:58:42 -05:00
James Barnett
cb1b080f98 update README 2016-04-22 13:58:04 -05:00
James Barnett
4dca29d2e6 update descriptions to show just pacman command 2016-04-22 13:52:35 -05:00
James Barnett
a54835d7ff add description of pacman command to snapper description 2016-04-21 15:11:53 -05:00
James Barnett
e8f1671853 grammar 2016-03-31 21:09:00 -05:00
James Barnett
eef77c8ded fix typo 2016-03-17 20:24:55 -05:00
James Barnett
cfaab80706 make config generation redirect stderr to /dev/null 2016-03-17 20:15:28 -05:00
James Barnett
9a3e96d579 update readme 2016-03-17 19:55:15 -05:00
James Barnett
b4d78e7ce7 add hook to regenerate grub config file (e.g., when using grub-btrfs 2016-03-17 19:52:53 -05:00
James Barnett
a596a458a4 update hook names so that snapshots are the first things done 2016-03-17 19:49:27 -05:00
James Barnett
bbedb6b505 udpate 2016-03-13 12:39:15 -05:00
James Barnett
7ce9dabd69 more specific 2016-03-12 21:03:23 -06:00
James Barnett
2132f71cde update readme 2016-03-11 14:12:20 -06:00
James Barnett
ccc295d8c7 fix typo 2016-03-11 14:10:50 -06:00
James Barnett
d0f31ca36d truncate output 2016-03-11 14:10:20 -06:00
James Barnett
ca536be860 fix description of pre hook 2016-03-11 14:09:19 -06:00
James Barnett
4f06537ceb update readme 2016-03-11 14:07:36 -06:00
James Barnett
82a62f5966 update readme 2016-03-11 14:06:02 -06:00
James Barnett
d490b01fe4 update readme 2016-03-11 14:05:17 -06:00
James Barnett
a9df03a623 grammar 2016-03-11 12:24:50 -06:00
James Barnett
1451753571 update 2016-03-11 10:26:22 -06:00
James Barnett
c38a46b2ba update readme 2016-03-11 10:20:46 -06:00
James Barnett
f872136ba2 update readme 2016-03-11 10:07:40 -06:00
James Barnett
916cfa86ba update hook descriptions 2016-03-11 09:59:31 -06:00
James Barnett
2bc20147a9 add cleanup algorithm 2016-03-11 09:59:23 -06:00
26 changed files with 1072 additions and 43 deletions

24
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View file

@ -0,0 +1,24 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Additional context**
Add any other context about the problem here.

View file

@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

3
.github/PULL_REQUEST_TEMPLATE.md vendored Normal file
View file

@ -0,0 +1,3 @@
- [ ] Closes #xxxx
- [ ] Tests added / passed
- [ ] All linting tests pass

28
.github/workflows/docs.yml vendored Normal file
View file

@ -0,0 +1,28 @@
name: Docs
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Python
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Install dependencies
run: python -m pip install --upgrade pip sphinx
- name: Build docs
run: sphinx-build -a docs/source docs/build
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs/build
publish_branch: gh-pages

24
.github/workflows/tests.yml vendored Normal file
View file

@ -0,0 +1,24 @@
name: Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Python
uses: actions/setup-python@v1
with:
python-version: 3.9
- name: Install dependencies
run: python -m pip install --upgrade pip pytest flake8
- name: Run linter
run: flake8 --max-line-length=120 scripts/
- name: Run tests
run: python -m pytest -v

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
__pycache__
venv
docs/build
man8

42
Makefile Normal file
View file

@ -0,0 +1,42 @@
# snap-pac
# https://github.com/wesbarnett/snap-pac
# Copyright (C) 2016-2021 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.,
PKGNAME = snap-pac
PREFIX ?= /usr
SHARE_DIR = $(DESTDIR)$(PREFIX)/share
.PHONY: install test docs
install: man
@install -Dm755 scripts/snap_pac.py $(SHARE_DIR)/libalpm/scripts/snap-pac
@install -Dm644 hooks/* -t $(SHARE_DIR)/libalpm/hooks/
@install -Dm644 LICENSE -t $(SHARE_DIR)/licenses/$(PKGNAME)/
@install -Dm644 man8/* -t $(SHARE_DIR)/man/man8/
@install -Dm644 README.md -t $(SHARE_DIR)/doc/$(PKGNAME)/
@install -Dm644 extra/snap-pac.ini $(DESTDIR)/etc/snap-pac.ini
test:
@python -m pytest -v .
man:
@cd docs && make man
@mkdir -p man8
@awk 'NR==33{print ".SH DESCRIPTION"}7' docs/build/man/snap-pac.8 > man8/snap-pac.8
docs: man
@sphinx-build -a docs/source docs/build

View file

@ -1,10 +1,25 @@
# snap-pac
These are used for Arch Linux's pacman, so that snapper automatically takes a
pre and post snapshot before and after pacman transactions. There's no need to
create aliases, etc. See `man alpm-hooks` and `man snapper` for more
information.
## Synopsis
## Installation
This is a set of [pacman](https://wiki.archlinux.org/index.php/Pacman) hooks and scripts that automatically cause [snapper](http://snapper.io/) to perform a snapshot before pacman transactions.
Install [the package from the AUR](https://aur.archlinux.org/packages/snap-pac/).
Forked from Wes Barnett's solution for my own personal needs. Takes a single screenshot vs. the original's pre/post pair.
## [Installation](https://wesbarnett.github.io/snap-pac/installation.html)
## Configuration
Most likely, configuration is not needed. By default, the snapper configuration named `root` will have snapshots taken before every pacman transaction.
For more information on configuring snap-pac, see [the documentation](https://wesbarnett.github.io/snap-pac/configuration.html).
## Documentation
See the [documentation here](https://wesbarnett.github.io/snap-pac/) or `man 8 snap-pac` after installation.
## Troubleshooting
After reviewing the documentation, [check the issues page] and file a new issue if your problem is not covered.
[check the issues page]: https://codeberg.org/ak95/snap-pac/issues

20
docs/Makefile Normal file
View file

@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

35
docs/make.bat Normal file
View file

@ -0,0 +1,35 @@
@ECHO OFF
pushd %~dp0
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=source
set BUILDDIR=build
if "%1" == "" goto help
%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end
:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
:end
popd

65
docs/source/conf.py Normal file
View file

@ -0,0 +1,65 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
# -- Project information -----------------------------------------------------
project = 'snap-pac'
copyright = '2021, Wes Barnett, PhD'
author = 'Wes Barnett, PhD'
# -- General configuration ---------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_theme_options = {
'badge_branch': 'main',
'description': 'pacman hooks that use snapper to create pre/post btrfs snapshots',
'fixed_sidebar': True,
'github_banner': True,
'github_user': 'wesbarnett',
'github_repo': 'snap-pac',
'github_type': 'star'
}
man_pages = [("index", "snap-pac", "Pacman hooks that use snapper to create pre/post btrfs snapshots like openSUSE's YaST", "Wes Barnett", "8")]
manpages_url = 'https://man.archlinux.org/man/{page}.{section}'

View file

@ -0,0 +1,99 @@
Configuration
=============
.. toctree::
:maxdepth: 2
Configuration is done via Python ini configuration files. The defaults
should be suitable for most users, so you may not need to do any configuration at all.
By default only the ``root`` snapper configuration is snapshotted.
A commented example configuration files is located at ``/etc/snap-pac.ini``.
Edit with your favorite editor. The file is commented and should be
self-explanatory.
Each section corresponds with a snapper configuration. Add additional sections to add
other snapper configurations to be snapshotted. By default, only the root configuration
is snapshotted. Additionally you can add a section named ``DEFAULT`` with options that
apply to all snapper configurations unless overridden in a later section.
Each section can have the following entries:
* ``desc_limit`` - integer; maximum length of description string before being truncated.
Default: 72
* ``important_packages`` - list of strings; names of packages that if involved in a pacman
transaction will add ``important=yes`` to the snapper userdata for the pair of
snapshots. Default: []
* ``important_commands`` - list of strings; parent commands that will add
``important=yes`` to the snapper userdata for the pair of snapshots. Default: []
* ``pre_description`` - string; description for the pre snapshot. Default: the parent
command that called the pacman hook.
* ``post_description`` - string; description for the post snapshot. Default: space
separated list of packages that were installed, upgraded, or removed.
* ``snapshot`` - boolean; whether or not to snapshot the configuration. Default: True for
``root`` configuration; False otherwise.
* ``userdata`` - list of strings; key-value pairs that will be added to the userdata for
the pair of snapshots. Default: []
Examples
--------
Turn off snapshots for ``root`` configuration and turn on for ``home`` configuration:
.. code-block:: ini
[root]
snapshot = False
[home]
snapshot = True
Set the snapper to add the userdata ``important=yes`` for every snapshot in the ``root``
configuration when a system upgrade is performed:
.. code-block:: ini
[root]
important_commands = ["pacman -Syu"]
Set the snapper to add the userdata ``important=yes`` for every snapshot in the ``root``
configuration when a pacman transaction handles the packages ``linux`` and ``linux-lts``:
.. code-block:: ini
[root]
important_packages = ["linux", "linux-lts"]
Here's a fuller example, with several options set for different configurations. In this
case the ``root`` configuration snapshot will have ``important=yes`` when ``linux`` and
``linux-lts`` packages are part of the transaction. Additionally when full system
upgrades are performed ``root`` snapshots will be marked ``important=yes``. Note that
you don't have to add ``snapshot = True`` for the ``root`` configuration since that is
the default.
This file also turns one snapshots for the ``home`` snapper configuration and adds the
userdata ``requestid=42,user=arthur`` to all snapshots for that configuration.
Additionally the post snapshot description is overridden.
.. code-block:: ini
[root]
important_packages = ["linux", "linux-lts"]
important_commands = ["pacman -Syu"]
[home]
snapshot = True
userdata = ["requestid=42", "user=arthur"]
post_description = "pacman transaction post snapshot"
Environment Variables
=====================
To temporarily prevent snapshots from being performed for a single pacman
command, set the environment variable ``SNAP_PAC_SKIP``. For example:
.. code-block:: bash
sudo SNAP_PAC_SKIP=y pacman -Syu

91
docs/source/examples.rst Normal file
View file

@ -0,0 +1,91 @@
Example
=======
.. toctree::
:maxdepth: 2
Here is an example of how the snapshots are created and how to rollback and pacman
transaction. Here the nano package is installed:
.. code-block:: bash
pacman -S nano
.. code-block:: none
resolving dependencies...
looking for conflicting packages...
Packages (1) nano-2.5.3-1
Total Installed Size: 2.14 MiB
:: Proceed with installation? [Y/n] Y
(1/1) checking keys in keyring [######################################] 100%
(1/1) checking package integrity [######################################] 100%
(1/1) loading package files [######################################] 100%
(1/1) checking for file conflicts [######################################] 100%
(1/1) checking available disk space [######################################] 100%
:: Running pre-transaction hooks...
(1/1) Performing snapper pre snapshots for the following configurations...
=> root: 1033
:: Processing package changes...
(1/1) installing nano [######################################] 100%
:: Running post-transaction hooks...
(1/1) Performing snapper post snapshots for the following configurations...
=> root: 1034
The snapper snapshot number is given for each snapper configuration that is used. This
is also logged in pacman's log.
Here are the snapshots created before and after the pacman transaction:
.. code-block:: bash
snapper -c root list -t pre-post | tail -n 1
.. code-block:: none
1033 | 1034 | Fri 22 Apr 2016 01:54:13 PM CDT | Fri 22 Apr 2016 01:54:14 PM CDT | pacman -S nano |
Here is what changed during the transaction:
.. code-block:: bash
snapper -c root status 1033..1034
.. code-block:: none
+..... /etc/nanorc
c..... /etc/snapper/.snap-pac-pre
+..... /usr/bin/nano
+..... /usr/bin/rnano
+..... /usr/share/doc/nano
+..... /usr/share/doc/nano/faq.html
+..... /usr/share/doc/nano/fr
+..... /usr/share/doc/nano/fr/nano.1.html
+..... /usr/share/doc/nano/fr/nanorc.5.html
+..... /usr/share/doc/nano/fr/rnano.1.html
The above output is truncated, but it continues. See :manpage:`snapper(8)` to for what each
symbol means. You can also do ``snapper diff`` in the same way.
Then, to undo the pacman transaction:
.. code-block:: bash
snapper -c root undochange 1033..1034
.. code-block:: none
create:0 modify:3 delete:100
Now nano is no longer installed, along with all the files it changed:
.. code-block:: bash
pacman -Qi nano
.. code-block:: none
error: package 'nano' was not found

47
docs/source/faq.rst Normal file
View file

@ -0,0 +1,47 @@
FAQ
===
.. toctree::
:maxdepth: 2
**Does snap-pac backup non-btrfs /boot partitions?**
No, but you can add a hook that does it for you. It would be something like the following:
.. code-block:: none
[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Package
Target = linux
[Action]
Description = Backing up /boot...
When = PreTransaction
Exec = /usr/bin/rsync -avzq --delete /boot /.bootbackup
Note that you will probably want to name the file with a numbered prefix less than
``05`` so that it is run before the snap-pac pre snapshot takes place. That will ensure
that the snapshot taken will have the boot partition back-up corresponding with the
state of the system. For example, you could name it ``04-backupboot.hook``.
**How do I link old kernel modules automatically when the kernel is upgraded?**
This behavior is no longer a part of this package. Use a pacman hook like the following:
.. code-block:: none
[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Package
Target = linux
[Action]
Description = Symlinking old kernel modules...
When = PostTransaction
Exec = /usr/bin/bash -c "find /usr/lib/modules -xtype l -delete; ln -sv /.snapshots/$(snapper -c root list | awk 'END{print $1}')/snapshot/usr/lib/modules/$(uname -r) /usr/lib/modules/"

79
docs/source/index.rst Normal file
View file

@ -0,0 +1,79 @@
.. snap-pac documentation master file, created by
sphinx-quickstart on Thu Mar 11 19:49:12 2021.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
snap-pac
========
This is a set of `pacman <https://archlinux.org/pacman/>`_ hooks and script that causes
`snapper <http://snapper.io/>`_ to automatically take a pre and post snapshot before and
after pacman transactions, similar to how `YaST <https://yast.opensuse.org/>`_ does with
OpenSuse. This provides a simple way to undo changes to a system after a pacman
transaction.
Because these are pacman hooks, it doesn't matter how you call pacman—whether
directly, through an AUR helper, or using an alias—snapper will create the snapshots
when pacman installs, upgrades, or removes a package. The pacman command used is
logged in the snapper description for the snapshots. Additionally the snapshot numbers
are output to the screen and to the pacman log for each snapper configuration during the
pacman transaction, so that the user can easily find which changes he or she may want to
revert.
.. code-block:: none
:caption: When you run pacman, the snapper pre/post snapshots are created automatically. For a fuller example see :doc:`examples`.
:emphasize-lines: 17,18,25,26
$ sudo pacman -S vim
resolving dependencies...
looking for conflicting packages...
Packages (1) vim-8.2.2489-1
Total Installed Size: 3.79 MiB
Net Upgrade Size: 0.00 MiB
:: Proceed with installation? [Y/n]
(1/1) checking keys in keyring [############] 100%
(1/1) checking package integrity [############] 100%
(1/1) loading package files [############] 100%
(1/1) checking for file conflicts [############] 100%
(1/1) checking available disk space [############] 100%
:: Running pre-transaction hooks...
(1/1) Performing snapper pre snapshots for the following configurations...
==> root: 7394
:: Processing package changes...
(1/1) installing vim [############] 100%
:: Running post-transaction hooks...
(1/4) Arming ConditionNeedsUpdate...
(2/4) Updating icon theme caches...
(3/4) Updating the desktop file MIME type cache...
(4/4) Performing snapper post snapshots for the following configurations...
==> root: 7395
To undo changes from a pacman transaction, use ``snapper undochange``. See the :manpage:`snapper(8)`
for more details as well as examples.
If you have severe breakage—like snapper is gone for some reason and you can't get it
back—you'll have to resort to more extreme methods, such as taking a snapshot of the pre
snapshot and making it the default subvolume or mounting it as /. Most likely you'll
need to use a live USB to get into a chroot environment to do any of these things.
Snapper has a ``snapper rollback`` feature, but your setup has to be properly configured to
use it. The exact procedure depends on your specific setup. Be careful.
Note that the pre transaction hooks occur before the pacman transaction but after the
pacman database is synced, if applicable. In other words, if you run `pacman -Syu` and
roll back the upgrade according to the above instructions, you will not have rolled back
the pacman database to the previous state. Thus, if, after upgrading and rolling back
the upgrade, you then install a package, it will possibly be a partial upgrade, which is
unsupported.
.. toctree::
:maxdepth: 1
installation
configuration
examples
troubleshooting
faq

View file

@ -0,0 +1,66 @@
Installation
============
Install the ``snap-pac`` package using pacman:
.. code-block:: bash
pacman -S snap-pac
Alternatively download the `latest release and signature
<https://github.com/wesbarnett/snap-pac/releases>`_. Then, verify the download:
.. code-block:: bash
gpg --verify snap-pac-<version>.tar.gz.sig
where ``<version>`` is the version number you downloaded.
Finally, run:
.. code-block:: bash
make install
I have signed the release tarball and commits with my PGP key. Starting with release
2.2, the tarballs are signed with my key with fingerprint
``F7B28C61944FE30DABEEB0B01070BCC98C18BD66``.
For previous releases, the key's fingerprint was
``8535CEF3F3C38EE69555BF67E4B5E45AA3B8C5C3``.
Dependencies
------------
``python``, ``pacman``, and ``snapper`` are all required.
Testing
-------
For testing, ``pytest`` is required. To run the tests do:
.. code-block:: bash
make test
Documentation
-------------
Typically, you will not need to build the documentation on your own and can simply
access it by visiting the `online documentation
<https://wesbarnett.github.io/snap-pac/>`_ or by accessing the manpage:
.. code-block:: bash
man 8 snap-pac
To build the documentation, ``sphinx`` is required. To build the documentation you can
do:
.. code-block:: bash
make docs
The resulting html documentation will then be located at ``docs/build/index.html``.
Additionally, this generates the manpage which will be located under ``man8``.

View file

@ -0,0 +1,23 @@
Troubleshooting
===============
.. toctree::
:maxdepth: 2
**snap-pac is only taking snapshots of the root configuration.**
That's the default behavior. See :doc:`configuration`.
**No snapshots are being taken when I run pacman.**
No snapper configurations are set up for snap-pac's pacman hooks. By default snap-pac
will take snapshots for the root configuration and any other configuration which has
SNAPSHOT set to yes in its configuration file. See :doc:`configuration`.
**After restoring snapshot from snap-pac, the pacman database is locked.**
The pre/post snaphots are taken while pacman is running, so this is expected. Follow
the instructions pacman gives you (*e.g.*, removing the lock file). You can add the
database lock file to a snapper filter so that snapper won't consider it when
performing snapper diff, snapper status, snapper undochange, etc. See the Filters
section in :manpage:`snapper(8)` for more information.

38
extra/snap-pac.ini Normal file
View file

@ -0,0 +1,38 @@
# snap-pac example configuration file
# see snap-pac(8) for more details
# Each section corresponds with a snapper configuration. Add additional sections to add
# other configurations to be snapshotted. By default, only the root configuration is snapshotted.
# Create a section named [DEFAULT] to have a setting apply for all snapper configurations
## Uncomment to set parameters for snapper configuration named root
#[root]
## How many characters to limit the description for snapper.
## Default is 72
#desc_limit = 72
## Whether or not to take snapshots of this snapper configuration
## Default is True for root configuration and False for all other configurations
#snapshot = True
## What snapper cleanup algorithm to use
## Default is number
#cleanup_algorithm = number
## Uncomment to add "important=yes" to userdata for snapshots referring to these packages
## Default is []
#important_packages = ["linux", "linux-lts"]
## Uncomment to add "important=yes" to userdata for snapshots that were created with the following commands
## Default is []
#important_commands = ["pacman -Syu"]
## Add custom userdata. Each key-value pair should be an item in the list
## Default is []
#userdata = ["key=value","foo=bar"]
## Example for another snapper configuration named "home"
# [home]
## Default is False
# snapshot = True

32
hooks/05-snap-pac.hook Normal file
View file

@ -0,0 +1,32 @@
# 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 = Upgrade
Operation = Install
Operation = Remove
Type = Package
Target = *
[Action]
Description = Taking snapper snapshot before installing...
Depends = snap-pac
When = PreTransaction
Exec = /usr/share/libalpm/scripts/snap-pac
NeedsTargets
AbortOnFail

View file

@ -0,0 +1,28 @@
# 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_*"

161
scripts/snap_pac.py Executable file
View file

@ -0,0 +1,161 @@
#!/usr/bin/env python
# Copyright (C) 2021 Wes 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.
"""Script for taking snapshots; run from pacman hooks."""
from argparse import ArgumentParser
from configparser import ConfigParser
import json
import logging
from pathlib import Path
import os
import sys
import tempfile
logging.basicConfig(format="%(message)s", level=logging.INFO)
class SnapperCmd:
def __init__(self, config, cleanup_algorithm, description="", nodbus=False, userdata=""):
self.cmd = ["snapper"]
if nodbus:
self.cmd.append("--no-dbus")
self.cmd.extend([
f"--config {config} create",
f"--cleanup-algorithm {cleanup_algorithm}",
"--print-number"
])
self.cmd.append("--read-write")
if description:
self.cmd.append(f"--description \"{description}\"")
if userdata:
self.cmd.append(f"--userdata \"{userdata}\"")
def __call__(self):
return os.popen(self.__str__()).read().rstrip("\n")
def __str__(self):
return " ".join(self.cmd)
class ConfigProcessor:
def __init__(self, ini_file, parent_cmd=None, packages=None):
"""Set up defaults for snap-pac configuration."""
if parent_cmd is None:
self.parent_cmd = os.popen(f"ps -p {os.getppid()} -o args=").read().strip()
else:
self.parent_cmd = parent_cmd
if packages is None:
self.packages = [line.rstrip("\n") for line in sys.stdin]
else:
self.packages = packages
self.config = ConfigParser()
self.config["DEFAULT"] = {
"snapshot": False,
"cleanup_algorithm": "number",
"description": self.parent_cmd,
"desc_limit": 72,
"important_packages": [],
"important_commands": [],
"userdata": []
}
self.config["root"] = {
"snapshot": True
}
self.config.read(ini_file)
def get_cleanup_algorithm(self, section):
return self.config.get(section, "cleanup_algorithm")
def get_description(self, section):
desc_limit = self.config.getint(section, "desc_limit")
return self.config.get(section, "description")[:desc_limit]
def check_important_commands(self, section):
return self.parent_cmd in json.loads(self.config.get(section, "important_commands"))
def check_important_packages(self, section):
important_packages = json.loads(self.config.get(section, "important_packages"))
return any(x in important_packages for x in self.packages)
def check_important(self, section):
return (self.check_important_commands(section) or
self.check_important_packages(section))
def get_userdata(self, section):
userdata = set(json.loads(self.config.get(section, "userdata")))
if self.check_important(section):
userdata.add("important=yes")
return ",".join(sorted(list(userdata)))
def __call__(self, section):
if section not in self.config:
self.config.add_section(section)
return {
"description": self.get_description(section),
"cleanup_algorithm": self.get_cleanup_algorithm(section),
"userdata": self.get_userdata(section),
"snapshot": self.config.getboolean(section, "snapshot")
}
def get_snapper_configs(conf_file):
"""Get the snapper configurations."""
for line in conf_file.read_text().split("\n"):
if line.startswith("SNAPPER_CONFIGS"):
line = line.rstrip("\n").rstrip("\"").split("=")
return line[1].lstrip("\"").split()
def check_skip():
return os.getenv("SNAP_PAC_SKIP", "n").lower() in ["y", "yes", "true", "1"]
def parse_args():
parser = ArgumentParser(description="Script for taking snapper snapshots. Used with pacman hooks.")
parser.add_argument(
"--ini", dest="snap_pac_ini", type=Path,
default=Path("/etc/snap-pac.ini"), help="snap-pac ini file path"
)
parser.add_argument(
"--conf", dest="snapper_conf_file", type=Path,
default=Path("/etc/conf.d/snapper"), help="snapper configuration file path"
)
return parser.parse_args()
if __name__ == "__main__":
if check_skip():
logging.warning("snapper snapshots skipped")
quit()
args = parse_args()
config_processor = ConfigProcessor(args.snap_pac_ini)
chroot = os.stat("/") != os.stat("/proc/1/root/.")
for snapper_config in get_snapper_configs(args.snapper_conf_file):
data = config_processor(snapper_config)
if data["snapshot"]:
num = SnapperCmd(snapper_config, data["cleanup_algorithm"], data["description"], chroot, data["userdata"])()
logging.info(f"==> {snapper_config}: {num}")

View file

@ -1,10 +0,0 @@
#!/bin/bash
PREFILE=/etc/snapper/.snap-pac-pre
if [ -f $PREFILE ]; then
SNAPPERPACPRE=$(cat $PREFILE)
snapper --config root create --type post --pre-number $SNAPPERPACPRE --description "pacman posttransaction"
rm $PREFILE
else
echo "WARNING: $PREFILE does not exist, so not performing post snapshot. If you are initially installing snap-pac, this is normal."
fi

View file

@ -1,3 +0,0 @@
#!/bin/bash
snapper --config root create --type pre --print-number --description "pacman pretransaction" > /etc/snapper/.snap-pac-pre

View file

@ -1,12 +0,0 @@
[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Package
Target = *
[Action]
Description = Snapper snapshot after a transaction
Depends = snapper
When = PostTransaction
Exec = /usr/bin/snapper-pac-post

View file

@ -1,12 +0,0 @@
[Trigger]
Operation = Upgrade
Operation = Install
Operation = Remove
Type = Package
Target = *
[Action]
Description = Snapper snapshot before a transaction
Depends = snapper
When = PreTransaction
Exec = /usr/bin/snapper-pac-pre

122
tests/test_script.py Normal file
View file

@ -0,0 +1,122 @@
import tempfile
from pathlib import Path
import os
import pytest
from scripts.snap_pac import check_skip, ConfigProcessor, get_snapper_configs, Prefile, SnapperCmd
@pytest.mark.parametrize("snapper_cmd, actual_cmd", [
(
SnapperCmd("root", "pre", "number", "foo"),
"snapper --config root create --cleanup-algorithm number --print-number --description \"foo\" --type pre"
),
(
SnapperCmd("root", "post", "number", "bar", False, 1234),
"snapper --config root create --cleanup-algorithm number --print-number"
" --description \"bar\" --pre-number 1234 --type post"
),
(
SnapperCmd("root", "post", "number", "bar", True, 1234),
"snapper --no-dbus --config root create --cleanup-algorithm number --print-number"
" --description \"bar\" --pre-number 1234 --type post"
),
(
SnapperCmd("root", "post", "number", "bar", False, 1234, "important=yes"),
"snapper --config root create --cleanup-algorithm number --print-number"
" --description \"bar\" --userdata \"important=yes\" --pre-number 1234 --type post"
),
(
SnapperCmd("root", "post", "number", "bar", False, 1234, "foo=bar,important=yes"),
"snapper --config root create --cleanup-algorithm number --print-number"
" --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):
assert str(snapper_cmd) == actual_cmd
def test_get_snapper_configs():
with tempfile.NamedTemporaryFile("w", delete=False) as f:
f.write("## Path: System/Snapper\n")
f.write("\n")
f.write("## Type: string\n")
f.write("## Default: \"\"\n")
f.write("# List of snapper configurations.\n")
f.write("SNAPPER_CONFIGS=\"home root foo bar\"\n")
name = f.name
assert get_snapper_configs(Path(name)) == ["home", "root", "foo", "bar"]
def test_skip_snap_pac():
os.environ["SNAP_PAC_SKIP"] = "y"
assert check_skip() is True
@pytest.mark.parametrize("section, command, packages, snapshot_type, result", [
(
"root", "foo", ["bar"], "pre",
{"description": "foo", "cleanup_algorithm": "number", "userdata": "", "snapshot": True}
),
(
"root", "pacman -Syu", [], "pre",
{"description": "pacman -Syu", "cleanup_algorithm": "number", "userdata": "important=yes", "snapshot": True}
),
(
"mail", "pacman -Syu", [], "pre",
{"description": "pacman -Syu", "cleanup_algorithm": "number", "userdata": "", "snapshot": False}
),
(
"home", "pacman -Syu", [], "pre",
{"description": "pac", "cleanup_algorithm": "number", "userdata": "foo=bar,requestid=42", "snapshot": True}
),
(
"home", "pacman -Syu", [], "post",
{"description": "a r", "cleanup_algorithm": "number", "userdata": "foo=bar,requestid=42", "snapshot": True}
),
(
"myconfig", "pacman -S linux", ["linux"], "post",
{"description": "linux", "cleanup_algorithm": "timeline",
"userdata": "foo=bar,important=yes,requestid=42", "snapshot": True}
),
])
def test_config_processor(section, command, packages, snapshot_type, result):
with tempfile.NamedTemporaryFile("w", delete=False) as f:
f.write("[root]\n")
f.write("important_commands = [\"pacman -Syu\"]\n\n")
f.write("[home]\n")
f.write("snapshot = True\n")
f.write("desc_limit = 3\n")
f.write("post_description = a really long description\n")
f.write("userdata = [\"foo=bar\", \"requestid=42\"]\n\n")
f.write("[myconfig]\n")
f.write("snapshot = True\n")
f.write("cleanup_algorithm = timeline\n")
f.write("important_packages = [\"linux\", \"linux-lts\"]\n")
f.write("userdata = [\"foo=bar\", \"requestid=42\"]\n")
name = f.name
config_processor = ConfigProcessor(name, snapshot_type, command, packages)
assert config_processor(section) == result
def test_prefile_read_none():
prefile = Prefile("root", "pre")
assert prefile.read() is None
def test_prefile_read():
prefile = Prefile("root", "pre")
prefile.write("1234")
prefile = Prefile("root", "post")
assert prefile.read() == "1234"
def test_no_prefile():
prefile = Prefile("foo-pre-file-not-found", "post")
assert prefile.read() is None