#!/bin/ksh # # @(#) $Revision: 1.0 $ # Didnt write this one, but it is useful # somewhere that is # admin@wickedmind.com # stty -imaxbel # Set up the terminal: if [ "$TERM" = "" ] then eval ` tset -s -Q -m ':?hp' ` else eval ` tset -s -Q ` fi SCCS_BASE=/export/src; export SCCS_BASE # Introductory Messages echo " " echo "+-----------------------------------------------------------------------+" echo "| Welcome to the Hoechst/Celanese Promotion Tool ...... |" echo "| For suggestions and/or comments please call Rick Kupcunas at 277-8587 |" echo "| Please follow the prompts, |" echo "| Option values are enclosed within parenthesis, |" echo "| Default values are enclosed within the square brackets |" echo "| - to exit at any time press ' c' |" echo "+-----------------------------------------------------------------------+" # Set the directory variables for the promotion process # # Set default values if not already set; if set, verify that the # value present is valid. To do this first change the value # to uppercase and then verify it is valid against a list of # items # # Get the APPLICATION variable # echo " " echo "What application are you working with (FOX, DW1 or MAR)? [FOX] ....... \c" read APPLICATION while : do typeset -u APPLICATION if [ "$APPLICATION" = "" ] then APPLICATION=FOX; export APPLICATION else case "$APPLICATION" in FOX) break;; MAR) break;; DW1) break;; * ) echo " Invalid Application, please reenter [FOX] ...................... \c" read APPLICATION;; esac fi done # # Get the ENVIRONMENT variable; after fetch convert to proper # value of the RELEASE # echo "Which database (HCDV, HCTS, HCTR, HCRL or HCPR) ? [HCDV] ............. \c" read ENVIRONMENT while : do typeset -u ENVIRONMENT if [ "$ENVIRONMENT" = "" ] then ENVIRONMENT=HCDV; export ENVIRONMENT else case "$ENVIRONMENT" in HCDV) MAJOR_RELEASE=1.0;export MAJOR_RELEASE; MINOR_RELEASE=3 ;export MINOR_RELEASE;break;; HCTS) MAJOR_RELEASE=1.0;export MAJOR_RELEASE; MINOR_RELEASE=2 ;export MINOR_RELEASE;break;; HCTR) MAJOR_RELEASE=1.0;export MAJOR_RELEASE; MINOR_RELEASE=1 ;export MINOR_RELEASE;break;; HCRL) MAJOR_RELEASE=1.0;export MAJOR_RELEASE; MINOR_RELEASE=1 ;export MINOR_RELEASE;break;; HCPR) MAJOR_RELEASE=1.0;export MAJOR_RELEASE; MINOR_RELEASE=0 ;export MINOR_RELEASE;break;; * ) echo " Invalid Environment, please reenter [HCDV] ..................... \c" read ENVIRONMENT;; esac fi done SCCS_PATH=${SCCS_BASE}/${APPLICATION}/${MAJOR_RELEASE}/SCCS; export SCCS_PATH echo " Current SCCS Parent directory is set to: '${SCCS_PATH}'" echo "" # # Get the name of the subdirectory to be modified # echo "Please enter a Sub-Directory structure ............................... \c" read SUB_DIRECTORY while : do while : do ACKNA=${SUB_DIRECTORY} typeset -L1 ACKNA case "$ACKNA" in /) echo " Invalid Path Name, Do not start with a '/' ..................... \c" read SUB_DIRECTORY;; *) ; esac if [ "$ACKNA" = "/" ] then break; fi if [ "$SUB_DIRECTORY" = "" ] || [ "$SUB_DIRECTORY" = " " ] then echo " Missing Sub-Directory name; would you like to see the list of all" echo " valid Sub-Directories (Y or N)? [N] ....................... \c" read OKAY while : do typeset -u OKAY if [ "$OKAY" = " " ] || [ "$OKAY" = "" ] then OKAY=N; export OKAY else typeset -L1 OKAY; export OKAY case "$OKAY" in N) break;; Y) break;; *) echo " Invalid option, please reenter [N] ........................... \c" read OKAY;; esac fi done if [ "$OKAY" = "Y" ] then echo " Possible SCCS sub-directories to select from:" ls $SCCS_PATH echo "" fi echo " Please enter a Sub-Directory structure ......................... \c" read SUB_DIRECTORY else if test -d ${SCCS_PATH}/${SUB_DIRECTORY} then echo " Current SCCS Parent directory is set to: '${SCCS_PATH}/${SUB_DIRECTORY}'" echo "" echo " Is this the proper path to the SCCS sub-directory (Y or N)? [Y] .... \c" read OKAY while : do typeset -u OKAY if [ "$OKAY" = " " ] || [ "$OKAY" = "" ] then OKAY=Y; export OKAY else typeset -L1 OKAY; export OKAY case "$OKAY" in N) break;; Y) break;; *) echo " Invalid Path Flag, please reenter [Y] ...................... \c" read OKAY;; esac fi done if [ "$OKAY" = "Y" ] then break; else echo " Name of sub-directory to be managed ............................ \c" read SUB_DIRECTORY fi else if test -d ${SCCS_PATH}/${SUB_DIRECTORY} then echo " Valid BUT it is does not have an SCCS extension ................ \c" read SUB_DIRECTORY; else echo " Invalid Directory ('${SCCS_PATH}/${SUB_DIRECTORY}')" echo " Name of sub-directory to be managed ............................ \c" read SUB_DIRECTORY; fi fi fi done if [ "$OKAY" = "Y" ] then break; fi done SCCS_PATH=${SCCS_BASE}/${APPLICATION}/${MAJOR_RELEASE}/SCCS/${SUB_DIRECTORY}; export SCCS_PATH # # Get the USERID variable # echo "What UserId are you working with? [$LOGNAME] .............................. \c" read USERID while : do if [ "$USERID" = "" ] then USERID=$LOGNAME; export USERID;break; else if test -d /home/${USERID} then break; else echo " Invalid UserId, please reenter [$LOGNAME] ....................... \c" read USERID; fi fi done # Set the variables for the promotion process # 1. Promoting invokes the SCCS Commands: # admin ..... adds code for the first time # delta ..... creates a delta of an existing source file # 2. Reserving invokes the SCCS Commands: # get ....... get and lock the source file # 3. UnReserving invokes the SCCS Commands # uget ...... unreserve and free the lock on a file echo "Are you Promoting, Reserving or UnReserving (P,R or U)? [R] .......... \c" read ACTION while : do typeset -u ACTION if [ "$ACTION" = " " ] || [ "$ACTION" = "" ] then ACTION=R; export ACTION else typeset -L1 ACTION case "$ACTION" in P) break;; R) break;; U) break;; *) echo " Invalid Action, please reenter [R] ............................. \c" read ACTION; esac fi done # # Get additional information when RESERVING (GET) code # if [ "$ACTION" = "R" ] then echo " RESERVING EDITS:" echo " Will you update the code (Y or N)? [N] ........................... \c" read UPDATE while : do typeset -u UPDATE if [ "$UPDATE" = " " ] || [ "$UPDATE" = "" ] then UPDATE=N; export UPDATE else typeset -uL1 UPDATE; export UPDATE case "$UPDATE" in N) break;; Y) break;; *) echo " Invalid Update Action, please reenter [N] .................... \c" read UPDATE;; esac fi done fi # # Get additional information when PROMOTING (DELTA) code # if [ "$ACTION" = "P" ] then echo " PROMOTING EDITS:" echo " Please enter a Modification Number(SCN)? ......................... \c" read MOD_NUMBER while : do if [ "$MOD_NUMBER" = " " ] || [ "$MOD_NUMBER" = "" ] then echo " A Modification Number is required .......................... \c" read MOD_NUMBER; else break; fi done echo " Do you wish to retain a read-only version (Y or N)? [N] .......... \c" read RETAIN while : do typeset -u RETAIN if [ "$RETAIN" = " " ] || [ "$RETAIN" = "" ] then RETAIN=N; export RETAIN else typeset -uL1 RETAIN; export RETAIN case "$RETAIN" in N) break;; Y) break;; *) echo " Invalid RETAIN Action, please reenter [N] ..................... \c" read RETAIN;; esac fi done fi # # Get additional information when UNRESERVING code # if [ "$ACTION" = "U" ] then echo " UNRESERVING EDITS:" echo " Do you wish to retain a read-only version (Y or N)? [N] .......... \c" read RETAIN while : do typeset -u RETAIN if [ "$RETAIN" = " " ] || [ "$RETAIN" = "" ] then RETAIN=N; export RETAIN else typeset -uL1 RETAIN; export RETAIN case "$RETAIN" in N) break;; Y) break;; *) echo " Invalid RETAIN Action, please reenter [N] .................. \c" read RETAIN;; esac fi done fi if [ "$ACTION" = "R" ] || [ "$ACTION" = "U" ] then echo " Would you like to see all available items that can be either " echo " reserved/unreserved (Y or N)? [N] ............................. \c" read OKAY while : do typeset -u OKAY if [ "$OKAY" = " " ] || [ "$OKAY" = "" ] then OKAY=N; export OKAY else typeset -L1 OKAY; export OKAY case "$OKAY" in N) break;; Y) break;; *) echo " Invalid option, please reenter [N] ........................... \c" read OKAY;; esac fi done if [ "$OKAY" = "Y" ] then echo "" echo " Possible SCCS items to select from:" ls $SCCS_PATH fi fi if [ "$ACTION" = "P" ] then echo " Would you like to see all available items that can be " echo " promoted (Y or N)? [N] .................................... \c" read OKAY while : do typeset -u OKAY if [ "$OKAY" = " " ] || [ "$OKAY" = "" ] then OKAY=N; export OKAY else typeset -L1 OKAY; export OKAY case "$OKAY" in N) break;; Y) break;; *) echo " Invalid option, please reenter [N] ........................... \c" read OKAY;; esac fi done if [ "$OKAY" = "Y" ] then echo " Possible items that can be promoted from $PWD:" ls fi fi # # &&&&& Looping Mechanism &&&&& # echo "" echo " ### To break out of loop hit ' c' or follow the prompt to exit ###" echo "" while : do # Get the name of the module to be promoted echo " Name of module to be managed ..................................... \c" read MODULE_NAME # Perform the following edits: # - Proceed only if extension is present. # - Proceed only if extension is valid. while : do if [ "$MODULE_NAME" = "" ] then echo " Would you like to quit the SCCS Promotion Tool? [N] .......... \c" read BREAK while : do typeset -u BREAK if [ "$BREAK" = " " ] || [ "$BREAK" = "" ] then BREAK=N; export BREAK else typeset -L1 BREAK; export BREAK case "$BREAK" in N) break;; Y) break;; *) echo " Invalid option, please reenter [N] ......................... \c" read BREAK;; esac fi done if [ "$BREAK" = "N" ] then echo " Please enter a Module name (with extension) .................... \c" read MODULE_NAME; else break; fi else TRASH=$MODULE_NAME typeset -L2 TRASH; export TRASH case "$TRASH" in s.) echo " Invalid name; must omit the 's.' prefix ...................... \c" read MODULE_NAME;; *) ; esac if test -f ${SCCS_PATH}/s.${MODULE_NAME} then break; else echo " Invalid name; not a valid SCCS file name ..................... \c" read MODULE_NAME; fi fi done if [ "$BREAK" = "Y" ] then break; fi echo "" # # %%%%% PERFORM THE ACTUAL GET/PUT LOGIC %%%%% # # # RETRIEVING(GETTING) files from SCCS # # 1. see if the file exists in SCCS # 2. if updating the file, see if anyone else has the file checked # out for update if [ "$ACTION" = "R" ] then if test -f ${SCCS_PATH}/s.${MODULE_NAME} then if [ "$UPDATE" = "Y" ] then EDIT_OUT="`sact ${SCCS_PATH}/s.${MODULE_NAME} | awk '{ print $1 }'`" if [ "$EDIT_OUT" = "No" ] || [ "$EDIT_OUT" = "" ] then get -e -s -r${MINOR_RELEASE} ${SCCS_PATH}/s.${MODULE_NAME} echo "ACK: Module '$MODULE_NAME' retrieved from SCCS for Update " else CHECKED_ID="`sact $SCCS_PATH/s.$MODULE_NAME | awk '{ print $3 }'`" if [ "$CHECKED_ID" = "$LOGNAME" ] then echo "ERROR: Module '$MODULE_NAME' already checked out by your ID " echo " Please promote (or unreserve) the code prior to retrieval" else echo "ERROR: Module '$MODULE_NAME' already checked out by '$CHECKED_ID' " echo " Unable to Retrieve from SCCS; coordinate with '$CHECKED_ID' " fi fi else get -s -r${MINOR_RELEASE} ${SCCS_PATH}/s.${MODULE_NAME} echo "ACK: Module '$MODULE_NAME' retrieved from SCCS for Read-Only " fi else echo "ERROR: Requested file '$MODULE_NAME' does not exist in SCCS " echo "ERROR: Ensure that '$SCCS_PATH/s.$MODULE_NAME exists' " fi fi # # PROMOTING files into SCCS # # 1. see if the file exists in SCCS # - if present then UPDATE the file in SCCS # - if not present then add the file to SCCS # 2. Use the 'admin' function to store the initial copy of program # 3. If already stored in SCCS; create a delta if [ "$ACTION" = "P" ] then if test -f ${SCCS_PATH}/s.${MODULE_NAME} then cp ${MODULE_NAME} s.${MODULE_NAME} if [ "$RETAIN" = "Y" ] then delta -m${MOD_NUMBER} -s -n $SCCS_PATH/s.${MODULE_NAME} else delta -m${MOD_NUMBER} -s $SCCS_PATH/s.${MODULE_NAME} fi rm s.${MODULE_NAME} echo "ACK: Module '$MODULE_NAME' successfully replaced in SCCS " else admin -fv -m${MOD_NUMBER} -r${MINOR_RELEASE} -i${MODULE_NAME} ${SCCS_PATH}/s.${MODULE_NAME} echo "ACK: Module '$MODULE_NAME' successfully stored in SCCS " # Generic Error messages for end-users benefit # echo " 'No id keywords (cm7)' indicates that no ID keywords are present" echo " and should be added - see documentation" fi fi # # UNRESERVING (Free SCCS Locks) files into SCCS # # 1. see if the file exists in SCCS # 2. see if the user has exclusive lock # - if so return to SCCS # - if not issue error if [ "$ACTION" = "U" ] then if test -f ${SCCS_PATH}/s.${MODULE_NAME} then CHECKED_OUT="`sact ${SCCS_PATH}/s.${MODULE_NAME} | awk '{ print $1 }'`" if [ "$CHECKED_OUT" = "No" ] || [ "$CHECKED_OUT" = "" ] then echo "ERROR: Module '$MODULE_NAME' is not checked out currently " echo " No action taken" else CHECKED_ID="`sact ${SCCS_PATH}/s.${MODULE_NAME} | awk '{ print $3 }'`" if [ "$CHECKED_ID" = "$LOGNAME" ] || [ "$CHECKED_ID" = "" ] then if [ "$RETAIN" = "Y" ] then unget -sn ${SCCS_PATH}/s.${MODULE_NAME} echo "ACK: Module '$MODULE_NAME' returned to SCCS with source retained" else unget -s ${SCCS_PATH}/s.${MODULE_NAME} echo "ACK: Module '$MODULE_NAME' returned to SCCS with source removed" fi else echo "ERROR: Module '$MODULE_NAME' already checked out by '$CHECKED_ID' " echo " Unable to Return to SCCS; cordinate with '$CHECKED_ID' " fi fi else echo "ERROR: Module '$MODULE_NAME' does not exist in SCCS " fi fi echo " " done echo " " echo "+-----------------------------------------------------------------------+" echo "| Thank-you for using the Hoechst/Celanese SCCS Promotion Tool ...... |" echo "+-----------------------------------------------------------------------+" echo ""