?? showallversions.sh
字號:
#!/bin/ksh## SAMPLE NAME: showFileVersions## FUNCTIONS: This sample shell script displays all the version numbers of# a file.## USAGE: showFileVersions pathName releaseName## ENVIRONMENT# VARIABLE(S): CMVC_FAMILY [CMVC_BECOME]## ORIGINS: 27## 5765-039 (C) COPYRIGHT International Business Machines Corp. 1991,1993# 5765-207 (C) COPYRIGHT International Business Machines Corp. 1993# 5765-202 (C) COPYRIGHT International Business Machines Corp. 1993# 5622-063 (C) COPYRIGHT International Business Machines Corp. 1993# 5765-069 (C) COPYRIGHT International Business Machines Corp. 1991,1993# All Rights Reserved# Licensed Materials - Property of IBM## US Government Users Restricted Rights - Use, duplication or# disclosure restricted by GSA ADP Schedule Contract with IBM Corp.### NOTICE TO USERS OF THE SOURCE CODE EXAMPLES## INTERNATIONAL BUSINESS MACHINES CORPORATION PROVIDES THE SOURCE CODE# EXAMPLES, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS, "AS IS" WITHOUT# WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT# LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A# PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE# OF THE SOURCE CODE EXAMPLES, BOTH INDIVIDUALLY AND AS ONE OR MORE GROUPS,# IS WITH YOU. SHOULD ANY PART OF THE SOURCE CODE EXAMPLES PROVE# DEFECTIVE, YOU (AND NOT IBM OR AN AUTHORIZED RISC System/6000* WORKSTATION# DEALER) ASSUME THE ENTIRE COST OF ALL NECESSARY SERVICING, REPAIR OR# CORRECTION.## * RISC System/6000 is a trademark of International Business Machines# Corporation.## /usr/lpp/cmvc/samples/showFileVersions#if [ $# -eq 0 ]; then echo "\nusage: $0 pathName releaseName\n" echo "This sample shell script displays a list of version numbers," echo "release names and path names for the specified file." echo echo "All versions of the specified file that are available within" echo "the CMVC family will be displayed." echo echo "Note that as the file matures, it may be renamed and linked" echo "to other releases. This shell script will list all such" echo "renames and linkages so that you can identify where common" echo "files exists within the family." echo echo "If a version entry contains a blank release and path name" echo "column, then the file is derived from a migrated file and" echo "this particular version is not being used as the current" echo "version in any of the releases within the CMVC family." echo exit 1fi# ------------------------------------------------------# Check that the CMVC_FAMILY environment variable is set# ------------------------------------------------------if [ -z "$CMVC_FAMILY" ]then echo "The CMVC family must be set with the CMVC_FAMILY environment variable." exit 1fiif [ -n "$CMVC_BECOME" ]then Report -view Users -where "login='$CMVC_BECOME'" -raw > /tmp/uv$$ if [[ ! -s /tmp/uv$$ ]] then echo echo "The user specified in the CMVC_BECOME environment variable" echo "does not exist in the CMVC family $CMVC_FAMILY. Verify" echo "the value you set in this environment variable and retry the" echo "script." echo [ -r /tmp/uv$$ ] && rm -f /tmp/uv$$ exit 1 fi [ -r /tmp/uv$$ ] && rm -f /tmp/uv$$fi# -------------------------# Save the input parameters# -------------------------pathName=$1releaseName=$2# ----------------------# Setup query statements# ----------------------sel="select 0,0,0,id,0,'','','','','','','','',SID,0,'' from Versions"pathseg="(select id from Path where name='$pathName')"relseg="(select id from Releases where name='$releaseName')"# ------------------------------------------------# Check that the release exists in the CMVC family# ------------------------------------------------Report -view ReleaseView -where "name='$releaseName'" -raw > /tmp/rv$$if [[ ! -s /tmp/rv$$ ]]then echo "Release $releaseName does not exist in the $CMVC_FAMILY CMVC family." exit 1fi[ -r /tmp/rv$$ ] && rm -f /tmp/rv$$# ---------------------------------------------------# Check that the file exists in the Release specified# ---------------------------------------------------Report -view FileView -where "pathId=$pathseg and releaseId=$relseg" \-raw > /tmp/fv$$if [[ ! -s /tmp/fv$$ ]]then echo "File $pathName is not associated with release $releaseName." [ -r /tmp/fv$$ ] && rm -f /tmp/fv$$ exit 1fi[ -r /tmp/fv$$ ] && rm -f /tmp/fv$$# ---------------------------------# Display the header for the report# ---------------------------------echo echo "Finding all versions of $pathName. This may take some time."echo "Searching...please wait."echo echo "NOTE: The entries in the table that have a blank release name"echo " and path name indicate that these versions of the file are "echo " not being used as the current version in any of the releases"echo " within the CMVC family."echoecho "Version Release Name Path Name" echo "-------------------- --------------- ------------------------------"# ----------------------------------------------------------------------# Find all versions of the file. This will find all versions that# are derived from the same initial source file. Note that as versions# are created the file may be linked to other releases and also renamed.# Store the output in a temporary file.# ----------------------------------------------------------------------Report -vi ChangeView -raw -where "trackId=0 union $sel where sourceId=(select sourceId from Files where pathId=$pathseg and releaseId=$relseg)" > /tmp/cv$$# ------------------------------------# Read each line in the temporary file# ------------------------------------checked=0while read linedo # ------------------------------------------------------------- # Read the version number from the raw output of the changeview # ------------------------------------------------------------- SID=`echo $line | cut -d'|' -f4 ` # -------------------------------------------------------------- # Check if the file is an original or a migrated file. If it is # an original file, there will be a changeview entry for the # version. If it was migrated, there will not be a changeview # for each version of the file. # -------------------------------------------------------------- if [[ $checked -eq 0 ]] then Report -view ChangeView -wh "versionSID='$SID' and pathName='$pathName' and releaseName='$releaseName'" -raw > /tmp/v2$$ if [[ -s /tmp/v2$$ ]] # file must have be an original then found=1 else found=0 fi checked=1 [ -r /tmp/v2$$ ] && rm -f /tmp/v2$$ fi # ---------------------------------------------------- # The file was originally created within the CMVC # and it is associated with a release under binding # control and therefore has a changeview entry # ---------------------------------------------------- if [[ $found -eq 1 ]] then # ---------------------------------------------------- # Display a line for each version of the file and any # common files # ---------------------------------------------------- Report -view ChangeView -wh "versionId in (select id from Versions where sourceId=(select sourceId from Files where pathId=$pathseg and releaseId=$relseg))" -raw | awk -F"|" ' BEGIN { fm="%-20.20s %-15.15s %30.30s\n" } { printf fm,$4,$1,$5 } END { }' return # ---------------------------------------------------------- # The file: # a) was created using the CMVC migration utility # b) is associated with a release under non-binding control # ---------------------------------------------------------- else # ----------------------------------------------------- # For each version, perform a fileview query to see if # it is the current version within any release. Store # the query results in a temporary file. # ----------------------------------------------------- Report -view FileView -wh "nuVersionSID='$SID' and sourceId=(select sourceId from Files where pathId=$pathseg and releaseId=$relseg)" -raw >> /tmp/fv$$ # # If the temporary file is not empty, then the fileview query # returned results. This means that this version of the file # is linked to a CMVC release. # if [[ -s /tmp/fv$$ ]] then # # Display the version number, release name and file # name # Report -view FileView -wh "nuVersionSID='$SID' and sourceId=(select sourceId from Files where pathId=$pathseg and releaseId=$relseg)" -raw | awk -F"|" ' BEGIN { fm="%-20.20s %-15.15s %30.30s\n" } { printf fm,$4,$2,$8 } END { }' else # # This file is not linked to any release at the # moment but the version of the file is available # within the system due to migration of the file. # Just display the version number. # echo $SID fi [ -r /tmp/fv$$ ] && rm -f /tmp/fv$$ fidone </tmp/cv$$[ -r /tmp/cv$$ ] && rm -f /tmp/cv$$
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -