diff --git a/gen_package.sh b/gen_package.sh index 394bc1bb34..d92cd30847 100755 --- a/gen_package.sh +++ b/gen_package.sh @@ -36,16 +36,27 @@ DIRS="oneapps stage flow market" export DESTDIR=$PWD/tmp if [ "$(id -u)" = "0" ]; then - OWNER_FLAGS='-u oneadmin -g oneadmin' + FLAGS='-u oneadmin -g oneadmin' fi +FLAVOR="other" +if [ "$PACKAGE_TYPE" = "deb" ]; then + FLAGS="$FLAGS -f debian" + FLAVOR="debian" +fi + +# Generate postinstall +sed "s/#FLAVOR#/$FLAVOR/" < $SCRIPTS_DIR/oneapps/postinstall.sh > \ + $SCRIPTS_DIR/oneapps/postinstall +chmod +x $SCRIPTS_DIR/oneapps/postinstall + rm -rf $DESTDIR mkdir $DESTDIR for TOOL in $DIRS; do ( cd $TOOL - ./install.sh $OWNER_FLAGS + ./install.sh $FLAGS ) done @@ -54,7 +65,7 @@ cd tmp fpm -n "$PACKAGE_NAME" -t "$PACKAGE_TYPE" -s dir --vendor "$VENDOR" \ --license "$LICENSE" --description "$DESCRIPTION" --url "$URL" \ -m "$MAINTAINER" -v "$VERSION" \ - --after-install $SCRIPTS_DIR/oneapps/postinstall.sh \ + --after-install $SCRIPTS_DIR/oneapps/postinstall \ -a all -p $SCRIPTS_DIR/$NAME * diff --git a/install_lib.sh b/install_lib.sh index ce62f12be7..fa468711f4 100644 --- a/install_lib.sh +++ b/install_lib.sh @@ -15,16 +15,17 @@ usage() { echo - echo "Usage: install.sh [-u install_user] [-g install_group]" + echo "Usage: install.sh [-u install_user] [-g install_group] [-f flavour]" echo " [-d ONE_LOCATION] [-l] [-h]" echo + echo "-f: distribution, debian or other" echo "-d: target installation directory, if not defined it'd be root. Must be" echo " an absolute path." echo "-l: creates symlinks instead of copying files, useful for development" echo "-h: prints this help" } -TEMP_OPT=`getopt -o hlu:g:d: -n 'install.sh' -- "$@"` +TEMP_OPT=`getopt -o hlu:g:d:f: -n 'install.sh' -- "$@"` if [ $? != 0 ] ; then usage @@ -37,6 +38,7 @@ LINK="no" ONEADMIN_USER=`id -u` ONEADMIN_GROUP=`id -g` SRC_DIR=$PWD +FLAVOR="other" while true ; do case "$1" in @@ -45,18 +47,33 @@ while true ; do -l) LINK="yes" ; shift ;; -u) ONEADMIN_USER="$2" ; shift 2;; -g) ONEADMIN_GROUP="$2"; shift 2;; + -f) FLAVOR="$2"; shift 2;; --) shift ; break ;; *) usage; exit 1 ;; esac done +echo $FLAVOR + if [ -z "$ROOT" ]; then - LIB_LOCATION="/usr/lib/one/ruby/oneapps" - BIN_LOCATION="/usr/bin" - PACKAGES_LOCATION="/usr/share/one/oneapps" - SHARE_LOCATION="/usr/share/one/oneapps" - ETC_LOCATION="/etc/one" - SUNSTONE_LOCATION="/usr/lib/one/sunstone" + case "$FLAVOR" in + "debian") + LIB_LOCATION="/usr/lib/one/ruby/oneapps" + BIN_LOCATION="/usr/bin" + PACKAGES_LOCATION="/usr/share/opennebula/oneapps" + SHARE_LOCATION="/usr/share/opennebula/oneapps" + ETC_LOCATION="/etc/one" + SUNSTONE_LOCATION="/usr/share/opennebula/sunstone" + ;; + *) + LIB_LOCATION="/usr/lib/one/ruby/oneapps" + BIN_LOCATION="/usr/bin" + PACKAGES_LOCATION="/usr/share/one/oneapps" + SHARE_LOCATION="/usr/share/one/oneapps" + ETC_LOCATION="/etc/one" + SUNSTONE_LOCATION="/usr/lib/one/sunstone" + ;; + esac else LIB_LOCATION="$ROOT/lib/ruby/oneapps" BIN_LOCATION="$ROOT/bin" diff --git a/oneapps/postinstall.sh b/oneapps/postinstall.sh index 14237ace97..e48f54a9a3 100755 --- a/oneapps/postinstall.sh +++ b/oneapps/postinstall.sh @@ -1,11 +1,26 @@ #!/bin/bash -SUNSTONE_PLUGINS=/etc/one/sunstone-plugins.yaml -SUNSTONE_SERVER=/etc/one/sunstone-server.conf -OPENNEBULA_JS=/usr/lib/one/sunstone/public/js/opennebula.js -OPENNEBULA_JS_NEW=/usr/share/one/oneapps/public/js/opennebula.js -SUNSTONE_AUTH="/var/lib/one/.one/sunstone_auth" -APPFLOW_AUTH="/var/lib/one/.one/appflow_auth" +FLAVOR="#FLAVOR#" + +case "$FLAVOR" in; +debian) + SUNSTONE_PLUGINS=/etc/one/sunstone-plugins.yaml + SUNSTONE_SERVER=/etc/one/sunstone-server.conf + OPENNEBULA_JS=/usr/share/opennebula/sunstone/public/js/opennebula.js + OPENNEBULA_JS_NEW=/usr/share/opennebula/oneapps/public/js/opennebula.js + SUNSTONE_AUTH="/var/lib/one/.one/sunstone_auth" + APPFLOW_AUTH="/var/lib/one/.one/appflow_auth" + ;; + +*) + SUNSTONE_PLUGINS=/etc/one/sunstone-plugins.yaml + SUNSTONE_SERVER=/etc/one/sunstone-server.conf + OPENNEBULA_JS=/usr/lib/one/sunstone/public/js/opennebula.js + OPENNEBULA_JS_NEW=/usr/share/one/oneapps/public/js/opennebula.js + SUNSTONE_AUTH="/var/lib/one/.one/sunstone_auth" + APPFLOW_AUTH="/var/lib/one/.one/appflow_auth" + ;; +esac function print_install_message() { cat <