#!/bin/bash set -e ############################################################################## # Copyright (c) 2015 Ericsson AB and others. # stefan.k.berg@ericsson.com # jonas.bjurel@ericsson.com # All rights reserved. This program and the accompanying materials # are made available under the terms of the Apache License, Version 2.0 # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## ############################################################################## # Default variable declarations COMMAND= PACKAGE_NAME= PACKAGE_SHORT_NAME= PACKAGE_VERSION= TARGET_BUILD_PATH= DEPENDENCIES= MAINTAINER= ARCH="amd64" BUILD_HISTORY=".odl-build-history" ############################################################################## # subroutine: usage # Description: Prints out usage of this script usage () { cat < -d myJavaDependence EOF } ############################################################################## # subroutine: clean # Description: Cleans up all artifacts from earlier builds clean () { if [ -e $BUILD_HISTORY ]; then while read line do rm -rf $line done < $BUILD_HISTORY rm ${BUILD_HISTORY} exit 0 fi } ############################################################################## # make-DEBIAN_control # Description: constructs the Debian pack control file make-DEBIAN_control () { cat <> "$BUILD_HISTORY" TARGET_INSTALL_PATH="/usr/share/java/${PACKAGE_SHORT_NAME}/" DEB_PACK_CONTENT_PATH="${DEB_PACK_BASE_PATH}/usr/share/java/${PACKAGE_SHORT_NAME}/" DEB_PACK_CONFIG_PATH="${DEB_PACK_BASE_PATH}/etc/${PACKAGE_SHORT_NAME}" TARGET_TAR=$(ls ${TARGET_BUILD_PATH}*.tar.gz) TARGET_TAR="${TARGET_TAR##*/}" TAR_PATH="${TARGET_TAR%.*}" TAR_PATH="${TAR_PATH%.*}" if [ -e $DEB_PACK_BASE_PATH ]; then rm -R $DEB_PACK_BASE_PATH fi # Create Deb pack content and configuration mkdir -p ${DEB_PACK_CONTENT_PATH} cp ${TARGET_BUILD_PATH}${TARGET_TAR} ${DEB_PACK_CONTENT_PATH} tar -xzf ${DEB_PACK_CONTENT_PATH}${TARGET_TAR} -C ${DEB_PACK_CONTENT_PATH} rm ${DEB_PACK_CONTENT_PATH}${TARGET_TAR} mv ${DEB_PACK_CONTENT_PATH}${TAR_PATH}/* ${DEB_PACK_CONTENT_PATH}. rm -R ${DEB_PACK_CONTENT_PATH}${TAR_PATH} # Crate and populate Deb pack config target mkdir -p ${DEB_PACK_CONFIG_PATH}/etc mv ${DEB_PACK_CONTENT_PATH}etc/* ${DEB_PACK_CONFIG_PATH}/etc/ rm -R ${DEB_PACK_CONTENT_PATH}etc mkdir -p ${DEB_PACK_CONFIG_PATH}/configuration mv ${DEB_PACK_CONTENT_PATH}configuration/* ${DEB_PACK_CONFIG_PATH}/configuration/ rm -R ${DEB_PACK_CONTENT_PATH}configuration # Set package permisions find ${DEB_PACK_CONTENT_PATH} -type d -print -exec chmod 755 {} \; find ${DEB_PACK_CONFIG_PATH}/etc/ -type f -print -exec chmod 644 {} \; find ${DEB_PACK_CONFIG_PATH}/etc/ -type d -print -exec chmod 755 {} \; # Create package usr/bin odl script mkdir "${DEB_PACK_BASE_PATH}/usr/bin" chmod 755 "${DEB_PACK_BASE_PATH}/usr/bin" make-DEBIAN_bin > "${DEB_PACK_BASE_PATH}/usr/bin/odl" chmod 755 "${DEB_PACK_BASE_PATH}/usr/bin/odl" # Create Deb pack install meta-data mkdir "${DEB_PACK_BASE_PATH}/DEBIAN" make-DEBIAN_control > "${DEB_PACK_BASE_PATH}/DEBIAN/control" make-DEBIAN_conffiles > "${DEB_PACK_BASE_PATH}/DEBIAN/conffiles" mkdir -p "${DEB_PACK_BASE_PATH}/usr/share/doc/${PACKAGE_SHORT_NAME}" make-DEBIAN_copyright > "${DEB_PACK_BASE_PATH}/usr/share/doc/${PACKAGE_SHORT_NAME}/copyright" make-DEBIAN_changelog > "${DEB_PACK_BASE_PATH}/usr/share/doc/${PACKAGE_SHORT_NAME}/changelog.Debian" # Create Deb pack post install symlinks and usr/bin scripts make-DEBIAN_postinst > "${DEB_PACK_BASE_PATH}/DEBIAN/postinst" chmod 755 "${DEB_PACK_BASE_PATH}/DEBIAN/postinst" mkdir -p "${DEB_PACK_BASE_PATH}/usr/bin"