highlight dependencies on graph
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
(package
|
||||
(name "libjpeg")
|
||||
(name "libjpeg-turbo")
|
||||
(version "3.1.3")
|
||||
(homepage "https://libjpeg-turbo.org/")
|
||||
(dependencies cmake ninja nasm)
|
||||
@@ -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")
|
||||
|
||||
@@ -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"))))
|
||||
|
||||
29
src/main.cc
29
src/main.cc
@@ -1,5 +1,6 @@
|
||||
#include "parser.h"
|
||||
#include "util.h"
|
||||
#include <algorithm>
|
||||
#include <filesystem>
|
||||
#include <functional>
|
||||
#include <span>
|
||||
@@ -9,6 +10,7 @@
|
||||
|
||||
std::unordered_map<std::string, Expr> 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<std::string> &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;
|
||||
|
||||
Reference in New Issue
Block a user