Skip to content

Commit

Permalink
feat(-A): restore -c
Browse files Browse the repository at this point in the history
This deletes a package's build directory after building has completed
and the tarball has been copied to the cache.
  • Loading branch information
fosskers committed Jul 27, 2024
1 parent c7641d4 commit 380c211
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 11 deletions.
1 change: 1 addition & 0 deletions book/src/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Governed within the `[aur]` section.
| `shellcheck` | bool | Run `shellcheck` over PKGBUILDs before building. |
| `diff` | bool | Display PKGBUILD diffs during upgrades. |
| `delmakedeps` | bool | Remove makedeps after building. |
| `clean` | bool | Delete a package's build directory after building. |
| `noconfirm` | bool | Automatically accept all prompts. |
| `nocheck` | bool | Don't run the `check()` function while building. |
| `skipdepcheck` | bool | Don't perform dependency checking at all. |
Expand Down
3 changes: 3 additions & 0 deletions misc/aura.texi
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,9 @@ See @code{aura stats --lang} for available language codes.
@item delmakedeps
@tab bool
@tab Remove makedeps after building
@item clean
@tab bool
@tab Delete a package's build directory after building
@item noconfirm
@tab bool
@tab Automatically accept all prompts
Expand Down
12 changes: 9 additions & 3 deletions rust/aura-pm/src/command/aur/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,6 @@ fn build_one(

// --- Prepare the Build Directory --- //
let build_dir = env.aur.build.join(base);
// TODO 2024-06-13 Consider giving the option to wipe the build dir every time.
//
// Sometimes certain packages don't want to have `configure` ran more than once, etc.
std::fs::create_dir_all(&build_dir).map_err(|e| Error::CreateDir(build_dir.clone(), e))?;

// --- Copy non-downloadable `source` files and PKGBUILD --- //
Expand Down Expand Up @@ -268,6 +265,15 @@ fn build_one(
.collect::<Vec<_>>()
};

if env.aur.clean {
// NOTE 2024-07-27 As a matter of policy, this call failing should not
// fail the entire rest of the build process, so we just catch it and
// warn.
if let Err(e) = Command::new("rm").arg("-rf").arg(&build_dir).status() {
warn!("Removing build dir {} failed: {}", build_dir.display(), e);
}
}

Ok(Built { clone, tarballs })
}

Expand Down
12 changes: 5 additions & 7 deletions rust/aura-pm/src/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -278,19 +278,13 @@ struct RawAur {
chroot: HashSet<String>,
#[serde(default)]
ignores: HashSet<String>,
#[serde(default)]
git: bool,
#[serde(default)]
hotedit: bool,
#[serde(default)]
shellcheck: bool,
#[serde(default)]
diff: bool,
#[serde(default)]
delmakedeps: bool,
#[serde(default)]
clean: bool,
noconfirm: bool,
#[serde(default)]
nocheck: bool,
}

Expand All @@ -315,6 +309,8 @@ pub(crate) struct Aur {
pub(crate) diff: bool,
/// Delete makedeps after building.
pub(crate) delmakedeps: bool,
/// Delete a package's build directory after the built tarball has been copied.
pub(crate) clean: bool,
/// Don't ask the user for confirmation.
pub(crate) noconfirm: bool,
/// Don't consider "checkdeps" during dependency resolution and when calling
Expand All @@ -340,6 +336,7 @@ impl Aur {
shellcheck: false,
diff: false,
delmakedeps: false,
clean: false,
noconfirm: false,
nocheck: false,
skipdepcheck: false,
Expand Down Expand Up @@ -426,6 +423,7 @@ impl TryFrom<RawAur> for Aur {
shellcheck: raw.shellcheck,
diff: raw.diff,
delmakedeps: raw.delmakedeps,
clean: raw.clean,
noconfirm: raw.noconfirm,
nocheck: raw.nocheck,
skipdepcheck: false,
Expand Down
6 changes: 5 additions & 1 deletion rust/aura-pm/src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,7 @@ pub struct Aur {
#[clap(long, short, display_order = 2)]
pub quiet: bool,

/// Open a given package's AUR package.
/// Open a given package's AUR page.
#[clap(group = "aur", long, short, value_name = "package", display_order = 1)]
pub open: Option<String>,

Expand Down Expand Up @@ -1242,6 +1242,10 @@ pub struct Aur {
#[clap(long, short = 'a', display_order = 4)]
pub delmakedeps: bool,

/// Delete a package's build directory after the built tarball has been copied.
#[clap(long, short, display_order = 4)]
pub clean: bool,

/// Upgrade all installed AUR packages.
#[clap(group = "aur", long, short = 'u', display_order = 1)]
pub sysupgrade: bool,
Expand Down

0 comments on commit 380c211

Please sign in to comment.