OSDN Git Service

mrcImagePyramid 修正 part2
[eos/base.git] / env / install-eos.sh
index 52b024b..e7b9d1a 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#RCRC!/bin/bash
 #### 
 WD=`pwd`
 
@@ -39,7 +39,7 @@ function setEosHome0() {
        #
        # EOS_HOME0
        #
-       echo "Set the directroy to be installed [$EOS_HOME0]: "; read ANS
+       echo -n "Set the directroy to be installed [$EOS_HOME0]: "; read ANS
        if [ ! -z $ANS ] ; then 
                EOS_HOME0=$ANS;
        fi
@@ -52,14 +52,14 @@ function setEosGitUser0() {
        #
        # EOS_GITUSER0
        #
-       echo "Do you have your git account for OSDN [Y|y or N|n] ?"; read ANS
+       echo -n "Do you have your git account for OSDN [Y|y or N|n] ?"; read ANS
        case $ANS in 
                N|n) 
                        export EOS_GITUSER0=
                        ;;
                Y|y)
                        unset ANS
-                       echo "Set the git account for OSDN [$EOS_GITUSER0]: "; read ANS 
+                       echo -n "Set the git account for OSDN [$EOS_GITUSER0]: "; read ANS 
                        if [ ! -z $ANS ] ; then
                                export EOS_GITUSER0=$ANS
                        fi
@@ -80,7 +80,7 @@ function surelyHome0andGitUser0() {
                echo "GIT Account: $EOS_GITUSER0"
        fi
        unset ANS
-       echo "Are these parameters OK [Y|y or N|n]? "; read ANS
+       echo -n "Are these parameters OK [Y|y or N|n]? "; read ANS
 
        case $ANS in
                Y|y) 
@@ -111,6 +111,16 @@ case $# in
                ;;
 esac
 
+unset FLAG_BASHPROFILE 
+echo -n "Do you want to rewrite $HOME/.bash_prfile ? [Y|y or N|n] " ; read FLAG_BASHPROFILE 
+unset FLAG_BASHRC
+echo -n "Do you want to rewrite $HOME/.bashrc ? [Y|y or N|n] " ; read FLAG_BASHRC
+unset FLAG_ZSHRC
+echo -n "Do you want to rewrite $HOME/.zshrc ? [Y|y or N|n] " ; read FLAG_ZSHRC
+unset FLAG_ZPROFILE
+echo -n "Do you want to rewrite $HOME/.zprofile ? [Y|y or N|n] " ; read FLAG_ZPROFILE 
+
+
 #### No Change
 #ROOT_EOS_SOURCEFORGE=https://sourceforge.jp/projects/eos/scm/git/base/blobs/master/
 ROOT_EOS_OSDN_GIT=git://git.osdn.jp/gitroot/eos/base.git
@@ -128,6 +138,7 @@ fi
 if [ -d $EOS_HOME0/.git ] ; then
        echo "Already installed"
        echo "Use update-eos.sh for updating or set a new directory for installation"
+       exit 1
 else
        if [ -z $EOS_GITUSER0 ] ; then
                INSTALL_FLAG=
@@ -135,37 +146,16 @@ else
                git clone --depth 1 $ROOT_EOS_OSDN_SSH $EOS_HOME0 || \
                git clone --depth 1 $ROOT_EOS_OSDN_HTTPS $EOS_HOME0 || \
                echo "A port for SSH or HTTPS is not open, or something wrong for $EOS_GITUSER0."
-               INSTALL_FLAG="NOGITUSER"
+               INSTALL_FLAG="GITUSER"
        fi
        if [ -z $INSTALL_FLAG ] ; then
                git clone --depth 1 $ROOT_EOS_OSDN_GIT  $EOS_HOME0 || \
                git clone --depth 1 $ROOT_EOS_OSDN_HTTP $EOS_HOME0 || \
                echo "A port for git (9418) or HTTP is not open, or something wrong."
+               INSTALL_FLAG="NOGITUSER"
        fi
 fi
 
-awk 'BEGIN {EOS="no"} {if($0=="## Eos_env Start") EOS="yes"; if(EOS!="yes") print $0;if($0=="## Eos_env End") EOS="no"; }' $HOME/.bash_profile > $HOME/.bash_profile.org
-
-cat $HOME/.bash_profile.org > $HOME/.bash_profile
-cat >> $HOME/.bash_profile << EOF
-## Eos_env Start
-##
-
-if [ ! -z $EOS_HOME0 ] ; then 
-       if [ -f $EOS_HOME0/env/Eos_env -a ! -f $HOME/.Eos_env ] ; then
-               ln -s $EOS_HOME0/env/Eos_env $HOME/.Eos_env
-       fi
-fi
-
-export EOS_HOME=$EOS_HOME0
-export EOS_GITUSER0=$EOS_GITUSER0
-
-test -r $HOME/.Eos_env  && . $HOME/.Eos_env
-
-##
-## Eos_env End
-EOF
-
 #
 # hostdepend
 #
@@ -204,6 +194,10 @@ if [ -d $EOS_HOME0/hostdepend ] ; then
                        git clone --depth 1 ${HOSTDEPEND_EOS_OSDN_SSH} ${EOS_HOSTDIR} || \
                        git clone --depth 1 ${HOSTDEPEND_EOS_OSDN_HTTPS} ${EOS_HOSTDIR} || \
                        echo "A port for SSH or HTTPS is not open, or something wrong."
+                       cd ${EOS_HOSTDIR}; \
+                       git clone --unshallow ${HOSTDEPEND_EOS_OSDN_SSH} || \
+                       git clone --unshallow 1 ${HOSTDEPEND_EOS_OSDN_HTTPS} || \
+                       echo "cannot --unshallow something wrong."
                        INSTALL_FLAG=INSTALL
                fi
                if [ -z $INSTALL_FLAG ] ; then
@@ -216,4 +210,174 @@ else
        echo "Cannot make hostdepend"
 fi
 
+
+#
+# .bash_profile or .zshprofile
+#
+echo "Setting an environment for Eos"
+
+case $FLAG_BASHPROFILE in 
+       Y|y)
+               awk 'BEGIN {EOS="no"} {if($0=="## Eos_env Start") EOS="yes"; if(EOS!="yes") print $0;if($0=="## Eos_env End") EOS="no"; }' $HOME/.bash_profile > $HOME/.bash_profile.org
+
+               cat $HOME/.bash_profile.org > $HOME/.bash_profile
+               if [ -f $EOS_HOME/env/template.bashrc ] ; then
+                       cat $EOS_HOME/env/template.bashrc >>  $HOME/.bash_profile
+               else 
+                       cat >> $HOME/.bash_profile << EOF
+## Eos_env Start
+##
+
+if [ ! -z $EOS_HOME0 ] ; then 
+       if [ -f $EOS_HOME0/env/Eos_env -a ! -f $HOME/.Eos_env ] ; then
+               ln -s $EOS_HOME0/env/Eos_env $HOME/.Eos_env
+       fi
+fi
+
+export EOS_HOME0=$EOS_HOME0
+export EOS_GITUSER0=$EOS_GITUSER0
+
+test -r $HOME/.Eos_env  && . $HOME/.Eos_env
+
+##
+## Eos_env End
+EOF
+               fi
+               echo "Please check $HOME/.bash_profile."
+               ;;
+
+       *)
+               echo "Before you use Eos, "
+               echo 'source $EOS_HOME0/env/Eos_env'
+               echo "  or " 
+               echo "You should rewrite $HOME/.bash_profile by yourself to execute $EOS_HOME0/env/Eos_env."
+               ;;
+esac
+
+case $FLAG_ZSHPROFILE in 
+       Y|y)
+               awk 'BEGIN {EOS="no"} {if($0=="## Eos_env Start") EOS="yes"; if(EOS!="yes") print $0;if($0=="## Eos_env End") EOS="no"; }' $HOME/.zprofile > $HOME/.zprofile.org
+
+               cat $HOME/.zprofile.org > $HOME/.zprofile
+               if [ -f $EOS_HOME/env/template.zshrc ] ; then
+                       cat $EOS_HOME/env/template.zshrc >>  $HOME/.zprofile
+               else 
+                       cat >> $HOME/.zprofile << EOF
+## Eos_env Start
+##
+
+if [ ! -z $EOS_HOME0 ] ; then 
+       if [ -f $EOS_HOME0/env/Eos_env -a ! -f $HOME/.Eos_env ] ; then
+               ln -s $EOS_HOME0/env/Eos_env $HOME/.Eos_env
+       fi
+fi
+
+export EOS_HOME0=$EOS_HOME0
+export EOS_GITUSER0=$EOS_GITUSER0
+
+test -r $HOME/.Eos_env  && . $HOME/.Eos_env
+
+##
+## Eos_env End
+EOF
+               fi
+               echo "Please check $HOME/.zprofile."
+               ;;
+
+       *)
+               echo "Before you use Eos, "
+               echo 'source $EOS_HOME0/env/Eos_env'
+               echo "  or " 
+               echo "You should rewrite $HOME/.zprofile by yourself to execute $EOS_HOME0/env/Eos_env."
+               ;;
+esac
+
+#
+# .bashrc
+#
+
+case $FLAG_BASHRC in 
+       Y|y)
+               awk 'BEGIN {EOS="no"} {if($0=="## Eos_env Start") EOS="yes"; if(EOS!="yes") print $0;if($0=="## Eos_env End") EOS="no"; }' $HOME/.bashrc > $HOME/.bashrc.org
+
+               cat $HOME/.bashrc.org > $HOME/.bashrc
+               if [ -f $EOS_HOME/env/template.bashrc ] ; then
+                       cat  $EOS_HOME/env/template.bashrc >> $HOME/.bashrc
+               else 
+                       cat >> $HOME/.bashrc << EOF
+## Eos_env Start
+##
+
+if [ ! -z $EOS_HOME0 ] ; then 
+       if [ -f $EOS_HOME0/env/Eos_env -a ! -f $HOME/.Eos_env ] ; then
+               ln -s $EOS_HOME0/env/Eos_env $HOME/.Eos_env
+       fi
+fi
+
+export EOS_HOME0=$EOS_HOME0
+export EOS_GITUSER0=$EOS_GITUSER0
+
+test -r $HOME/.Eos_env  && . $HOME/.Eos_env
+
+##
+## Eos_env End
+EOF
+               fi
+               echo "Please check $HOME/.bash_profile."
+               ;;
+
+       *)
+               echo "Before you use Eos, "
+               echo 'source $EOS_HOME0/env/Eos_env'
+               echo "  or " 
+               echo "You should rewrite $HOME/.bash_profile by yourself to execute $EOS_HOME0/env/Eos_env."
+               ;;
+esac
+
+
+case $FLAG_ZSHRC in 
+       Y|y)
+               awk 'BEGIN {EOS="no"} {if($0=="## Eos_env Start") EOS="yes"; if(EOS!="yes") print $0;if($0=="## Eos_env End") EOS="no"; }' $HOME/.zshrc > $HOME/.zshrc.org
+
+               cat $HOME/.zshrc.org > $HOME/.zshrc
+               if [ -f $EOS_HOME/env/template.zshrc ] ; then
+                       cat  $EOS_HOME/env/template.zshrc >> $HOME/.zshrc
+               else 
+                       cat >> $HOME/.zshrc << EOF
+## Eos_env Start
+##
+
+if [ ! -z $EOS_HOME0 ] ; then 
+       if [ -f $EOS_HOME0/env/Eos_env -a ! -f $HOME/.Eos_env ] ; then
+               ln -s $EOS_HOME0/env/Eos_env $HOME/.Eos_env
+       fi
+fi
+
+export EOS_HOME0=$EOS_HOME0
+export EOS_GITUSER0=$EOS_GITUSER0
+
+test -r $HOME/.Eos_env  && . $HOME/.Eos_env
+
+##
+## Eos_env End
+EOF
+               fi
+               echo "Please check $HOME/.zshirc"
+               ;;
+
+       *)
+               echo "Before you use Eos, "
+               echo 'source $EOS_HOME0/env/Eos_env'
+               echo "  or " 
+               echo "You should rewrite $HOME/.zshrc by yourself to execute $EOS_HOME0/env/Eos_env."
+               ;;
+esac
+
+
+
+#
+#
+#
+echo "You finished Eos installation."
+
 cd $WD