diff options
author | Andrew Cady <d@jerkface.net> | 2020-09-10 13:12:15 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2020-09-10 13:12:15 -0400 |
commit | aeb39422452102a513686b3d334930c8aa3a09cc (patch) | |
tree | 4f3675e6fe7259a053629a3c7ab001aec78717fb | |
parent | 54f0355abfca74986dbe43d1162ad95235b05025 (diff) |
avoid building deps package if dependencies did not change
also removed verbosity in various places
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | selfpublish.sh | 64 |
2 files changed, 58 insertions, 8 deletions
@@ -1,4 +1,4 @@ | |||
1 | 1 | ||
2 | self-publish: | 2 | self-publish: |
3 | sudo bash -x selfpublish.sh | 3 | sudo bash $(if $(VERBOSE),-x) selfpublish.sh |
4 | 4 | ||
diff --git a/selfpublish.sh b/selfpublish.sh index 98dd2df..d16ac53 100644 --- a/selfpublish.sh +++ b/selfpublish.sh | |||
@@ -47,24 +47,73 @@ dpkg_install() | |||
47 | as_root $SHELL -c "set -$- +e; dpkg -i $*; apt-get -t buster-backports -f install" | 47 | as_root $SHELL -c "set -$- +e; dpkg -i $*; apt-get -t buster-backports -f install" |
48 | } | 48 | } |
49 | 49 | ||
50 | dependencies() | ||
51 | { | ||
52 | cat <<EOF | ||
53 | apache2 (>= 2.4.46) | ||
54 | cgit | ||
55 | curl | ||
56 | fortune-mod | ||
57 | fortunes-min | ||
58 | libssl1.1 (>= 1.1.1d) | ||
59 | EOF | ||
60 | } | ||
61 | |||
62 | fmt_dependencies() | ||
63 | { | ||
64 | local outline= | ||
65 | while read inline | ||
66 | do | ||
67 | if [ ! "$outline" ] | ||
68 | then | ||
69 | outline="Depends: $inline" | ||
70 | elif [ $((${#outline} + ${#inline})) -ge 60 ] | ||
71 | then | ||
72 | printf '%s,\n' "$outline" | ||
73 | outline=" $inline" | ||
74 | else | ||
75 | outline="$outline, $inline" | ||
76 | fi | ||
77 | done | ||
78 | if [ "$outline" ] | ||
79 | then | ||
80 | printf '%s\n' "$outline" | ||
81 | fi | ||
82 | } | ||
83 | |||
84 | |||
50 | control_file() | 85 | control_file() |
51 | { | 86 | { |
52 | cat <<EOF | 87 | cat <<EOF |
53 | Package: selfpublish-dot-sh-deps | 88 | Package: selfpublish-dot-sh-deps |
54 | Depends: apache2 (>= 2.4.46), libssl1.1 (>= 1.1.1d), | ||
55 | fortune-mod, fortunes-min, curl, cgit | ||
56 | Description: selfpublish.sh dependency package | 89 | Description: selfpublish.sh dependency package |
57 | This package depends on the dependencies of the | 90 | This package depends on the dependencies of the |
58 | selfpublish.sh script, and is installed by that | 91 | selfpublish.sh script, and is installed by that |
59 | script to self-satisfy those dependencies. | 92 | script to self-satisfy those dependencies. |
60 | |||
61 | EOF | 93 | EOF |
94 | dependencies | fmt_dependencies | ||
95 | echo | ||
96 | } | ||
97 | |||
98 | control_file_unchanged() | ||
99 | { | ||
100 | ( | ||
101 | destdir=$(mktemp -d) | ||
102 | trap 'rm -r "$destdir"' EXIT | ||
103 | dependencies > want-dependencies | ||
104 | dpkg-query -f '${Depends}\n' -W selfpublish-dot-sh-deps | sed 's/, */\n/g' | sort -u > have-dependencies | ||
105 | diff -q want-dependencies have-dependencies | ||
106 | ) | ||
62 | } | 107 | } |
63 | 108 | ||
64 | equivocate() | 109 | equivocate() |
65 | { | 110 | { |
66 | if dpkg-query -s selfpublish-dot-sh-deps | grep -q '^Status: install ok installed' | 111 | if dpkg-query -s selfpublish-dot-sh-deps | grep -q '^Status: install ok installed' 2>/dev/null |
67 | then | 112 | then |
113 | if ! force | ||
114 | then | ||
115 | control_file_unchanged && return | ||
116 | fi | ||
68 | as_root dpkg -r selfpublish-dot-sh-deps | 117 | as_root dpkg -r selfpublish-dot-sh-deps |
69 | fi | 118 | fi |
70 | which equivs-build >/dev/null 2>&1 || apt_install equivs | 119 | which equivs-build >/dev/null 2>&1 || apt_install equivs |
@@ -72,7 +121,8 @@ equivocate() | |||
72 | destdir=$(mktemp -d) | 121 | destdir=$(mktemp -d) |
73 | cd "$destdir" | 122 | cd "$destdir" |
74 | control_file > ./control | 123 | control_file > ./control |
75 | equivs-build ./control >/dev/null 2>&1 | 124 | cat ./control |
125 | equivs-build ./control >&2 | ||
76 | dpkg_install selfpublish-dot-sh-deps_1.0_all.deb | 126 | dpkg_install selfpublish-dot-sh-deps_1.0_all.deb |
77 | ) | 127 | ) |
78 | } | 128 | } |
@@ -256,7 +306,7 @@ write_cgit_config() | |||
256 | cgit_scan_dir=$SITE_DIR/public_git/ | 306 | cgit_scan_dir=$SITE_DIR/public_git/ |
257 | mkdir -p "$cgit_scan_dir" | 307 | mkdir -p "$cgit_scan_dir" |
258 | line="scan-path=$cgit_scan_dir" | 308 | line="scan-path=$cgit_scan_dir" |
259 | grep -xF "$line" /etc/cgitrc || printf '%s\n' "$line" >> /etc/cgitrc | 309 | grep -qxF "$line" /etc/cgitrc || printf '%s\n' "$line" >> /etc/cgitrc |
260 | } | 310 | } |
261 | 311 | ||
262 | configure_apache_vhost() | 312 | configure_apache_vhost() |
@@ -407,7 +457,7 @@ check_tls() | |||
407 | curl -s -S -I https://"$1" >/dev/null | 457 | curl -s -S -I https://"$1" >/dev/null |
408 | } | 458 | } |
409 | 459 | ||
410 | [ "$NO_APT" ] || equivocate | 460 | [ "$NO_APT" ] || equivocate >&2 |
411 | 461 | ||
412 | APACHE_MODULES='status md rewrite ssl include cgi' | 462 | APACHE_MODULES='status md rewrite ssl include cgi' |
413 | APACHE_SITE_DIRS='logs public_html' | 463 | APACHE_SITE_DIRS='logs public_html' |