diff --git a/.clang-tidy b/.clang-tidy index f90308a..19bbb5d 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1 +1 @@ -Checks: '*,clang-analyzer-*,-llvmlibc-*,-fuchsia-*,-altera-*,-abseil-*,-android-*,-modernize-use-trailing-return-type,-readability-identifier-length,-*-readability-todo,-*-magic-numbers,-readability-function-cognitive-complexity,-*-easily-swappable-parameters,-*-non-private-member-variables-in-classes,-*-no-recursion,-concurrency-mt-unsafe,-*-runtime-int,-*-non-const-global-variables,-performance-inefficient-string-concatenation,-cert-err58-cpp,-*-signed-bitwise' \ No newline at end of file +Checks: '*,clang-analyzer-*,-llvmlibc-*,-fuchsia-*,-altera-*,-abseil-*,-android-*,-modernize-use-trailing-return-type,-readability-identifier-length,-*-readability-todo,-*-magic-numbers,-readability-function-cognitive-complexity,-*-easily-swappable-parameters,-*-non-private-member-variables-in-classes,-*-no-recursion,-concurrency-mt-unsafe,-*-runtime-int,-*-non-const-global-variables,-performance-inefficient-string-concatenation,-cert-err58-cpp,-*-signed-bitwise' diff --git a/CMakeLists.txt b/CMakeLists.txt index 22161ac..c662be1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,7 @@ project(shrap) set(CMAKE_CXX_STANDARD 20) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(SQLITE_OMIT_LOAD_EXTENSION ON CACHE BOOL "Disable SQLite load_extension()" FORCE) find_package(blake3 REQUIRED) @@ -18,4 +19,4 @@ add_executable(${PROJECT_NAME} src/main.cc) target_link_libraries(${PROJECT_NAME} PRIVATE blake3 SQLiteCpp) -set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-static") \ No newline at end of file +set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-static") diff --git a/packages/apache.shrap b/packages/apache.shrap new file mode 100644 index 0000000..ee84c9f --- /dev/null +++ b/packages/apache.shrap @@ -0,0 +1,13 @@ +(package + (name "apache") + (version "2.4.66") + (homepage "https://httpd.apache.org/") + (dependencies libpcre2 libapr-util curl libnghttp2 libjansson) + (src (tar + (url "https://dlcdn.apache.org/httpd/httpd-2.4.66.tar.gz") + (dir "httpd-2.4.66") + (blake3 "5e85077659e0afb6e51ba017b6a8807b74b53be28bd7d4e9e1821c96600b1fb2"))) + (build + (configure_make + (configure_flags "--enable-ssl --enable-mods-shared=\"all cgi\"")) + (shell "sed -i 's|^#LoadModule ssl_module|LoadModule ssl_module|' /usr/conf/httpd.conf"))) diff --git a/packages/libapr-util.shrap b/packages/libapr-util.shrap new file mode 100644 index 0000000..7773356 --- /dev/null +++ b/packages/libapr-util.shrap @@ -0,0 +1,12 @@ +(package + (name "libapr-util") + (version "1.6.3") + (homepage "https://apr.apache.org/") + (dependencies libapr libexpat) + (src (tar + (url "https://dlcdn.apache.org//apr/apr-util-1.6.3.tar.gz") + (dir "apr-util-1.6.3") + (blake3 "a887fcd96b9c9dc5c1039a6ae6b7df5baab22a54ee18ce2ebde6e902e3d3a3da"))) + (build + (configure_make + (configure_flags "--with-apr=/usr/bin/apr-1-config")))) diff --git a/packages/libapr.shrap b/packages/libapr.shrap new file mode 100644 index 0000000..00d4d56 --- /dev/null +++ b/packages/libapr.shrap @@ -0,0 +1,12 @@ +(package + (name "libapr") + (version "1.7.6") + (homepage "https://apr.apache.org/") + (dependencies make libopenssl) + (src (tar + (url "https://dlcdn.apache.org//apr/apr-1.7.6.tar.gz") + (dir "apr-1.7.6") + (blake3 "d8f55af9e3d5c0548c5a6c2345cf22ea98c1960874caff81aa168e32f0c2f159"))) + (build + (configure_make + (configure_flags "--with-crypto")))) diff --git a/packages/libjansson.shrap b/packages/libjansson.shrap new file mode 100644 index 0000000..7c1f444 --- /dev/null +++ b/packages/libjansson.shrap @@ -0,0 +1,11 @@ +(package + (name "libjansson") + (version "2.15.0") + (homepage "https://github.com/akheron/jansson") + (dependencies make) + (src (tar + (url "https://github.com/akheron/jansson/releases/download/v2.15.0/jansson-2.15.0.tar.gz") + (dir "jansson-2.15.0") + (blake3 "53432e6ba17b7ad7640c397c5f382eb2d6dbb7f22d13f04078454c7a6affe4bd"))) + (build + (configure_make))) diff --git a/packages/libnghttp2.shrap b/packages/libnghttp2.shrap new file mode 100644 index 0000000..1641436 --- /dev/null +++ b/packages/libnghttp2.shrap @@ -0,0 +1,11 @@ +(package + (name "libnghttp2") + (version "1.68.0") + (homepage "https://nghttp2.org/") + (dependencies make) + (src (tar + (url "https://github.com/nghttp2/nghttp2/releases/download/v1.68.0/nghttp2-1.68.0.tar.gz") + (dir "nghttp2-1.68.0") + (blake3 "1894c685f2aaad1112757fdb525bbd2305ddda3975b0cdb68a80d36184934093"))) + (build + (configure_make))) diff --git a/packages/libpcre2.shrap b/packages/libpcre2.shrap index 3e2379a..212e4df 100644 --- a/packages/libpcre2.shrap +++ b/packages/libpcre2.shrap @@ -8,4 +8,5 @@ (dir "pcre2-10.47") (blake3 "e80086b5f6da0896be2bb6d0d94ba976a6b21a43fddb831a189d2c8c9747d962"))) (build - (configure_make))) + (configure_make + (configure_flags "--disable-shared")))) diff --git a/packages/nginx.shrap b/packages/nginx.shrap new file mode 100644 index 0000000..776b1dc --- /dev/null +++ b/packages/nginx.shrap @@ -0,0 +1,12 @@ +(package + (name "nginx") + (version "1.29.5") + (homepage "https://nginx.org/") + (dependencies libpcre2 zlib libopenssl) + (src (tar + (url "https://nginx.org/download/nginx-1.29.5.tar.gz") + (dir "nginx-1.29.5") + (blake3 "e37ca0ef47e09e907952840dc29cf3b8eef59d90894eb585fcafc8ec62aebbd1"))) + (build + (configure_make + (configure_flags "--with-http_ssl_module --with-http_v2_module --with-http_v3_module --with-threads")))) diff --git a/packages/php.shrap b/packages/php.shrap index 49c5065..e042883 100644 --- a/packages/php.shrap +++ b/packages/php.shrap @@ -2,7 +2,7 @@ (name "php") (version "8.5.3") (homepage "https://www.php.net/") - (dependencies pkg-config libxml2 sqlite3 libreadline libopenssl zlib bzip2 curl libpng libwebp libfreetype libicu liboniguruma) + (dependencies pkg-config libxml2 sqlite3 libreadline 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") diff --git a/packages/python.shrap b/packages/python.shrap index 541c01e..b1bfbdd 100644 --- a/packages/python.shrap +++ b/packages/python.shrap @@ -2,7 +2,7 @@ (name "python") (version "3.14.3") (homepage "https://www.python.org/") - (dependencies zlib libopenssl bzip2) + (dependencies zlib libopenssl bzip2 libffi sqlite3 libdb libreadline) (src (tar (url "https://www.python.org/ftp/python/3.14.3/Python-3.14.3.tgz") (dir "Python-3.14.3") diff --git a/packages/rustc.shrap b/packages/rustc.shrap index 36c35bd..3cdb0d6 100644 --- a/packages/rustc.shrap +++ b/packages/rustc.shrap @@ -8,9 +8,9 @@ (dir "rustc-1.93.1-src") (blake3 "c8f492b93a95d64efb51fbcc5eab1e8edc1468a3f5be923c756b69d66892161a"))) (build - (shell "cp bootstrap.example.toml bootstrap.toml || true") + (shell "cp -v bootstrap.example.toml bootstrap.toml || true") (shell "sed -i '1illvm.targets = \"X86\"' bootstrap.toml") (shell "sed -i '1ibuild.docs = false' bootstrap.toml") (shell "sed -i '1iinstall.prefix = \"/opt/rustc\"' bootstrap.toml") (shell "./x.py install") - (shell "for f in /opt/rustc/bin/*; do ln -s \"$f\" /usr/bin/ || true; done"))) + (shell "for f in /opt/rustc/bin/*; do ln -sf \"$f\" /usr/bin/ || true; done"))) diff --git a/packages/tor.shrap b/packages/tor.shrap new file mode 100644 index 0000000..d38ae08 --- /dev/null +++ b/packages/tor.shrap @@ -0,0 +1,12 @@ +(package + (name "tor") + (version "0.4.9.5") + (homepage "https://www.torproject.org/") + (dependencies libevent zlib zstd) + (src (tar + (url "https://dist.torproject.org/tor-0.4.9.5.tar.gz") + (dir "tor-0.4.9.5") + (blake3 "6e0e93223b4b22693207750cb850abe9e106c2b6a4e5e14b9f2012ee43fd4fab"))) + (build + (configure_make + (configure_flags "--enable-lzma --enable-zstd")))) diff --git a/packages/util-linux.shrap b/packages/util-linux.shrap new file mode 100644 index 0000000..3d27c07 --- /dev/null +++ b/packages/util-linux.shrap @@ -0,0 +1,11 @@ +(package + (name "util-linux") + (version "2.41.3") + (homepage "https://www.kernel.org/pub/linux/utils/util-linux/") + (dependencies make sqlite3 pkg-config) + (src (tar + (url "https://www.kernel.org/pub/linux/utils/util-linux/v2.41/util-linux-2.41.3.tar.gz") + (dir "util-linux-2.41.3") + (blake3 "cc3729fd494203532832ee68acbedb39ed876e07c6fd7d61900f926664e859a6"))) + (build + (configure_make))) diff --git a/src/db.h b/src/db.h index d3bc5a7..6fef851 100644 --- a/src/db.h +++ b/src/db.h @@ -35,4 +35,4 @@ public: private: SQLite::Database m_db{DB_PATH + "/shrap.db", SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE}; -}; \ No newline at end of file +}; diff --git a/src/main.cc b/src/main.cc index f00d56f..3effb3d 100644 --- a/src/main.cc +++ b/src/main.cc @@ -8,7 +8,7 @@ #include #include -static const std::string BUILD_PATH = "/tmp/shrap"; +constexpr static const std::string BUILD_PATH = "/tmp/shrap"; std::unordered_map packages; @@ -216,6 +216,11 @@ void generate_graph(const std::vector &to_highlight) { int main(int argc, char **argv) { auto args = std::span(argv, static_cast(argc)); + if (geteuid() != 0) { + std::cerr << "This program needs to be ran as root.\n"; + return 1; + } + std::filesystem::create_directories(BUILD_PATH); std::filesystem::create_directories(DB::DB_PATH); @@ -239,10 +244,6 @@ int main(int argc, char **argv) { } } - if (!flag_raw) { - to_install = resolve_dependencies(to_install, db); - } - if (flag_graph) { generate_graph(to_install); return 0; @@ -253,9 +254,8 @@ int main(int argc, char **argv) { return 1; } - if (geteuid() != 0) { - std::cerr << "This program needs to be ran as root.\n"; - return 1; + if (!flag_raw) { + to_install = resolve_dependencies(to_install, db); } std::cout << "\nFollowing packages will be installed:\n"; diff --git a/src/util.h b/src/util.h index 0d50607..bdab65f 100644 --- a/src/util.h +++ b/src/util.h @@ -27,6 +27,7 @@ static void shell_command(const std::string &cmd, _exit(1); } + std::cout << cmd << std::endl; execl("/bin/sh", "sh", "-c", cmd.c_str(), nullptr); // NOLINT(*-vararg) perror("execl failed"); @@ -79,4 +80,4 @@ static std::string hash_file(const std::string &path) { return ss.str(); } -}; // namespace Util \ No newline at end of file +}; // namespace Util