Experimental static Docker image [CI SKIP]
This commit is contained in:
parent
e1282dacb0
commit
849caf74ef
14 changed files with 214 additions and 85 deletions
|
|
@ -1,3 +1,7 @@
|
|||
// This needs to be explicitely included before diesel is imported to make sure
|
||||
// compilation succeeds
|
||||
extern crate openssl;
|
||||
|
||||
#[macro_use]
|
||||
extern crate rocket;
|
||||
|
||||
|
|
@ -33,5 +37,6 @@ fn rocket() -> _ {
|
|||
"Run database migrations",
|
||||
run_db_migrations,
|
||||
))
|
||||
.mount("/", routes::routes())
|
||||
.mount("/pkgs", routes::pkgs::routes())
|
||||
// .attach(routes::all())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1 @@
|
|||
use rocket::Route;
|
||||
use libhilde::packages::generate_release_file;
|
||||
use crate::HildeDbConn;
|
||||
|
||||
pub fn routes() -> Vec<Route> {
|
||||
routes![get_dist_release]
|
||||
}
|
||||
|
||||
// NOTE: for now, only dists without slashes are supported
|
||||
#[get("/dists/<dist>/Release")]
|
||||
async fn get_dist_release(conn: HildeDbConn, dist: String) -> String {
|
||||
conn.run(|c| generate_release_file(dist, c)).await
|
||||
}
|
||||
pub mod pkgs;
|
||||
|
|
|
|||
27
src/hilde/routes/pkgs/mod.rs
Normal file
27
src/hilde/routes/pkgs/mod.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
use rocket::{
|
||||
Route,
|
||||
fs::TempFile,
|
||||
serde::json::Json
|
||||
};
|
||||
|
||||
pub fn routes() -> Vec<Route> {
|
||||
routes![get_package_info, upload_package_version]
|
||||
}
|
||||
|
||||
// #[get("/<pkg>")]
|
||||
// async fn get_package_versions(pkg: String) -> Json<Vec<String>> {
|
||||
// Json(vec![])
|
||||
// }
|
||||
|
||||
/// Returns the stored metadata for the given package version.
|
||||
#[get("/<pkg>/<version>")]
|
||||
fn get_package_info(pkg: String, version: String) {
|
||||
|
||||
}
|
||||
|
||||
/// Upload a package version to the server.
|
||||
#[put("/<pkg>/<version>", data="<file>")]
|
||||
async fn upload_package_version(mut file: TempFile<'_>, pkg: String, version: String) {
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
#[macro_use]
|
||||
extern crate diesel;
|
||||
// Not sure if this is needed here
|
||||
// extern crate openssl;
|
||||
#[macro_use] extern crate diesel;
|
||||
|
||||
pub mod packages;
|
||||
pub mod schema;
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
use diesel::{PgConnection, Queryable, QueryDsl, ExpressionMethods, RunQueryDsl};
|
||||
use crate::schema::distributions::dsl::*;
|
||||
|
||||
#[derive(Queryable)]
|
||||
struct Distribution {
|
||||
id: uuid::Uuid,
|
||||
name: String,
|
||||
description: Option<String>,
|
||||
origin: Option<String>,
|
||||
label: Option<String>,
|
||||
version: Option<String>,
|
||||
suite: Option<String>,
|
||||
codename: Option<String>
|
||||
}
|
||||
|
||||
/// Generate a Release file for a given distribution
|
||||
pub fn generate_release_file(dist: String, conn: &PgConnection) -> String {
|
||||
let results = distributions.filter(name.eq(dist)).load::<Distribution>(conn).unwrap();
|
||||
|
||||
format!("{}", results.len())
|
||||
}
|
||||
3
src/libhilde/pkgs/deb.rs
Normal file
3
src/libhilde/pkgs/deb.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
use std::fs::PathBuf;
|
||||
|
||||
pub fn extract_control(path: PathBuf) ->
|
||||
0
src/libhilde/pkgs/mod.rs
Normal file
0
src/libhilde/pkgs/mod.rs
Normal file
|
|
@ -1,12 +0,0 @@
|
|||
table! {
|
||||
distributions (id) {
|
||||
id -> Uuid,
|
||||
name -> Text,
|
||||
description -> Nullable<Text>,
|
||||
origin -> Nullable<Text>,
|
||||
label -> Nullable<Text>,
|
||||
version -> Nullable<Text>,
|
||||
suite -> Nullable<Text>,
|
||||
codename -> Nullable<Text>,
|
||||
}
|
||||
}
|
||||
Reference in a new issue