smart mirroring
This commit is contained in:
parent
68cb32f07b
commit
7647616242
13 changed files with 701 additions and 67 deletions
|
@ -18,18 +18,21 @@ pub struct Package {
|
|||
/// Name of the package
|
||||
pub name: String,
|
||||
/// Version of the package
|
||||
version: Option<String>,
|
||||
pub version: Option<String>,
|
||||
}
|
||||
|
||||
impl Package {
|
||||
/// Create a new package
|
||||
pub fn new(repo: &str, arch: Architecture, pkg_name: &str, version: &str) -> Self {
|
||||
Package {
|
||||
let pkg = Package {
|
||||
repo: repo.to_string(),
|
||||
arch,
|
||||
name: pkg_name.to_string(),
|
||||
version: Some(version.to_string()),
|
||||
}
|
||||
};
|
||||
|
||||
std::fs::create_dir_all(pkg.base_path()).unwrap();
|
||||
pkg
|
||||
}
|
||||
|
||||
pub fn install_script(&self) -> Option<String> {
|
||||
|
@ -186,7 +189,7 @@ impl Package {
|
|||
|
||||
pub fn pacman_hooks(&self) -> Vec<(String, String)> {
|
||||
let pkg_file = self.base_path().join(self.file_name());
|
||||
let files = list_tar_file(&pkg_file).unwrap_or_default();
|
||||
let files = self.file_list();
|
||||
files
|
||||
.into_iter()
|
||||
.filter(|x| {
|
||||
|
@ -237,12 +240,10 @@ impl Package {
|
|||
|
||||
fn base_path(&self) -> PathBuf {
|
||||
// <repo>/<arch>/<pkg>/
|
||||
let p = Path::new("./data")
|
||||
Path::new("./data")
|
||||
.join(&self.repo)
|
||||
.join(self.arch.to_string())
|
||||
.join(&self.name);
|
||||
std::fs::create_dir_all(&p).unwrap();
|
||||
p
|
||||
.join(&self.name)
|
||||
}
|
||||
|
||||
/// Switch the `Architecture` of the package
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue