diff options
author | Andrew Cady <d@jerkface.net> | 2020-10-03 09:34:38 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2020-10-03 09:34:38 -0400 |
commit | 192ad140591b9618550157ed15b3265549326367 (patch) | |
tree | 6f63ba6711360bd36237e3575b61dfe1896b5dd4 | |
parent | 75f6e7378f7e61700cb6ed1047c73acc910072ce (diff) |
Rebuild the .deb only when needed
Also fixed a bug related to blank lines in the control file. The format
represents a blank line as a single '.' and literal '.' beginning a line
is escaped as '..'.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | selfpublish.sh | 74 |
2 files changed, 64 insertions, 12 deletions
@@ -2,3 +2,5 @@ | |||
2 | self-publish: | 2 | self-publish: |
3 | sudo$(if $(FORCE), FORCE=y) bash$(if $(VERBOSE), -x) selfpublish.sh | 3 | sudo$(if $(FORCE), FORCE=y) bash$(if $(VERBOSE), -x) selfpublish.sh |
4 | 4 | ||
5 | fast: | ||
6 | sudo NO_APT=y bash selfpublish.sh | ||
diff --git a/selfpublish.sh b/selfpublish.sh index 56f1b68..3aa0a77 100644 --- a/selfpublish.sh +++ b/selfpublish.sh | |||
@@ -89,7 +89,52 @@ fmt_dependencies() | |||
89 | control_file_file() | 89 | control_file_file() |
90 | { | 90 | { |
91 | printf 'File: %s %s\n' "$1" "$2" | 91 | printf 'File: %s %s\n' "$1" "$2" |
92 | sed -e 's/^/ /' | 92 | sed -e ' s/^[.]/../; s/^$/./; s/^/ /; ' |
93 | } | ||
94 | |||
95 | control_file_file_check() | ||
96 | { | ||
97 | local prefix RESULT=0 header= data o | ||
98 | tempout=$(mktemp) | ||
99 | while [ "$header" ] || read header | ||
100 | do | ||
101 | set -- $header | ||
102 | case "$1" in | ||
103 | File:) | ||
104 | |||
105 | case "$2" in | ||
106 | /*) ;; | ||
107 | *) return 1 ;; | ||
108 | esac | ||
109 | |||
110 | :> "$tempout" | ||
111 | while IFS= read -r data | ||
112 | do | ||
113 | case "$data" in | ||
114 | ' .'*) | ||
115 | printf '%s\n' "${data# .}" >> "$tempout" | ||
116 | continue | ||
117 | ;; | ||
118 | ' '*) | ||
119 | printf '%s\n' "${data# }" >> "$tempout" | ||
120 | continue | ||
121 | ;; | ||
122 | esac | ||
123 | |||
124 | if ! diff -q "$2" "$tempout" | ||
125 | then | ||
126 | RESULT=1 | ||
127 | install -v -m "$3" "$tempout" -T "$2" | ||
128 | fi | ||
129 | header=$data | ||
130 | continue 2 | ||
131 | |||
132 | done | ||
133 | ;; | ||
134 | esac | ||
135 | header= | ||
136 | done | ||
137 | return $RESULT | ||
93 | } | 138 | } |
94 | 139 | ||
95 | SELF_VERSION='0.1' | 140 | SELF_VERSION='0.1' |
@@ -105,10 +150,10 @@ Description: selfpublish.sh dependency package | |||
105 | script to self-satisfy those dependencies. | 150 | script to self-satisfy those dependencies. |
106 | EOF | 151 | EOF |
107 | dependencies | fmt_dependencies | 152 | dependencies | fmt_dependencies |
108 | cat <<EOF | 153 | # cat <<EOF |
109 | File: /usr/share/doc/selfpublish-dot-sh/README.Debian 644 | 154 | # File: /usr/share/doc/selfpublish-dot-sh/README.Debian 644 |
110 | This gets overwritten :( | 155 | # This gets overwritten :( |
111 | EOF | 156 | # EOF |
112 | control_file_file /usr/lib/cryptonomic/cryptonomic-gpg 755 <<'EOF' | 157 | control_file_file /usr/lib/cryptonomic/cryptonomic-gpg 755 <<'EOF' |
113 | #!/bin/sh | 158 | #!/bin/sh |
114 | 159 | ||
@@ -323,9 +368,11 @@ equivocate() | |||
323 | { | 368 | { |
324 | if dpkg-query -s selfpublish-dot-sh | grep -q '^Status: install ok installed' 2>/dev/null | 369 | if dpkg-query -s selfpublish-dot-sh | grep -q '^Status: install ok installed' 2>/dev/null |
325 | then | 370 | then |
326 | if ! force | 371 | if control_file_unchanged && control_file | control_file_file_check |
327 | then | 372 | then |
328 | control_file_unchanged && return | 373 | if ! force |
374 | then return | ||
375 | fi | ||
329 | fi | 376 | fi |
330 | fi | 377 | fi |
331 | which equivs-build >/dev/null 2>&1 || apt_install equivs | 378 | which equivs-build >/dev/null 2>&1 || apt_install equivs |
@@ -333,12 +380,15 @@ equivocate() | |||
333 | destdir=$(mktemp -d) | 380 | destdir=$(mktemp -d) |
334 | cd "$destdir" | 381 | cd "$destdir" |
335 | control_file > ./control | 382 | control_file > ./control |
336 | # cat ./control | ||
337 | equivs-build ./control >&2 | 383 | equivs-build ./control >&2 |
338 | DEB=selfpublish-dot-sh_${SELF_VERSION}_all.deb | 384 | DEB=selfpublish-dot-sh_${SELF_VERSION}_all.deb |
339 | as_root dpkg -r selfpublish-dot-sh | 385 | |
340 | dpkg_install "$DEB" | 386 | if ! [ "$NO_APT" ] |
341 | install -m0644 "$DEB" "$DEBDEST" | 387 | then |
388 | as_root dpkg -r selfpublish-dot-sh | ||
389 | dpkg_install "$DEB" | ||
390 | install -m0644 "$DEB" "$DEBDEST" | ||
391 | fi | ||
342 | ) || exit | 392 | ) || exit |
343 | } | 393 | } |
344 | 394 | ||
@@ -765,7 +815,7 @@ check_tls() | |||
765 | } | 815 | } |
766 | 816 | ||
767 | DEBDEST=$(realpath .) | 817 | DEBDEST=$(realpath .) |
768 | [ "$NO_APT" ] || equivocate >&2 | 818 | [ "$NO_EQUIVS" ] || equivocate >&2 |
769 | 819 | ||
770 | APACHE_MODULES='status md rewrite ssl include cgi' | 820 | APACHE_MODULES='status md rewrite ssl include cgi' |
771 | APACHE_SITE_DIRS='logs public_html' | 821 | APACHE_SITE_DIRS='logs public_html' |