OSDN Git Service

process of creating symbolic link is removed from each script. modify README.
authorTadashi Koike <t-koike@users.sourceforge.jp>
Sat, 27 Mar 2010 13:37:55 +0000 (22:37 +0900)
committerTadashi Koike <t-koike@users.sourceforge.jp>
Sat, 27 Mar 2010 13:37:55 +0000 (22:37 +0900)
README
gast
gast_make
gast_rpmbuild

diff --git a/README b/README
index 0b5387b..5d75af5 100644 (file)
--- a/README
+++ b/README
@@ -145,22 +145,43 @@ Table of contents
         gast-0.1.2/README.ja_JP.UTF-8
 
   [ setup ]
-    Change a working directory to an extracted directory, and execte
-    each scripts with no argument.
-    Symbolic link file are created at same directory.
+    1) Change a working directory to an extracted directory.
 
         $ cd /home/foo/gast-0.1.2
-        $ ./gast
-        gast : Create symbolic link 'gcc'
-        gast : Create symbolic link 'cc'
-        gast : Create symbolic link 'g++'
 
-        $ ./gast_make
-        gast_make : Create symbolic link 'make'
-        gast_make : Create symbolic link 'gmake'
+    2) If you need, please add/modify your compiler/make 
+       utility name to 'gast.aliases'.
 
-        $ ./gast_rpmbuild
-        gast_rpmbuild : Create symbolic link 'rpmbuild'
+        $ vi gast.aliases
+
+    3) Execute 'gast_symlink' script. this script creates
+       symbolic link file foe each wrapper script.
+       Symbolic link filename are selected from 'gast.aliases'.
+
+        $ ./gast_symlink
+
+       If you want to add new symbolic link, you have to modify
+       'gast.aliases' file again, and re-execute 'gast_symlink'.
+
+       for exampe)
+        $ ./gast_symlink
+
+       If you want to select script to create symbolic link, 
+       please specify script name.
+
+       for exampe)
+        $ ./gast_symlink gast
+       
+    4) If you want to delete symbolic link, execute 'gast_symlink'
+       with '-u' option. All symbolic link files are deleted.
+
+        $ ./gast_symlink -u
+
+       If you want to select script to delete  symbolic link,
+       please specify script name.
+
+       for exampe)
+        $ ./gast_symlink -u gast_make
 
   [ NOTICE ]
     - gast, gast_make, gast_rpmbuild must be in same directory.
diff --git a/gast b/gast
index 00682b4..f8cc1bf 100755 (executable)
--- a/gast
+++ b/gast
@@ -76,7 +76,20 @@ VERSION="0.1.2"
 ORIGINAL_NAME="gast"
 CWD=`pwd`
 SCRIPT_NAME=${0##*/}
-SCRIPT_PATH=${0%/*}
+if [[ "$0" =~ ".+/[^/]+" ]]; then
+    SCRIPT_PATH=${0%/*}
+else
+    SCRIPT_PATH=${0%${SCRIPT_NAME}}
+fi
+# get a directory path (full-path) of this script
+case "${SCRIPT_PATH}" in
+    '.' | '')  SCRIPT_PATH="${CWD}" ;;
+    \./*)      SCRIPT_PATH="${CWD}/${SCRIPT_PATH#*/}" ;;
+    '~')       SCRIPT_PATH="${HOME}" ;;
+    \~/*)      SCRIPT_PATH="${HOME}/${SCRIPT_PATH#*/}" ;;
+    \/*)               :       ;;
+    *)         SCRIPT_PATH="${CWD}/${SCRIPT_PATH}" ;;
+esac
 
 WORK_DIR="/tmp"
 
@@ -125,37 +138,10 @@ EOL
             ;;
         esac
     done
-
-    cd "${SCRIPT_PATH}"
-    for cmd in gcc cc g++
-    do
-        if [ -e "${cmd}" ]; then
-            file "${cmd}" 2>/dev/null | egrep 'symbolic link' >/dev/null 2>&1
-            if [ "$?" -ne 0 ]; then
-                echo "${ORIGINAL_NAME} : '${cmd}' exists as normal file or directory. Could not create symbolic link." >&2
-                continue
-            fi
-        fi
-        ln -sf "${ORIGINAL_NAME}" "${cmd}"
-        if [ "$?" -eq 0 ]; then
-            echo "${ORIGINAL_NAME} : Create symbolic link '${cmd}'" >&2
-        else
-            echo "${ORIGINAL_NAME} : Couldn't create symbolic link '${cmd}'" >&2
-        fi
-    done
+    # symbolic link management are moved to 'gast_symlink' script.
     exit 0
 fi
 
-# get a directory path (full-path) of this script
-case "${SCRIPT_PATH}" in
-    '.')       SCRIPT_PATH="${CWD}" ;;
-    \./*)      SCRIPT_PATH="${CWD}/${SCRIPT_PATH#*/}" ;;
-    '~')       SCRIPT_PATH="${HOME}" ;;
-    \~/*)      SCRIPT_PATH="${HOME}/${SCRIPT_PATH#*/}" ;;
-    \/*)               :       ;;
-    *)         SCRIPT_PATH="${CWD}/${SCRIPT_PATH}" ;;
-esac
-
 # leaves out a script path name from PATH environment variable because of
 # executing original compiler binary file in this script.
 path_tmp=
index f238bf0..710f86b 100755 (executable)
--- a/gast_make
+++ b/gast_make
@@ -25,7 +25,20 @@ VERSION=0.1.2
 ORIGINAL_NAME="gast_make"
 CWD=`pwd`
 SCRIPT_NAME=${0##*/}
-SCRIPT_PATH=${0%/*}
+if [[ "$0" =~ ".+/[^/]+" ]]; then
+    SCRIPT_PATH=${0%/*}
+else
+    SCRIPT_PATH=${0%${SCRIPT_NAME}}
+fi
+# get a directory path (full-path) of this script
+case "${SCRIPT_PATH}" in
+    '.' | '')  SCRIPT_PATH="${CWD}" ;;
+    \./*)      SCRIPT_PATH="${CWD}/${SCRIPT_PATH#*/}" ;;
+    '~')       SCRIPT_PATH="${HOME}" ;;
+    \~/*)      SCRIPT_PATH="${HOME}/${SCRIPT_PATH#*/}" ;;
+    \/*)               :       ;;
+    *)         SCRIPT_PATH="${CWD}/${SCRIPT_PATH}" ;;
+esac
 
 # check wheter perl can use or not.
 HAS_PERL=`which perl 2>/dev/null`
@@ -62,37 +75,10 @@ EOL
             ;;
         esac
     done
-
-    cd "${SCRIPT_PATH}"
-    for cmd in make gmake
-    do
-        if [ -e "${cmd}" ]; then
-            file "${cmd}" 2>/dev/null | egrep 'symbolic link' >/dev/null 2>&1
-            if [ "$?" -ne 0 ]; then
-                echo "${ORIGINAL_NAME} : '${cmd}' exists as normal file or directory. Could not create symbolic link." >&2
-                continue
-            fi
-        fi
-        ln -sf "${ORIGINAL_NAME}" "${cmd}"
-        if [ "$?" -eq 0 ]; then
-            echo "${ORIGINAL_NAME} : Create symbolic link '${cmd}'" >&2
-        else
-            echo "${ORIGINAL_NAME} : Couldn't create symbolic link '${cmd}'" >&2
-        fi
-    done
+    # symbolic link management are moved to 'gast_symlink' script.
     exit 0
 fi
 
-# get a directory path (full-path) of this script
-case "${SCRIPT_PATH}" in
-    '.')       SCRIPT_PATH="${CWD}" ;;
-    \./*)      SCRIPT_PATH="${CWD}/${SCRIPT_PATH#*/}" ;;
-    '~')       SCRIPT_PATH="${HOME}" ;;
-    \~/*)      SCRIPT_PATH="${HOME}/${SCRIPT_PATH#*/}" ;;
-    \/*)               :       ;;
-    *)         SCRIPT_PATH="${CWD}/${SCRIPT_PATH}" ;;
-esac
-
 # Get an original make command.
 path_save="${PATH}"
 path_tmp=
index c602752..79cc273 100755 (executable)
 
 VERSION=0.1.2
 ORIGINAL_NAME="gast_rpmbuild"
-SCRIPT_NAME=${0##*/}
-SCRIPT_PATH=${0%/*}
 CWD=`pwd`
+SCRIPT_NAME=${0##*/}
+if [[ "$0" =~ ".+/[^/]+" ]]; then
+    SCRIPT_PATH=${0%/*}
+else
+    SCRIPT_PATH=${0%${SCRIPT_NAME}}
+fi
+# get a directory path (full-path) of directory this script
+case "${SCRIPT_PATH}" in
+    '.' | '')  SCRIPT_PATH="${CWD}" ;;
+    \./*)      SCRIPT_PATH="${CWD}/${SCRIPT_PATH#*/}" ;;
+    '~')       SCRIPT_PATH="${HOME}" ;;
+    \~/*)      SCRIPT_PATH="${HOME}/${SCRIPT_PATH#*/}" ;;
+    \/*)               :       ;;
+    *)         SCRIPT_PATH="${CWD}/${SCRIPT_PATH}" ;;
+esac
 
 # When this script is executed as 'gast_rpmbuild', this script creates symbolic link
 # file name as 'rpmbuild' and exit.
@@ -87,16 +100,6 @@ if [ -z "${RPMBUILD_BIN}" ]; then
     exit 1
 fi
 
-# get a directory path (full-path) of directory this script
-case "${SCRIPT_PATH}" in
-    '.')       SCRIPT_PATH="${CWD}" ;;
-    \./*)      SCRIPT_PATH="${CWD}/${SCRIPT_PATH#*/}" ;;
-    '~')       SCRIPT_PATH="${HOME}" ;;
-    \~/*)      SCRIPT_PATH="${HOME}/${SCRIPT_PATH#*/}" ;;
-    \/*)               :       ;;
-    *)         SCRIPT_PATH="${CWD}/${SCRIPT_PATH}" ;;
-esac
-
 # Set this script's directory to PATH environment variable.
 # (to be found a gcc wrapper script (=gast) in advance of original compiler binary).
 PATH="${SCRIPT_PATH}:${PATH}"