You are not logged in.

#1 2017-12-12 11:19:55

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 1,988
Website

[solved] Pacman cache: Keep currently installed and newest version

Hi all,

I am looking for a tool that cleans up the pacman cache with the following requirements.

  • Keep currently installed version of the package.

  • Keep latest version of the package.

  • Remove all other versions.

To clarify, let's assume that /var/cache/pacman/pkg contains:

  • foo-1.0.0-1.pkg.tar.xz

  • foo-1.0.1-1.pkg.tar.xz  # ← Installed

  • foo-1.0.2-1.pkg.tar.xz

  • foo-1.0.3-1.pkg.tar.xz

  • foo-1.0.4-1.pkg.tar.xz  # ← Latest

Then I'd do

cacheutil --keep-newest --keep-current

And end up with:

  • foo-1.0.1-1.pkg.tar.xz  # ← Installed

  • foo-1.0.4-1.pkg.tar.xz  # ← Latest

I think that this cannot be done with paccache, can it?
Is there another utility that can do the above, or do I need to write my own?

Last edited by schard (2018-08-13 08:34:26)


macro_rules! yolo { { $($tokens:tt)* } => { unsafe { $($tokens)* } }; }

Offline

#2 2017-12-12 11:26:18

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [solved] Pacman cache: Keep currently installed and newest version

Why do you not have the latest version of all packages installed?

Partial upgrades aren't supported, so an application that is only useful on a partially updated system is unlikely to exist or to be useful to anyone else.

Last edited by Slithery (2017-12-12 11:28:21)


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

#3 2017-12-12 11:33:05

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 1,988
Website

Re: [solved] Pacman cache: Keep currently installed and newest version

Who's talking about partial upgrades?
I do not have the latest packages installed, because I do not constantly run pacman -Syu.

Basically the use case comes from that I run

pacman -Syuw --noc

periodically using a systemd.timer to have the latest packages in the local cache for a later upgrade via

pacman -Su

.
The reason for that is, that I have a very slow internet connection on the respective machine and want to download new packages unattended over night, but later manually perform the (complete) system upgrade without having to wait hours for pacman to download the packages first.
However I do not always find the time to do a system upgrade with the systemd.timer interval but also have limited disk space.
Hence I'm looking for a way to keep the pacman cache clean in the aforementioned way.


macro_rules! yolo { { $($tokens:tt)* } => { unsafe { $($tokens)* } }; }

Offline

#4 2017-12-12 11:37:07

progandy
Member
Registered: 2012-05-17
Posts: 5,196

Re: [solved] Pacman cache: Keep currently installed and newest version

paccache has an --ignore option you can use if you have one or two downgraded packages to wait out bugs. You'll get too keep all versions in the cache instead of the newest and the installed, but for one or two packages that shouldn't be a big deal.

Edit: OK, that use case is a bit different. I don't think a tool for that exists.

Last edited by progandy (2017-12-12 11:38:31)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' |

Offline

#5 2017-12-12 11:39:57

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 1,988
Website

Re: [solved] Pacman cache: Keep currently installed and newest version

This is not the issue.
I want to keep the currently installed versions of all packages in case something breaks during the upgrade process to be able to downgrade back.

Edit: I suspected that it might not.

Last edited by schard (2017-12-12 11:40:42)


macro_rules! yolo { { $($tokens:tt)* } => { unsafe { $($tokens)* } }; }

Offline

#6 2017-12-12 14:02:48

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,532
Website

Re: [solved] Pacman cache: Keep currently installed and newest version

Just use paccache in your timer script right before the Syuw, e.g.:

paccache -rk1
pacman -Syuw --noc

EDIT: I suppose this might lead to the removal of some packages that would then need to be re-downloaded.  Is your internet access metered (do you pay per byte, or is it just slow)?  Alternatively, I suppose it might end up deleting the installed package - I'm not sure how paccache works in such a case as it is a corner case that generally should not exist.

Perhaps an alternative would be to use an alternative cachedir for the -Syuw job.  Clean out that cachedir keeping just the newest regularly.  Then when you want to update, move everything from the alternate cache into the real cache.  In otherwords, just add a --cachedir flag to your -Syuw script.  Then when you are ready to update:

# run the next line as often as you want, perhaps even as part of the -Syuw script:
paccache -rk1 -c /path/to/alternative/cache/

# run these lines together to update:
mv /path/to/alternative/cache/* /var/cache/pacman/pkg/
pacman -Su
paccache -rk2

Last edited by Trilby (2017-12-12 14:12:25)


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#7 2018-08-13 08:33:21

schard
Forum Moderator
From: Hannover
Registered: 2016-05-06
Posts: 1,988
Website

Re: [solved] Pacman cache: Keep currently installed and newest version

Sorry for the late reply.
I finally ended up with:

[Unit]
Description=Download up-to-date packages
After=network.target
Requires=network.target

[Service]
Type=oneshot
ExecStart=/usr/bin/pacman -Syuw --noconfirm
ExecStart=/usr/bin/paccache -r

Last edited by schard (2018-08-13 08:33:30)


macro_rules! yolo { { $($tokens:tt)* } => { unsafe { $($tokens)* } }; }

Offline

Board footer

Powered by FluxBB