This commit is contained in:
parent
9ed46ba9fb
commit
3080fee86b
1 changed files with 23 additions and 9 deletions
32
src/pkg.rs
32
src/pkg.rs
|
@ -55,19 +55,33 @@ impl Repository {
|
|||
.ok()
|
||||
}
|
||||
|
||||
pub fn extract_pkg_name(name: &str) -> (String, String, String, String) {
|
||||
// "{}-{}-{}-{}.pkg.tar.zst"
|
||||
let splitted: Vec<&str> = name.split('-').collect();
|
||||
let name = splitted.get(0).unwrap();
|
||||
let version = splitted.get(1).unwrap();
|
||||
let rel = splitted.get(2).unwrap();
|
||||
let arch = splitted.get(3).unwrap().trim_end_matches(".pkg.tar.zst");
|
||||
|
||||
(
|
||||
name.to_string(),
|
||||
version.to_string(),
|
||||
rel.to_string(),
|
||||
arch.to_string(),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn get_pkg(&self, arch: &str, pkg_name: &str) -> Option<Package> {
|
||||
let pkg = if pkg_name.ends_with(".pkg.tar.zst") {
|
||||
Package::find(&self.name, arch, pkg_name.trim_end_matches(".pkg.tar.zst"))
|
||||
} else if pkg_name.ends_with(".pkg.tar.zst.sig") {
|
||||
Package::find(
|
||||
&self.name,
|
||||
arch,
|
||||
pkg_name.trim_end_matches(".pkg.tar.zst.sig"),
|
||||
)
|
||||
let pkg_name = if pkg_name.ends_with(".sig") {
|
||||
pkg_name.trim_end_matches(".sig").to_string()
|
||||
} else {
|
||||
Package::find(&self.name, arch, pkg_name)
|
||||
pkg_name.to_string()
|
||||
};
|
||||
|
||||
let (name, version, _, _) = Repository::extract_pkg_name(&pkg_name);
|
||||
|
||||
let pkg = Package::new(&self.name, &arch, &name, &version);
|
||||
|
||||
if pkg.exists() {
|
||||
return Some(pkg);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue