BlueGit

timfa posprint

Merge branch 'fix/arch-makepkg-rustup'

timfa Tim Falken · pushed by timfa

Authored 2026-07-16 · 4 months ago

Hash
9dd9f3bba6fb13484b1b367e3ced84787b948800
2 files changed +26 −0
docs/BUILD.md +2 −0
@@ -48,6 +48,8 @@ chmod +x scripts/build-arch.sh
48 48 ./scripts/build-arch.sh --install # build and install with pacman
49 49 ```
50 50
51 `build-arch.sh` accepts a **rustup** toolchain on `PATH`. If the pacman `rust`/`cargo` packages are not installed, it runs `makepkg --nodeps` after verifying `rustc`/`cargo` work (the PKGBUILD still lists those packages for AUR/CI).
52
51 53 After a successful package build, both scripts ask whether to install (TTY only). Pass `--install` to skip the prompt and install automatically. Non-interactive runs (CI/pipes) never prompt.
52 54
53 55 Outputs:
@@ -48,6 +48,8 @@ chmod +x scripts/build-arch.sh
48./scripts/build-arch.sh --install # build and install with pacman
48./scripts/build-arch.sh --install # build and install with pacman
49```
49```
50
50
51`build-arch.sh` accepts a **rustup** toolchain on `PATH`. If the pacman `rust`/`cargo` packages are not installed, it runs `makepkg --nodeps` after verifying `rustc`/`cargo` work (the PKGBUILD still lists those packages for AUR/CI).
52
51After a successful package build, both scripts ask whether to install (TTY only). Pass `--install` to skip the prompt and install automatically. Non-interactive runs (CI/pipes) never prompt.
53After a successful package build, both scripts ask whether to install (TTY only). Pass `--install` to skip the prompt and install automatically. Non-interactive runs (CI/pipes) never prompt.
52
54
53Outputs:
55Outputs:
scripts/build-arch.sh +24 −0
@@ -19,6 +19,7 @@ for arg in "$@"; do
19 19 echo "Builds packaging/arch/posprint-<ver>-<rel>-x86_64.pkg.tar.zst"
20 20 echo " --install install the package with pacman after building"
21 21 echo "Without --install, prompts interactively when stdin is a TTY."
22 echo "Uses rustup/cargo on PATH; runs makepkg --nodeps if pacman rust/cargo are absent."
22 23 exit 0
23 24 ;;
24 25 *) echo "Unknown option: $arg"; exit 1 ;;
@@ -42,6 +43,26 @@ if ! command -v makepkg &>/dev/null; then
42 43 exit 1
43 44 fi
44 45
46 # Ensure rustup toolchains are visible to makepkg's build().
47 if [[ -f "$HOME/.cargo/env" ]]; then
48 # shellcheck source=/dev/null
49 source "$HOME/.cargo/env"
50 fi
51
52 if ! command -v cargo &>/dev/null || ! command -v rustc &>/dev/null; then
53 echo "cargo/rustc not found. Install via rustup (https://rustup.rs) or: sudo pacman -S rust"
54 exit 1
55 fi
56
57 # PKGBUILD lists pacman rust/cargo as makedepends. rustup installs don't register
58 # those packages, so skip dep resolution when the toolchain is already on PATH.
59 MAKEPKG_NODEPS=false
60 if ! pacman -Q rust &>/dev/null || ! pacman -Q cargo &>/dev/null; then
61 echo "Note: pacman rust/cargo not installed; using toolchain on PATH ($(rustc --version))."
62 echo " makepkg will run with --nodeps."
63 MAKEPKG_NODEPS=true
64 fi
65
45 66 if [[ "$SKIP_TESTS" != "true" ]]; then
46 67 cargo test
47 68 fi
@@ -55,6 +76,9 @@ MAKEPKG_FLAGS=(-f --noconfirm)
55 76 if [[ "$AS_ROOT" == "true" ]]; then
56 77 MAKEPKG_FLAGS+=(--asroot)
57 78 fi
79 if [[ "$MAKEPKG_NODEPS" == "true" ]]; then
80 MAKEPKG_FLAGS+=(--nodeps)
81 fi
58 82 makepkg "${MAKEPKG_FLAGS[@]}"
59 83
60 84 shopt -s nullglob
@@ -19,6 +19,7 @@ for arg in "$@"; do
19 echo "Builds packaging/arch/posprint-<ver>-<rel>-x86_64.pkg.tar.zst"
19 echo "Builds packaging/arch/posprint-<ver>-<rel>-x86_64.pkg.tar.zst"
20 echo " --install install the package with pacman after building"
20 echo " --install install the package with pacman after building"
21 echo "Without --install, prompts interactively when stdin is a TTY."
21 echo "Without --install, prompts interactively when stdin is a TTY."
22 echo "Uses rustup/cargo on PATH; runs makepkg --nodeps if pacman rust/cargo are absent."
22 exit 0
23 exit 0
23 ;;
24 ;;
24 *) echo "Unknown option: $arg"; exit 1 ;;
25 *) echo "Unknown option: $arg"; exit 1 ;;
@@ -42,6 +43,26 @@ if ! command -v makepkg &>/dev/null; then
42 exit 1
43 exit 1
43fi
44fi
44
45
46# Ensure rustup toolchains are visible to makepkg's build().
47if [[ -f "$HOME/.cargo/env" ]]; then
48 # shellcheck source=/dev/null
49 source "$HOME/.cargo/env"
50fi
51
52if ! command -v cargo &>/dev/null || ! command -v rustc &>/dev/null; then
53 echo "cargo/rustc not found. Install via rustup (https://rustup.rs) or: sudo pacman -S rust"
54 exit 1
55fi
56
57# PKGBUILD lists pacman rust/cargo as makedepends. rustup installs don't register
58# those packages, so skip dep resolution when the toolchain is already on PATH.
59MAKEPKG_NODEPS=false
60if ! pacman -Q rust &>/dev/null || ! pacman -Q cargo &>/dev/null; then
61 echo "Note: pacman rust/cargo not installed; using toolchain on PATH ($(rustc --version))."
62 echo " makepkg will run with --nodeps."
63 MAKEPKG_NODEPS=true
64fi
65
45if [[ "$SKIP_TESTS" != "true" ]]; then
66if [[ "$SKIP_TESTS" != "true" ]]; then
46 cargo test
67 cargo test
47fi
68fi
@@ -55,6 +76,9 @@ MAKEPKG_FLAGS=(-f --noconfirm)
55if [[ "$AS_ROOT" == "true" ]]; then
76if [[ "$AS_ROOT" == "true" ]]; then
56 MAKEPKG_FLAGS+=(--asroot)
77 MAKEPKG_FLAGS+=(--asroot)
57fi
78fi
79if [[ "$MAKEPKG_NODEPS" == "true" ]]; then
80 MAKEPKG_FLAGS+=(--nodeps)
81fi
58makepkg "${MAKEPKG_FLAGS[@]}"
82makepkg "${MAKEPKG_FLAGS[@]}"
59
83
60shopt -s nullglob
84shopt -s nullglob