Skip to content

Commit

Permalink
feat: inject custom commands into package()
Browse files Browse the repository at this point in the history
  • Loading branch information
fosskers committed Mar 21, 2024
1 parent 99f36f8 commit 6ea9720
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# `cargo-aur` Changelog

## Unreleased

#### Added

- A new `custom` field in `[package.metadata.aur]` which accepts a list of
strings that will be added as-is to the `package()` function of the PKGBUILD.
This allows the user to add specific extra commands to their build process.
See the README for more details.

## 1.7.1 (2024-03-18)

#### Fixed
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ panic = "abort"
[package.metadata.aur]
# depends = ["blah"]
# files = [[".github/dependabot.yml", "/usr/local/share/cargo-aur/dependabot.yml"]]
custom = ["echo hi"]
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,28 @@ package() {
}
```

### Custom commands within `package()`

The `custom` list can be used to add specific commands to the `package()`
function. This config:

```toml
[package.metadata.aur]
custom = ["echo hi"]
```

yields:

```
package() {
install -Dm755 cargo-aur -t "$pkgdir/usr/bin"
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
echo hi
}
```

**Note:** Caveat emptor. No attempt is made to verify the injected commands.

### Static Binaries

Run with `--musl` to produce a release binary that is statically linked via
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,4 +164,6 @@ pub struct AUR {
optdepends: Vec<String>,
#[serde(default)]
pub files: Vec<(PathBuf, PathBuf)>,
#[serde(default)]
pub custom: Vec<String>,
}
4 changes: 4 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,10 @@ where
)?;
}
}

for custom in aur.custom.iter() {
writeln!(file, " {}", custom)?;
}
}

writeln!(file, "}}")?;
Expand Down

0 comments on commit 6ea9720

Please sign in to comment.