Initial commit
This commit is contained in:
commit
f706e8612f
9 changed files with 1689 additions and 0 deletions
BIN
..gitignore.un~
Normal file
BIN
..gitignore.un~
Normal file
Binary file not shown.
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
/target
|
||||||
|
**/*.rs.bk
|
||||||
|
/REPO_TESTS
|
||||||
|
i
|
2
.gitignore~
Normal file
2
.gitignore~
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/target
|
||||||
|
**/*.rs.bk
|
1577
Cargo.lock
generated
Normal file
1577
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
12
Cargo.toml
Normal file
12
Cargo.toml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
[package]
|
||||||
|
name = "i"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["Skye Bleed <skyebleed@mailfence.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
reqwest = "0.9.20"
|
||||||
|
flate2 = "1.0.11"
|
||||||
|
tar = "0.4.26"
|
15
README.md
Normal file
15
README.md
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# The Imperfect Package Manager
|
||||||
|
Extremely in progress
|
||||||
|
|
||||||
|
### Disclaimer
|
||||||
|
This has hardly been worked on and is essentially useless at its current state. Please don't use this unless you plan on developing it.
|
||||||
|
|
||||||
|
### TODO
|
||||||
|
[ ] Parse cmdline options well, including parsing the package name from the package repo
|
||||||
|
[ ] Make a KO
|
||||||
|
[ ] Correctly download from several repos
|
||||||
|
[ ] Unpack tarballs of various types
|
||||||
|
[ ] More, probably
|
||||||
|
|
||||||
|
### Building
|
||||||
|
This project is made in the rust programming language, so a simple `cargo run` will suffice to build the binary. In addition, you may wish to run `scripts/setup.sh` to configure your environment.
|
21
scripts/setup.sh
Executable file
21
scripts/setup.sh
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ ! -d "/imperfect" ]; then
|
||||||
|
printf "Creating /imperfect/\n"
|
||||||
|
sudo mkdir /imperfect
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "/imperfect/repo" ]; then
|
||||||
|
printf "Creating /imperfect/repo\n"
|
||||||
|
sudo mkdir /imperfect/repo
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "/imperfect/etc" ]; then
|
||||||
|
printf "Creating /imperfect/etc/\n"
|
||||||
|
sudo mkdir /imperfect/etc
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "/imperfect/containers" ]; then
|
||||||
|
printf "Creating /imperfect/containers/\n"
|
||||||
|
sudo mkdir /imperfect/containers
|
||||||
|
fi
|
36
src/main.rs
Normal file
36
src/main.rs
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
extern crate flate2;
|
||||||
|
extern crate tar;
|
||||||
|
|
||||||
|
use flate2::read::GzDecoder;
|
||||||
|
use tar::Archive;
|
||||||
|
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::prelude::*;
|
||||||
|
|
||||||
|
use reqwest::Client;
|
||||||
|
use reqwest::header::ETAG;
|
||||||
|
|
||||||
|
fn main() -> Result<(), std::io::Error> {
|
||||||
|
let client = Client::new();
|
||||||
|
|
||||||
|
let mut resp = client.get("http://mirrors.advancedhosters.com/archlinux/core/os/x86_64/bash-5.0.009-1-x86_64.pkg.tar.xz")
|
||||||
|
.send().expect("Failed to make request");
|
||||||
|
|
||||||
|
if resp.status().is_success() {
|
||||||
|
if let Some(etag) = resp.headers().get(ETAG) {
|
||||||
|
std::fs::write("etag", etag.as_bytes()).expect("Failed to write ETAG...");
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut file = File::create("/imperfect/repo/arch/tarballs/bash.pkg.tar.xz").expect("file creation failed");
|
||||||
|
resp.copy_to(&mut file).expect("failed to write file");
|
||||||
|
}
|
||||||
|
|
||||||
|
let path = "/imperfect/pkgs/tarballs/bash.pkg.tar.xz";
|
||||||
|
|
||||||
|
let tar_gz = File::open(path).expect("Failed to open tar file...");
|
||||||
|
let tar = GzDecoder::new(tar_gz);
|
||||||
|
let mut archive = Archive::new(tar);
|
||||||
|
archive.unpack("/imperfect/pkgs/tarball").expect("Could not unpack tarball");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
22
src/old_main.rs
Normal file
22
src/old_main.rs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
extern crate curl;
|
||||||
|
|
||||||
|
use curl::easy::Easy;
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::prelude::*;
|
||||||
|
|
||||||
|
// Capture output into a local `Vec`.
|
||||||
|
fn main() {
|
||||||
|
let mut dst = Vec::new();
|
||||||
|
let mut easy = Easy::new();
|
||||||
|
easy.url("http://mirrors.advancedhosters.com/archlinux/core/os/x86_64/bash-5.0.009-1-x86_64.pkg.tar.xz").unwrap();
|
||||||
|
|
||||||
|
let mut transfer = easy.transfer();
|
||||||
|
transfer.write_function(|data| {
|
||||||
|
dst.extend_from_slice(data);
|
||||||
|
Ok(data.len())
|
||||||
|
}).unwrap();
|
||||||
|
transfer.perform().unwrap();
|
||||||
|
|
||||||
|
let mut file = std::fs::File::create("./bash.pkg.tar.xz").expect("file creation failed");
|
||||||
|
file.write_all(&dst).expect("failed to write file");
|
||||||
|
}
|
Loading…
Reference in a new issue