start working on unakite

axtloss/rework-partitioning
axtlos 3 years ago
parent 1b05b6d203
commit c47f47789c
No known key found for this signature in database
GPG Key ID: A468AFD71DD51D4A

60
Cargo.lock generated

@ -87,9 +87,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "clap" name = "clap"
version = "3.1.10" version = "3.1.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3124f3f75ce09e22d1410043e1e24f2ecc44fad3afe4f08408f1f7663d68da2b" checksum = "47582c09be7c8b32c0ab3a6181825ababb713fde6fff20fc573a3870dd45c6a0"
dependencies = [ dependencies = [
"atty", "atty",
"bitflags", "bitflags",
@ -117,9 +117,9 @@ dependencies = [
[[package]] [[package]]
name = "clap_lex" name = "clap_lex"
version = "0.1.1" version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "189ddd3b5d32a70b35e7686054371742a937b0d99128e76dde6340210e966669" checksum = "a37c35f1112dad5e6e0b1adaff798507497a18fceeb30cceb3bae7d1427b9213"
dependencies = [ dependencies = [
"os_str_bytes", "os_str_bytes",
] ]
@ -237,24 +237,24 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.124" version = "0.2.125"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21a41fed9d98f27ab1c6d161da622a4fa35e8a54a8adc24bbf3ddd0ef70b0e50" checksum = "5916d2ae698f6de9bfb891ad7a8d65c09d232dc58cc4ac433c7da3b2fd84bc2b"
[[package]] [[package]]
name = "log" name = "log"
version = "0.4.16" version = "0.4.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8" checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.4.1" version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
[[package]] [[package]]
name = "miniz_oxide" name = "miniz_oxide"
@ -267,9 +267,9 @@ dependencies = [
[[package]] [[package]]
name = "num_threads" name = "num_threads"
version = "0.1.5" version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aba1801fb138d8e85e11d0fc70baf4fe1cdfffda7c6cd34a854905df588e5ed0" checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44"
dependencies = [ dependencies = [
"libc", "libc",
] ]
@ -324,18 +324,18 @@ dependencies = [
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.36" version = "1.0.38"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" checksum = "9027b48e9d4c9175fa2218adf3557f91c1137021739951d4932f5f8268ac48aa"
dependencies = [ dependencies = [
"unicode-xid", "unicode-xid",
] ]
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.15" version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" checksum = "a1feb54ed693b93a84e14094943b84b7c4eae204c512b7ccb95ab0c66d278ad1"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
@ -377,18 +377,18 @@ checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.136" version = "1.0.137"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" checksum = "61ea8d54c77f8315140a05f4c7237403bf38b72704d031543aa1d16abbf517d1"
dependencies = [ dependencies = [
"serde_derive", "serde_derive",
] ]
[[package]] [[package]]
name = "serde_derive" name = "serde_derive"
version = "1.0.136" version = "1.0.137"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" checksum = "1f26faba0c3959972377d3b2d306ee9f71faee9714294e41bb777f83f88578be"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -397,9 +397,9 @@ dependencies = [
[[package]] [[package]]
name = "serde_json" name = "serde_json"
version = "1.0.78" version = "1.0.81"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d23c1ba4cf0efd44be32017709280b32d1cea5c3f1275c3b6d9e8bc54f758085" checksum = "9b7ce2b32a1aed03c558dc61a5cd328f15aff2dbc17daad8fb8af04d2100e15c"
dependencies = [ dependencies = [
"itoa", "itoa",
"ryu", "ryu",
@ -414,9 +414,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.86" version = "1.0.92"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" checksum = "7ff7c592601f11445996a06f8ad0c27f094a58857c2f89e97974ab9235b92c52"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -440,18 +440,18 @@ checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.30" version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.30" version = "1.0.31"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -487,9 +487,9 @@ dependencies = [
[[package]] [[package]]
name = "unicode-xid" name = "unicode-xid"
version = "0.2.2" version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" checksum = "957e51f3646910546462e67d5f7599b9e4fb8acdd304b087a6494730f9eebf04"
[[package]] [[package]]
name = "uuid" name = "uuid"

@ -60,6 +60,10 @@ pub enum Command {
#[clap(name = "flatpak")] #[clap(name = "flatpak")]
Flatpak, Flatpak,
/// Setup unakite
#[clap(name = "unakite")]
Unakite,
/// Read jade installation config /// Read jade installation config
#[clap(name = "config")] #[clap(name = "config")]
Config { Config {

@ -39,7 +39,7 @@ pub fn genfstab() {
} }
pub fn install_bootloader_efi(efidir: PathBuf) { pub fn install_bootloader_efi(efidir: PathBuf) {
install::install(vec!["grub", "efibootmgr", "grub-btrfs", "crystal-grub-theme"]); install::install(vec!["grub", "efibootmgr", "grub-btrfs", "crystal-grub-theme", "os-prober"]);
let efidir = std::path::Path::new("/mnt").join(efidir); let efidir = std::path::Path::new("/mnt").join(efidir);
let efi_str = efidir.to_str().unwrap(); let efi_str = efidir.to_str().unwrap();
if !std::path::Path::new(&format!("/mnt{efi_str}")).exists() { if !std::path::Path::new(&format!("/mnt{efi_str}")).exists() {
@ -82,7 +82,7 @@ pub fn install_bootloader_efi(efidir: PathBuf) {
} }
pub fn install_bootloader_legacy(device: PathBuf) { pub fn install_bootloader_legacy(device: PathBuf) {
install::install(vec!["grub", "grub-btrfs", "crystal-grub-theme"]); install::install(vec!["grub", "grub-btrfs", "crystal-grub-theme", "os-prober"]);
if !device.exists() { if !device.exists() {
crash(format!("The device {device:?} does not exist"), 1); crash(format!("The device {device:?} does not exist"), 1);
} }
@ -123,5 +123,6 @@ pub fn install_flatpak() {
install(vec!["flatpak"]); install(vec!["flatpak"]);
exec_eval( exec_eval(
exec_chroot("flatpak", vec![String::from("remote-add"), String::from("--if-not-exists"), String::from("flathub"), String::from("https://flathub.org/repo/flathub.flatpakrepo")]), exec_chroot("flatpak", vec![String::from("remote-add"), String::from("--if-not-exists"), String::from("flathub"), String::from("https://flathub.org/repo/flathub.flatpakrepo")]),
"add flathub remote",
) )
} }

@ -4,3 +4,4 @@ pub mod locale;
pub mod network; pub mod network;
pub mod partition; pub mod partition;
pub mod users; pub mod users;
pub mod unakite;

@ -7,8 +7,8 @@ use std::path::{Path, PathBuf};
/*mkfs.bfs mkfs.cramfs mkfs.ext3 mkfs.fat mkfs.msdos mkfs.xfs /*mkfs.bfs mkfs.cramfs mkfs.ext3 mkfs.fat mkfs.msdos mkfs.xfs
mkfs.btrfs mkfs.ext2 mkfs.ext4 mkfs.minix mkfs.vfat */ mkfs.btrfs mkfs.ext2 mkfs.ext4 mkfs.minix mkfs.vfat */
pub fn fmt_mount(mountpoint: &String, filesystem: &String, blockdevice: &String) { pub fn fmt_mount(mountpoint: &str, filesystem: &str, blockdevice: &str) {
match filesystem.as_str() { match filesystem {
"vfat" => { "vfat" => {
exec_eval( exec_eval(
exec( exec(
@ -155,7 +155,7 @@ pub fn fmt_mount(mountpoint: &String, filesystem: &String, blockdevice: &String)
), ),
format!("Creating mountpoint {mountpoint} for {blockdevice}").as_str(), format!("Creating mountpoint {mountpoint} for {blockdevice}").as_str(),
); );
mount(&blockdevice, &mountpoint, ""); mount(blockdevice, mountpoint, "");
} }
pub fn partition(device: PathBuf, mode: PartitionMode, efi: bool, partitions: &mut Vec<args::Partition>) { pub fn partition(device: PathBuf, mode: PartitionMode, efi: bool, partitions: &mut Vec<args::Partition>) {

@ -0,0 +1,142 @@
use crate::internal::exec::*;
use crate::internal::*;
pub fn install_bootloader_efi(efidir: PathBuf) {
install::install(vec!["grub", "efibootmgr", "grub-btrfs", "crystal-grub-theme"]);
let efidir = std::path::Path::new("/mnt").join(efidir);
let efi_str = efidir.to_str().unwrap();
if !std::path::Path::new(&format!("/mnt{efi_str}")).exists() {
crash(format!("The efidir {efidir:?} doesn't exist"), 1);
}
exec_eval(
exec_chroot(
"grub-install",
vec![
String::from("--target=x86_64-efi"),
format!("--efi-directory={}" , efi_str),
String::from("--bootloader-id=unakite"),
String::from("--removable"),
],
),
"install unakite grub as efi with --removable",
);
exec_eval(
exec_chroot(
"grub-install",
vec![
String::from("--target=x86_64-efi"),
format!("--efi-directory={}", efi_str),
String::from("--bootloader-id=unakite"),
],
),
"install unakite grub as efi without --removable",
);
files_eval(
append_file("/mnt/etc/default/grub", "GRUB_THEME=\"/usr/share/grub/themes/crystal/theme.txt\""),
"enable crystal grub theme"
);
exec_eval(
exec_chroot(
"grub-mkconfig",
vec![String::from("-o"), String::from("/boot/grub/grub.cfg")],
),
"create grub.cfg",
);
}
pub fn remount(root: &str, oldroot: &stre, efi: bool, efidir: &str, bootdev: &str, firstrun: bool) {
if efi && firstrun {
exec_eval(
exec(
"umount",
vec![String::from(bootdev)],
),
format!("Unmount {}", bootdev),
)
exec_eval(
exec(
"umount",
vec![String::from("/")],
),
format!("Unmount old root"),
);
mount(root, "/");
mount(bootdev, efidir);
} else if efi && !firstrun {
exec_eval(
exec(
"umount",
vec![String::from(bootdev)],
),
format!("Unmount {}", bootdev),
)
exec_eval(
exec(
"umount",
vec![String::from("/")],
),
format!("Unmount unakite root"),
);
mount(root, "/");
mount(bootdev, efidir);
} else if !efi && firstrun {
exec_eval(
exec(
"umount",
vec![String::from(bootdev)],
),
format!("Unmount {}", bootdev),
)
exec_eval(
exec(
"umount",
vec![String::from("/")],
),
format!("Unmount old root"),
);
mount(root, "/");
mount(bootdev, "/boot");
} else if !efi && !firstrun {
exec_eval(
exec(
"umount",
vec![String::from(bootdev)],
),
format!("Unmount {}", bootdev),
);
exec_eval(
exec(
"umount",
vec![String::from("/")],
),
format!("Unmount unakite root"),
);
mount(oldroot, "/");
mount(bootdev, "/boot");
} else {
panic!("Unknown state");
}
}
pub fn setup_unakite(root: &str, oldroot: &stre, efi: bool, efidir: &str, bootdev: &str) {
log::debug!("Setting up Unakite");
remount_efi(root, oldroot, efi, efidir, bootdev, true);
base::install_base_packages();
base::genfstab();
if efi {
install_bootloader_efi(PathBuf::from(efidir));
}
locale::set_locale("");
locale::set_timezone("Europe/Berlin"); // TODO: get the proper timezone
network::set_hostname("unakite");
network::create_hosts("");
users::new_user(
"unakite",
true,
"Cp7oN04ZY0PsA", // unakite
)
users::root_pass("Cp7oN04ZY0PsA"); // unakite
desktops::install_desktop_desktup_setup(DesktopSetup::Xfce);
install(vec!["gparted", "firefox"]);
remount(root, oldroot, efi, efidir, bootdev, false);
}

@ -148,7 +148,7 @@ pub fn read_config(configpath: PathBuf) {
println!(); println!();
log::info!("Enabling flatpak : {}", config.flatpak); log::info!("Enabling flatpak : {}", config.flatpak);
if config.flatpak { if config.flatpak {
base::setup_flatpak(); base::install_flatpak();
} }
log::info!("Extra packages : {:?}", config.extra_packages); log::info!("Extra packages : {:?}", config.extra_packages);
let mut extra_packages: Vec<&str> = Vec::new(); let mut extra_packages: Vec<&str> = Vec::new();

@ -59,6 +59,9 @@ fn main() {
Command::Flatpak => { Command::Flatpak => {
base::install_flatpak(); base::install_flatpak();
} }
Command::Unakite => {
unakite::setup_unakite();
},
Command::Config { config } => { Command::Config { config } => {
crate::internal::config::read_config(config); crate::internal::config::read_config(config);
} }

Loading…
Cancel
Save