9706: Add postinst script to Go packages that have systemd unit files, so (on Debian...
authorTom Clegg <tom@curoverse.com>
Thu, 4 Aug 2016 22:43:17 +0000 (18:43 -0400)
committerTom Clegg <tom@curoverse.com>
Thu, 4 Aug 2016 22:43:17 +0000 (18:43 -0400)
build/go-package-scripts/postinst [new file with mode: 0755]
build/run-library.sh

diff --git a/build/go-package-scripts/postinst b/build/go-package-scripts/postinst
new file mode 100755 (executable)
index 0000000..137f898
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+set -e
+
+script="${0##*/}"
+pkg="${script%.postinst}"
+
+case "${1}" in
+    configure)
+        if which systemctl >/dev/null && [[ -e "/lib/systemd/system/${pkg}.service" ]]; then
+            systemctl enable "${pkg}"
+            systemctl start "${pkg}"
+        fi
+        ;;
+esac
index aee579c7c1532ce77c00a6b84ad553988e0b2b48..9140ac1611bd05041bd99314015468497bc8cb5c 100755 (executable)
@@ -101,14 +101,15 @@ package_go_binary() {
     cd $WORKSPACE/packages/$TARGET
     go get "git.curoverse.com/arvados.git/$src_path"
 
-    declare -a addfiles=()
+    declare -a switches=()
     systemd_unit="$WORKSPACE/${src_path}/${prog}.service"
     if [[ -e "${systemd_unit}" ]]; then
-        addfiles+=("${systemd_unit}=/lib/systemd/system/${prog}.service")
+        switches+=("${systemd_unit}=/lib/systemd/system/${prog}.service")
+        switches+=(--after-install "$WORKSPACE/build/go-package-scripts/postinst")
     fi
-    addfiles+=("$WORKSPACE/$license_file=/usr/share/doc/$prog/$license_file")
+    switches+=("$WORKSPACE/$license_file=/usr/share/doc/$prog/$license_file")
 
-    fpm_build "$GOPATH/bin/$basename=/usr/bin/$prog" "$prog" 'Curoverse, Inc.' dir "$version" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=$description" "${addfiles[@]}"
+    fpm_build "$GOPATH/bin/$basename=/usr/bin/$prog" "$prog" 'Curoverse, Inc.' dir "$version" "--url=https://arvados.org" "--license=GNU Affero General Public License, version 3.0" "--description=$description" "${switches[@]}"
 }
 
 default_iteration() {