pikaur icon indicating copy to clipboard operation
pikaur copied to clipboard

Feature Request: Possibility to add environment variable to pacman command

Open ckotte opened this issue 5 years ago • 8 comments

Pikaur v1.6.12
Pacman v5.2.2 - libalpm v12.0.2
Description:

Would it be possible to implement a configurable environment variable for installation and de-installation of build dependencies?

I use btrfs and snap-pac to create pre and post snapshots for every pacman operation. This means 6 snapshots are created if I update a single package that requires additional packages to build.

For example:

pre-snapshot (1) pacman --color=always --sync --asdeps yarn bazel post-snapshot (2) pre-snapshot (3) pacman --color=always --remove yarn bazel post-snapshot (4) pre-snapshot (5) pacman --color=always --upgrade --needed /home/<user>/.cache/pikaur/pkg/gnome-shell-extension-gtile-git-41.r0.ga4ff7ae-1-any.pkg.tar.zst post-snapshot (6)

I use the snapshots to be able to revert to an older system state or to restore files in case of an issue. To avoid running out of space and to avoid performance impacts, you should not keep hundreds of snapshots. On my system 30 snapshots are kept.

However, if I do a system update and many AUR packages are updated it could happen that many snapshots are created and the old snapshots before the update will be deleted because too many new snapshots were created. If I could disable the snapshot creation for build deps, I could prevent this from happening.

The creation of the snapshots can be skipped with this environment variable:

SNAP_PAC_SKIP=y pacman --color=always --sync --asdeps yarn bazel

ckotte avatar Nov 13 '20 19:11 ckotte

since those dependencies are being installed into your system, not inside some chroot, installing dependencies could break up the system the same as installing "normal" packages

regarding your request, i'm not going to add it myself for sure. but could merge it if there is no other way to solve the problem

actionless avatar Nov 13 '20 21:11 actionless

since those dependencies are being installed into your system, not inside some chroot, installing dependencies could break up the system the same as installing "normal" packages

Sure, but if I do a system update via pikaur -Syu --devel --needed then I would have two snapshots for pacman packages anyway and I don't really need the snapshots created for build dependencies.

ckotte avatar Nov 14 '20 13:11 ckotte

mb it can be done in a more clear way:

  1. you set always SNAP_PAC_SKIP=y
  2. in pikaur i might be reasonable to add some options for hooks (like BeforeAll, AfterAll, BeforeRepo, AfterAUR, etc)
  3. in such of the hooks you could explicitly make a snapshot

actionless avatar Nov 14 '20 15:11 actionless

The variable is used by the hooks to disable their functionality.

[vagrant@vagrant-btrfs-restore ansible-linux]$ sudo SNAP_PAC_SKIP=y pacman -S bazel yarn --noconfirm
resolving dependencies...
looking for conflicting packages...

Packages (4) java-environment-common-3-3  jdk11-openjdk-11.0.8.u10-1  bazel-3.7.0-1  yarn-1.22.10-1

Total Download Size:   154.02 MiB
Total Installed Size:  204.77 MiB

:: Proceed with installation? [Y/n] 
:: Retrieving packages...
 java-environment-common-3-3-any                                                         2.5 KiB  0.00   B/s 00:00 [#####################################################################] 100%
 jdk11-openjdk-11.0.8.u10-1-x86_64                                                      76.4 MiB  1162 KiB/s 01:07 [#####################################################################] 100%
 bazel-3.7.0-1-x86_64                                                                   76.6 MiB  1141 KiB/s 01:09 [#####################################################################] 100%
 yarn-1.22.10-1-any                                                                    953.5 KiB  1222 KiB/s 00:01 [#####################################################################] 100%
(4/4) checking keys in keyring                                                                                     [#####################################################################] 100%
(4/4) checking package integrity                                                                                   [#####################################################################] 100%
(4/4) loading package files                                                                                        [#####################################################################] 100%
(4/4) checking for file conflicts                                                                                  [#####################################################################] 100%
(4/4) checking available disk space                                                                                [#####################################################################] 100%
:: Running pre-transaction hooks...
(1/2) Disable and stop systemd timers before performing snapper pre snapshots...
==> skipping due to SNAP_PAC_SKIP being set
==> skipping due to SNAP_PAC_SKIP being set
(2/2) Performing snapper pre snapshots for the following configurations...
==> skipping due to SNAP_PAC_SKIP being set
==> skipping due to SNAP_PAC_SKIP being set
:: Processing package changes...
(1/4) installing java-environment-common                                                                           [#####################################################################] 100%
(2/4) installing jdk11-openjdk                                                                                     [#####################################################################] 100%
(3/4) installing bazel                                                                                             [#####################################################################] 100%
(4/4) installing yarn                                                                                              [#####################################################################] 100%
:: Running post-transaction hooks...
(1/7) Arming ConditionNeedsUpdate...
(2/7) Updating icon theme caches...
(3/7) Updating the desktop file MIME type cache...
(4/7) Performing snapper post snapshots for the following configurations...
==> skipping due to SNAP_PAC_SKIP being set
==> skipping due to SNAP_PAC_SKIP being set
(5/7) Enable and start systemd timers after performing snapper post snapshots...
==> skipping due to SNAP_PAC_SKIP being set
==> skipping due to SNAP_PAC_SKIP being set
(6/7) Generate GRUB config to let grub-btrfs detect new snapshots
==> skipping due to SNAP_PAC_SKIP being set
==> skipping due to SNAP_PAC_SKIP being set
(7/7) Saving installed packages...

If you add snapshot hooks to pikaur then you would implement redundant functionality which already exists (in snap-pac and a few other custom hooks) and that needs to be maintained.

ckotte avatar Nov 14 '20 17:11 ckotte

would implement redundant functionality which already exists (in snap-pac and a few other custom hooks)

you don't need to implement it, you can just call some of already implemented ones

actionless avatar Nov 14 '20 18:11 actionless

But then you need to set/unset SNAP_PAC_SKIP if you executed SNAP_PAC_SKIP=y pikuar .... Otherwise, the hooks will just be skipped.

This is included in every hook:

[[ -v SNAP_PAC_SKIP ]] && { printf "==> skipping due to SNAP_PAC_SKIP being set"; exit 0; }

You should execute the hooks in the same sequence pacman does, custom hooks should be executed as well, etc. pp.

Adding a new command line option and just add SNAP_PAC_SKIP before the pacman commands if it's set is much simpler.

ckotte avatar Nov 15 '20 12:11 ckotte

Would you accept a pull request at all that implements an additional command-line option (and maybe a config option) just for a specific use case and tool?

ckotte avatar Nov 15 '20 12:11 ckotte

Otherwise, the hooks will just be skipped.

you can just invoke a hook as env SNAP_PAC_SKIP=n /path/to/hook to avoid that

just for a specific use case and tool?

i'd like it to be as much general as possible

actionless avatar Nov 15 '20 12:11 actionless