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

4
.gitignore vendored
View File

@@ -1,5 +1,3 @@
/.cache /.cache
/build /build
/*.py /TODO
docker.sh
/curl

View File

@@ -1,32 +1,13 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
project(shrap) project(shrap)
include(FetchContent)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
FetchContent_Declare( find_package(blake3 REQUIRED)
blake3
GIT_REPOSITORY https://github.com/BLAKE3-team/BLAKE3.git
GIT_TAG 1.8.3
)
FetchContent_MakeAvailable(blake3)
add_library(blake3_lib STATIC
${blake3_SOURCE_DIR}/c/blake3.c
${blake3_SOURCE_DIR}/c/blake3_dispatch.c
${blake3_SOURCE_DIR}/c/blake3_portable.c
)
target_compile_definitions(blake3_lib PRIVATE
BLAKE3_NO_SSE2
BLAKE3_NO_SSE41
BLAKE3_NO_AVX2
BLAKE3_NO_AVX512
)
target_include_directories(blake3_lib PUBLIC ${blake3_SOURCE_DIR}/c)
add_executable(${PROJECT_NAME} src/main.cc) add_executable(${PROJECT_NAME} src/main.cc)
target_link_libraries(${PROJECT_NAME} PRIVATE blake3_lib) target_link_libraries(${PROJECT_NAME} PRIVATE blake3)
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-static") set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-static")

BIN
curl Executable file

Binary file not shown.

19
docker.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/bash
set -xe
cmake --build build -j 12
cat << EOF > Dockerfile
FROM debian:trixie-slim
RUN apt update -y && apt install -y --no-install-recommends gcc g++ libc6-dev ca-certificates
RUN apt remove -y --allow-remove-essential perl manpages-dev perl-base && apt autoremove -y
WORKDIR /app
CMD ["/bin/bash"]
EOF
docker build -t shrap .
rm Dockerfile
docker run --rm -it -v .:/app shrap

View File

@@ -2,7 +2,7 @@
(name "clamav") (name "clamav")
(version "1.5.1") (version "1.5.1")
(homepage "https://www.clamav.net/") (homepage "https://www.clamav.net/")
(dependencies cmake rust-bin zlib bzip2 libxml2 libpcre2 libjson-c curl libncurses libmilter) (dependencies cmake rustc bzip2 libxml2 libpcre2 libjson-c curl libncurses libmilter)
(src (tar (src (tar
(url "https://www.clamav.net/downloads/production/clamav-1.5.1.tar.gz") (url "https://www.clamav.net/downloads/production/clamav-1.5.1.tar.gz")
(dir "clamav-1.5.1") (dir "clamav-1.5.1")

View File

@@ -2,11 +2,11 @@
(name "cmake") (name "cmake")
(version "4.2.3") (version "4.2.3")
(homepage "https://cmake.org/") (homepage "https://cmake.org/")
(dependencies libopenssl) (dependencies curl libexpat libarchive libuv)
(src (tar (src (tar
(url "https://github.com/Kitware/CMake/releases/download/v4.2.3/cmake-4.2.3.tar.gz") (url "https://github.com/Kitware/CMake/releases/download/v4.2.3/cmake-4.2.3.tar.gz")
(dir "cmake-4.2.3") (dir "cmake-4.2.3")
(blake3 "d4cf435ab124932c313d4c8a125c8a3add3d171587438e8c82773a44b038fd34"))) (blake3 "d4cf435ab124932c313d4c8a125c8a3add3d171587438e8c82773a44b038fd34")))
(build (build
(shell "./bootstrap --prefix=/usr --parallel=8") (shell "./bootstrap --prefix=/usr --parallel=8 --system-libs --no-system-librhash --no-system-jsoncpp --no-system-cppdap")
(shell "make install"))) (make)))

11
packages/libarchive.shrap Normal file
View File

@@ -0,0 +1,11 @@
(package
(name "libarchive")
(version "3.8.5")
(homepage "https://libarchive.org/")
(dependencies make)
(src (tar
(url "https://libarchive.org/downloads/libarchive-3.8.5.tar.gz")
(dir "libarchive-3.8.5")
(blake3 "88054392b2b96bedf7d048eb5cd78cb13cab0829f0df1802b289d58c48702149")))
(build
(configure_make)))

11
packages/libcap-ng.shrap Normal file
View File

@@ -0,0 +1,11 @@
(package
(name "libcap-ng")
(version "0.8.5")
(homepage "https://people.redhat.com/sgrubb/libcap-ng/")
(dependencies make)
(src (tar
(url "https://people.redhat.com/sgrubb/libcap-ng/libcap-ng-0.8.5.tar.gz")
(dir "libcap-ng-0.8.5")
(blake3 "31cf706701f3f7b34dd3f2d8ad4ca85a1b633dc15a72d90b76c9a973ac07c103")))
(build
(configure_make)))

View File

@@ -2,11 +2,11 @@
(name "libgnutls") (name "libgnutls")
(version "3.8.12") (version "3.8.12")
(homepage "https://gnutls.org/") (homepage "https://gnutls.org/")
(dependencies xz pkg-config libnettle libp11-kit) (dependencies xz pkg-config libnettle libp11-kit libunistring)
(src (tar (src (tar
(url "https://www.gnupg.org/ftp/gcrypt/gnutls/v3.8/gnutls-3.8.12.tar.xz") (url "https://www.gnupg.org/ftp/gcrypt/gnutls/v3.8/gnutls-3.8.12.tar.xz")
(dir "gnutls-3.8.12") (dir "gnutls-3.8.12")
(blake3 "d60d32619210c02b3b280a79e32c8323a7fd556ae77e1b461d69744bc93f05d5"))) (blake3 "d60d32619210c02b3b280a79e32c8323a7fd556ae77e1b461d69744bc93f05d5")))
(build (build
(configure_make (configure_make
(configure_flags "--with-included-libtasn1 --with-included-unistring --disable-doc --disable-tests --disable-tools")))) (configure_flags "--disable-doc --disable-tests --disable-tools"))))

11
packages/libnl.shrap Normal file
View File

@@ -0,0 +1,11 @@
(package
(name "libnl")
(version "3.12.0")
(homepage "https://github.com/thom311/libnl")
(dependencies bison flex)
(src (tar
(url "https://github.com/thom311/libnl/releases/download/libnl3_12_0/libnl-3.12.0.tar.gz")
(dir "libnl-3.12.0")
(blake3 "e2905e07eedd9100fb1d3e49625e0d27f9c855cfbc33845bbb65336c8a991ea1")))
(build
(configure_make)))

View File

@@ -0,0 +1,11 @@
(package
(name "libunistring")
(version "1.4.1")
(homepage "https://www.gnu.org/software/libunistring/")
(dependencies make)
(src (tar
(url "https://ftp.gnu.org/gnu/libunistring/libunistring-1.4.1.tar.gz")
(dir "libunistring-1.4.1")
(blake3 "24b086d0dba812ef13648edcf9566925929fe9dd31c58804b7b4ce0dd28dc801")))
(build
(configure_make)))

11
packages/libuv.shrap Normal file
View File

@@ -0,0 +1,11 @@
(package
(name "libuv")
(version "1.52.0")
(homepage "https://libuv.org/")
(dependencies make)
(src (tar
(url "https://dist.libuv.org/dist/v1.52.0/libuv-v1.52.0-dist.tar.gz")
(dir "libuv-1.52.0")
(blake3 "fa785aef13aa86b4cdf66e440235a3fd869424781a7341b49041b9ed20de8f35")))
(build
(configure_make)))

View File

@@ -2,6 +2,7 @@
(name "libyaml") (name "libyaml")
(version "0.2.5") (version "0.2.5")
(homepage "https://pyyaml.org/wiki/LibYAML") (homepage "https://pyyaml.org/wiki/LibYAML")
(dependencies make)
(src (tar (src (tar
(url "https://github.com/yaml/libyaml/releases/download/0.2.5/yaml-0.2.5.tar.gz") (url "https://github.com/yaml/libyaml/releases/download/0.2.5/yaml-0.2.5.tar.gz")
(dir "yaml-0.2.5") (dir "yaml-0.2.5")

11
packages/lzo.shrap Normal file
View File

@@ -0,0 +1,11 @@
(package
(name "lzo")
(version "2.10")
(homepage "https://www.oberhumer.com/opensource/lzo/")
(dependencies make)
(src (tar
(url "https://www.oberhumer.com/opensource/lzo/download/lzo-2.10.tar.gz")
(dir "lzo-2.10")
(blake3 "3e1c1d7b5858ca4415510a80ad48566b44f5d393714f847ea3652c8805a5abca")))
(build
(configure_make)))

11
packages/ocaml.shrap Normal file
View File

@@ -0,0 +1,11 @@
(package
(name "ocaml")
(version "5.4.1")
(homepage "https://ocaml.org/")
(dependencies make zstd)
(src (tar
(url "https://github.com/ocaml/ocaml/releases/download/5.4.1/ocaml-5.4.1.tar.gz")
(dir "ocaml-5.4.1")
(blake3 "b834191efd80d8cabfd674f5d76b5785b383c9e701c8af8fe017bcd7b3932693")))
(build
(configure_make)))

11
packages/openvpn.shrap Normal file
View File

@@ -0,0 +1,11 @@
(package
(name "openvpn")
(version "2.7.0")
(homepage "https://openvpn.net/")
(dependencies pkg-config libnl libcap-ng libopenssl lz4 lzo libpam)
(src (tar
(url "https://github.com/OpenVPN/openvpn/releases/download/v2.7.0/openvpn-2.7.0.tar.gz")
(dir "openvpn-2.7.0")
(blake3 "94adeb6c9bdce39b1148b33507b0f5b049bb7691dca9111c9401e0a60350df70")))
(build
(configure_make)))

11
packages/patch.shrap Normal file
View File

@@ -0,0 +1,11 @@
(package
(name "patch")
(version "2.8")
(homepage "https://savannah.gnu.org/projects/patch/")
(dependencies make)
(src (tar
(url "https://ftp.gnu.org/gnu/patch/patch-2.8.tar.gz")
(dir "patch-2.8")
(blake3 "bf50f1dcbece294082d0b4e25b9179a1cdaa8a491a9df64425b37b03093a93d6")))
(build
(configure_make)))

View File

@@ -2,11 +2,11 @@
(name "qemu") (name "qemu")
(version "10.2.1") (version "10.2.1")
(homepage "https://www.qemu.org/") (homepage "https://www.qemu.org/")
(dependencies libglib bison flex libpng) (dependencies libglib bison flex)
(src (tar (src (tar
(url "https://download.qemu.org/qemu-10.2.1.tar.xz") (url "https://download.qemu.org/qemu-10.2.1.tar.xz")
(dir "qemu-10.2.1") (dir "qemu-10.2.1")
(blake3 "c4ac0f9dbe06a68950ef2d999a411584bc8474b8576123848c593af7bc03fb1d"))) (blake3 "c4ac0f9dbe06a68950ef2d999a411584bc8474b8576123848c593af7bc03fb1d")))
(build (build
(configure_make (configure_make
(configure_flags "--disable-docs --enable-vmdk --enable-tools --enable-png")))) (configure_flags "--disable-docs --enable-vmdk --enable-tools"))))

View File

@@ -2,7 +2,7 @@
(name "rsync") (name "rsync")
(version "3.4.1") (version "3.4.1")
(homepage "https://rsync.samba.org/") (homepage "https://rsync.samba.org/")
(dependencies openssl libxxhash zstd lz4) (dependencies libopenssl libxxhash zstd lz4)
(src (tar (src (tar
(url "https://download.samba.org/pub/rsync/src/rsync-3.4.1.tar.gz") (url "https://download.samba.org/pub/rsync/src/rsync-3.4.1.tar.gz")
(dir "rsync-3.4.1") (dir "rsync-3.4.1")

View File

@@ -1,11 +0,0 @@
(package
(name "rust-bin")
(version "1.93.1")
(homepage "https://rust-lang.org/")
(dependencies xz)
(src (tar
(url "https://static.rust-lang.org/dist/rust-1.93.1-x86_64-unknown-linux-gnu.tar.xz")
(dir "rust-1.93.1-x86_64-unknown-linux-gnu")
(blake3 "1de14a92da1b8a2ddeddef6c744db0b46fc413bc67db6bd20bd6233b79fa2fd9")))
(build
(shell "./install.sh --prefix=/usr")))

16
packages/rustc.shrap Normal file
View File

@@ -0,0 +1,16 @@
(package
(name "rustc")
(version "1.93.1")
(homepage "https://rust-lang.org/")
(dependencies xz ninja cmake)
(src (tar
(url "https://static.rust-lang.org/dist/rustc-1.93.1-src.tar.xz")
(dir "rustc-1.93.1-src")
(blake3 "c8f492b93a95d64efb51fbcc5eab1e8edc1468a3f5be923c756b69d66892161a")))
(build
(shell "cp 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")))

View File

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