From 9fde568beefa60ad7607efcfb05cf73dd791edd8 Mon Sep 17 00:00:00 2001 From: Toni Date: Sun, 15 Feb 2026 18:58:17 +0100 Subject: [PATCH] highlight dependencies on graph --- .../{libjpeg.shrap => libjpeg-turbo.shrap} | 2 +- packages/libwebp.shrap | 2 +- packages/php.shrap | 4 +-- src/main.cc | 29 +++++++++++++------ 4 files changed, 24 insertions(+), 13 deletions(-) rename packages/{libjpeg.shrap => libjpeg-turbo.shrap} (95%) diff --git a/packages/libjpeg.shrap b/packages/libjpeg-turbo.shrap similarity index 95% rename from packages/libjpeg.shrap rename to packages/libjpeg-turbo.shrap index 8b435a2..fc490f4 100644 --- a/packages/libjpeg.shrap +++ b/packages/libjpeg-turbo.shrap @@ -1,5 +1,5 @@ (package - (name "libjpeg") + (name "libjpeg-turbo") (version "3.1.3") (homepage "https://libjpeg-turbo.org/") (dependencies cmake ninja nasm) diff --git a/packages/libwebp.shrap b/packages/libwebp.shrap index 201f6d6..dde8b72 100644 --- a/packages/libwebp.shrap +++ b/packages/libwebp.shrap @@ -2,7 +2,7 @@ (name "libwebp") (version "1.6.0") (homepage "https://libwebp.com/") - (dependencies libjpeg libtiff) + (dependencies libjpeg-turbo libtiff) (src (tar (url "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.6.0.tar.gz") (dir "libwebp-1.6.0") diff --git a/packages/php.shrap b/packages/php.shrap index 9b3891e..49c5065 100644 --- a/packages/php.shrap +++ b/packages/php.shrap @@ -2,11 +2,11 @@ (name "php") (version "8.5.3") (homepage "https://www.php.net/") - (dependencies pkg-config libxml2 sqlite3 openssl zlib bzip2 curl libpng libwebp libfreetype libicu liboniguruma) + (dependencies pkg-config libxml2 sqlite3 libreadline libopenssl zlib bzip2 curl libpng libwebp libfreetype libicu liboniguruma) (src (tar (url "https://www.php.net/distributions/php-8.5.3.tar.gz") (dir "php-8.5.3") (blake3 "717d92bb41ce7c62c579469dfd5fec79f99ea0aeeeedfb813a749986b075cfdf"))) (build (configure_make - (configure_flags "--with-curl --with-zlib --with-openssl --with-bz2 --enable-xml --enable-mbstring --enable-intl --enable-gd --enable-exif --with-gettext --with-webp --with-jpeg --with-mysqli --with-freetype")))) + (configure_flags "--with-curl --with-readline --with-zlib --with-openssl --with-bz2 --enable-xml --enable-mbstring --enable-intl --enable-gd --enable-exif --with-gettext --with-webp --with-jpeg --with-mysqli --with-freetype")))) diff --git a/src/main.cc b/src/main.cc index a6ad8af..27247e5 100644 --- a/src/main.cc +++ b/src/main.cc @@ -1,5 +1,6 @@ #include "parser.h" #include "util.h" +#include #include #include #include @@ -9,6 +10,7 @@ std::unordered_map packages; bool flag_raw = false; +bool flag_graph = false; void load_packages() { for (const auto &e : std::filesystem::directory_iterator("./packages/")) { @@ -87,7 +89,7 @@ void install_package(const std::string &name) { bool needs_download = true; // dont redownload if checksum matches - if (std::ifstream(archive_path)) { + if (std::filesystem::exists(archive_path)) { std::string current_hash = Util::hash_file(archive_path); if (current_hash == expected_hash) { needs_download = false; @@ -183,14 +185,19 @@ void install_package(const std::string &name) { } } -void generate_graph() { +void generate_graph(const std::vector &to_highlight) { std::ofstream out("/tmp/shrap/graph.dot"); out << "digraph dependencies {\n"; out << " rankdir=LR;\n"; for (const auto &[pkg_name, pkg] : packages) { - out << " \"" << pkg_name << "\";\n"; + if (std::find(to_highlight.begin(), to_highlight.end(), pkg_name) != + to_highlight.end()) { + out << " \"" << pkg_name << "\" [style=filled, fillcolor=yellow];\n"; + } else { + out << " \"" << pkg_name << "\";\n"; + } try { for (const auto &dep : pkg.get("dependencies").children) { out << " \"" << pkg_name << "\" -> \"" << dep.value << "\";\n"; @@ -217,22 +224,26 @@ int main(int argc, char **argv) { if (arg == "-r") { flag_raw = true; } else if (arg == "-g") { - generate_graph(); - return 0; + flag_graph = true; } else { to_install.push_back(arg); } } + if (!flag_raw) { + to_install = resolve_dependencies(to_install); + } + + if (flag_graph) { + generate_graph(to_install); + return 0; + } + if (to_install.empty()) { std::cerr << "Usage: " << args[0] << " [-g] [-r] package1 [package2 ...]\n"; return 1; } - if (!flag_raw) { - to_install = resolve_dependencies(to_install); - } - if (geteuid() != 0) { std::cerr << "This program needs to be ran as root.\n"; return 1;