highlight dependencies on graph
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
(package
|
(package
|
||||||
(name "libjpeg")
|
(name "libjpeg-turbo")
|
||||||
(version "3.1.3")
|
(version "3.1.3")
|
||||||
(homepage "https://libjpeg-turbo.org/")
|
(homepage "https://libjpeg-turbo.org/")
|
||||||
(dependencies cmake ninja nasm)
|
(dependencies cmake ninja nasm)
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
(name "libwebp")
|
(name "libwebp")
|
||||||
(version "1.6.0")
|
(version "1.6.0")
|
||||||
(homepage "https://libwebp.com/")
|
(homepage "https://libwebp.com/")
|
||||||
(dependencies libjpeg libtiff)
|
(dependencies libjpeg-turbo libtiff)
|
||||||
(src (tar
|
(src (tar
|
||||||
(url "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.6.0.tar.gz")
|
(url "https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.6.0.tar.gz")
|
||||||
(dir "libwebp-1.6.0")
|
(dir "libwebp-1.6.0")
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
(name "php")
|
(name "php")
|
||||||
(version "8.5.3")
|
(version "8.5.3")
|
||||||
(homepage "https://www.php.net/")
|
(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
|
(src (tar
|
||||||
(url "https://www.php.net/distributions/php-8.5.3.tar.gz")
|
(url "https://www.php.net/distributions/php-8.5.3.tar.gz")
|
||||||
(dir "php-8.5.3")
|
(dir "php-8.5.3")
|
||||||
(blake3 "717d92bb41ce7c62c579469dfd5fec79f99ea0aeeeedfb813a749986b075cfdf")))
|
(blake3 "717d92bb41ce7c62c579469dfd5fec79f99ea0aeeeedfb813a749986b075cfdf")))
|
||||||
(build
|
(build
|
||||||
(configure_make
|
(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 "parser.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include <algorithm>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <span>
|
#include <span>
|
||||||
@@ -9,6 +10,7 @@
|
|||||||
|
|
||||||
std::unordered_map<std::string, Expr> packages;
|
std::unordered_map<std::string, Expr> packages;
|
||||||
bool flag_raw = false;
|
bool flag_raw = false;
|
||||||
|
bool flag_graph = false;
|
||||||
|
|
||||||
void load_packages() {
|
void load_packages() {
|
||||||
for (const auto &e : std::filesystem::directory_iterator("./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;
|
bool needs_download = true;
|
||||||
|
|
||||||
// dont redownload if checksum matches
|
// 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);
|
std::string current_hash = Util::hash_file(archive_path);
|
||||||
if (current_hash == expected_hash) {
|
if (current_hash == expected_hash) {
|
||||||
needs_download = false;
|
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");
|
std::ofstream out("/tmp/shrap/graph.dot");
|
||||||
|
|
||||||
out << "digraph dependencies {\n";
|
out << "digraph dependencies {\n";
|
||||||
out << " rankdir=LR;\n";
|
out << " rankdir=LR;\n";
|
||||||
|
|
||||||
for (const auto &[pkg_name, pkg] : packages) {
|
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 {
|
try {
|
||||||
for (const auto &dep : pkg.get("dependencies").children) {
|
for (const auto &dep : pkg.get("dependencies").children) {
|
||||||
out << " \"" << pkg_name << "\" -> \"" << dep.value << "\";\n";
|
out << " \"" << pkg_name << "\" -> \"" << dep.value << "\";\n";
|
||||||
@@ -217,22 +224,26 @@ int main(int argc, char **argv) {
|
|||||||
if (arg == "-r") {
|
if (arg == "-r") {
|
||||||
flag_raw = true;
|
flag_raw = true;
|
||||||
} else if (arg == "-g") {
|
} else if (arg == "-g") {
|
||||||
generate_graph();
|
flag_graph = true;
|
||||||
return 0;
|
|
||||||
} else {
|
} else {
|
||||||
to_install.push_back(arg);
|
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()) {
|
if (to_install.empty()) {
|
||||||
std::cerr << "Usage: " << args[0] << " [-g] [-r] package1 [package2 ...]\n";
|
std::cerr << "Usage: " << args[0] << " [-g] [-r] package1 [package2 ...]\n";
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!flag_raw) {
|
|
||||||
to_install = resolve_dependencies(to_install);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (geteuid() != 0) {
|
if (geteuid() != 0) {
|
||||||
std::cerr << "This program needs to be ran as root.\n";
|
std::cerr << "This program needs to be ran as root.\n";
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user