From fae9829d8623fc3701eef41142a318149258ed96 Mon Sep 17 00:00:00 2001 From: JeWe37 Date: Sun, 20 Feb 2022 20:08:55 +0100 Subject: [PATCH] Option to keep old package versions with local repo (#668) * Option to not remove old packages in local repo * Add command line option and docs. * Add completions * Fix wrong option setting * remove test files * Renamed option to KeepRepoCache * fix copy paste error --- completions/bash | 2 +- completions/fish | 2 ++ completions/zsh | 2 ++ man/paru.8 | 9 +++++++++ man/paru.conf.5 | 5 +++++ paru.conf | 1 + src/command_line.rs | 2 ++ src/config.rs | 2 ++ src/repo.rs | 7 ++++++- 9 files changed, 30 insertions(+), 2 deletions(-) diff --git a/completions/bash b/completions/bash index 12eb5857..e9295698 100644 --- a/completions/bash +++ b/completions/bash @@ -76,7 +76,7 @@ _paru() { nouseask savechanges nosavechanges combinedupgrade nocombinedupgrade batchinstall nobatchinstall provides noprovides devel nodevel develsuffixes sudoloop nosudoloop bottomup topdown newsonupgrade bat batflags chroot nochroot - sign nosign signdb nosigndb + sign nosign keeprepocache nokeeprepocache signdb nosigndb localrepo review skipreview' 'b d h q r v a') show=('news stats' 'w s') diff --git a/completions/fish b/completions/fish index cd0abd66..7181f9c8 100644 --- a/completions/fish +++ b/completions/fish @@ -240,6 +240,8 @@ complete -c $progname -n "not $noopt" -l chroot -d 'Build packages in a chroot' complete -c $progname -n "not $noopt" -l nochroot -d "Don't build packages in a chroot" -f complete -c $progname -n "not $noopt" -l sign -d 'Sign packages with gpg' -f complete -c $progname -n "not $noopt" -l nosign -d "Don't sign packages with gpg" -f +complete -c $progname -n "not $noopt" -l keeprepocache -d 'Keep old versions of packages with local repo' -f +complete -c $progname -n "not $noopt" -l nokeeprepocache -d "Don't keep old versions of packages with local repo" -f complete -c $progname -n "not $noopt" -l signdb -d 'Sign databases with gpg' -f complete -c $progname -n "not $noopt" -l nosigndb -d "Don't sign databases with gpg" -f complete -c $progname -n "not $noopt" -l localrepo -d 'Build packages in a local repo' -f diff --git a/completions/zsh b/completions/zsh index fb151edd..3add7fdc 100644 --- a/completions/zsh +++ b/completions/zsh @@ -106,6 +106,8 @@ _pacman_opts_common=( "--nochroot[Don't build packages in a chroot]" '--sign[Sign packages with gpg]' "--nosign[Don't sign packages with gpg]" + '--keeprepocache[Keep old versions of packages with local repo]' + "--nokeeprepocache[Don't keep old versions of packages with local repo]" '--signdb[Sign databases with gpg]' "--nosigndb[Don't sign databases with gpg]" '--localrepo[Build packages in a local repo]' diff --git a/man/paru.8 b/man/paru.8 index 2a75a1a0..2aa66df6 100644 --- a/man/paru.8 +++ b/man/paru.8 @@ -591,6 +591,15 @@ Sign packages with gpg. Optionally indicate which key to sign with. .B \-\-nosign Don't sign package with gpg. +.TP +.B \-\-keeprepocache +Normally upon AUR packages getting updated the old versions will be removed from the local repo. +This option disables that behavior, keeping the both all versions and only updating the DB. + +.TP +.B \-\-nokeeprepocache +Don't keep old packages. + .TP .B \-\-signdb [= key] Sign databases with gpg. Optionally indicate which key to sign with. diff --git a/man/paru.conf.5 b/man/paru.conf.5 index bff91e90..62dbd666 100644 --- a/man/paru.conf.5 +++ b/man/paru.conf.5 @@ -219,6 +219,11 @@ Sign packages with gpg. Optionally indicate which key to sign with. .B SignDb [= key] Sign databases with gpg. Optionally indicate which key to sign with. +.TP +.B KeepRepoCache +Normally upon AUR packages getting updated the old versions will be removed from the local repo. +This option disables that behavior, keeping the both all versions and only updating the DB. + .TP .B SkipReview Skip the review process. diff --git a/paru.conf b/paru.conf index 509715ef..e040ae17 100644 --- a/paru.conf +++ b/paru.conf @@ -28,6 +28,7 @@ DevelSuffixes = -git -cvs -svn -bzr -darcs -always -hg #Chroot #Sign #SignDb +#KeepRepoCache # # Binary OPTIONS diff --git a/src/command_line.rs b/src/command_line.rs index 3af7dc4a..6b6f5779 100644 --- a/src/command_line.rs +++ b/src/command_line.rs @@ -317,6 +317,8 @@ impl Config { Err(_) => Sign::Yes, } } + Arg::Long("nokeeprepocache") => self.keep_repo_cache = false, + Arg::Long("keeprepocache") => self.keep_repo_cache = true, Arg::Long("signdb") => { self.sign_db = match value { Ok(k) => Sign::Key(k.to_string()), diff --git a/src/config.rs b/src/config.rs index 850dca31..41b8aba1 100644 --- a/src/config.rs +++ b/src/config.rs @@ -391,6 +391,7 @@ pub struct Config { pub news_on_upgrade: bool, pub comments: bool, pub sign: Sign, + pub keep_repo_cache: bool, pub sign_db: Sign, pub pre_build_command: Option, @@ -870,6 +871,7 @@ impl Config { None => Sign::Yes, } } + "KeepRepoCache" => self.keep_repo_cache = true, "SignDb" => { self.sign_db = match value { Some(v) => Sign::Key(v.to_string()), diff --git a/src/repo.rs b/src/repo.rs index d7044645..7deb43f0 100644 --- a/src/repo.rs +++ b/src/repo.rs @@ -55,7 +55,12 @@ pub fn add, S: AsRef>( .collect::>(); let mut cmd = Command::new("repo-add"); - cmd.arg("-R").arg(file).args(pkgs); + + if !config.keep_repo_cache { + cmd.arg("-R"); + } + + cmd.arg(file).args(pkgs); if config.sign_db != Sign::No { cmd.arg("-s");