BlueGit

timfa posprint

Merge branch 'feature/build-scripts-offer-install'

timfa Tim Falken · pushed by timfa

Authored 2026-07-16 · 4 months ago

Hash
93ea4c9af3456cc45ecb1c1b66bd6466e3e1905d
3 files changed +80 −8
docs/BUILD.md +7 −4
@@ -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
37chmod +x scripts/build-linux.sh
37chmod +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
42On **Arch Linux**:
43On **Arch Linux**:
43
44
44```bash
45```bash
45chmod +x scripts/build-arch.sh
46chmod +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)
47sudo 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
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.
52
50Outputs:
53Outputs:
51
54
52| Artifact | Path |
55| Artifact | Path |
scripts/build-arch.sh +32 −3
@@ -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 pipefail
5ROOT="$(cd "$(dirname "$0")/.." && pwd)"
5ROOT="$(cd "$(dirname "$0")/.." && pwd)"
6cd "$ROOT"
6cd "$ROOT"
7
7
8BUILD_DEB=false
9SKIP_TESTS=false
8SKIP_TESTS=false
10AS_ROOT=false
9AS_ROOT=false
10INSTALL=false
11
11
12for arg in "$@"; do
12for arg in "$@"; do
13 case "$arg" in
13 case "$arg" in
14 --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 0
22 exit 0
20 ;;
23 ;;
21 *) echo "Unknown option: $arg"; exit 1 ;;
24 *) echo "Unknown option: $arg"; exit 1 ;;
22 esac
25 esac
23done
26done
24
27
28want_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
25if ! command -v makepkg &>/dev/null; then
40if ! command -v makepkg &>/dev/null; then
26 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 1
42 exit 1
@@ -41,5 +56,19 @@ if [[ "$AS_ROOT" == "true" ]]; then
41fi
56fi
42makepkg "${MAKEPKG_FLAGS[@]}"
57makepkg "${MAKEPKG_FLAGS[@]}"
43
58
59shopt -s nullglob
60PACKAGES=(posprint-"${PKGVER}"-*-x86_64.pkg.tar.zst)
61shopt -u nullglob
62if [[ ${#PACKAGES[@]} -eq 0 ]]; then
63 echo "No package produced."
64 exit 1
65fi
66
44echo "Arch package:"
67echo "Arch package:"
45ls -lh posprint-"${PKGVER}"-*-x86_64.pkg.tar.zst
68ls -lh "${PACKAGES[@]}"
69
70if want_install; then
71 echo "Installing with pacman..."
72 sudo pacman -U --noconfirm "${PACKAGES[@]}"
73 echo "Installed."
74fi
scripts/build-linux.sh +41 −1
@@ -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
7BUILD_DEB=false
7BUILD_DEB=false
8SKIP_TESTS=false
8SKIP_TESTS=false
9INSTALL=false
9
10
10for arg in "$@"; do
11for arg in "$@"; do
11 case "$arg" in
12 case "$arg" in
12 --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 0
23 ;;
14 *) echo "Unknown option: $arg"; exit 1 ;;
24 *) echo "Unknown option: $arg"; exit 1 ;;
15 esac
25 esac
16done
26done
17
27
28if [[ "$INSTALL" == "true" ]]; then
29 BUILD_DEB=true
30fi
31
32want_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
18echo "Building posprint for Linux (x86_64)..."
44echo "Building posprint for Linux (x86_64)..."
19
45
20if [[ "$SKIP_TESTS" != "true" ]]; then
46if [[ "$SKIP_TESTS" != "true" ]]; then
@@ -32,6 +58,20 @@ if [[ "$BUILD_DEB" == "true" ]]; then
32 cargo install cargo-deb --locked
58 cargo install cargo-deb --locked
33 fi
59 fi
34 cargo deb
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 echo "Debian packages:"
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
37fi
77fi