Skip to content

Commit

Permalink
Add --keepsrc
Browse files Browse the repository at this point in the history
Fixes #664
  • Loading branch information
Morganamilo committed Apr 12, 2022
1 parent 2843a71 commit 6b7858a
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 21 deletions.
2 changes: 1 addition & 1 deletion completions/bash
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ _paru() {
asp gpg gpgflags fm fmflags pager completioninterval sortby searchby limit upgrademenu
removemake noremovemake cleanafter nocleanafter rebuild rebuildall norebuild
rebuildtree redownload noredownload redownloadall pgpfetch nopgpfetch useask
nouseask savechanges nosavechanges failfast nofailfast combinedupgrade
nouseask savechanges nosavechanges failfast nofailfast keepsrc nokeepsrc combinedupgrade
nocombinedupgrade batchinstall nobatchinstall provides noprovides devel nodevel
develsuffixes sudoloop nosudoloop bottomup topdown newsonupgrade bat batflags
chroot nochroot sign nosign keeprepocache nokeeprepocache signdb nosigndb
Expand Down
2 changes: 2 additions & 0 deletions completions/fish
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ complete -c $progname -n "not $noopt" -l savechanges -d 'Commit changes to pkgbu
complete -c $progname -n "not $noopt" -l nosavechanges -d "Don't commit changes to pkgbuilds made during review" -f
complete -c $progname -n "not $noopt" -l failfast -d 'Exit as soon as any AUR packages fail to build' -f
complete -c $progname -n "not $noopt" -l nofailfast -d "Don't Exit as soon as any AUR packages fail to build" -f
complete -c $progname -n "not $noopt" -l keepsrc -d "Keep src/ and pkg/ directories after building packages" -f
complete -c $progname -n "not $noopt" -l nokeepsrc -d "Don't keep src/ and pkg/ directories after building packages" -f
complete -c $progname -n "not $noopt" -l combinedupgrade -d 'Refresh then perform the repo and AUR upgrade together' -f
complete -c $progname -n "not $noopt" -l nocombinedupgrade -d 'Perform the repo upgrade and AUR upgrade separately' -f
complete -c $progname -n "not $noopt" -l batchinstall -d 'Build multiple AUR packages then install them together' -f
Expand Down
2 changes: 2 additions & 0 deletions completions/zsh
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ _pacman_opts_common=(
"--nosavechanges[Don't commit changes to pkgbuilds made during review]"
"--failfast[Exit as soon as any AUR packages fail to build]"
"--nofailfast[Don't exit as soon as any AUR packages fail to build]"
"--keepsrc[Keep src/ and pkg/ directories after building packages]"
"--nokeepsrc[Don't keep src/ and pkg/ directories after building packages]"
'--combinedupgrade[Refresh then perform the repo and AUR upgrade together]'
'--nocombinedupgrade[Perform the repo upgrade and AUR upgrade separately]'
'--mflags[Pass arguments to makepkg]:mflags'
Expand Down
8 changes: 8 additions & 0 deletions man/paru.8
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,14 @@ By default Paru will continue and try to build other AUR packages.
.B \-\-nofailfast
Don't exit as soon as any AUR packages fail to build.

.TP
.B \-\-keepsrc
Keep src/ and pkg/ directories after building packages.

.TP
.B \-\-nokeepsrc
Don't keep src/ and pkg/ directories after building packages.

.TP
.B \-\-combinedupgrade
During sysupgrade, paru will first perform a refresh, then show
Expand Down
4 changes: 4 additions & 0 deletions man/paru.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ Exit as soon as any AUR packages fail to build.

By default Paru will continue and try to build other AUR packages.

.TP
.B KeepSrc
Keep src/ and pkg/ directories after building packages.

.TP
.B Redownload [= all]
Always download PKGBUILDs of targets even when a copy is available in cache. If
Expand Down
2 changes: 2 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ pub struct Config {
pub ssh: bool,
pub keep_repo_cache: bool,
pub fail_fast: bool,
pub keep_src: bool,

pub sign: Sign,
pub sign_db: Sign,
Expand Down Expand Up @@ -890,6 +891,7 @@ impl Config {
}
"KeepRepoCache" => self.keep_repo_cache = true,
"FailFast" => self.fail_fast = true,
"KeepSrc" => self.keep_src = true,
"SignDb" => {
self.sign_db = match value {
Some(v) => Sign::Key(v.to_string()),
Expand Down
56 changes: 36 additions & 20 deletions src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,24 @@ pub async fn build_pkgbuild(config: &mut Config) -> Result<i32> {

if config.chroot {
chroot
.build(&dir, &["-cu"], &["-ofA"])
.build(&dir, &["-u"], &["-ofA"])
.context(tr!("failed to download sources"))?;
} else {
// download sources
exec::makepkg(config, &dir, &["--verifysource", "-ACcf"])?
let mut args = vec!["--verifysource", "-Af"];
if !config.keep_src {
args.push("-Cc");
}
exec::makepkg(config, &dir, &args)?
.success()
.context(tr!("failed to download sources"))?;

// pkgver bump
exec::makepkg(config, &dir, &["-ofCA"])?
let mut args = vec!["-ofA"];
if !config.keep_src {
args.push("-C");
}
exec::makepkg(config, &dir, &args)?
.success()
.context(tr!("failed to build"))?;
}
Expand All @@ -249,13 +257,13 @@ pub async fn build_pkgbuild(config: &mut Config) -> Result<i32> {
)
.context(tr!("failed to build"))?;
} else {
exec::makepkg(
config,
&dir,
&["-cfeA", "--noconfirm", "--noprepare", "--holdver"],
)?
.success()
.context(tr!("failed to build"))?;
let mut args = vec!["-feA", "--noconfirm", "--noprepare", "--holdver"];
if !config.keep_src {
args.push("-c");
}
exec::makepkg(config, &dir, &args)?
.success()
.context(tr!("failed to build"))?;
}
} else {
println!(
Expand Down Expand Up @@ -1453,16 +1461,24 @@ fn build_install_pkgbuild<'a>(

if config.chroot {
chroot
.build(&dir, &["-cu"], &["-ofA"])
.build(&dir, &["-u"], &["-ofA"])
.with_context(|| tr!("failed to download sources for '{}'", base))?;
} else {
// download sources
exec::makepkg(config, &dir, &["--verifysource", "-ACcf"])?
let mut args = vec!["--verifysource", "-Af"];
if !config.keep_src {
args.push("-Cc");
}
exec::makepkg(config, &dir, &args)?
.success()
.with_context(|| tr!("failed to download sources for '{}'", base))?;

// pkgver bump
exec::makepkg(config, &dir, &["-ofCA"])?
let mut args = vec!["-ofA"];
if !config.keep_src {
args.push("-C");
}
exec::makepkg(config, &dir, &args)?
.success()
.with_context(|| tr!("failed to build '{}'", base))?;
}
Expand Down Expand Up @@ -1505,13 +1521,13 @@ fn build_install_pkgbuild<'a>(
)
.with_context(|| tr!("failed to build '{}'", base))?;
} else {
exec::makepkg(
config,
&dir,
&["-cfeA", "--noconfirm", "--noprepare", "--holdver"],
)?
.success()
.with_context(|| tr!("failed to build '{}'", base))?;
let mut args = vec!["-feA", "--noconfirm", "--noprepare", "--holdver"];
if !config.keep_src {
args.push("-c");
}
exec::makepkg(config, &dir, &args)?
.success()
.with_context(|| tr!("failed to build '{}'", base))?;
}
} else {
println!(
Expand Down

0 comments on commit 6b7858a

Please sign in to comment.