diff --git a/.woodpecker/build.yml b/.woodpecker/build.yml index 7b4c3bc..3ea4b09 100644 --- a/.woodpecker/build.yml +++ b/.woodpecker/build.yml @@ -13,3 +13,4 @@ steps: username: jmarya password: from_secret: registry_token + diff --git a/src/pkg.rs b/src/pkg.rs index 57649e4..1af5e49 100644 --- a/src/pkg.rs +++ b/src/pkg.rs @@ -35,6 +35,20 @@ impl Repository { } } + pub fn arch(&self) -> Vec { + let dir_path = PathBuf::from("./data").join(&self.name); + let mut arch = vec![]; + + if let Ok(entries) = std::fs::read_dir(dir_path) { + for entry in entries.filter_map(Result::ok) { + let file_name = entry.file_name().into_string().unwrap_or_default(); + arch.push(file_name); + } + } + + arch + } + pub fn base_path(&self, arch: &str) -> PathBuf { PathBuf::from("./data").join(&self.name).join(arch) } @@ -143,6 +157,27 @@ impl Package { db_file.to_str().unwrap(), pkg_file.to_str().unwrap(), ]); + + if &self.arch == "any" { + let archs = Repository::new(&self.repo).unwrap().arch(); + + for arch in archs { + if arch == "any" { + continue; + } + + let db_file = PathBuf::from("./data") + .join(&self.repo) + .join(&arch) + .join(format!("{}.db.tar.gz", self.repo)); + + run_command(vec![ + "repo-add", + db_file.to_str().unwrap(), + pkg_file.to_str().unwrap(), + ]); + } + } } fn base_path(&self) -> PathBuf {