speed up cmake, rustc, openvpn

This commit is contained in:
2026-02-20 12:45:31 +01:00
parent 38c3ec542b
commit 9f9c5b7c9c
22 changed files with 156 additions and 46 deletions

View File

@@ -4,7 +4,6 @@
#include <filesystem>
#include <functional>
#include <span>
#include <sys/stat.h>
#include <thread>
#include <unordered_map>
@@ -75,7 +74,7 @@ void install_package(const std::string &name) {
Expr pkg = packages[name];
std::cout << "\n\n\tInstalling " << pkg.get_one("name").value << " ("
<< pkg.get_one("version").value << ")...\n\n\n";
<< pkg.get_one("version").value << ")...\n\n";
Expr src = pkg.get_one("src");
std::string src_type = src.children[0].value;
@@ -90,6 +89,7 @@ void install_package(const std::string &name) {
// dont redownload if checksum matches
if (std::filesystem::exists(archive_path)) {
std::cout << "\tComputing checksum...\n";
std::string current_hash = Util::hash_file(archive_path);
if (current_hash == expected_hash) {
needs_download = false;
@@ -99,6 +99,7 @@ void install_package(const std::string &name) {
if (needs_download) {
Util::shell_command("./curl -L -o " + archive_path + " " + src_url);
std::cout << "\n\tComputing checksum...\n";
std::string hash = Util::hash_file(archive_path);
if (expected_hash != hash) {
std::cerr << "Checksum check failed.\n";
@@ -108,6 +109,7 @@ void install_package(const std::string &name) {
}
}
std::cout << "\n\tExtracting...\n";
Util::shell_command("tar xf " + archive_path + " -C /tmp/shrap/");
} else {
throw std::runtime_error("unrecognized src type");
@@ -115,6 +117,7 @@ void install_package(const std::string &name) {
std::string jobs = std::to_string(std::thread::hardware_concurrency());
std::cout << "\n\tBuilding...\n\n";
for (const auto &step : pkg.get("build").children) {
std::string step_type = step.children[0].value;
@@ -242,6 +245,10 @@ int main(int argc, char **argv) {
std::cout << "\nFollowing packages will be installed:\n";
for (const std::string &pkg : to_install) {
if (!packages.contains(pkg)) {
std::cerr << "Package not found: " << pkg << "\n";
std::exit(1);
}
std::cout << " - " << pkg << " (" << packages[pkg].get_one("version").value
<< ")" << std::endl;
}