summaryrefslogtreecommitdiff
path: root/src/pkgtoolkit/pkgtools.rs
diff options
context:
space:
mode:
authorNamilskyy <alive6863@gmail.com>2025-11-30 16:26:39 +0300
committerNamilskyy <alive6863@gmail.com>2025-11-30 16:31:25 +0300
commit4bf685f951217b0b5b4df067b8dfeec8bae01357 (patch)
tree7e0065d13a3eb88b783e9468e785856784d8734e /src/pkgtoolkit/pkgtools.rs
parentf756b0d1c97193a0c1ad440977fb279c88c4e66a (diff)
Major updates in network sector, implemented package fetch by index, some fixes in pkgtoolkit
Diffstat (limited to 'src/pkgtoolkit/pkgtools.rs')
-rw-r--r--src/pkgtoolkit/pkgtools.rs38
1 files changed, 23 insertions, 15 deletions
diff --git a/src/pkgtoolkit/pkgtools.rs b/src/pkgtoolkit/pkgtools.rs
index 6c37595..8198624 100644
--- a/src/pkgtoolkit/pkgtools.rs
+++ b/src/pkgtoolkit/pkgtools.rs
@@ -8,6 +8,7 @@ use std::{
path::Path,
process::Command,
str,
+ collections::HashMap
};
// use emissary_core::i2np::tunnel::build;
@@ -28,16 +29,16 @@ pub enum Archs {
#[derive(Serialize, Debug, Deserialize, Clone)]
pub struct Package {
- name: String,
- version: String,
- arch: Archs,
- descr: Option<String>,
+ pub name: String,
+ pub version: String,
+ pub arch: Archs,
+ pub descr: Option<String>,
+ pub license: Option<String>,
+ pub url: String,
}
-#[allow(dead_code)]
#[derive(Deserialize, Debug, Clone)]
-struct Install {
- package: Package,
+pub struct Install_meta {
path: String,
user: String,
group: String,
@@ -47,6 +48,13 @@ struct Install {
}
#[allow(dead_code)]
+#[derive(Deserialize, Debug, Clone)]
+struct Install {
+ package: Package,
+ install: Install_meta,
+}
+
+#[allow(dead_code)]
#[derive(Deserialize, Debug)]
struct Setts {
env: Option<String>, // Export environment variables if this needed
@@ -162,7 +170,7 @@ impl Package {
/// # Returns
/// * `Ok(())` if the archive is successfully unpacked.
/// * `Err(std::io::Error)` if there's an issue opening, reading, or unpacking the archive.
- fn extract_archive(path_to_archive: &str) -> Result<(), std::io::Error> {
+ pub fn extract_archive(path_to_archive: &str) -> Result<(), std::io::Error> {
let config = Config::parse().unwrap();
create_dir_all(&config.paths.cache_dir)?;
@@ -260,7 +268,7 @@ impl Package {
}
// Log if custom script is present
- if let Some(ref _script) = install_meta.custom_script {
+ if let Some(ref _script) = install_meta.install.custom_script {
println!(
"Custom script found for package: {}",
install_meta.package.name
@@ -396,11 +404,11 @@ impl Package {
match strategy {
Strategies::BIN => {
- if install_meta.custom_script.is_none() {
+ if install_meta.install.custom_script.is_none() {
log::info!("Strategy: BIN; No custom script. Running default install hook.");
} else {
log::info!("Strategy: BIN; Running custom script.");
- let script = install_meta.custom_script.as_ref().unwrap();
+ let script = install_meta.install.custom_script.as_ref().unwrap();
if !script.starts_with("./") {
let _output = std::process::Command::new(format!("{}", script));
} else {
@@ -471,7 +479,7 @@ impl Package {
"No BUILD file or it's empty. Treating as binary package. Installing via INSTALL config or custom script."
);
// Установка бинарного пакета
- if let Some(ref script) = install_meta.custom_script {
+ if let Some(ref script) = install_meta.install.custom_script {
log::info!(
"Executing custom install script for {}",
install_meta.package.name
@@ -505,7 +513,7 @@ impl Package {
let build_dir = Path::new(&config.paths.cache_dir)
.join(format!("{}-{}", self.name, self.version));
let src_path = build_dir.join(source_file_name);
- let dest_path = Path::new(&install_meta.path);
+ let dest_path = Path::new(&install_meta.install.path);
// Убедимся, что целевая директория существует
if let Some(parent) = dest_path.parent() {
@@ -524,7 +532,7 @@ impl Package {
)
})?;
- let mode = u32::from_str_radix(&install_meta.mode, 8).map_err(|_| {
+ let mode = u32::from_str_radix(&install_meta.install.mode, 8).map_err(|_| {
std::io::Error::new(
std::io::ErrorKind::InvalidData,
"Invalid mode string in INSTALL",
@@ -539,7 +547,7 @@ impl Package {
})?;
let output = Command::new("chown")
- .arg(&format!("{}:{}", install_meta.user, install_meta.group))
+ .arg(&format!("{}:{}", install_meta.install.user, install_meta.install.group))
.arg(dest_path)
.output()
.map_err(|e| {