diff --git a/Cargo.lock b/Cargo.lock index 67520f5..f0b93b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -896,6 +896,21 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + [[package]] name = "form_urlencoded" version = "1.2.2" @@ -1634,6 +1649,22 @@ dependencies = [ "webpki-roots", ] +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + [[package]] name = "hyper-util" version = "0.1.20" @@ -2259,6 +2290,23 @@ dependencies = [ "getrandom 0.2.17", ] +[[package]] +name = "native-tls" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "465500e14ea162429d264d44189adc38b199b62b1c21eea9f69e4b73cb03bbf2" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + [[package]] name = "nix" version = "0.31.2" @@ -2503,12 +2551,50 @@ version = "1.70.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe" +[[package]] +name = "openssl" +version = "0.10.76" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "951c002c75e16ea2c65b8c7e4d3d51d5530d8dfa7d060b4776828c88cfb18ecf" +dependencies = [ + "bitflags 2.11.0", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.117", +] + [[package]] name = "openssl-probe" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c87def4c32ab89d880effc9e097653c8da5d6ef28e6b539d313baaacfbafcbe" +[[package]] +name = "openssl-sys" +version = "0.9.112" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d55af3b3e226502be1526dfdba67ab0e9c96fc293004e79576b2b9edb0dbdb" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "option-ext" version = "0.2.0" @@ -3066,10 +3152,12 @@ dependencies = [ "http-body-util", "hyper", "hyper-rustls", + "hyper-tls", "hyper-util", "js-sys", "log", "mime", + "native-tls", "percent-encoding", "pin-project-lite", "quinn", @@ -3080,6 +3168,7 @@ dependencies = [ "serde_json", "sync_wrapper", "tokio", + "tokio-native-tls", "tokio-rustls", "tower", "tower-http", @@ -3794,6 +3883,16 @@ dependencies = [ "windows-sys 0.61.2", ] +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + [[package]] name = "tokio-rustls" version = "0.26.4" @@ -4156,6 +4255,12 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version-compare" version = "0.2.1" diff --git a/aur/owlry-core/PKGBUILD b/aur/owlry-core/PKGBUILD index 5a5ac19..f24d730 100644 --- a/aur/owlry-core/PKGBUILD +++ b/aur/owlry-core/PKGBUILD @@ -6,7 +6,7 @@ pkgdesc='Core daemon for the Owlry application launcher — manages plugins, pro arch=('x86_64') url='https://somegit.dev/Owlibou/owlry' license=('GPL-3.0-or-later') -depends=('gcc-libs') +depends=('gcc-libs' 'openssl') makedepends=('cargo') source=("$pkgname-$pkgver.tar.gz::https://somegit.dev/Owlibou/owlry/archive/owlry-core-v$pkgver.tar.gz") b2sums=('e37383fd650a3bf9a2c554eb37676037e3ae72bbc2e1aad7c316809094254173b6fcd5ac87907c2f38ce5506e9f26201ec62f82446bc789153c280373e31fc9e') diff --git a/aur/owlry-lua/PKGBUILD b/aur/owlry-lua/PKGBUILD index 720eebc..34a7fb2 100644 --- a/aur/owlry-lua/PKGBUILD +++ b/aur/owlry-lua/PKGBUILD @@ -6,7 +6,7 @@ pkgdesc="Lua scripting runtime for Owlry — enables user-created Lua plugins" arch=('x86_64') url="https://somegit.dev/Owlibou/owlry" license=('GPL-3.0-or-later') -depends=('owlry-core') +depends=('owlry-core' 'openssl') makedepends=('cargo') source=("$pkgname-$pkgver.tar.gz::https://somegit.dev/Owlibou/owlry/archive/owlry-lua-v$pkgver.tar.gz") b2sums=('a0e1fa032db8dda8e6bc24457f3c04948129d3f14c1d3e61b8e080340b24f560d43294beb133ad4b1c6eb7942d401108ea91c367b074eaeeefa284e9b2a9dbc8') @@ -30,7 +30,7 @@ check() { cd "owlry" export RUSTUP_TOOLCHAIN=stable export CARGO_TARGET_DIR=target - cargo test -p $_cratename --frozen --release + cargo test -p $_cratename --frozen --lib } package() { diff --git a/aur/owlry-rune/PKGBUILD b/aur/owlry-rune/PKGBUILD index c1f77d8..1b6e162 100644 --- a/aur/owlry-rune/PKGBUILD +++ b/aur/owlry-rune/PKGBUILD @@ -6,7 +6,7 @@ pkgdesc="Rune scripting runtime for Owlry — enables user-created Rune plugins" arch=('x86_64') url="https://somegit.dev/Owlibou/owlry" license=('GPL-3.0-or-later') -depends=('owlry-core') +depends=('owlry-core' 'openssl') makedepends=('cargo') source=("$pkgname-$pkgver.tar.gz::https://somegit.dev/Owlibou/owlry/archive/owlry-rune-v$pkgver.tar.gz") b2sums=('a0e1fa032db8dda8e6bc24457f3c04948129d3f14c1d3e61b8e080340b24f560d43294beb133ad4b1c6eb7942d401108ea91c367b074eaeeefa284e9b2a9dbc8') diff --git a/crates/owlry-core/Cargo.toml b/crates/owlry-core/Cargo.toml index d68db17..fa95708 100644 --- a/crates/owlry-core/Cargo.toml +++ b/crates/owlry-core/Cargo.toml @@ -50,7 +50,7 @@ notify-rust = "4" # Built-in providers meval = "0.2" -reqwest = { version = "0.13", default-features = false, features = ["rustls", "json", "blocking"] } +reqwest = { version = "0.13", default-features = false, features = ["native-tls", "json", "blocking"] } # Optional: embedded Lua runtime mlua = { version = "0.11", features = ["lua54", "vendored", "send", "serialize"], optional = true } diff --git a/crates/owlry-lua/Cargo.toml b/crates/owlry-lua/Cargo.toml index 5cf9d51..f6bef9e 100644 --- a/crates/owlry-lua/Cargo.toml +++ b/crates/owlry-lua/Cargo.toml @@ -31,7 +31,7 @@ serde_json = "1.0" semver = "1" # HTTP client for plugins -reqwest = { version = "0.13", features = ["blocking", "json"] } +reqwest = { version = "0.13", default-features = false, features = ["native-tls", "blocking", "json"] } # Math expression evaluation meval = "0.2" diff --git a/crates/owlry-rune/Cargo.toml b/crates/owlry-rune/Cargo.toml index 74af385..cd21b3d 100644 --- a/crates/owlry-rune/Cargo.toml +++ b/crates/owlry-rune/Cargo.toml @@ -22,7 +22,7 @@ log = "0.4" env_logger = "0.11" # HTTP client for network API -reqwest = { version = "0.13", default-features = false, features = ["rustls", "json", "blocking"] } +reqwest = { version = "0.13", default-features = false, features = ["native-tls", "json", "blocking"] } # Serialization serde = { version = "1", features = ["derive"] } diff --git a/justfile b/justfile index 8211842..7e022e9 100644 --- a/justfile +++ b/justfile @@ -328,7 +328,7 @@ bump-meta new_version: # === Testing === -# Test a specific AUR package build locally +# Quick local build test (no chroot, uses host deps) aur-test-pkg pkg: #!/usr/bin/env bash set -euo pipefail @@ -337,3 +337,14 @@ aur-test-pkg pkg: makepkg -sf echo "Package built successfully!" ls -lh *.pkg.tar.zst + +# Build AUR packages from the local working tree in a clean chroot. +# Packages current source (incl. uncommitted changes), patches PKGBUILD, +# builds in dep order, injects local artifacts, restores PKGBUILD on exit. +# +# Examples: +# just aur-local-test owlry-core +# just aur-local-test -c owlry-core owlry-rune +# just aur-local-test --all --reset +aur-local-test *args: + scripts/aur-local-test {{args}} diff --git a/scripts/aur-local-test b/scripts/aur-local-test new file mode 100755 index 0000000..6b2b9cb --- /dev/null +++ b/scripts/aur-local-test @@ -0,0 +1,329 @@ +#!/usr/bin/env bash +# scripts/aur-local-test +# +# Build AUR packages from the local working tree in a clean extra chroot. +# +# Packages the current working tree (including uncommitted changes) into a +# tarball, temporarily patches each PKGBUILD to use it, runs +# extra-x86_64-build, then restores the PKGBUILD on exit regardless of +# success or failure. +# +# Packages with local AUR deps (e.g. owlry-rune depends on owlry-core) are +# built in topological order and their artifacts injected automatically. +# +# Usage: scripts/aur-local-test [OPTIONS] [PKG...] +# See --help for details. + +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel)" +REPO_NAME="$(basename "$REPO_ROOT")" +AUR_DIR="$REPO_ROOT/aur" + +# State tracked for cleanup +TMP_TARBALL="" +declare -a PKGBUILD_BACKUPS=() +declare -a PLACED_FILES=() + +# Build config +RESET_CHROOT=0 +declare -a INPUT_PKGS=() +declare -a EXTRA_INJECT=() # --inject paths (external AUR deps) + +# ─── Output helpers ────────────────────────────────────────────────────────── + +die() { echo "error: $*" >&2; exit 1; } +info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; } +ok() { printf '\033[1;32m ->\033[0m %s\n' "$*"; } +warn() { printf '\033[1;33m !\033[0m %s\n' "$*" >&2; } +fail() { printf '\033[1;31mFAIL\033[0m %s\n' "$*" >&2; } + +# ─── Cleanup ───────────────────────────────────────────────────────────────── + +cleanup() { + local code=$? + local f pkgbuild + + # Remove tarballs placed in aur/ dirs + for f in "${PLACED_FILES[@]+"${PLACED_FILES[@]}"}"; do + [[ -f "$f" ]] && rm -f "$f" + done + + # Restore patched PKGBUILDs from backups + for f in "${PKGBUILD_BACKUPS[@]+"${PKGBUILD_BACKUPS[@]}"}"; do + pkgbuild="${f%.bak}" + [[ -f "$f" ]] && mv "$f" "$pkgbuild" + done + + [[ -n "$TMP_TARBALL" && -f "$TMP_TARBALL" ]] && rm -f "$TMP_TARBALL" + + exit "$code" +} +trap cleanup EXIT INT TERM + +# ─── Usage ─────────────────────────────────────────────────────────────────── + +usage() { + cat >&2 </dev/null || wc -c < "$TMP_TARBALL") bytes" +} + +# ─── PKGBUILD patching ─────────────────────────────────────────────────────── + +# Patch a package's PKGBUILD to use the local tarball. +# Backs up the original; cleanup() restores it on exit. +patch_pkgbuild() { + local pkg="$1" + local pkgbuild="$AUR_DIR/$pkg/PKGBUILD" + local pkgdir="$AUR_DIR/$pkg" + + # Skip packages with no remote source (meta/group packages) + if ! grep -q '^source=' "$pkgbuild" || grep -qE '^source=\(\s*\)' "$pkgbuild"; then + ok "No source URL to patch — skipping tarball injection for $pkg" + return 0 + fi + + local pkgname pkgver filename hash + pkgname=$(grep '^pkgname=' "$pkgbuild" | cut -d= -f2- | tr -d "\"'") + pkgver=$(grep '^pkgver=' "$pkgbuild" | cut -d= -f2- | tr -d "\"'") + filename="${pkgname}-${pkgver}.tar.gz" + hash=$(b2sum "$TMP_TARBALL" | cut -d' ' -f1) + + # Backup original PKGBUILD + cp "$pkgbuild" "${pkgbuild}.bak" + PKGBUILD_BACKUPS+=("${pkgbuild}.bak") + + # Place local tarball where makepkg looks for it + cp "$TMP_TARBALL" "$pkgdir/$filename" + PLACED_FILES+=("$pkgdir/$filename") + + # Patch source and checksum lines in-place + sed -i "s|^source=.*|source=(\"${filename}\")|" "$pkgbuild" + sed -i "s|^b2sums=.*|b2sums=('${hash}')|" "$pkgbuild" + + ok "Patched PKGBUILD: source=${filename}, b2sum=${hash:0:12}…" +} + +# ─── Build ─────────────────────────────────────────────────────────────────── + +# built_artifacts[pkg] = path to the .pkg.tar.zst produced in this run. +# Used to inject pkg artifacts into dependent builds. +declare -A BUILT_ARTIFACTS=() + +find_artifact() { + local pkg="$1" + local pkgver + # pkgver is the same in patched and original PKGBUILD + pkgver=$(grep '^pkgver=' "$AUR_DIR/$pkg/PKGBUILD" | cut -d= -f2- | tr -d "\"'" \ + || grep '^pkgver=' "$AUR_DIR/$pkg/PKGBUILD.bak" | cut -d= -f2- | tr -d "\"'") + ls "$AUR_DIR/$pkg/${pkg}-${pkgver}-"*".pkg.tar.zst" 2>/dev/null \ + | grep -v -- '-debug-' | sort -V | tail -1 || true +} + +build_one() { + local pkg="$1" + local pkgdir="$AUR_DIR/$pkg" + + info "[$pkg] Patching PKGBUILD..." + patch_pkgbuild "$pkg" + + # Collect inject args: extra (external) + artifacts of local deps built earlier + local inject=() + for f in "${EXTRA_INJECT[@]+"${EXTRA_INJECT[@]}"}"; do + inject+=("-I" "$f") + done + while IFS= read -r dep; do + if [[ -v "BUILT_ARTIFACTS[$dep]" ]]; then + inject+=("-I" "${BUILT_ARTIFACTS[$dep]}") + else + warn "$pkg depends on $dep (local AUR) which was not built in this run" + warn " → Build $dep first or pass: -I path/to/${dep}-*.pkg.tar.zst" + fi + done < <(local_deps_of "$pkg") + + # Build args: -c only on the first package, then cleared + local build_args=() + if [[ $RESET_CHROOT -eq 1 ]]; then + build_args+=("-c") + RESET_CHROOT=0 + fi + + info "[$pkg] Running extra-x86_64-build..." + ( + cd "$pkgdir" + if [[ ${#inject[@]} -gt 0 ]]; then + extra-x86_64-build "${build_args[@]+"${build_args[@]}"}" -- "${inject[@]}" + else + extra-x86_64-build "${build_args[@]+"${build_args[@]}"}" + fi + ) + + # Record artifact for potential injection into dependents + local artifact + artifact=$(find_artifact "$pkg") + if [[ -n "$artifact" ]]; then + BUILT_ARTIFACTS[$pkg]="$artifact" + ok "[$pkg] artifact: $(basename "$artifact")" + fi +} + +# ─── Main ──────────────────────────────────────────────────────────────────── + +# Validate all requested packages exist +for pkg in "${INPUT_PKGS[@]}"; do + [[ -d "$AUR_DIR/$pkg" && -f "$AUR_DIR/$pkg/PKGBUILD" ]] \ + || die "package not found: aur/$pkg/PKGBUILD" +done + +# Sort into build order (deps before dependents) +resolve_order "${INPUT_PKGS[@]}" + +# Create one tarball, reused for all packages in this run +make_tarball + +declare -a FAILED=() + +for pkg in "${TOPO_ORDER[@]}"; do + echo "" + if build_one "$pkg"; then + : + else + fail "[$pkg]" + FAILED+=("$pkg") + fi +done + +echo "" +if [[ ${#FAILED[@]} -gt 0 ]]; then + fail "packages failed: ${FAILED[*]}" + exit 1 +fi + +info "All packages built successfully!"