Offer to install missing build deps in interactive shells.
Linux/Arch/Windows scripts detect absent Rust and OS packages and prompt before installing; CI/non-TTY still exits with instructions. Co-authored-by: Cursor <cursoragent@cursor.com>
@@ -17,6 +17,8 @@ sudo pacman -S --needed rust
17
17
18
18
Also install the platform build libraries under **Linux build dependencies** below before `cargo test` / `cargo build`.
19
19
20
**Interactive shells:** the build scripts detect missing requirements (Rust, apt/pacman packages, `cargo-deb`, `base-devel`) and ask whether to install them automatically. Non-interactive runs (CI/pipes) never prompt; they print install instructions and exit.
21
20
22
## Windows
21
23
22
24
```powershell
@@ -25,10 +27,12 @@ Also install the platform build libraries under **Linux build dependencies** bel
25
27
26
28
Output: `target\release\posprint.exe`
27
29
30
If `cargo`/`rustc` are missing and the shell is interactive, the script offers to install Rust via **winget** (`Rustlang.Rustup`) or **rustup-init**.
31
28
32
Options:
29
33
30
34
```powershell
31
.\scripts\build-windows.ps1 -Deb:$false # exe only (default)
35
.\scripts\build-windows.ps1 -SkipTests
32
36
```
33
37
34
38
## Linux
@@ -40,6 +44,8 @@ chmod +x scripts/build-linux.sh
40
44
./scripts/build-linux.sh --deb --install # build .deb and install with apt
41
45
```
42
46
47
On a TTY, missing **apt** build packages and (with `--deb`) **cargo-deb** are offered for install before building.
48
43
49
On **Arch Linux**:
44
50
45
51
```bash
@@ -48,6 +54,8 @@ chmod +x scripts/build-arch.sh
48
54
./scripts/build-arch.sh --install # build and install with pacman
49
55
```
50
56
57
On a TTY, missing **base-devel**, Rust, and common pacman build libs are offered for install before building.
58
51
59
`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
60
53
61
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.
@@ -17,6 +17,8 @@ sudo pacman -S --needed rust17
17
18
Also install the platform build libraries under **Linux build dependencies** below before `cargo test` / `cargo build`.18
Also install the platform build libraries under **Linux build dependencies** below before `cargo test` / `cargo build`.19
19
20
**Interactive shells:** the build scripts detect missing requirements (Rust, apt/pacman packages, `cargo-deb`, `base-devel`) and ask whether to install them automatically. Non-interactive runs (CI/pipes) never prompt; they print install instructions and exit.21
20
## Windows22
## Windows21
23
22
```powershell24
```powershell@@ -25,10 +27,12 @@ Also install the platform build libraries under **Linux build dependencies** bel25
27
26
Output: `target\release\posprint.exe`28
Output: `target\release\posprint.exe`27
29
30
If `cargo`/`rustc` are missing and the shell is interactive, the script offers to install Rust via **winget** (`Rustlang.Rustup`) or **rustup-init**.31
28
Options:32
Options:29
33
30
```powershell34
```powershell31
.\scripts\build-windows.ps1 -Deb:$false # exe only (default)35
.\scripts\build-windows.ps1 -SkipTests32
```36
```33
37
34
## Linux38
## Linux@@ -40,6 +44,8 @@ chmod +x scripts/build-linux.sh40
./scripts/build-linux.sh --deb --install # build .deb and install with apt44
./scripts/build-linux.sh --deb --install # build .deb and install with apt41
```45
```42
46
47
On a TTY, missing **apt** build packages and (with `--deb`) **cargo-deb** are offered for install before building.48
43
On **Arch Linux**:49
On **Arch Linux**:44
50
45
```bash51
```bash@@ -48,6 +54,8 @@ chmod +x scripts/build-arch.sh48
./scripts/build-arch.sh --install # build and install with pacman54
./scripts/build-arch.sh --install # build and install with pacman49
```55
```50
56
57
On a TTY, missing **base-devel**, Rust, and common pacman build libs are offered for install before building.58
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).59
`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
60
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.61
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.@@ -18,6 +18,7 @@ for arg in "$@"; do
18
18
echo "Usage: $0 [--skip-tests] [--asroot] [--install]"
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
echo "On a TTY, missing build dependencies are offered for automatic install."
21
22
echo "Without --install, prompts interactively when stdin is a TTY."
22
23
echo "Uses rustup/cargo on PATH; runs makepkg --nodeps if pacman rust/cargo are absent."
23
24
exit 0
@@ -26,33 +27,123 @@ for arg in "$@"; do
26
27
esac
27
28
done
28
29
30
is_interactive() {
31
[[ -t 0 ]]
32
}
33
34
ask_yes_no() {
35
local prompt="$1"
36
if ! is_interactive; then
37
return 1
38
fi
39
local answer
40
read -r -p "$prompt [y/N] " answer
41
[[ "$answer" =~ ^[Yy]([Ee][Ss])?$ ]]
42
}
43
29
44
want_install() {
30
45
if [[ "$INSTALL" == "true" ]]; then
31
46
return 0
32
47
fi
33
if [[ ! -t 0 ]]; then
48
if ! is_interactive; then
34
49
return 1
35
50
fi
36
local answer
37
read -r -p "Install the package now with pacman? [y/N] " answer
38
[[ "$answer" =~ ^[Yy]([Ee][Ss])?$ ]]
51
ask_yes_no "Install the package now with pacman?"
39
52
}
40
53
41
if ! command -v makepkg &>/dev/null; then
42
echo "makepkg not found. On Arch, install base-devel: sudo pacman -S base-devel"
43
exit 1
44
fi
45
46
54
# Ensure rustup toolchains are visible to makepkg's build().
47
55
if [[ -f "$HOME/.cargo/env" ]]; then
48
56
# shellcheck source=/dev/null
49
57
source "$HOME/.cargo/env"
50
58
fi
51
59
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
60
ensure_makepkg() {
61
if command -v makepkg &>/dev/null; then
62
return 0
63
fi
64
65
echo "makepkg not found (base-devel)."
66
if ask_yes_no "Install base-devel with pacman now?"; then
67
sudo pacman -S --needed --noconfirm base-devel
68
else
69
echo "Install manually: sudo pacman -S base-devel"
70
exit 1
71
fi
72
73
if ! command -v makepkg &>/dev/null; then
74
echo "makepkg still not found after install."
75
exit 1
76
fi
77
}
78
79
ensure_rust() {
80
if command -v cargo &>/dev/null && command -v rustc &>/dev/null; then
81
return 0
82
fi
83
84
echo "cargo/rustc not found."
85
if ask_yes_no "Install Rust via rustup now?"; then
86
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
87
# shellcheck source=/dev/null
88
source "$HOME/.cargo/env"
89
elif ask_yes_no "Install pacman rust/cargo packages instead?"; then
90
sudo pacman -S --needed --noconfirm rust
91
else
92
echo "Install via rustup (https://rustup.rs) or: sudo pacman -S rust"
93
exit 1
94
fi
95
96
if ! command -v cargo &>/dev/null || ! command -v rustc &>/dev/null; then
97
echo "Rust install finished but cargo/rustc still not on PATH. Open a new shell or: source \"\$HOME/.cargo/env\""
98
exit 1
99
fi
100
}
101
102
ensure_arch_build_deps() {
103
if ! command -v pacman &>/dev/null; then
104
return 0
105
fi
106
107
# Runtime/build libs commonly needed for egui + serialport (beyond base-devel).
108
local pkgs=(
109
pkgconf
110
openssl
111
libxkbcommon
112
libxcb
113
dbus
114
wayland
115
libx11
116
fontconfig
117
freetype2
118
libglvnd
119
git
120
rsync
121
)
122
local missing=()
123
local pkg
124
for pkg in "${pkgs[@]}"; do
125
if ! pacman -Q "$pkg" &>/dev/null; then
126
missing+=("$pkg")
127
fi
128
done
129
130
if [[ ${#missing[@]} -eq 0 ]]; then
131
return 0
132
fi
133
134
echo "Missing pacman packages: ${missing[*]}"
135
if ask_yes_no "Install them with pacman now?"; then
136
sudo pacman -S --needed --noconfirm "${missing[@]}"
137
else
138
echo "Install manually, then re-run:"
139
echo " sudo pacman -S --needed ${missing[*]}"
140
exit 1
141
fi
142
}
143
144
ensure_makepkg
145
ensure_rust
146
ensure_arch_build_deps
56
147
57
148
# PKGBUILD lists pacman rust/cargo as makedepends. rustup installs don't register
58
149
# those packages, so skip dep resolution when the toolchain is already on PATH.
@@ -18,6 +18,7 @@ for arg in "$@"; do18
echo "Usage: $0 [--skip-tests] [--asroot] [--install]"18
echo "Usage: $0 [--skip-tests] [--asroot] [--install]"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 "On a TTY, missing build dependencies are offered for automatic install."21
echo "Without --install, prompts interactively when stdin is a TTY."22
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."23
echo "Uses rustup/cargo on PATH; runs makepkg --nodeps if pacman rust/cargo are absent."23
exit 024
exit 0@@ -26,33 +27,123 @@ for arg in "$@"; do26
esac27
esac27
done28
done28
29
30
is_interactive() {31
[[ -t 0 ]]32
}33
34
ask_yes_no() {35
local prompt="$1"36
if ! is_interactive; then37
return 138
fi39
local answer40
read -r -p "$prompt [y/N] " answer41
[[ "$answer" =~ ^[Yy]([Ee][Ss])?$ ]]42
}43
29
want_install() {44
want_install() {30
if [[ "$INSTALL" == "true" ]]; then45
if [[ "$INSTALL" == "true" ]]; then31
return 046
return 032
fi47
fi33
if [[ ! -t 0 ]]; then48
if ! is_interactive; then34
return 149
return 135
fi50
fi36
local answer51
ask_yes_no "Install the package now with pacman?"37
read -r -p "Install the package now with pacman? [y/N] " answer38
[[ "$answer" =~ ^[Yy]([Ee][Ss])?$ ]]39
}52
}40
53
41
if ! command -v makepkg &>/dev/null; then42
echo "makepkg not found. On Arch, install base-devel: sudo pacman -S base-devel"43
exit 144
fi45
46
# Ensure rustup toolchains are visible to makepkg's build().54
# Ensure rustup toolchains are visible to makepkg's build().47
if [[ -f "$HOME/.cargo/env" ]]; then55
if [[ -f "$HOME/.cargo/env" ]]; then48
# shellcheck source=/dev/null56
# shellcheck source=/dev/null49
source "$HOME/.cargo/env"57
source "$HOME/.cargo/env"50
fi58
fi51
59
52
if ! command -v cargo &>/dev/null || ! command -v rustc &>/dev/null; then60
ensure_makepkg() {53
echo "cargo/rustc not found. Install via rustup (https://rustup.rs) or: sudo pacman -S rust"61
if command -v makepkg &>/dev/null; then54
exit 162
return 055
fi63
fi64
65
echo "makepkg not found (base-devel)."66
if ask_yes_no "Install base-devel with pacman now?"; then67
sudo pacman -S --needed --noconfirm base-devel68
else69
echo "Install manually: sudo pacman -S base-devel"70
exit 171
fi72
73
if ! command -v makepkg &>/dev/null; then74
echo "makepkg still not found after install."75
exit 176
fi77
}78
79
ensure_rust() {80
if command -v cargo &>/dev/null && command -v rustc &>/dev/null; then81
return 082
fi83
84
echo "cargo/rustc not found."85
if ask_yes_no "Install Rust via rustup now?"; then86
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y87
# shellcheck source=/dev/null88
source "$HOME/.cargo/env"89
elif ask_yes_no "Install pacman rust/cargo packages instead?"; then90
sudo pacman -S --needed --noconfirm rust91
else92
echo "Install via rustup (https://rustup.rs) or: sudo pacman -S rust"93
exit 194
fi95
96
if ! command -v cargo &>/dev/null || ! command -v rustc &>/dev/null; then97
echo "Rust install finished but cargo/rustc still not on PATH. Open a new shell or: source \"\$HOME/.cargo/env\""98
exit 199
fi100
}101
102
ensure_arch_build_deps() {103
if ! command -v pacman &>/dev/null; then104
return 0105
fi106
107
# Runtime/build libs commonly needed for egui + serialport (beyond base-devel).108
local pkgs=(109
pkgconf110
openssl111
libxkbcommon112
libxcb113
dbus114
wayland115
libx11116
fontconfig117
freetype2118
libglvnd119
git120
rsync121
)122
local missing=()123
local pkg124
for pkg in "${pkgs[@]}"; do125
if ! pacman -Q "$pkg" &>/dev/null; then126
missing+=("$pkg")127
fi128
done129
130
if [[ ${#missing[@]} -eq 0 ]]; then131
return 0132
fi133
134
echo "Missing pacman packages: ${missing[*]}"135
if ask_yes_no "Install them with pacman now?"; then136
sudo pacman -S --needed --noconfirm "${missing[@]}"137
else138
echo "Install manually, then re-run:"139
echo " sudo pacman -S --needed ${missing[*]}"140
exit 1141
fi142
}143
144
ensure_makepkg145
ensure_rust146
ensure_arch_build_deps56
147
57
# PKGBUILD lists pacman rust/cargo as makedepends. rustup installs don't register148
# PKGBUILD lists pacman rust/cargo as makedepends. rustup installs don't register58
# those packages, so skip dep resolution when the toolchain is already on PATH.149
# those packages, so skip dep resolution when the toolchain is already on PATH.@@ -18,6 +18,7 @@ for arg in "$@"; do
18
18
echo "Builds target/release/posprint (and optionally a .deb)."
19
19
echo " --deb also build a Debian package with cargo-deb"
20
20
echo " --install install the .deb with apt after building (implies --deb)"
21
echo "On a TTY, missing build dependencies are offered for automatic install."
21
22
echo "Without --install, prompts interactively for .deb install when stdin is a TTY."
22
23
exit 0
23
24
;;
@@ -29,18 +30,112 @@ if [[ "$INSTALL" == "true" ]]; then
29
30
BUILD_DEB=true
30
31
fi
31
32
33
is_interactive() {
34
[[ -t 0 ]]
35
}
36
37
ask_yes_no() {
38
local prompt="$1"
39
if ! is_interactive; then
40
return 1
41
fi
42
local answer
43
read -r -p "$prompt [y/N] " answer
44
[[ "$answer" =~ ^[Yy]([Ee][Ss])?$ ]]
45
}
46
32
47
want_install() {
33
48
if [[ "$INSTALL" == "true" ]]; then
34
49
return 0
35
50
fi
36
if [[ ! -t 0 ]]; then
51
if ! is_interactive; then
37
52
return 1
38
53
fi
39
local answer
40
read -r -p "Install the .deb now with apt? [y/N] " answer
41
[[ "$answer" =~ ^[Yy]([Ee][Ss])?$ ]]
54
ask_yes_no "Install the .deb now with apt?"
55
}
56
57
# Make rustup toolchains visible when installed but not yet on PATH.
58
if [[ -f "$HOME/.cargo/env" ]]; then
59
# shellcheck source=/dev/null
60
source "$HOME/.cargo/env"
61
fi
62
63
ensure_rust() {
64
if command -v cargo &>/dev/null && command -v rustc &>/dev/null; then
65
return 0
66
fi
67
68
echo "cargo/rustc not found."
69
if ask_yes_no "Install Rust via rustup now?"; then
70
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
71
# shellcheck source=/dev/null
72
source "$HOME/.cargo/env"
73
else
74
echo "Install Rust from https://rustup.rs (or your distro packages), then re-run."
75
exit 1
76
fi
77
78
if ! command -v cargo &>/dev/null || ! command -v rustc &>/dev/null; then
79
echo "Rust install finished but cargo/rustc still not on PATH. Open a new shell or: source \"\$HOME/.cargo/env\""
80
exit 1
81
fi
42
82
}
43
83
84
ensure_debian_build_deps() {
85
if ! command -v apt-get &>/dev/null; then
86
return 0
87
fi
88
89
local pkgs=(
90
build-essential
91
pkg-config
92
libxcb-render0-dev
93
libxcb-shape0-dev
94
libxcb-xfixes0-dev
95
libxkbcommon-dev
96
libssl-dev
97
libudev-dev
98
)
99
local missing=()
100
local pkg
101
for pkg in "${pkgs[@]}"; do
102
if ! dpkg -s "$pkg" &>/dev/null; then
103
missing+=("$pkg")
104
fi
105
done
106
107
if [[ ${#missing[@]} -eq 0 ]]; then
108
return 0
109
fi
110
111
echo "Missing apt packages: ${missing[*]}"
112
if ask_yes_no "Install them with apt now?"; then
113
sudo apt-get update
114
sudo apt-get install -y "${missing[@]}"
115
else
116
echo "Install manually, then re-run:"
117
echo " sudo apt-get install -y ${missing[*]}"
118
exit 1
119
fi
120
}
121
122
ensure_cargo_deb() {
123
if command -v cargo-deb &>/dev/null; then
124
return 0
125
fi
126
127
echo "cargo-deb not found (needed for --deb)."
128
if ask_yes_no "Install cargo-deb with cargo now?"; then
129
cargo install cargo-deb --locked
130
else
131
echo "Install manually: cargo install cargo-deb --locked"
132
exit 1
133
fi
134
}
135
136
ensure_rust
137
ensure_debian_build_deps
138
44
139
echo "Building posprint for Linux (x86_64)..."
45
140
46
141
if [[ "$SKIP_TESTS" != "true" ]]; then
@@ -53,10 +148,7 @@ echo "OK: $BIN"
53
148
ls -lh "$BIN"
54
149
55
150
if [[ "$BUILD_DEB" == "true" ]]; then
56
if ! command -v cargo-deb &>/dev/null; then
57
echo "Installing cargo-deb..."
58
cargo install cargo-deb --locked
59
fi
151
ensure_cargo_deb
60
152
cargo deb
61
153
shopt -s nullglob
62
154
DEBS=("$ROOT"/target/debian/*.deb)
@@ -18,6 +18,7 @@ for arg in "$@"; do18
echo "Builds target/release/posprint (and optionally a .deb)."18
echo "Builds target/release/posprint (and optionally a .deb)."19
echo " --deb also build a Debian package with cargo-deb"19
echo " --deb also build a Debian package with cargo-deb"20
echo " --install install the .deb with apt after building (implies --deb)"20
echo " --install install the .deb with apt after building (implies --deb)"21
echo "On a TTY, missing build dependencies are offered for automatic install."21
echo "Without --install, prompts interactively for .deb install when stdin is a TTY."22
echo "Without --install, prompts interactively for .deb install when stdin is a TTY."22
exit 023
exit 023
;;24
;;@@ -29,18 +30,112 @@ if [[ "$INSTALL" == "true" ]]; then29
BUILD_DEB=true30
BUILD_DEB=true30
fi31
fi31
32
33
is_interactive() {34
[[ -t 0 ]]35
}36
37
ask_yes_no() {38
local prompt="$1"39
if ! is_interactive; then40
return 141
fi42
local answer43
read -r -p "$prompt [y/N] " answer44
[[ "$answer" =~ ^[Yy]([Ee][Ss])?$ ]]45
}46
32
want_install() {47
want_install() {33
if [[ "$INSTALL" == "true" ]]; then48
if [[ "$INSTALL" == "true" ]]; then34
return 049
return 035
fi50
fi36
if [[ ! -t 0 ]]; then51
if ! is_interactive; then37
return 152
return 138
fi53
fi39
local answer54
ask_yes_no "Install the .deb now with apt?"40
read -r -p "Install the .deb now with apt? [y/N] " answer55
}41
[[ "$answer" =~ ^[Yy]([Ee][Ss])?$ ]]56
57
# Make rustup toolchains visible when installed but not yet on PATH.58
if [[ -f "$HOME/.cargo/env" ]]; then59
# shellcheck source=/dev/null60
source "$HOME/.cargo/env"61
fi62
63
ensure_rust() {64
if command -v cargo &>/dev/null && command -v rustc &>/dev/null; then65
return 066
fi67
68
echo "cargo/rustc not found."69
if ask_yes_no "Install Rust via rustup now?"; then70
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y71
# shellcheck source=/dev/null72
source "$HOME/.cargo/env"73
else74
echo "Install Rust from https://rustup.rs (or your distro packages), then re-run."75
exit 176
fi77
78
if ! command -v cargo &>/dev/null || ! command -v rustc &>/dev/null; then79
echo "Rust install finished but cargo/rustc still not on PATH. Open a new shell or: source \"\$HOME/.cargo/env\""80
exit 181
fi42
}82
}43
83
84
ensure_debian_build_deps() {85
if ! command -v apt-get &>/dev/null; then86
return 087
fi88
89
local pkgs=(90
build-essential91
pkg-config92
libxcb-render0-dev93
libxcb-shape0-dev94
libxcb-xfixes0-dev95
libxkbcommon-dev96
libssl-dev97
libudev-dev98
)99
local missing=()100
local pkg101
for pkg in "${pkgs[@]}"; do102
if ! dpkg -s "$pkg" &>/dev/null; then103
missing+=("$pkg")104
fi105
done106
107
if [[ ${#missing[@]} -eq 0 ]]; then108
return 0109
fi110
111
echo "Missing apt packages: ${missing[*]}"112
if ask_yes_no "Install them with apt now?"; then113
sudo apt-get update114
sudo apt-get install -y "${missing[@]}"115
else116
echo "Install manually, then re-run:"117
echo " sudo apt-get install -y ${missing[*]}"118
exit 1119
fi120
}121
122
ensure_cargo_deb() {123
if command -v cargo-deb &>/dev/null; then124
return 0125
fi126
127
echo "cargo-deb not found (needed for --deb)."128
if ask_yes_no "Install cargo-deb with cargo now?"; then129
cargo install cargo-deb --locked130
else131
echo "Install manually: cargo install cargo-deb --locked"132
exit 1133
fi134
}135
136
ensure_rust137
ensure_debian_build_deps138
44
echo "Building posprint for Linux (x86_64)..."139
echo "Building posprint for Linux (x86_64)..."45
140
46
if [[ "$SKIP_TESTS" != "true" ]]; then141
if [[ "$SKIP_TESTS" != "true" ]]; then@@ -53,10 +148,7 @@ echo "OK: $BIN"53
ls -lh "$BIN"148
ls -lh "$BIN"54
149
55
if [[ "$BUILD_DEB" == "true" ]]; then150
if [[ "$BUILD_DEB" == "true" ]]; then56
if ! command -v cargo-deb &>/dev/null; then151
ensure_cargo_deb57
echo "Installing cargo-deb..."58
cargo install cargo-deb --locked59
fi60
cargo deb152
cargo deb61
shopt -s nullglob153
shopt -s nullglob62
DEBS=("$ROOT"/target/debian/*.deb)154
DEBS=("$ROOT"/target/debian/*.deb)@@ -7,6 +7,68 @@ $ErrorActionPreference = "Stop"
7
7
$Root = Split-Path -Parent $PSScriptRoot
8
8
Set-Location $Root
9
9
10
function Test-IsInteractive {
11
try {
12
return [Environment]::UserInteractive -and -not [Console]::IsInputRedirected
13
} catch {
14
return $Host.Name -eq "ConsoleHost"
15
}
16
}
17
18
function Ask-YesNo([string]$Prompt) {
19
if (-not (Test-IsInteractive)) {
20
return $false
21
}
22
$answer = Read-Host "$Prompt [y/N]"
23
return $answer -match '^[Yy]([Ee][Ss])?$'
24
}
25
26
function Ensure-Rust {
27
if ((Get-Command cargo -ErrorAction SilentlyContinue) -and (Get-Command rustc -ErrorAction SilentlyContinue)) {
28
return
29
}
30
31
$cargoEnv = Join-Path $env:USERPROFILE ".cargo\env"
32
if (Test-Path $cargoEnv) {
33
# Best-effort: put cargo on PATH for this session if rustup is installed.
34
$cargoBin = Join-Path $env:USERPROFILE ".cargo\bin"
35
if ((Test-Path $cargoBin) -and ($env:PATH -notlike "*$cargoBin*")) {
36
$env:PATH = "$cargoBin;$env:PATH"
37
}
38
}
39
40
if ((Get-Command cargo -ErrorAction SilentlyContinue) -and (Get-Command rustc -ErrorAction SilentlyContinue)) {
41
return
42
}
43
44
Write-Host "cargo/rustc not found."
45
46
$winget = Get-Command winget -ErrorAction SilentlyContinue
47
if ($winget -and (Ask-YesNo "Install Rust via winget (Rustlang.Rustup) now?")) {
48
& winget install --id Rustlang.Rustup -e --accept-package-agreements --accept-source-agreements
49
$cargoBin = Join-Path $env:USERPROFILE ".cargo\bin"
50
if ((Test-Path $cargoBin) -and ($env:PATH -notlike "*$cargoBin*")) {
51
$env:PATH = "$cargoBin;$env:PATH"
52
}
53
} elseif (Ask-YesNo "Download and run rustup-init.exe now?") {
54
$tmp = Join-Path $env:TEMP "rustup-init.exe"
55
Invoke-WebRequest -Uri "https://win.rustup.rs/x86_64" -OutFile $tmp
56
& $tmp -y
57
$cargoBin = Join-Path $env:USERPROFILE ".cargo\bin"
58
if ((Test-Path $cargoBin) -and ($env:PATH -notlike "*$cargoBin*")) {
59
$env:PATH = "$cargoBin;$env:PATH"
60
}
61
} else {
62
Write-Error "Install Rust from https://rustup.rs (or: winget install Rustlang.Rustup), then re-run this script."
63
}
64
65
if (-not (Get-Command cargo -ErrorAction SilentlyContinue) -or -not (Get-Command rustc -ErrorAction SilentlyContinue)) {
66
Write-Error "Rust install finished but cargo/rustc are still not on PATH. Open a new PowerShell window and re-run."
67
}
68
}
69
70
Ensure-Rust
71
10
72
Write-Host "Building posprint for Windows (x64)..."
11
73
12
74
if (-not $SkipTests) {
@@ -7,6 +7,68 @@ $ErrorActionPreference = "Stop"7
$Root = Split-Path -Parent $PSScriptRoot7
$Root = Split-Path -Parent $PSScriptRoot8
Set-Location $Root8
Set-Location $Root9
9
10
function Test-IsInteractive {11
try {12
return [Environment]::UserInteractive -and -not [Console]::IsInputRedirected13
} catch {14
return $Host.Name -eq "ConsoleHost"15
}16
}17
18
function Ask-YesNo([string]$Prompt) {19
if (-not (Test-IsInteractive)) {20
return $false21
}22
$answer = Read-Host "$Prompt [y/N]"23
return $answer -match '^[Yy]([Ee][Ss])?$'24
}25
26
function Ensure-Rust {27
if ((Get-Command cargo -ErrorAction SilentlyContinue) -and (Get-Command rustc -ErrorAction SilentlyContinue)) {28
return29
}30
31
$cargoEnv = Join-Path $env:USERPROFILE ".cargo\env"32
if (Test-Path $cargoEnv) {33
# Best-effort: put cargo on PATH for this session if rustup is installed.34
$cargoBin = Join-Path $env:USERPROFILE ".cargo\bin"35
if ((Test-Path $cargoBin) -and ($env:PATH -notlike "*$cargoBin*")) {36
$env:PATH = "$cargoBin;$env:PATH"37
}38
}39
40
if ((Get-Command cargo -ErrorAction SilentlyContinue) -and (Get-Command rustc -ErrorAction SilentlyContinue)) {41
return42
}43
44
Write-Host "cargo/rustc not found."45
46
$winget = Get-Command winget -ErrorAction SilentlyContinue47
if ($winget -and (Ask-YesNo "Install Rust via winget (Rustlang.Rustup) now?")) {48
& winget install --id Rustlang.Rustup -e --accept-package-agreements --accept-source-agreements49
$cargoBin = Join-Path $env:USERPROFILE ".cargo\bin"50
if ((Test-Path $cargoBin) -and ($env:PATH -notlike "*$cargoBin*")) {51
$env:PATH = "$cargoBin;$env:PATH"52
}53
} elseif (Ask-YesNo "Download and run rustup-init.exe now?") {54
$tmp = Join-Path $env:TEMP "rustup-init.exe"55
Invoke-WebRequest -Uri "https://win.rustup.rs/x86_64" -OutFile $tmp56
& $tmp -y57
$cargoBin = Join-Path $env:USERPROFILE ".cargo\bin"58
if ((Test-Path $cargoBin) -and ($env:PATH -notlike "*$cargoBin*")) {59
$env:PATH = "$cargoBin;$env:PATH"60
}61
} else {62
Write-Error "Install Rust from https://rustup.rs (or: winget install Rustlang.Rustup), then re-run this script."63
}64
65
if (-not (Get-Command cargo -ErrorAction SilentlyContinue) -or -not (Get-Command rustc -ErrorAction SilentlyContinue)) {66
Write-Error "Rust install finished but cargo/rustc are still not on PATH. Open a new PowerShell window and re-run."67
}68
}69
70
Ensure-Rust71
10
Write-Host "Building posprint for Windows (x64)..."72
Write-Host "Building posprint for Windows (x64)..."11
73
12
if (-not $SkipTests) {74
if (-not $SkipTests) {