Skip to content

Commit

Permalink
feat: Add Crunchbang++
Browse files Browse the repository at this point in the history
  • Loading branch information
lj3954 authored and flexiondotorg committed Jul 4, 2024
1 parent 65922eb commit 5917284
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ mod independent;
mod ubuntu;

pub(crate) use arch::{manjaro::BigLinux, ArchLinux, Archcraft, ArcoLinux, ArtixLinux, AthenaOS, BlendOS, CachyOS};
pub(crate) use debian::{Antix, BunsenLabs};
pub(crate) use debian::{Antix, BunsenLabs, CrunchbangPlusPlus};
pub(crate) use fedora_redhat::{Alma, Bazzite, CentOSStream};
pub(crate) use independent::{Alpine, Batocera, ChimeraLinux, NixOS};
pub(crate) use ubuntu::{Bodhi, Edubuntu, Elementary, Kubuntu, Lubuntu, Ubuntu, UbuntuBudgie, UbuntuCinnamon, UbuntuKylin, UbuntuMATE, UbuntuServer, UbuntuStudio, UbuntuUnity, Xubuntu};
2 changes: 1 addition & 1 deletion src/linux/arch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl Distro for ArcoLinux {
let checksums = ChecksumSeparation::CustomRegex(checksum_regex.clone(), 2, 1);
async move {
let page = capture_page(&mirror).await?;
let checksums = checksums.build_with_data(&page).await;
let checksums = checksums.build_with_data(&page);

let futures = iso_regex
.captures_iter(&page)
Expand Down
40 changes: 38 additions & 2 deletions src/linux/debian.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::{
store_data::{ChecksumSeparation, Config, Distro, Source, WebSource},
utils::capture_page,
utils::{capture_page, GatherData, GithubAPI},
};
use regex::Regex;
use std::{collections::HashMap, sync::Arc};
Expand Down Expand Up @@ -39,7 +39,7 @@ impl Distro for Antix {
let main_checksums = capture_page(&checksum_mirror).await.map(skip_until_sha256).unwrap_or_default();
let runit_checksums = capture_page(&runit_checksum_mirror).await.map(skip_until_sha256);
let checksums = main_checksums + "\n" + &runit_checksums.unwrap_or_default();
let mut checksums = ChecksumSeparation::Whitespace.build_with_data(&checksums).await;
let mut checksums = ChecksumSeparation::Whitespace.build_with_data(&checksums);

let page = capture_page(&mirror).await?;
let iso_regex = iso_regex.clone();
Expand Down Expand Up @@ -119,3 +119,39 @@ impl Distro for BunsenLabs {
.into()
}
}

const CRUNCHBANG_API: &str = "https://api.github.com/repos/CBPP/cbpp/releases";

pub struct CrunchbangPlusPlus;
impl Distro for CrunchbangPlusPlus {
const NAME: &'static str = "crunchbang++";
const PRETTY_NAME: &'static str = "Crunchbangplusplus";
const HOMEPAGE: Option<&'static str> = Some("https://crunchbangplusplus.org/");
const DESCRIPTION: Option<&'static str> = Some("The classic minimal crunchbang feel, now with debian 12 bookworm.");
async fn generate_configs() -> Option<Vec<Config>> {
let mut api_data = GithubAPI::gather_data(CRUNCHBANG_API).await?;
api_data.retain(|v| !v.prerelease);
api_data
.into_iter()
.take(3)
.filter_map(|value| {
let release = value.tag_name;
let iso = value.assets.into_iter().find(|a| a.name.contains("amd64"))?;
let url = iso.browser_download_url;
let checksum_data = value
.body
.lines()
.skip_while(|l| !l.contains("md5sum"))
.collect::<Vec<&str>>()
.join("\n");
let checksum = ChecksumSeparation::Whitespace.build_with_data(&checksum_data).remove(&iso.name);
Some(Config {
release: Some(release),
iso: Some(vec![Source::Web(WebSource::new(url, checksum, None, None))]),
..Default::default()
})
})
.collect::<Vec<Config>>()
.into()
}
}
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ async fn main() {
spawn(linux::CachyOS.to_os()),
spawn(linux::CentOSStream.to_os()),
spawn(linux::ChimeraLinux.to_os()),
spawn(linux::CrunchbangPlusPlus.to_os()),
];

let distros = futures::future::join_all(futures)
Expand Down
4 changes: 2 additions & 2 deletions src/store_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ pub enum ChecksumSeparation {
impl ChecksumSeparation {
pub async fn build(self, url: &str) -> Option<HashMap<String, String>> {
let data = crate::utils::capture_page(url).await?;
Some(self.build_with_data(&data).await)
Some(self.build_with_data(&data))
}
pub async fn build_with_data(self, data: &str) -> HashMap<String, String> {
pub fn build_with_data(self, data: &str) -> HashMap<String, String> {
match self {
Self::Whitespace => data
.lines()
Expand Down
1 change: 1 addition & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ pub struct GithubAPIValue {
pub tag_name: String,
pub assets: Vec<GithubAsset>,
pub prerelease: bool,
pub body: String,
}
#[derive(Deserialize)]
pub struct GithubAsset {
Expand Down

0 comments on commit 5917284

Please sign in to comment.