I screwed up the git oops
commit
68337b9011
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,21 @@
|
||||
cargo-features = ["strip"]
|
||||
[package]
|
||||
name = "gaybsd_package_manager"
|
||||
description = "GayBSD Package Manager"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
meowhash = "0.3.0"
|
||||
clap = { version = "3.0.14", features = ["derive"] }
|
||||
reqwest = "0.11.9"
|
||||
sled = "0.34.7"
|
||||
toml = "0.5.8"
|
||||
serde_derive = "1.0.136"
|
||||
serde = "1.0.136"
|
||||
[profile.release]
|
||||
strip = true
|
||||
opt-level = "z"
|
||||
lto = true
|
@ -0,0 +1,17 @@
|
||||
mf-version = 100
|
||||
name = "example-package"
|
||||
version = 100
|
||||
key = ""
|
||||
[files]
|
||||
"/opt/etc" = { match = "etc/*", tracked = false }
|
||||
"/opt/etc/enby/manuals" = "manual.gmi"
|
||||
"/opt/bin" = { file = "example-package.x86-64.elf", name = "example-package"}
|
||||
[locale.en_US]
|
||||
name = "Example Package"
|
||||
description = "Example Package for testing GayPackage format."
|
||||
[locale.tp_XW]
|
||||
name = ""
|
||||
description = ""
|
||||
|
||||
|
||||
|
Binary file not shown.
@ -0,0 +1 @@
|
||||
Hello world!
|
@ -0,0 +1,2 @@
|
||||
example package literally runs a hello world and that's all it does
|
||||
how am i supposed to write a manual for that?
|
@ -0,0 +1,52 @@
|
||||
mod download;
|
||||
mod query;
|
||||
mod list;
|
||||
mod remove;
|
||||
mod repository;
|
||||
mod install;
|
||||
mod package;
|
||||
|
||||
use meowhash::*;
|
||||
use reqwest::*;
|
||||
use sled::*;
|
||||
use clap::*;
|
||||
|
||||
fn main() {
|
||||
let operation = std::env::args().nth(1).expect("too few arguments!");
|
||||
let args: String = std::env::args().collect();
|
||||
match operation.as_str() {
|
||||
"upgrade" | "u" => {
|
||||
|
||||
}
|
||||
"install" | "i" => {
|
||||
if std::env::args().nth(2).expect("too few arguments!") == "--local" {
|
||||
|
||||
} else {
|
||||
let package_name = std::env::args().nth(2).expect("too few arguments!");
|
||||
println!("Reading package list");
|
||||
let package_list = sled::open("/var/gaypack/packages").expect("Failed to open package list");
|
||||
if package_list.contains_key(package_name).expect("Unexpected error") {
|
||||
println!("Package was found in package list, checking for updates");
|
||||
}
|
||||
}
|
||||
}
|
||||
"remove" | "r" => {
|
||||
|
||||
}
|
||||
"list" | "l" => {
|
||||
|
||||
}
|
||||
"query" | "q" => {
|
||||
|
||||
}
|
||||
"repository" | "repo" => {
|
||||
|
||||
}
|
||||
_ => {
|
||||
panic!("Unknown operation: {}", operation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
use toml::value::Table;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
/// Represents a Package.toml file.
|
||||
pub struct PackageData {
|
||||
manifest_verison: u64,
|
||||
name: String,
|
||||
version: u64,
|
||||
key: String,
|
||||
files: Table,
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
use std::error::Error;
|
||||
use std::fs::{File, OpenOptions};
|
||||
use std::io::BufRead;
|
||||
use std::path::Path;
|
||||
use reqwest::StatusCode;
|
||||
use toml::toml;
|
||||
|
||||
pub async fn find_package_in_repositories(package: String, installed: Option<u64>) -> Vec<String> {
|
||||
let mut hits: Vec<String> = vec!();
|
||||
let client = reqwest::Client::new();
|
||||
let repo_file = File::open("/var/gaypack/repositories.list").expect("Failed to open repository list");
|
||||
for repository in std::io::BufReader::new(repo_file).lines() {
|
||||
let repository = repository.expect("Unexpected error"); // i find this line kinda funny for some reason
|
||||
let resp = client.get(format!("{}/gaypack/{}/latest/Package.toml", repository, package)).send().await.unwrap();
|
||||
if installed.is_some() {
|
||||
let package_data: crate::package::PackageData = toml::from_str(resp.text().await.expect("Failed to read text").as_str()).expect("Failed to parse toml");
|
||||
}
|
||||
if resp.status() == StatusCode::from_u16(200).unwrap() {
|
||||
hits.push(repository);
|
||||
}
|
||||
};
|
||||
return hits;
|
||||
}
|
Loading…
Reference in New Issue