diff --git a/generate.sh b/generate.sh index d338284..13f6e53 100755 --- a/generate.sh +++ b/generate.sh @@ -82,10 +82,13 @@ fi set -e BUILD_DIR=$(mktemp -d) + _POSTIN=$(mktemp) _PREUN=$(mktemp) +_POSTUN=$(mktemp) +_POSTUP=$(mktemp) -trap "rm -rf ${BUILD_DIR} ${_POSTIN} ${_PREUN}" EXIT +trap "rm -rf ${BUILD_DIR} ${_POSTIN} ${_PREUN} ${_POSTUN} ${_POSTUP}" EXIT while IFS= read -r -d $'\0' SRC; do F_TAGS=${SRC##*##} @@ -148,13 +151,23 @@ else cat ${PREUN} >"${_PREUN}" fi + if [ -n "${POSTUN}" ]; then + cat ${POSTUN} >"${_POSTUN}" + fi + + if [ -n "${POSTUP}" ]; then + cat ${POSTUP} >"${_POSTUP}" + fi + fpm --name "${NAME}" --version "${VERSION}" --iteration "${RELEASE_FULL}" \ --architecture all --license "${LICENSE}" \ --vendor "${VENDOR}" --maintainer "${MAINTAINER}" \ --description "${DESCRIPTION}" --url "${URL}" \ --output-type "${TYPE}" --input-type dir --chdir "${BUILD_DIR}" \ ${POSTIN:+ --after-install ${_POSTIN}} \ + ${POSTUP:+ --after-upgrade ${_POSTUP}} \ ${PREUN:+ --before-remove ${_PREUN}} \ + ${POSTUN:+ --after-remove ${_POSTUN}} \ --rpm-os linux \ --rpm-summary "${SUMMARY}" \ ${DEPENDS:+ --depends ${DEPENDS// / --depends }} \ diff --git a/postinstall b/pkg/postinstall similarity index 73% rename from postinstall rename to pkg/postinstall index e6b5800..1103f77 100755 --- a/postinstall +++ b/pkg/postinstall @@ -1,21 +1,5 @@ #!/bin/bash -# -------------------------------------------------------------------------- # -# Copyright 2010-2017, OpenNebula Systems # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - NETWORK=${NETWORK:-yes} NETWORK_EC2=${NETWORK_EC2:-no} SERVICES=${SERVICES:-one-context-local one-context} @@ -31,8 +15,10 @@ if which systemctl >/dev/null 2>&1 && \ [ -d /etc/systemd ] && \ [ -f /usr/lib/systemd/system/one-context.service ]; then + systemctl daemon-reload >/dev/null 2>&1 || : + for S in ${SERVICES}; do - systemctl enable "${S}.service" + systemctl enable "${S}.service" >/dev/null 2>&1 done fi diff --git a/pkg/postinstall.ec2 b/pkg/postinstall.ec2 new file mode 100755 index 0000000..7043895 --- /dev/null +++ b/pkg/postinstall.ec2 @@ -0,0 +1,4 @@ +#!/bin/bash + +NETWORK_EC2=yes +SERVICES='one-context' diff --git a/pkg/postuninstall b/pkg/postuninstall new file mode 100755 index 0000000..6c42b36 --- /dev/null +++ b/pkg/postuninstall @@ -0,0 +1,7 @@ +#!/bin/bash + +udevadm control --reload >/dev/null 2>&1 || : + +if which systemctl >/dev/null 2>&1 && [ -d /etc/systemd ]; then + systemctl daemon-reload >/dev/null 2>&1 || : +fi diff --git a/pkg/postupgrade b/pkg/postupgrade new file mode 100755 index 0000000..6c42b36 --- /dev/null +++ b/pkg/postupgrade @@ -0,0 +1,7 @@ +#!/bin/bash + +udevadm control --reload >/dev/null 2>&1 || : + +if which systemctl >/dev/null 2>&1 && [ -d /etc/systemd ]; then + systemctl daemon-reload >/dev/null 2>&1 || : +fi diff --git a/pkg/preuninstall b/pkg/preuninstall new file mode 100755 index 0000000..ddec50d --- /dev/null +++ b/pkg/preuninstall @@ -0,0 +1,27 @@ +#!/bin/bash + +SERVICES=${SERVICES:-one-context one-context-local} + +# Disable services +if which systemctl >/dev/null 2>&1 && [ -d /etc/systemd ]; then + for S in ${SERVICES}; do + systemctl --no-reload disable "${S}.service" >/dev/null 2>&1 || : + systemctl stop "${S}.service" >/dev/null 2>&1 || : + done +fi + +if which chkconfig >/dev/null 2>&1; then + for S in ${SERVICES}; do + chkconfig --del "${S}" >/dev/null 2>&1 || : + done + +elif which update-rc.d >/dev/null 2>&1; then + for S in ${SERVICES}; do + update-rc.d -f "${S}" remove >/dev/null 2>&1 || : + done + +elif which rc-update >/dev/null 2>&1; then + for S in ${SERVICES}; do + rc-update del "${S}" boot >/dev/null 2>&1 || : + done +fi diff --git a/pkg/preuninstall.ec2 b/pkg/preuninstall.ec2 new file mode 100755 index 0000000..a51f172 --- /dev/null +++ b/pkg/preuninstall.ec2 @@ -0,0 +1,3 @@ +#!/bin/bash + +SERVICES='one-context' diff --git a/postinstall.ec2 b/postinstall.ec2 deleted file mode 100755 index fcb7641..0000000 --- a/postinstall.ec2 +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2010-2017, OpenNebula Systems # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -NETWORK_EC2=yes -SERVICES='one-context' diff --git a/preuninstall b/preuninstall deleted file mode 100755 index f4e1f33..0000000 --- a/preuninstall +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2010-2017, OpenNebula Systems # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -SERVICES=${SERVICES:-one-context one-context-local} - -# Disable services -if which systemctl >/dev/null 2>&1 && [ -d /etc/systemd ]; then - for S in ${SERVICES}; do - systemctl --no-reload disable "${S}.service" >/dev/null 2>&1 || : - done - - systemctl daemon-reload >/dev/null 2>&1 || : -fi - -if which chkconfig >/dev/null 2>&1; then - for S in ${SERVICES}; do - chkconfig --del "${S}" >/dev/null 2>&1 || : - done - -elif which update-rc.d >/dev/null 2>&1; then - for S in ${SERVICES}; do - update-rc.d -f "${S}" remove >/dev/null 2>&1 || : - done - -elif which rc-update >/dev/null 2>&1; then - for S in ${SERVICES}; do - rc-update del "${S}" boot >/dev/null 2>&1 || : - done -fi diff --git a/preuninstall.ec2 b/preuninstall.ec2 deleted file mode 100755 index ef61834..0000000 --- a/preuninstall.ec2 +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2010-2017, OpenNebula Systems # -# # -# Licensed under the Apache License, Version 2.0 (the "License"); you may # -# not use this file except in compliance with the License. You may obtain # -# a copy of the License at # -# # -# http://www.apache.org/licenses/LICENSE-2.0 # -# # -# Unless required by applicable law or agreed to in writing, software # -# distributed under the License is distributed on an "AS IS" BASIS, # -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -# See the License for the specific language governing permissions and # -# limitations under the License. # -#--------------------------------------------------------------------------- # - -SERVICES='one-context' diff --git a/targets.sh b/targets.sh index 3d032f1..7d2b455 100644 --- a/targets.sh +++ b/targets.sh @@ -8,8 +8,10 @@ case "${TARGET}" in PROVIDES=${PROVIDES:-} REPLACES=${REPLACES:-cloud-init} CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2} - POSTIN=${POSTINST:-postinstall} - PREUN=${PREUN:-preuninstall} + POSTIN=${POSTINST:-pkg/postinstall} + PREUN=${PREUN:-pkg/preuninstall} + POSTUN=${POSTUN:-pkg/postuninstall} + POSTUP=${POSTUP:-pkg/postupgrade} ;; @@ -22,8 +24,10 @@ case "${TARGET}" in PROVIDES=${PROVIDES:-} REPLACES=${REPLACES:-cloud-init} CONFLICTS=${CONFLICTS:-${REPLACES} one-context} - POSTIN=${POSTINST:-postinstall.ec2 postinstall} - PREUN=${PREUN:-preuninstall.ec2 preuninstall} + POSTIN=${POSTINST:-pkg/postinstall.ec2 pkg/postinstall} + PREUN=${PREUN:-pkg/preuninstall.ec2 pkg/preuninstall} + POSTUN=${POSTUN:-pkg/postuninstall} + POSTUP=${POSTUP:-pkg/postupgrade} ;; 'el7') @@ -35,8 +39,10 @@ case "${TARGET}" in PROVIDES=${PROVIDES:-} REPLACES=${REPLACES:-cloud-init} CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2} - POSTIN=${POSTINST:-postinstall} - PREUN=${PREUN:-preuninstall} + POSTIN=${POSTINST:-pkg/postinstall} + PREUN=${PREUN:-pkg/preuninstall} + POSTUN=${POSTUN:-pkg/postuninstall} + POSTUP=${POSTUP:-pkg/postupgrade} ;; 'el7_ec2') @@ -48,8 +54,10 @@ case "${TARGET}" in PROVIDES=${PROVIDES:-} REPLACES=${REPLACES:-cloud-init} CONFLICTS=${CONFLICTS:-${REPLACES} one-context} - POSTIN=${POSTINST:-postinstall.ec2 postinstall} - PREUN=${PREUN:-preuninstall.ec2 preuninstall} + POSTIN=${POSTINST:-pkg/postinstall.ec2 pkg/postinstall} + PREUN=${PREUN:-pkg/preuninstall.ec2 pkg/preuninstall} + POSTUN=${POSTUN:-pkg/postuninstall} + POSTUP=${POSTUP:-pkg/postupgrade} ;; 'suse') @@ -61,8 +69,10 @@ case "${TARGET}" in PROVIDES=${PROVIDES:-} REPLACES=${REPLACES:-cloud-init cloud-init-config-suse} CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2} - POSTIN=${POSTINST:-postinstall} - PREUN=${PREUN:-preuninstall} + POSTIN=${POSTINST:-pkg/postinstall} + PREUN=${PREUN:-pkg/preuninstall} + POSTUN=${POSTUN:-pkg/postuninstall} + POSTUP=${POSTUP:-pkg/postupgrade} ;; 'suse_ec2') @@ -74,8 +84,10 @@ case "${TARGET}" in PROVIDES=${PROVIDES:-} REPLACES=${REPLACES:-cloud-init cloud-init-config-suse} CONFLICTS=${CONFLICTS:-${REPLACES} one-context} - POSTIN=${POSTINST:-postinstall.ec2 postinstall} - PREUN=${PREUN:-preuninstall.ec2 preuninstall} + POSTIN=${POSTINST:-pkg/postinstall.ec2 pkg/postinstall} + PREUN=${PREUN:-pkg/preuninstall.ec2 pkg/preuninstall} + POSTUN=${POSTUN:-pkg/postuninstall} + POSTUP=${POSTUP:-pkg/postupgrade} ;; @@ -88,8 +100,10 @@ case "${TARGET}" in PROVIDES=${PROVIDES:-} REPLACES=${REPLACES:-cloud-init} CONFLICTS=${CONFLICTS:-${REPLACES} one-context-ec2} - POSTIN=${POSTINST:-postinstall} - PREUN=${PREUN:-preuninstall} + POSTIN=${POSTINST:-pkg/postinstall} + PREUN=${PREUN:-pkg/preuninstall} + POSTUN=${POSTUN:-pkg/postuninstall} + POSTUP=${POSTUP:-pkg/postupgrade} ;; 'deb_ec2') @@ -101,8 +115,10 @@ case "${TARGET}" in PROVIDES=${PROVIDES:-} REPLACES=${REPLACES:-cloud-init} CONFLICTS=${CONFLICTS:-${REPLACES} one-context} - POSTIN=${POSTINST:-postinstall.ec2 postinstall} - PREUN=${PREUN:-preuninstall.ec2 preuninstall} + POSTIN=${POSTINST:-pkg/postinstall.ec2 pkg/postinstall} + PREUN=${PREUN:-pkg/preuninstall.ec2 pkg/preuninstall} + POSTUN=${POSTUN:-pkg/postuninstall} + POSTUP=${POSTUP:-pkg/postupgrade} ;; 'alpine') @@ -114,8 +130,10 @@ case "${TARGET}" in PROVIDES=${PROVIDES:-} REPLACES=${REPLACES:-} #not respected CONFLICTS=${CONFLICTS:-one-context-ec2} - POSTIN=${POSTINST:-postinstall} - PREUN=${PREUN:-preuninstall} + POSTIN=${POSTINST:-pkg/postinstall} + PREUN=${PREUN:-pkg/preuninstall} + POSTUN=${POSTUN:-pkg/postuninstall} + POSTUP=${POSTUP:-} # FPM 1.9.3 bug: https://github.com/jordansissel/fpm/blob/v1.9.3/lib/fpm/package/apk.rb#L149 ;; 'alpine_ec2') @@ -127,8 +145,10 @@ case "${TARGET}" in PROVIDES=${PROVIDES:-} REPLACES=${REPLACES:-} #not respected CONFLICTS=${CONFLICTS:-one-context} - POSTIN=${POSTINST:-postinstall.ec2 postinstall} - PREUN=${PREUN:-preuninstall.ec2 preuninstall} + POSTIN=${POSTINST:-pkg/postinstall.ec2 pkg/postinstall} + PREUN=${PREUN:-pkg/preuninstall.ec2 pkg/preuninstall} + POSTUN=${POSTUN:-pkg/postuninstall} + POSTUP=${POSTUP:-} # FPM 1.9.3 bug: https://github.com/jordansissel/fpm/blob/v1.9.3/lib/fpm/package/apk.rb#L149 ;; 'iso')