Offer to install Linux packages after a local build.
Add --install and an interactive TTY prompt to the Arch and Debian build scripts so the built package can be applied with pacman or apt. Co-authored-by: Cursor <cursoragent@cursor.com>
@@ -35,18 +35,21 @@ Options:
35
35
36
36
```bash
37
37
chmod +x scripts/build-linux.sh
38
./scripts/build-linux.sh # release binary
39
./scripts/build-linux.sh --deb # binary + .deb package
38
./scripts/build-linux.sh # release binary
39
./scripts/build-linux.sh --deb # binary + .deb (prompts to install if interactive)
40
./scripts/build-linux.sh --deb --install # build .deb and install with apt
40
41
```
41
42
42
43
On **Arch Linux**:
43
44
44
45
```bash
45
46
chmod +x scripts/build-arch.sh
46
./scripts/build-arch.sh # .pkg.tar.zst for pacman
47
sudo pacman -U packaging/arch/posprint-*-x86_64.pkg.tar.zst
47
./scripts/build-arch.sh # .pkg.tar.zst (prompts to install if interactive)
48
./scripts/build-arch.sh --install # build and install with pacman
48
49
```
49
50
51
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
50
53
Outputs:
51
54
52
55
| Artifact | Path |
@@ -35,18 +35,21 @@ Options:35
35
36
```bash
36
```bash
37
chmod +x scripts/build-linux.sh
37
chmod +x scripts/build-linux.sh
38
./scripts/build-linux.sh # release binary
38
./scripts/build-linux.sh # release binary
39
./scripts/build-linux.sh --deb # binary + .deb package
39
./scripts/build-linux.sh --deb # binary + .deb (prompts to install if interactive)
40
./scripts/build-linux.sh --deb --install # build .deb and install with apt
40
```
41
```
41
42
42
On **Arch Linux**:
43
On **Arch Linux**:
43
44
44
```bash
45
```bash
45
chmod +x scripts/build-arch.sh
46
chmod +x scripts/build-arch.sh
46
./scripts/build-arch.sh # .pkg.tar.zst for pacman
47
./scripts/build-arch.sh # .pkg.tar.zst (prompts to install if interactive)
47
sudo pacman -U packaging/arch/posprint-*-x86_64.pkg.tar.zst
48
./scripts/build-arch.sh --install # build and install with pacman
48
```
49
```
49
50
51
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
50
Outputs:
53
Outputs:
51
54
52
| Artifact | Path |
55
| Artifact | Path |
@@ -5,23 +5,38 @@ set -euo pipefail
5
5
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
6
6
cd "$ROOT"
7
7
8
BUILD_DEB=false
9
8
SKIP_TESTS=false
10
9
AS_ROOT=false
10
INSTALL=false
11
11
12
12
for arg in "$@"; do
13
13
case "$arg" in
14
14
--skip-tests) SKIP_TESTS=true ;;
15
15
--asroot) AS_ROOT=true ;;
16
--install) INSTALL=true ;;
16
17
-h|--help)
17
echo "Usage: $0 [--skip-tests] [--asroot]"
18
echo "Usage: $0 [--skip-tests] [--asroot] [--install]"
18
19
echo "Builds packaging/arch/posprint-<ver>-<rel>-x86_64.pkg.tar.zst"
20
echo " --install install the package with pacman after building"
21
echo "Without --install, prompts interactively when stdin is a TTY."
19
22
exit 0
20
23
;;
21
24
*) echo "Unknown option: $arg"; exit 1 ;;
22
25
esac
23
26
done
24
27
28
want_install() {
29
if [[ "$INSTALL" == "true" ]]; then
30
return 0
31
fi
32
if [[ ! -t 0 ]]; then
33
return 1
34
fi
35
local answer
36
read -r -p "Install the package now with pacman? [y/N] " answer
37
[[ "$answer" =~ ^[Yy]([Ee][Ss])?$ ]]
38
}
39
25
40
if ! command -v makepkg &>/dev/null; then
26
41
echo "makepkg not found. On Arch, install base-devel: sudo pacman -S base-devel"
27
42
exit 1
@@ -41,5 +56,19 @@ if [[ "$AS_ROOT" == "true" ]]; then
41
56
fi
42
57
makepkg "${MAKEPKG_FLAGS[@]}"
43
58
59
shopt -s nullglob
60
PACKAGES=(posprint-"${PKGVER}"-*-x86_64.pkg.tar.zst)
61
shopt -u nullglob
62
if [[ ${#PACKAGES[@]} -eq 0 ]]; then
63
echo "No package produced."
64
exit 1
65
fi
66
44
67
echo "Arch package:"
45
ls -lh posprint-"${PKGVER}"-*-x86_64.pkg.tar.zst
68
ls -lh "${PACKAGES[@]}"
69
70
if want_install; then
71
echo "Installing with pacman..."
72
sudo pacman -U --noconfirm "${PACKAGES[@]}"
73
echo "Installed."
74
fi
@@ -5,23 +5,38 @@ set -euo pipefail5
ROOT="$(cd "$(dirname "$0")/.." && pwd)"5
ROOT="$(cd "$(dirname "$0")/.." && pwd)"6
cd "$ROOT"6
cd "$ROOT"7
7
8
BUILD_DEB=false9
SKIP_TESTS=false8
SKIP_TESTS=false10
AS_ROOT=false9
AS_ROOT=false10
INSTALL=false11
11
12
for arg in "$@"; do12
for arg in "$@"; do13
case "$arg" in13
case "$arg" in14
--skip-tests) SKIP_TESTS=true ;;14
--skip-tests) SKIP_TESTS=true ;;15
--asroot) AS_ROOT=true ;;15
--asroot) AS_ROOT=true ;;16
--install) INSTALL=true ;;16
-h|--help)17
-h|--help)17
echo "Usage: $0 [--skip-tests] [--asroot]"18
echo "Usage: $0 [--skip-tests] [--asroot] [--install]"18
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"21
echo "Without --install, prompts interactively when stdin is a TTY."19
exit 022
exit 020
;;23
;;21
*) echo "Unknown option: $arg"; exit 1 ;;24
*) echo "Unknown option: $arg"; exit 1 ;;22
esac25
esac23
done26
done24
27
28
want_install() {29
if [[ "$INSTALL" == "true" ]]; then30
return 031
fi32
if [[ ! -t 0 ]]; then33
return 134
fi35
local answer36
read -r -p "Install the package now with pacman? [y/N] " answer37
[[ "$answer" =~ ^[Yy]([Ee][Ss])?$ ]]38
}39
25
if ! command -v makepkg &>/dev/null; then40
if ! command -v makepkg &>/dev/null; then26
echo "makepkg not found. On Arch, install base-devel: sudo pacman -S base-devel"41
echo "makepkg not found. On Arch, install base-devel: sudo pacman -S base-devel"27
exit 142
exit 1@@ -41,5 +56,19 @@ if [[ "$AS_ROOT" == "true" ]]; then41
fi56
fi42
makepkg "${MAKEPKG_FLAGS[@]}"57
makepkg "${MAKEPKG_FLAGS[@]}"43
58
59
shopt -s nullglob60
PACKAGES=(posprint-"${PKGVER}"-*-x86_64.pkg.tar.zst)61
shopt -u nullglob62
if [[ ${#PACKAGES[@]} -eq 0 ]]; then63
echo "No package produced."64
exit 165
fi66
44
echo "Arch package:"67
echo "Arch package:"45
ls -lh posprint-"${PKGVER}"-*-x86_64.pkg.tar.zst68
ls -lh "${PACKAGES[@]}"69
70
if want_install; then71
echo "Installing with pacman..."72
sudo pacman -U --noconfirm "${PACKAGES[@]}"73
echo "Installed."74
fi@@ -6,15 +6,41 @@ cd "$ROOT"
6
6
7
7
BUILD_DEB=false
8
8
SKIP_TESTS=false
9
INSTALL=false
9
10
10
11
for arg in "$@"; do
11
12
case "$arg" in
12
13
--deb) BUILD_DEB=true ;;
13
14
--skip-tests) SKIP_TESTS=true ;;
15
--install) INSTALL=true ;;
16
-h|--help)
17
echo "Usage: $0 [--deb] [--skip-tests] [--install]"
18
echo "Builds target/release/posprint (and optionally a .deb)."
19
echo " --deb also build a Debian package with cargo-deb"
20
echo " --install install the .deb with apt after building (implies --deb)"
21
echo "Without --install, prompts interactively for .deb install when stdin is a TTY."
22
exit 0
23
;;
14
24
*) echo "Unknown option: $arg"; exit 1 ;;
15
25
esac
16
26
done
17
27
28
if [[ "$INSTALL" == "true" ]]; then
29
BUILD_DEB=true
30
fi
31
32
want_install() {
33
if [[ "$INSTALL" == "true" ]]; then
34
return 0
35
fi
36
if [[ ! -t 0 ]]; then
37
return 1
38
fi
39
local answer
40
read -r -p "Install the .deb now with apt? [y/N] " answer
41
[[ "$answer" =~ ^[Yy]([Ee][Ss])?$ ]]
42
}
43
18
44
echo "Building posprint for Linux (x86_64)..."
19
45
20
46
if [[ "$SKIP_TESTS" != "true" ]]; then
@@ -32,6 +58,20 @@ if [[ "$BUILD_DEB" == "true" ]]; then
32
58
cargo install cargo-deb --locked
33
59
fi
34
60
cargo deb
61
shopt -s nullglob
62
DEBS=("$ROOT"/target/debian/*.deb)
63
shopt -u nullglob
64
if [[ ${#DEBS[@]} -eq 0 ]]; then
65
echo "No .deb produced."
66
exit 1
67
fi
35
68
echo "Debian packages:"
36
ls -lh "$ROOT/target/debian/"*.deb
69
ls -lh "${DEBS[@]}"
70
71
if want_install; then
72
echo "Installing with apt..."
73
# Relative path so apt treats it as a local package file.
74
sudo apt-get install -y "${DEBS[@]}"
75
echo "Installed."
76
fi
37
77
fi
@@ -6,15 +6,41 @@ cd "$ROOT"6
6
7
BUILD_DEB=false7
BUILD_DEB=false8
SKIP_TESTS=false8
SKIP_TESTS=false9
INSTALL=false9
10
10
for arg in "$@"; do11
for arg in "$@"; do11
case "$arg" in12
case "$arg" in12
--deb) BUILD_DEB=true ;;13
--deb) BUILD_DEB=true ;;13
--skip-tests) SKIP_TESTS=true ;;14
--skip-tests) SKIP_TESTS=true ;;15
--install) INSTALL=true ;;16
-h|--help)17
echo "Usage: $0 [--deb] [--skip-tests] [--install]"18
echo "Builds target/release/posprint (and optionally a .deb)."19
echo " --deb also build a Debian package with cargo-deb"20
echo " --install install the .deb with apt after building (implies --deb)"21
echo "Without --install, prompts interactively for .deb install when stdin is a TTY."22
exit 023
;;14
*) echo "Unknown option: $arg"; exit 1 ;;24
*) echo "Unknown option: $arg"; exit 1 ;;15
esac25
esac16
done26
done17
27
28
if [[ "$INSTALL" == "true" ]]; then29
BUILD_DEB=true30
fi31
32
want_install() {33
if [[ "$INSTALL" == "true" ]]; then34
return 035
fi36
if [[ ! -t 0 ]]; then37
return 138
fi39
local answer40
read -r -p "Install the .deb now with apt? [y/N] " answer41
[[ "$answer" =~ ^[Yy]([Ee][Ss])?$ ]]42
}43
18
echo "Building posprint for Linux (x86_64)..."44
echo "Building posprint for Linux (x86_64)..."19
45
20
if [[ "$SKIP_TESTS" != "true" ]]; then46
if [[ "$SKIP_TESTS" != "true" ]]; then@@ -32,6 +58,20 @@ if [[ "$BUILD_DEB" == "true" ]]; then32
cargo install cargo-deb --locked58
cargo install cargo-deb --locked33
fi59
fi34
cargo deb60
cargo deb61
shopt -s nullglob62
DEBS=("$ROOT"/target/debian/*.deb)63
shopt -u nullglob64
if [[ ${#DEBS[@]} -eq 0 ]]; then65
echo "No .deb produced."66
exit 167
fi35
echo "Debian packages:"68
echo "Debian packages:"36
ls -lh "$ROOT/target/debian/"*.deb69
ls -lh "${DEBS[@]}"70
71
if want_install; then72
echo "Installing with apt..."73
# Relative path so apt treats it as a local package file.74
sudo apt-get install -y "${DEBS[@]}"75
echo "Installed."76
fi37
fi77
fi