Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 62 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,18 +1,65 @@
build/*
packs/QuasarTools/*
```
# Compiled and build artifacts
*.o
*.obj
*.out
build/
dist/

# Dependencies
node_modules/
venv/
.venv/
__pycache__/
.mypy_cache/
.pytest_cache/
target/
.gradle/

*.kate-swp
*.swap
*.iso
*.img
releases/
# Logs and temp files
*.log
*.o
*.a
*.so
*.tmp
framwork/
regions-*
region-*
region_settings
packs/var.*
*.swp

# Environment
.env
.env.local
*.env.*

# Editors
.vscode/
.idea/

# OS specific
.DS_Store
Thumbs.db

# Coverage
coverage/
htmlcov/
.coverage

# Compressed files
*.zip
*.gz
*.tar
*.tgz
*.bz2
*.xz
*.7z
*.rar
*.zst
*.lz4
*.lzh
*.cab
*.arj
*.rpm
*.deb
*.Z
*.lz
*.lzo
*.tar.gz
*.tar.bz2
*.tar.xz
*.tar.zst
```
1 change: 1 addition & 0 deletions main/QuasarLinux/backend/basepack/basepack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define BOLD_BRIGHT_WHITE "\033[1;97m"
using namespace std;
void log(std::string level, std::string message);
void save_progress(const std::string& module, const std::string& action, bool success);
void prepart();
void system_settings();

Expand Down
54 changes: 50 additions & 4 deletions main/QuasarLinux/backend/basepack/main.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,59 @@
#include <string>
#include <iostream>
#include <sstream>
#include "basepack.hpp"

void log(std::string level, std::string message) {
if (level == "debug") {
std::cerr << BOLD_BRIGHT_WHITE << "DEBUG: " << RESET << _(message.c_str()) << std::endl;
std::cerr << BOLD_BRIGHT_WHITE << "DEBUG::basepack:: " << RESET << _(message.c_str()) << std::endl;
}
if (level == "info") {
std::cerr << BLUE << "INFO::basepack:: " << RESET << _(message.c_str()) << std::endl;
}
if (level == "error") {
std::cerr << RED << "ERR: " << RESET << _(message.c_str()) << std::endl;
std::cerr << RED << "ERR::basepack:: " << RESET << _(message.c_str()) << std::endl;
}
if (level == "warning") {
std::cerr << YELLOW << "WAR: " << RESET << _(message.c_str()) << std::endl;
std::cerr << YELLOW << "WAR::basepack:: " << RESET << _(message.c_str()) << std::endl;
}
if (level == "fixme") {
std::cerr << MAGENTA << "FIXME: " << RESET << _(message.c_str()) << std::endl;
std::cerr << MAGENTA << "FIXME::basepack:: " << RESET << _(message.c_str()) << std::endl;
}
}

void save_progress(const std::string& module, const std::string& action, bool success) {
std::string save_path = "/mnt/save.json";
std::ifstream file(save_path);
std::string content = "{";

if (file.is_open()) {
std::stringstream buffer;
buffer << file.rdbuf();
content = buffer.str();
file.close();
}

// Simple manual JSON update without jsoncpp
std::ofstream out(save_path);
if (out.is_open()) {
// Remove closing brace and add new entry
if (content.length() > 1 && content.back() == '}') {
content.pop_back();
if (content.length() > 1) content += ",";
} else {
content = "{";
}
content += "\"" + module + "\":" + (success ? "true" : "false");
content += ",\"last_action\":\"" + action + "\"";
content += "}";
out << content;
out.close();
log("debug", "Saved progress: " + module + " = " + (success ? "true" : "false"));
} else {
log("error", "Failed to save progress to " + save_path);
}
}

void prepart()
{
if (mount("/dev", "/mnt/dev", NULL, MS_BIND, NULL) == -1) {
Expand Down Expand Up @@ -48,13 +86,19 @@ int main(int argc, char *argv[]) {
return 0;
}

if (argc < 5) {
log("error", "Not enough arguments!");
return 1;
}

std::string revision = argv[1];
std::string init = argv[2];
std::string kernel = argv[3];
std::string zram_flag = argv[4];

// basepack REV openrc linux zram_on
log("debug", "Starting setup: init=" + init + " kernel=" + kernel + " zram=" + zram_flag);
save_progress("basepack", "started", true);

if (init == "openrc") {
openrc_base_system(kernel);
Expand All @@ -74,9 +118,11 @@ int main(int argc, char *argv[]) {
}
else {
log("error", "Unknown init system: " + init);
save_progress("basepack", "failed", false);
return 1;
}

log("info", "Setup completed!");
save_progress("basepack", "completed", true);
return 0;
}
1 change: 1 addition & 0 deletions main/QuasarLinux/backend/bootloader/Setbootloader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
namespace fs = std::filesystem;
//main
void log(std::string level, std::string message);
void save_progress(const std::string& module, const std::string& action, bool success);
void prepart();

//grub
Expand Down
88 changes: 69 additions & 19 deletions main/QuasarLinux/backend/bootloader/main.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,57 @@
#include "Setbootloader.hpp"
#include <sstream>

void log(std::string level, std::string message) {
if (level == "debug") {
std::cerr << BOLD_BRIGHT_WHITE << "DEBUG: " << RESET << _(message.c_str()) << std::endl;
std::cerr << BOLD_BRIGHT_WHITE << "DEBUG::bootloader:: " << RESET << _(message.c_str()) << std::endl;
}
if (level == "info") {
std::cerr << BLUE << "INFO::bootloader:: " << RESET << _(message.c_str()) << std::endl;
}
if (level == "error") {
std::cerr << RED << "ERR: " << RESET << _(message.c_str()) << std::endl;
std::cerr << RED << "ERR::bootloader:: " << RESET << _(message.c_str()) << std::endl;
}
if (level == "warning") {
std::cerr << YELLOW << "WAR: " << RESET << _(message.c_str()) << std::endl;
std::cerr << YELLOW << "WAR::bootloader:: " << RESET << _(message.c_str()) << std::endl;
}
if (level == "fixme") {
std::cerr << MAGENTA << "FIXME: " << RESET << _(message.c_str()) << std::endl;
std::cerr << MAGENTA << "FIXME::bootloader:: " << RESET << _(message.c_str()) << std::endl;
}
}

void save_progress(const std::string& module, const std::string& action, bool success) {
std::string save_path = "/mnt/save.json";
std::ifstream file(save_path);
std::string content = "{";

if (file.is_open()) {
std::stringstream buffer;
buffer << file.rdbuf();
content = buffer.str();
file.close();
}

// Simple manual JSON update without jsoncpp
std::ofstream out(save_path);
if (out.is_open()) {
// Remove closing brace and add new entry
if (content.length() > 1 && content.back() == '}') {
content.pop_back();
if (content.length() > 1) content += ",";
} else {
content = "{";
}
content += "\"" + module + "\":" + (success ? "true" : "false");
content += ",\"last_action\":\"" + action + "\"";
content += "}";
out << content;
out.close();
log("debug", "Saved progress: " + module + " = " + (success ? "true" : "false"));
} else {
log("error", "Failed to save progress to " + save_path);
}
}

void prepart()
{
if (mount("/dev", "/mnt/dev", NULL, MS_BIND, NULL) == -1) {
Expand All @@ -35,12 +73,11 @@ int main(int argc, char* argv[]) {
setlocale(LC_ALL, "");
bindtextdomain("installer", "/usr/local/sdk/global/locale");
textdomain("installer");
// bootinstall legacy grub /dev/sda
// legacy bootloader disk

// 1 == grub
// 2 == syslinux/efistub
// 3 == refind

if (argc < 6) {
log("error", "Not enough arguments!");
return 1;
}

std::string efi = argv[1];
std::string bootloader = argv[2];
Expand All @@ -49,52 +86,65 @@ int main(int argc, char* argv[]) {
std::string ESPBoot = argv[5];
if (efi.empty()) {
log("error", "Cannot detect firmware!");
exit(1);
return 1;
}
if (bootloader.empty()) {
log("error", "Cannot detect bootloader!");
exit(1);
return 1;
}
if (DISK.empty()) {
log("error", "Cannot detect disk!");
exit(1);
return 1;
}
if (kernel.empty() || kernel == "NULL") {
log("warring", "the kernel is not selected, efistab and syslinux cannot be installed, only grub");
log("warning", "the kernel is not selected, efistab and syslinux cannot be installed, only grub");
}
if (ESPBoot.empty() || ESPBoot == "NULL") {
log("warring", "no ESP section is specified, only grub");
log("warning", "no ESP section is specified, only grub");
}


log("info", "Starting bootloader installation");
save_progress("bootloader", "started", true);

if ( efi == "legacy" ) {
if (bootloader == "grub") {
InstallGrubLegacy(DISK);
} else if ( bootloader == "syslinux") {
if (kernel.empty() || kernel == "NULL") {
log("error", "the kernel is not selected, efistab and syslinux cannot be installed, only grub");
exit(1);
save_progress("bootloader", "failed", false);
return 1;
}
InstallSyslinux(DISK, kernel);
} else {
log("fixme", "unknow bootloader");
save_progress("bootloader", "failed", false);
return 1;
}
} else if ( efi == "UEFI" || efi == "uefi") {
if (bootloader == "grub") {
InstallGrubUEFI();
} else if (bootloader == "efistub") {
if (kernel.empty() || kernel == "NULL") {
log("error", "the kernel is not selected, efistab and syslinux cannot be installed, only grub");
exit(1);
save_progress("bootloader", "failed", false);
return 1;
}
EfistubInstall(DISK, ESPBoot, kernel);
} else if (bootloader == "refind") {
RefindInstall(DISK, ESPBoot);
} else {
log("fixme", "unknow bootloader");
save_progress("bootloader", "failed", false);
return 1;
}
} else {
log("fixme", "unknow firmware");
save_progress("bootloader", "failed", false);
return 1;
}


log("info", "Bootloader installation completed");
save_progress("bootloader", "completed", true);
return 0;
}
Loading