summaryrefslogtreecommitdiff
path: root/install-packages.bash
diff options
context:
space:
mode:
authorDebian Live user <user@debian-BULLSEYE-live-builder-AMD64>2023-04-28 17:02:20 -0400
committerDebian Live user <user@debian-BULLSEYE-live-builder-AMD64>2023-04-28 17:33:42 -0400
commit7e183e38d8ac3d0fc0d5ab257b63771e5badaa31 (patch)
treef006478d09ae4ec788a97d4c08e8a5e5bbe7b10b /install-packages.bash
parent49b42e352dae1eac7499090db68e5f18ebe75c8b (diff)
package installer that auto-backports i3-wm
Diffstat (limited to 'install-packages.bash')
-rw-r--r--install-packages.bash105
1 files changed, 105 insertions, 0 deletions
diff --git a/install-packages.bash b/install-packages.bash
new file mode 100644
index 0000000..3363353
--- /dev/null
+++ b/install-packages.bash
@@ -0,0 +1,105 @@
1#!/bin/bash
2set -e
3
4apt()
5{
6 (set -x; command apt "$@")
7}
8
9[ "$(id -u)" = 0 ] || exec sudo bash "$0" "$@"
10
11basics='etckeeper git par ssh tmux vim w3m'
12#xorg='xorg xterm i3'
13xorg='xorg xterm'
14media='libdbus-glib-1-2 mpv pulseaudio'
15apt install --no-upgrade $basics $xorg $media
16
17apt_backport()
18{
19 (
20 set -e
21 apt install --no-upgrade debhelper
22 SOURCES_DIR=$1
23 TARGET_URL=$2
24 TARGET_PKG=$3
25 case "$TARGET_PKG" in
26 '' | */*) exit 1 ;;
27 esac
28 mkdir -p "$SOURCES_DIR"
29 cd "$SOURCES_DIR"
30
31 if [ -e "$TARGET_PKG" ]
32 then
33 cd "$TARGET_PKG"
34 git pull --ff-only
35 else
36 rm -rf "$TARGET_PKG"~tmp
37 git clone --depth=1 "$TARGET_URL" "$TARGET_PKG"~tmp
38 mv -T "$TARGET_PKG"~tmp "$TARGET_PKG"
39 cd "$TARGET_PKG"
40 fi
41
42 arch=$(dpkg-architecture -q DEB_BUILD_ARCH)
43 version=$(dpkg-parsechangelog --show-field Version)
44 pkgs=$(dh_listpackages)
45 debs=
46 for pkg in $pkgs
47 do
48 debs="$debs ${pkg}_${version}_${arch}.deb"
49 done
50
51 set -x
52 pwd
53 for deb in $debs
54 do
55 [ -e ../"$deb" ] && continue || true
56 # We are missing a deb, therefore build.
57
58 if command -v mk-build-deps >/dev/null
59 then
60 mk-build-deps "$TARGET_PKG" --install
61 else
62 # We could 'apt install devscripts' but it pulls
63 # in like 50MB of perl deps, possibly nullifying
64 # the savings from removing unneeded build deps.
65
66 # However, we cannot simply use 'apt build-dep'
67 # because that would use the build-deps from the
68 # version of the package in the repo, which may
69 # differ from the source version.
70
71 # Arguably we do want to try that though, since
72 # it's a backport...
73
74 if [ "$try_newer_build_deps" ]
75 then
76 build_deps=$(get_build_deps)
77 apt install $build_deps
78 else
79 apt build-dep "$TARGET_PKG"
80 fi
81 fi
82 fakeroot ./debian/rules binary
83 break
84 done
85
86 set --
87 for deb in $debs
88 do
89 set -- "$@" ../"$deb"
90 done
91 apt install "$@"
92 )
93}
94
95get_build_deps()
96{
97 # credit: Archemar @ https://unix.stackexchange.com/a/648927
98 build_deps=$(dpkg-checkbuilddeps 2>&1 |
99 sed -n -e 's/dpkg-checkbuilddeps:\serror:\sUnmet build dependencies: //gp' \
100 -e 's/[\(][^)]*[\)] //g')
101}
102
103try_newer_build_deps=y
104apt_backport /usr/local/src https://salsa.debian.org/i3-team/i3-wm.git i3-wm
105