Added modules to extend
This commit is contained in:
parent
5b6a5caf5e
commit
91660d8226
5 changed files with 127 additions and 58 deletions
51
Cargo.lock
generated
51
Cargo.lock
generated
|
@ -427,6 +427,14 @@ name = "httparse"
|
|||
version = "1.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "humantime"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.12.33"
|
||||
|
@ -526,6 +534,14 @@ name = "libc"
|
|||
version = "0.2.62"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "line-wrap"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"safemem 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
version = "0.1.5"
|
||||
|
@ -734,6 +750,7 @@ dependencies = [
|
|||
name = "pack"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"plist 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"reqwest 0.9.20 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"smush 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
@ -774,6 +791,19 @@ name = "pkg-config"
|
|||
version = "0.3.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "plist"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"indexmap 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"line-wrap 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"serde 1.0.99 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.5"
|
||||
|
@ -815,6 +845,11 @@ dependencies = [
|
|||
"bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quick-error"
|
||||
version = "1.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "0.6.13"
|
||||
|
@ -1086,6 +1121,11 @@ name = "ryu"
|
|||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "safemem"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "same-file"
|
||||
version = "1.0.5"
|
||||
|
@ -1595,6 +1635,11 @@ dependencies = [
|
|||
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "xml-rs"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "xz2"
|
||||
version = "0.1.6"
|
||||
|
@ -1684,6 +1729,7 @@ dependencies = [
|
|||
"checksum http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)" = "372bcb56f939e449117fb0869c2e8fd8753a8223d92a172c6e808cf123a5b6e4"
|
||||
"checksum http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d"
|
||||
"checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9"
|
||||
"checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f"
|
||||
"checksum hyper 0.12.33 (registry+https://github.com/rust-lang/crates.io-index)" = "7cb44cbce9d8ee4fb36e4c0ad7b794ac44ebaad924b9c8291a63215bb44c2c8f"
|
||||
"checksum hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f"
|
||||
"checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e"
|
||||
|
@ -1694,6 +1740,7 @@ dependencies = [
|
|||
"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
|
||||
"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
"checksum libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)" = "34fcd2c08d2f832f376f4173a231990fa5aef4e99fb569867318a227ef4c06ba"
|
||||
"checksum line-wrap 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f30344350a2a51da54c1d53be93fade8a237e545dbcc4bdbe635413f2117cab9"
|
||||
"checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c"
|
||||
"checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7"
|
||||
"checksum lz4 1.23.1 (registry+https://github.com/rust-lang/crates.io-index)" = "43c94a9f09a60017f373020cc93d4291db4cd92b0db64ff25927f27d09dc23d5"
|
||||
|
@ -1721,11 +1768,13 @@ dependencies = [
|
|||
"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
|
||||
"checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
|
||||
"checksum pkg-config 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "a7c1d2cfa5a714db3b5f24f0915e74fcdf91d09d496ba61329705dda7774d2af"
|
||||
"checksum plist 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31850d149352e2b75f0e4b206045ee3775076c422892328343beca48a2b5cf17"
|
||||
"checksum ppv-lite86 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e3cbf9f658cdb5000fcf6f362b8ea2ba154b9f146a61c7a20d647034c6b6561b"
|
||||
"checksum proc-macro2 0.4.30 (registry+https://github.com/rust-lang/crates.io-index)" = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759"
|
||||
"checksum proc-macro2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4c5c2380ae88876faae57698be9e9775e3544decad214599c3a6266cca6ac802"
|
||||
"checksum publicsuffix 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9bf259a81de2b2eb9850ec990ec78e6a25319715584fd7652b9b26f96fcb1510"
|
||||
"checksum pulldown-cmark 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "eef52fac62d0ea7b9b4dc7da092aa64ea7ec3d90af6679422d3d7e0e14b6ee15"
|
||||
"checksum quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9274b940887ce9addde99c4eee6b5c44cc494b182b97e73dc8ffdcb3397fd3f0"
|
||||
"checksum quote 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1"
|
||||
"checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe"
|
||||
"checksum rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
|
||||
|
@ -1754,6 +1803,7 @@ dependencies = [
|
|||
"checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783"
|
||||
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
|
||||
"checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997"
|
||||
"checksum safemem 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d2b08423011dae9a5ca23f07cf57dac3857f5c885d352b76f6d95f4aea9434d0"
|
||||
"checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421"
|
||||
"checksum schannel 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "f2f6abf258d99c3c1c5c2131d99d064e94b7b3dd5f416483057f308fea253339"
|
||||
"checksum scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "94258f53601af11e6a49f722422f6e3425c52b06245a5cf9bc09908b174f5e27"
|
||||
|
@ -1812,6 +1862,7 @@ dependencies = [
|
|||
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
"checksum winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9"
|
||||
"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e"
|
||||
"checksum xml-rs 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "541b12c998c5b56aa2b4e6f18f03664eef9a4fd0a246a55594efae6cc2d964b5"
|
||||
"checksum xz2 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c179869f34fc7c01830d3ce7ea2086bc3a07e0d35289b667d0a8bf910258926c"
|
||||
"checksum zstd 0.4.28+zstd.1.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "f4e716acaad66f2daf2526f37a1321674a8814c0b37a366ebe6c97a699f85ddc"
|
||||
"checksum zstd-safe 1.4.13+zstd.1.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bfe4d3b26a0790201848865663e8ffabf091e126e548bc9710ccfa95621ece48"
|
||||
|
|
|
@ -9,3 +9,4 @@ edition = "2018"
|
|||
[dependencies]
|
||||
reqwest = "0.9.20"
|
||||
smush = "0.1.4"
|
||||
plist = "0.5"
|
||||
|
|
65
src/arch/mod.rs
Normal file
65
src/arch/mod.rs
Normal file
|
@ -0,0 +1,65 @@
|
|||
use std::fs::File;
|
||||
use std::process::Command;
|
||||
|
||||
use reqwest::Client;
|
||||
|
||||
use crate::err_and_exit;
|
||||
|
||||
pub fn get_arch_pkg(repo: &str, pkgname: &str, vec: Vec<&str>, client: Client) {
|
||||
print!("[PACK]: Making request...");
|
||||
let url = reqwest::Url::parse(&(repo.to_string() + pkgname)).expect("Failed to parse URL");
|
||||
let mut resp = match client.get(url).send() {
|
||||
Ok(a) => a,
|
||||
Err(e) => {
|
||||
println!("ERROR!: Couldn't get package from url. Are you connected to the internet?\n\n{}", e);
|
||||
std::process::exit(0);
|
||||
},
|
||||
};
|
||||
|
||||
if resp.status().is_success() {
|
||||
println!("OK");
|
||||
|
||||
let mut file = match File::create(format!("/usr/pack/repo/{}/tarballs/{}", vec[1], pkgname)) {
|
||||
Ok(res) => res,
|
||||
Err(e) => {
|
||||
println!("Failed to create file...did you setup you environment? Do you have permission to create files?\n\n{}", e);
|
||||
std::process::exit(0);
|
||||
},
|
||||
};
|
||||
|
||||
resp.copy_to(&mut file).expect("failed to write file");
|
||||
} else {
|
||||
err_and_exit(format!("Request was unsuccessful...did you request from the correct repo?\nStatus is: \"{}\"", resp.status()), 0)
|
||||
}
|
||||
|
||||
let spltdirname: Vec<&str> = pkgname.split(".").collect();
|
||||
let dirname = spltdirname[0];
|
||||
|
||||
print!("[PACK]: Creating package dir...");
|
||||
match std::fs::create_dir(format!("/usr/pack/repo/{}/{}", vec[1], dirname)) {
|
||||
Ok(_) => (),
|
||||
Err(e) => err_and_exit(format!("Failed to create directory! Remove the directory if it already exists. Got error \"{}\"", e), 0),
|
||||
}
|
||||
println!("OK");
|
||||
|
||||
print!("[PACK]: Executing tar...");
|
||||
Command::new("tar")
|
||||
.arg(format!("-C/usr/pack/repo/{}/{}", vec[1], dirname))
|
||||
.arg("-xf")
|
||||
.arg(format!("/usr/pack/repo/{}/tarballs/{}", vec[1], pkgname))
|
||||
.output()
|
||||
.expect("Failed to execute tar");
|
||||
println!("OK");
|
||||
|
||||
let paths = std::fs::read_dir(format!("/usr/pack/repo/{}/{}/usr/bin/", vec[1], dirname)).expect("Failed to read dir...");
|
||||
println!("[PACK]: Creating symlinks");
|
||||
for file in paths {
|
||||
let pth = &file.expect("Failed to read file").path();
|
||||
let strpth = pth.to_str().expect("Failed to convert to str...");
|
||||
println!("\tAdding file {} to /usr/pack/bin/", strpth);
|
||||
|
||||
let a: Vec<&str> = strpth.split("/").collect();
|
||||
let name = a[a.len() - 1];
|
||||
std::os::unix::fs::symlink(pth, format!("/usr/pack/bin/{}", name)).expect("Failed to symlink...");
|
||||
}
|
||||
}
|
61
src/main.rs
61
src/main.rs
|
@ -1,10 +1,10 @@
|
|||
use std::fs::File;
|
||||
use std::path::Path;
|
||||
use std::result::Result;
|
||||
use std::process::Command;
|
||||
use std::path::Path;
|
||||
|
||||
use reqwest::Client;
|
||||
|
||||
mod arch;
|
||||
|
||||
fn err_and_exit(msg: String, code: i32) {
|
||||
println!("ERROR!: {}", msg);
|
||||
std::process::exit(code);
|
||||
|
@ -37,65 +37,14 @@ fn main() -> Result<(), std::io::Error> {
|
|||
"arch_core" => "http://mirrors.advancedhosters.com/archlinux/core/os/x86_64/",
|
||||
"arch_extra" => "http://mirrors.advancedhosters.com/archlinux/extra/os/x86_64/",
|
||||
"arch_community" => "http://mirrors.advancedhosters.com/archlinux/community/os/x86_64/",
|
||||
"void" => "http://mirror.clarkson.edu/voidlinux/current/x86_64-repodata",
|
||||
_ => {
|
||||
println!("ERROR!: Repo {} is not supported...", vec[1]);
|
||||
std::process::exit(0);
|
||||
},
|
||||
};
|
||||
|
||||
print!("[PACK]: Making request...");
|
||||
let url = reqwest::Url::parse(&(repo.to_string() + pkgname)).expect("Failed to parse URL");
|
||||
let mut resp = match client.get(url).send() {
|
||||
Ok(a) => a,
|
||||
Err(e) => {
|
||||
println!("ERROR!: Couldn't get package from url. Are you connected to the internet?\n\n{}", e);
|
||||
std::process::exit(0);
|
||||
},
|
||||
};
|
||||
|
||||
if resp.status().is_success() {
|
||||
println!("OK");
|
||||
|
||||
let mut file = match File::create(format!("/usr/pack/repo/{}/tarballs/{}", vec[1], pkgname)) {
|
||||
Ok(res) => res,
|
||||
Err(e) => {
|
||||
println!("Failed to create file...did you setup you environment? Do you have permission to create files?\n\n{}", e);
|
||||
std::process::exit(0);
|
||||
},
|
||||
};
|
||||
|
||||
resp.copy_to(&mut file).expect("failed to write file");
|
||||
} else {
|
||||
err_and_exit(format!("Request was unsuccessful...did you request from the correct repo?\nStatus is: \"{}\"", resp.status()), 0)
|
||||
}
|
||||
|
||||
let spltdirname: Vec<&str> = pkgname.split(".").collect();
|
||||
let dirname = spltdirname[0];
|
||||
|
||||
print!("[PACK]: Creating package dir...");
|
||||
std::fs::create_dir(format!("/usr/pack/repo/{}/{}", vec[1], dirname)).expect("Failed to create directory");
|
||||
println!("OK");
|
||||
|
||||
print!("[PACK]: Executing tar...");
|
||||
Command::new("tar")
|
||||
.arg(format!("-C/usr/pack/repo/{}/{}", vec[1], dirname))
|
||||
.arg("-xf")
|
||||
.arg(format!("/usr/pack/repo/{}/tarballs/{}", vec[1], pkgname))
|
||||
.output()
|
||||
.expect("Failed to execute tar");
|
||||
println!("OK");
|
||||
|
||||
let paths = std::fs::read_dir(format!("/usr/pack/repo/{}/{}/usr/bin/", vec[1], dirname)).expect("Failed to read dir...");
|
||||
println!("[PACK]: Creating symlinks");
|
||||
for file in paths {
|
||||
let pth = &file.expect("Failed to read file").path();
|
||||
let strpth = pth.to_str().expect("Failed to convert to str...");
|
||||
println!("\tAdding file {} to /usr/pack/bin/", strpth);
|
||||
|
||||
let a: Vec<&str> = strpth.split("/").collect();
|
||||
let name = a[a.len() - 1];
|
||||
std::os::unix::fs::symlink(pth, format!("/usr/pack/bin/{}", name)).expect("Failed to symlink...");
|
||||
}
|
||||
arch::get_arch_pkg(repo, pkgname, vec, client);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
3
src/void/mod.rs
Normal file
3
src/void/mod.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
pub fn get_void_pkg() {
|
||||
|
||||
}
|
Loading…
Reference in a new issue