diff options
author | u <u@billy> | 2023-05-01 09:36:41 -0400 |
---|---|---|
committer | u <u@billy> | 2023-05-01 09:36:41 -0400 |
commit | 4d13e44b6f5ed8e47b13c0e6acbd1ed1a74bfc1d (patch) | |
tree | a7d75db92761280057b8cce7672ac6f9dcafcf7e /install-packages.bash | |
parent | 79b0dee7daed2f457cb5b56fedbfbe4d5a88ccad (diff) |
use apt option --mark-auto; also cleanups
Diffstat (limited to 'install-packages.bash')
-rw-r--r-- | install-packages.bash | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/install-packages.bash b/install-packages.bash index 61af49e..2cc2e1f 100644 --- a/install-packages.bash +++ b/install-packages.bash | |||
@@ -15,6 +15,34 @@ media='libdbus-glib-1-2 mpv pulseaudio imagemagick' | |||
15 | 15 | ||
16 | apt install -q --show-progress --no-upgrade $basics $docs $xorg $media | 16 | apt install -q --show-progress --no-upgrade $basics $docs $xorg $media |
17 | 17 | ||
18 | all_files_exist() | ||
19 | { | ||
20 | for f in "$@" | ||
21 | do | ||
22 | [ -e "$f" ] || return | ||
23 | done | ||
24 | true | ||
25 | } | ||
26 | |||
27 | # Clone into temporary directory then move to final dest -- to preserve | ||
28 | # idempotence in case of git failure. | ||
29 | git_clone() | ||
30 | { | ||
31 | local src dst tmpdst | ||
32 | local src="$1" | ||
33 | local dst="$(realpath "$2")" || return | ||
34 | local tmpdst="$(mktemp -d "$dst"~tmp~XXXXXX)" || return | ||
35 | |||
36 | if git clone --depth=1 -- "$src" "$tmpdst" | ||
37 | then | ||
38 | mv -T -- "$tmpdst" "$dst" | ||
39 | else | ||
40 | r=$? | ||
41 | rm -rf -- "$tmpdst" | ||
42 | return $r | ||
43 | fi | ||
44 | } | ||
45 | |||
18 | apt_backport() | 46 | apt_backport() |
19 | { | 47 | { |
20 | ( | 48 | ( |
@@ -33,60 +61,31 @@ apt_backport() | |||
33 | cd "$TARGET_PKG" | 61 | cd "$TARGET_PKG" |
34 | git pull --ff-only | 62 | git pull --ff-only |
35 | else | 63 | else |
36 | rm -rf "$TARGET_PKG"~tmp | 64 | git_clone "$TARGET_URL" "$TARGET_PKG" |
37 | git clone --depth=1 "$TARGET_URL" "$TARGET_PKG"~tmp | ||
38 | mv -T "$TARGET_PKG"~tmp "$TARGET_PKG" | ||
39 | cd "$TARGET_PKG" | 65 | cd "$TARGET_PKG" |
40 | fi | 66 | fi |
41 | 67 | ||
42 | arch=$(dpkg-architecture -q DEB_BUILD_ARCH) | 68 | arch=$(dpkg-architecture -q DEB_BUILD_ARCH) |
43 | version=$(dpkg-parsechangelog --show-field Version) | 69 | version=$(dpkg-parsechangelog --show-field Version) |
44 | pkgs=$(dh_listpackages) | 70 | pkgs=$(dh_listpackages) |
71 | |||
45 | debs= | 72 | debs= |
46 | for pkg in $pkgs | 73 | for pkg in $pkgs |
47 | do | 74 | do |
48 | debs="$debs ${pkg}_${version}_${arch}.deb" | 75 | debs="$debs ../${pkg}_${version}_${arch}.deb" |
49 | done | 76 | done |
50 | 77 | ||
51 | for deb in $debs | 78 | if ! all_files_exist $debs |
52 | do | 79 | then |
53 | [ -e ../"$deb" ] && continue || true | 80 | build_deps=$(get_build_deps) |
54 | # We are missing a deb, therefore build. | 81 | if [ "$build_deps" ] |
55 | |||
56 | if command -v mk-build-deps >/dev/null | ||
57 | then | 82 | then |
58 | mk-build-deps "$TARGET_PKG" --install | 83 | apt install --mark-auto $build_deps |
59 | else | ||
60 | # We could 'apt install devscripts' but it pulls | ||
61 | # in like 50MB of perl deps, possibly nullifying | ||
62 | # the savings from removing unneeded build deps. | ||
63 | |||
64 | # However, we cannot simply use 'apt build-dep' | ||
65 | # because that would use the build-deps from the | ||
66 | # version of the package in the repo, which may | ||
67 | # differ from the source version. | ||
68 | |||
69 | # Arguably we do want to try that though, since | ||
70 | # it's a backport... | ||
71 | |||
72 | if [ "$try_newer_build_deps" ] | ||
73 | then | ||
74 | build_deps=$(get_build_deps) | ||
75 | apt install $build_deps | ||
76 | else | ||
77 | apt build-dep "$TARGET_PKG" | ||
78 | fi | ||
79 | fi | 84 | fi |
80 | fakeroot ./debian/rules binary | 85 | fakeroot ./debian/rules binary |
81 | break | 86 | fi |
82 | done | ||
83 | 87 | ||
84 | set -- | 88 | apt install $debs |
85 | for deb in $debs | ||
86 | do | ||
87 | set -- "$@" ../"$deb" | ||
88 | done | ||
89 | apt install "$@" | ||
90 | ) | 89 | ) |
91 | } | 90 | } |
92 | 91 | ||