mirror of
https://github.com/fosskers/cargo-aur.git
synced 2026-03-09 07:13:12 -05:00
feat: prepend $pkgdir to avoid user hassle
This commit is contained in:
@@ -27,4 +27,4 @@ panic = "abort"
|
||||
|
||||
[package.metadata.aur]
|
||||
# depends = ["blah"]
|
||||
# files = [[".github/dependabot.yml", "$pkgdir/usr/local/share/cargo-aur/dependabot.yml"]]
|
||||
# files = [[".github/dependabot.yml", "/usr/local/share/cargo-aur/dependabot.yml"]]
|
||||
|
||||
@@ -90,7 +90,7 @@ filesystem. So this:
|
||||
|
||||
```toml
|
||||
[package.metadata.aur]
|
||||
files = [["path/to/local/foo.txt", "$pkgdir/usr/local/share/your-app/foo.txt"]]
|
||||
files = [["path/to/local/foo.txt", "/usr/local/share/your-app/foo.txt"]]
|
||||
```
|
||||
|
||||
will result in this:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Errors that can occur in this application.
|
||||
|
||||
use std::fmt::Display;
|
||||
use std::{fmt::Display, path::PathBuf};
|
||||
|
||||
pub(crate) enum Error {
|
||||
IO(std::io::Error),
|
||||
@@ -9,6 +9,7 @@ pub(crate) enum Error {
|
||||
Utf8OsString,
|
||||
MissingMuslTarget,
|
||||
MissingLicense,
|
||||
TargetNotAbsolute(PathBuf),
|
||||
}
|
||||
|
||||
impl Display for Error {
|
||||
@@ -25,6 +26,9 @@ impl Display for Error {
|
||||
Error::MissingLicense => {
|
||||
write!(f, "Missing LICENSE file. See https://choosealicense.com/")
|
||||
}
|
||||
Error::TargetNotAbsolute(p) => {
|
||||
write!(f, "Target filepath is not absolute: {}", p.display())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,5 +163,5 @@ pub struct AUR {
|
||||
#[serde(default)]
|
||||
optdepends: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub files: Vec<(String, String)>,
|
||||
pub files: Vec<(PathBuf, PathBuf)>,
|
||||
}
|
||||
|
||||
11
src/main.rs
11
src/main.rs
@@ -239,7 +239,16 @@ where
|
||||
|
||||
if let Some(aur) = package.metadata.as_ref().and_then(|m| m.aur.as_ref()) {
|
||||
for (source, target) in aur.files.iter() {
|
||||
writeln!(file, " install -Dm644 \"{}\" \"{}\"", source, target)?;
|
||||
if target.has_root().not() {
|
||||
return Err(Error::TargetNotAbsolute(target.to_path_buf()));
|
||||
} else {
|
||||
writeln!(
|
||||
file,
|
||||
" install -Dm644 \"{}\" \"$pkgdir{}\"",
|
||||
source.display(),
|
||||
target.display()
|
||||
)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user