diff --git a/apptools/install.sh b/apptools/install.sh index 2edef801e3..5234b1c4d1 100755 --- a/apptools/install.sh +++ b/apptools/install.sh @@ -15,66 +15,7 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -usage() { - echo - echo "Usage: install.sh [-d ONE_LOCATION] [-l] [-h]" - echo - 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 hld: -n 'install.sh' -- "$@"` - -if [ $? != 0 ] ; then - usage - exit 1 -fi - -eval set -- "$TEMP_OPT" - -LINK="no" -SRC_DIR=$PWD - -while true ; do - case "$1" in - -h) usage; exit 0;; - -d) ROOT="$2" ; shift 2 ;; - -l) LINK="yes" ; shift ;; - --) shift ; break ;; - *) usage; exit 1 ;; - esac -done - -if [ -z "$ROOT" ]; then - SUNSTONE_LOCATION="/usr/lib/one/sunstone" -else - SUNSTONE_LOCATION="$ROOT/lib/sunstone" -fi - -do_file() { - if [ "$UNINSTALL" = "yes" ]; then - rm $2/`basename $1` - else - if [ "$LINK" = "yes" ]; then - ln -s $SRC_DIR/$1 $2 - else - cp -R $SRC_DIR/$1 $2 - fi - fi -} - -copy_files() { - FILES=$1 - DST=$DESTDIR$2 - - mkdir -p $DST - - for f in $FILES; do - do_file $f $DST - done -} +. ../install_lib.sh copy_files "sunstone/public/images/*" "$SUNSTONE_LOCATION/public/images" copy_files "sunstone/public/js/user-plugins/*" "$SUNSTONE_LOCATION/public/js/user-plugins" diff --git a/env/install.sh b/env/install.sh index 7def4c78d4..088e45b4a1 100755 --- a/env/install.sh +++ b/env/install.sh @@ -15,78 +15,10 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -usage() { - echo - echo "Usage: install.sh [-d ONE_LOCATION] [-l] [-h]" - echo - 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" -} +. ../install_lib.sh -TEMP_OPT=`getopt -o hld: -n 'install.sh' -- "$@"` - -if [ $? != 0 ] ; then - usage - exit 1 -fi - -eval set -- "$TEMP_OPT" - -LINK="no" -SRC_DIR=$PWD - -while true ; do - case "$1" in - -h) usage; exit 0;; - -d) ROOT="$2" ; shift 2 ;; - -l) LINK="yes" ; shift ;; - --) shift ; break ;; - *) usage; exit 1 ;; - esac -done - -if [ -z "$ROOT" ]; then - LIB_LOCATION="/usr/lib/one/ruby/apptools/env" - BIN_LOCATION="/usr/bin" - PACKAGES_LOCATION="/usr/share/one/apptools" - SUNSTONE_LOCATION="/usr/lib/one/sunstone" -else - LIB_LOCATION="$ROOT/lib/ruby/apptools/env" - BIN_LOCATION="$ROOT/bin" - PACKAGES_LOCATION="$ROOT/share/apptools" - SUNSTONE_LOCATION="$ROOT/lib/sunstone" -fi - -DIRECTORIES="$LIB_LOCATION $BIN_LOCATION" - -do_file() { - if [ "$UNINSTALL" = "yes" ]; then - rm $2/`basename $1` - else - if [ "$LINK" = "yes" ]; then - ln -s $SRC_DIR/$1 $2 - else - cp -R $SRC_DIR/$1 $2 - fi - fi -} - -copy_files() { - FILES=$1 - DST=$DESTDIR$2 - - mkdir -p $DST - - for f in $FILES; do - do_file $f $DST - done -} - -copy_files "lib/* cli/*" "$LIB_LOCATION" +copy_files "lib/* cli/*" "$LIB_LOCATION/env" copy_files "bin/*" "$BIN_LOCATION" copy_files "share/packages/*" "$PACKAGES_LOCATION" copy_files "sunstone/public/js/user-plugins/*" "$SUNSTONE_LOCATION/public/js/user-plugins" copy_files "sunstone/routes/*" "$SUNSTONE_LOCATION/routes" - diff --git a/flow/install.sh b/flow/install.sh index 3cef318c58..5903768aa7 100755 --- a/flow/install.sh +++ b/flow/install.sh @@ -15,68 +15,16 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -TEMP_OPT=`getopt -o ld: -n 'install.sh' -- "$@"` - -if [ $? != 0 ] ; then - usage - exit 1 -fi - -eval set -- "$TEMP_OPT" - -LINK="no" -SRC_DIR=$PWD - -while true ; do - case "$1" in - -d) ROOT="$2" ; shift 2 ;; - -l) LINK="yes" ; shift ;; - --) shift ; break ;; - *) usage; exit 1 ;; - esac -done +. ../install_lib.sh if [ -z "$ROOT" ]; then - LIB_LOCATION="/usr/lib/one/ruby/apptools/flow" - BIN_LOCATION="/usr/bin" - ETC_LOCATION="/etc/one" LOG_LOCATION="/var/log/one/appflow" - SUNSTONE_LOCATION="/usr/lib/one/sunstone" else - LIB_LOCATION="$ROOT/lib/ruby/apptools/flow" - BIN_LOCATION="$ROOT/bin" - ETC_LOCATION="$ROOT/etc" LOG_LOCATION="$ROOT/var/appflow" - SUNSTONE_LOCATION="$ROOT/lib/sunstone" fi -DIRECTORIES="$LIB_LOCATION $BIN_LOCATION $ETC_LOCATION $LOG_LOCATION" - -do_file() { - if [ "$UNINSTALL" = "yes" ]; then - rm $2/`basename $1` - else - if [ "$LINK" = "yes" ]; then - ln -s $SRC_DIR/$1 $2 - else - cp -R $SRC_DIR/$1 $2 - fi - fi -} - -copy_files() { - FILES=$1 - DST=$DESTDIR$2 - - mkdir -p $DST - - for f in $FILES; do - do_file $f $DST - done -} - ## Client files -copy_files "client/lib/*" "$LIB_LOCATION" +copy_files "client/lib/*" "$LIB_LOCATION/flow" copy_files "client/bin/*" "$BIN_LOCATION" ## Server files @@ -85,11 +33,11 @@ copy_files "client/bin/*" "$BIN_LOCATION" copy_files "bin/*" "$BIN_LOCATION" # dirs containing files -copy_files "controllers models lcm" "$LIB_LOCATION" +copy_files "controllers models lcm" "$LIB_LOCATION/flow" # files copy_files "lib/* models.rb config.ru Gemfile Gemfile.lock \ - Rakefile" "$LIB_LOCATION" + Rakefile" "$LIB_LOCATION/flow" # Sunstone copy_files "sunstone/public/js/user-plugins/*" \ @@ -100,5 +48,3 @@ copy_files "sunstone/routes/*" "$SUNSTONE_LOCATION/routes" LINK="no" copy_files "sunstone/etc/sunstone-appflow.conf" "$ETC_LOCATION" copy_files "config/appflow-server.conf" "$ETC_LOCATION" - - diff --git a/install_lib.sh b/install_lib.sh new file mode 100644 index 0000000000..a540182f69 --- /dev/null +++ b/install_lib.sh @@ -0,0 +1,84 @@ +# -------------------------------------------------------------------------- # +# Copyright 2010-2012, C12G Labs S.L. # +# # +# Licensed under the C12G Commercial Open-source License (the # +# "License"); you may not use this file except in compliance # +# with the License. You may obtain a copy of the License as part # +# of the software distribution. # +# # +# Unless 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. # +#--------------------------------------------------------------------------- # + +usage() { + echo + echo "Usage: install.sh [-d ONE_LOCATION] [-l] [-h]" + echo + 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 hld: -n 'install.sh' -- "$@"` + +if [ $? != 0 ] ; then + usage + exit 1 +fi + +eval set -- "$TEMP_OPT" + +LINK="no" +SRC_DIR=$PWD + +while true ; do + case "$1" in + -h) usage; exit 0;; + -d) ROOT="$2" ; shift 2 ;; + -l) LINK="yes" ; shift ;; + --) shift ; break ;; + *) usage; exit 1 ;; + esac +done + +if [ -z "$ROOT" ]; then + LIB_LOCATION="/usr/lib/one/ruby/apptools" + BIN_LOCATION="/usr/bin" + PACKAGES_LOCATION="/usr/share/one/apptools" + ETC_LOCATION="/etc/one" + SUNSTONE_LOCATION="/usr/lib/one/sunstone" +else + LIB_LOCATION="$ROOT/lib/ruby/apptools" + BIN_LOCATION="$ROOT/bin" + PACKAGES_LOCATION="$ROOT/share/apptools" + ETC_LOCATION="$ROOT/etc" + SUNSTONE_LOCATION="$ROOT/lib/sunstone" +fi + +do_file() { + if [ "$UNINSTALL" = "yes" ]; then + rm $2/`basename $1` + else + if [ "$LINK" = "yes" ]; then + ln -fs $SRC_DIR/$1 $2 + else + cp -R $SRC_DIR/$1 $2 + fi + fi +} + +copy_files() { + FILES=$1 + DST=$DESTDIR$2 + + mkdir -p $DST + + for f in $FILES; do + do_file $f $DST + done +} + diff --git a/market/install.sh b/market/install.sh index a7b47b2c18..4217f097f7 100755 --- a/market/install.sh +++ b/market/install.sh @@ -15,66 +15,10 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -TEMP_OPT=`getopt -o ld: -n 'install.sh' -- "$@"` - -if [ $? != 0 ] ; then - usage - exit 1 -fi - -eval set -- "$TEMP_OPT" - -LINK="no" -SRC_DIR=$PWD - -while true ; do - case "$1" in - -d) ROOT="$2" ; shift 2 ;; - -l) LINK="yes" ; shift ;; - --) shift ; break ;; - *) usage; exit 1 ;; - esac -done - -if [ -z "$ROOT" ]; then - LIB_LOCATION="/usr/lib/one/ruby/apptools/market" - BIN_LOCATION="/usr/bin" - ETC_LOCATION="/etc/one" - SUNSTONE_LOCATION="/usr/lib/one/sunstone" -else - LIB_LOCATION="$ROOT/lib/ruby/apptools/market" - BIN_LOCATION="$ROOT/bin" - ETC_LOCATION="$ROOT/etc" - SUNSTONE_LOCATION="$ROOT/lib/sunstone" -fi - -DIRECTORIES="$LIB_LOCATION $BIN_LOCATION $ETC_LOCATION" - -do_file() { - if [ "$UNINSTALL" = "yes" ]; then - rm $2/`basename $1` - else - if [ "$LINK" = "yes" ]; then - ln -fs $SRC_DIR/$1 $2 - else - cp -R $SRC_DIR/$1 $2 - fi - fi -} - -copy_files() { - FILES=$1 - DST=$DESTDIR$2 - - mkdir -p $DST - - for f in $FILES; do - do_file $f $DST - done -} +. ../install_lib.sh ## Client files -copy_files "client/lib/*" "$LIB_LOCATION" +copy_files "client/lib/*" "$LIB_LOCATION/market" copy_files "client/bin/*" "$BIN_LOCATION" ## Server files @@ -83,11 +27,11 @@ copy_files "client/bin/*" "$BIN_LOCATION" copy_files "bin/*" "$BIN_LOCATION" # dirs containing files -copy_files "controllers models public views" "$LIB_LOCATION" +copy_files "controllers models public views" "$LIB_LOCATION/market" # files copy_files "lib/* models.rb config.ru Gemfile Gemfile.lock \ - Rakefile config/init.rb" "$LIB_LOCATION" + Rakefile config/init.rb" "$LIB_LOCATION/market" # Sunstone copy_files "sunstone/public/js/user-plugins/*" \ @@ -98,4 +42,3 @@ copy_files "sunstone/routes/*" "$SUNSTONE_LOCATION/routes" LINK="no" copy_files "sunstone/etc/sunstone-appmarket.conf" "$ETC_LOCATION" copy_files "config/appmarket-server.conf" "$ETC_LOCATION" -