Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for environment variable to skip pacman-hook snap #35

Open
KAGEYAM4 opened this issue May 29, 2024 · 4 comments
Open

Add support for environment variable to skip pacman-hook snap #35

KAGEYAM4 opened this issue May 29, 2024 · 4 comments

Comments

@KAGEYAM4
Copy link

Source - https://barnettphd.com/snap-pac/configuration.html#environment-variables

snap-pac-hook has support for using SNAP_PAC_SKIP to skip snapper snapshot for pacman transaction.


Can you advise on this ->

I usually many time install and uninstall single application through pacman, this ends up creating snapshot which are barely worth it be snapshotted and ends up filling snapshots which will inturn delete important snapshots.

What do you to solve this ?

For me i had added SNAP_PAC_SKIP=yes in environment and when i do full system upgrade , i explicitly set SNAP_PAC_SKIP=no. But i have observed that i most of the time forget to do this. now i am in limbo, i either end up with all snapshot or end up with no snapshots for pacman.

@hirak99
Copy link
Owner

hirak99 commented May 29, 2024

Interesting problem. Yes using a environment variable seems fragile.

May I ask how you determine which pacman updates you want to snapshot?

If, for example, you want to only snap all pacman -Syu, then probably a better solution will be to add a regex matcher for pacman snapshots.

Say if we had the ability to add something like this to the config -

preinstall_pacman_include_regex='.*\s\-Syu\s.*'

Would it work better you?

@KAGEYAM4
Copy link
Author

preinstall_pacman_include_regex='.\s-Syu\s.'

Would it work better you?

i use yay ( it lets me skip packages that is creating trouble for me ) and it shows this in pacman_log ->

[2024-05-29T17:41:17+0530] [PACMAN] Running 'pacman -S -y -u --ignore hyprland --ignore git-quick-stats --ignore wox-bin --config /etc/pacman.conf --'

May I ask how you determine which pacman updates you want to snapshot?

Super confusing. Been thinking about this for 30mins. I have been using btrfs for 8 months and didn't used snapshot restore functionality.

Now i think it's just fine the way it is. ( maybe the above regex would be a good addition but no sure ). Using pacman to determine when to snapshot is very hard. I will just stick to timeline snapshot.

@hirak99
Copy link
Owner

hirak99 commented May 29, 2024

Cool. As workaround, you could probably increase the number of snapshots. Note that the snapshots created for pacman will not remove periodic snapshots. So you can essentially have many of those.

If your criteria is to skip full upgrades, regex will still help with also with yay or paru. E.g. we could use a regex to match the exact full upgrade string, "^pacman \-S \-y \-u \-\-config /etc/pacman\.conf \-\-$".

However I admit crafting the regex can be complicated. But a tool like this can help, https://regex101.com/

Another option I'm thinking of is to introduce a way to hold a particular snap. I will be slightly different solution though, since until you decide to unhold, the snap will never be deleted automatically. This gives the freedom however to make a decision not prior to, but later - which can be more convenient.

Now i think it's just fine the way it is. ( maybe the above regex would be a good addition but no sure ). Using pacman to determine when to snapshot is very hard. I will just stick to timeline snapshot.

I will hold off for now, and also think a bit more. LMK if you find a solid criteria that you tend to use, and I will help to cover it!

BTW, I realized setting the environment variable may be a bit fragile - since if a user sets it, the parent shell, or root which runs pacman, may not see the variable. So I am not sure how it is used for snap pac, but expect there are some frustration in it not working as expected.

@KAGEYAM4
Copy link
Author

Another option I'm thinking of is to introduce a way to hold a particular snap. I will be slightly different solution though, since until you decide to unhold, the snap will never be deleted automatically. This gives the freedom however to make a decision not prior to, but later - which can be more convenient.

Now i think it's just fine the way it is. ( maybe the above regex would be a good addition but no sure ). Using pacman to determine when to snapshot is very hard. I will just stick to timeline snapshot.

I will hold off for now, and also think a bit more. LMK if you find a solid criteria that you tend to use, and I will help to cover it!

Yes lets see, maybe someone else in community has any idea. Do you have any suitable title for this, so that it will be easy for others to find.

BTW, I realized setting the environment variable may be a bit fragile - since if a user sets it, the parent shell, or root which runs pacman, may not see the variable. So I am not sure how it is used for snap pac, but expect there are some frustration in it not working as expected.

For that, i intialize the variable in /etc/environment and preserve the variable for root session by adding it to /etc/sudoers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants