(file) Return to CreateDmtfSchema CVS log (file) (dir) Up to [Pegasus] / pegasus / mak

  1 karl  1.1 #!/bin/bash
  2           ###########################################################################
  3           ##
  4           ## createschema script to create CIM Schema "interface" files:
  5           ##
  6           ## This script was used starting when CIM Schema Version 2.11 was
  7           ## installed because the new DMTF distribution is different that
  8 kumpf 1.2 ## the file structure used by the Pegasus repository build functions.
  9           ## It is not intended for general use. It is available here as
 10           ## further documentation of the CIM Schema install process and for
 11 karl  1.1 ## future reference when new CIM Schema versions are installed.
 12           ##
 13 kumpf 1.2 ## This bash shell script file creates "interface" files for the new
 14           ## DMTF CIM Schema Version 2.11 and later to make them compatible with the
 15 karl  1.1 ## OpenPegasus build enviroment that has been used for previous versions.
 16           ##
 17 kumpf 1.2 ##
 18           ## The following files are needed and will each include the appropriate
 19           ## DMTF files.
 20 karl  1.1 ## In Schemas/CIMxxx where xxx is the schema directory
 21           ##      CIM_Schema.mof
 22           ##      CIM_Event.mof
 23           ##      CIM_Core.mof
 24           ##      Core_Qualifiers.mof
 25           ##      CIM_Interop.mof
 26           ##
 27           ##      CIM_Physical.mof
 28           ##      CIM_Schema.mof
 29           ##
 30           ## The original DMTF CIM schema files are installed in Schemas/CIMxxx/DMTF
 31           ##
 32           ## To use this script:
 33           ##    1. Download the CIM schema MOF zip file from the DMTF web site
 34           ##    2. Insure that $PEGASUS_ROOT is set
 35           ##    3. run the script with the following options
 36           ##        a.  parameter 1 the schema version (ex. 214)
 37           ##        b.  parameter 2 is the location of the downloaded zip file.
 38           ##
 39           ##   NOTE: If the Schema directory already exists the user is offered
 40           ##         the option to replace the enitre directory.
 41 karl  1.1 ##
 42           ##   CURRENT ISSUES AND LIMITATIONS
 43           ##   1. Intended for use with FINAL mof files.  It does not make any
 44           ##      provisions for the experimental mof.
 45           ##   2. This is a bash script and intended to be used only on systems
 46           ##      with the bash shell.
 47           ##   3. Does not test to determne if the input schema version is valid
 48           ##########################################################################
 49           
 50           ##########################################################################
 51           ##
 52           ## FUNCTION DEFINITIONS
 53           ##
 54           ##########################################################################
 55           
 56           function usage {
 57               printf "\nUsage: %s <cim version> <DMTF CIM mof zip file>\n" $0 >&2
 58               printf "    Example: %s 214 ~/cimv214Final-MOFs.zip\n" $0 >&2
 59           }
 60           
 61           ## INSERT_LICENSE ()
 62 karl  1.1 ## Insert the current Pegasus License into a new file
 63           ## used for the new files we create to link the schema
 64           ## This function creates the file.
 65           ##
 66           function INSERT_LICENSE {
 67               FILE=$1 ;
 68               cat "${PEGASUS_ROOT}/doc/license.txt" > ${FILE} ;
 69           }
 70           
 71           ## INSERT_BLANK_LINE ()
 72           ## $1 filename w/o extensions
 73           function INSERT_BLANK_LINE {
 74               FILE=$1 ;
 75               echo " " >> ${FILE}.mof ;
 76           }
 77           
 78           ## INSERT_LINE ()
 79           ## Parameter 1 File to target w/o extension
 80           ## Parameter 2 Text for line to insert
 81           ##
 82           function INSERT_LINE {
 83 karl  1.1     FILE=$1 ;
 84               echo "$2" >> ${FILE}.mof ;
 85           }
 86           
 87           ## INSERT_EXTRACTED_INCLUDES ()
 88           ##
 89 kumpf 1.2 ## copy all include lines for this file from $CIMSCHEMAVERSION.mof
 90           ## changing them to add the DMTF directory.
 91 karl  1.1 ##
 92 kumpf 1.2 ## IE: The following line for the CIM_Core.mof file
 93 karl  1.1 ##
 94           ##    #pragma include ("Core\CIM_ManagedElement.mof")
 95           ##
 96           ##     gets changed to the following:
 97           ##
 98           ##    #pragma include ("DMTF/Core\CIM_ManagedElement.mof")
 99           ## Parameters
100 kumpf 1.2 ##  $1   CIM version number for DMTF schema File to grep
101 karl  1.1 ##  $2   Output to build w/o extension
102           ##
103           function INSERT_EXTRACTED_INCLUDES
104           {
105               FILE=$1 ;
106               NAME=$2 ;
107           
108               grep "(\"${NAME}" DMTF/cimv${CIM_SCHEMA_VER}.mof | \
109                   sed 's/include ("/include ("DMTF\//' >> ${FILE}.mof ;
110               return 0 ;
111           }
112           
113 kumpf 1.2 ## CREATE_MOF_FILE
114 karl  1.1 ## Creates the new mof file with name and filename
115           ## and inserts license and descriptive material
116           ## $1 = Name for mof file to create (without extension)
117           function CREATE_MOF_FILE {
118               NAME=$1 ;
119               FILE=${NAME}.mof
120               local TODAY=$(date '+%m/%d/%Y')
121               INSERT_LICENSE ${FILE}
122               echo "// ====================================================" >> ${FILE}
123               echo "// Title      : ${NAME} MOF" >> ${FILE}
124               echo "// Filename   : ${NAME}.mof" >> ${FILE}
125               echo "// Version    :" >> ${FILE}
126               echo "// Date       : ${TODAY}" >> ${FILE}
127               echo "// Description: This file was created by The OpenPegasus Group to" \
128                    >> ${FILE}
129               echo "//              create DMTF CIM Schema Version ${CIM_SCHEMA_VER} " \
130                    >> ${FILE}
131               echo "//              interface filesfiles compatible with OpenPegasus " \
132                    >> ${FILE}
133               echo "//              build enviroment." >> ${FILE}
134               echo "//" >> ${FILE}
135 karl  1.1     echo "//=====================================================" >> ${FILE}
136           
137 kumpf 1.2 INSERT_BLANK_LINE ${NAME} ;
138 karl  1.1 }
139           
140           ## Let user make choice.
141           ## called like: chice <prompt>
142           ## Returns: global variable choice with y / n or answer
143           function choice {
144               CHOICE=''
145               local prompt="$*"
146               local answer
147 kumpf 1.2 
148 karl  1.1     read -p "$prompt" answer
149               case "$answer" in
150                   [yY1] ) CHOICE='y';;
151                   [nN0] ) CHOICE='n';;
152                   *     ) CHOICE="$answer";;
153               esac
154           }  # end of choice function
155           
156           #######################################################################
157           ##
158           ## Execute the script
159           ##
160           #######################################################################
161           
162           
163           #######################################################################
164           ## Test and setup variables for this create
165           ## $1 - CIM Schema version to create in the #PEGASUS_ROOT/Schemas
166           ##      directory (ex. 214)
167           ## $2 - Name of the DMTF CIM release zip file to install.
168           if (( $# < 2 )); then
169 karl  1.1     usage
170               exit 1
171           fi
172           
173           CIM_SCHEMA_VER=${1:?"Error. CIM Version parameter required ex. 214"}
174           ZIP_FILE=${2:?"Error. Location of CIM MOF zip file required"}
175           
176           SCHEMA_DIR=$PEGASUS_ROOT/Schemas/CIM${CIM_SCHEMA_VER}
177           
178           ## confirm that the zip file exists. Error if not
179           if [ !  -e "$ZIP_FILE" ]; then
180               echo "The input MOF ZIP file $ZIP_FILE does not exist."
181               exit 1
182           fi
183           
184           ## Check with user to be sure input was correct
185           choice "Create ${SCHEMA_DIR} from input file ${ZIP_FILE} [y/n]?"
186           if [ "$CHOICE" != "y" ]; then
187               echo "Terminating because user elected not to continue."
188               exit 1
189           fi
190 karl  1.1 
191           ## if the schema directory exists, ask if we want to redo it.
192           ## Deletes the DMTF subdirectory and mof in the SCHEMA_DIR
193           if [ -a $SCHEMA_DIR ]; then
194               echo Schema directory $SCHEMA_DIR already exists.
195               choice "Replace existing Directory ${SCHEMA_DIR} [y/n]?"
196               if [ "$CHOICE" = "y" ]; then
197                   rm -rf "$SCHEMA_DIR"
198               else
199                   echo Terminating without changing Directory $SCHEMA_DIR MOF.
200                   exit 1
201 kumpf 1.2     fi
202 karl  1.1 fi
203           
204 kumpf 1.2 mkdir "$SCHEMA_DIR" || { echo Unable to create $SCHEMA_DIR ; exit 4; }
205 karl  1.1 cd $SCHEMA_DIR
206           
207           ## Create DMTF directory and unzip the CIM release into this directory
208           mkdir DMTF
209           
210           echo "Source $ZIP_FILE" >DMTFSchemaInfo.txt
211           
212           ## unzip because DMTF files zipped with pkzip or equivalent
213           unzip $ZIP_FILE -d DMTF
214 kumpf 1.2 
215 karl  1.1 ##########################################################################
216           ##
217           ## Create the mof files
218           ##
219           ##########################################################################
220           
221           #### create  Core_Qualifiers.mof
222           CREATE_MOF_FILE Core_Qualifiers
223           INSERT_LINE Core_Qualifiers "#pragma include (\"DMTF/qualifiers.mof\")"
224           INSERT_LINE Core_Qualifiers "#pragma include (\"DMTF/qualifiers_optional.mof\")"
225           INSERT_BLANK_LINE Core_Qualifiers ;
226           
227           #### create CIM_Schema.mof
228           CREATE_MOF_FILE CIM_Schema
229           INSERT_LINE CIM_Schema "#pragma include (\"DMTF/cimv${CIM_SCHEMA_VER}.mof\")"
230           INSERT_BLANK_LINE CIM_Schema ;
231           
232           #### create CIM_Core.mof
233           CREATE_MOF_FILE CIM_Core
234           INSERT_LINE CIM_Core  "#pragma include (\"DMTF/qualifiers.mof\")" ;
235           INSERT_LINE CIM_Core "#pragma include (\"DMTF/qualifiers_optional.mof\")"
236 karl  1.1 INSERT_BLANK_LINE CIM_Core ;
237           INSERT_EXTRACTED_INCLUDES CIM_Core Core ;
238           INSERT_BLANK_LINE CIM_Core ;
239           
240           
241           #### create CIM_Event.mof
242           CREATE_MOF_FILE CIM_Event
243           INSERT_EXTRACTED_INCLUDES CIM_Event Event ;
244           INSERT_BLANK_LINE CIM_Event ;
245           
246           
247           #### create CIM_Interop.mof
248           CREATE_MOF_FILE CIM_Interop
249           INSERT_EXTRACTED_INCLUDES CIM_Interop Interop ;
250           INSERT_BLANK_LINE CIM_Interop ;
251           
252           ############################################################
253           #### The following are required for the make testrepository
254           
255           #### create CIM_Physical.mof
256           CREATE_MOF_FILE CIM_Physical
257 karl  1.1 INSERT_EXTRACTED_INCLUDES CIM_Physical Physical ;
258           INSERT_BLANK_LINE CIM_Physical ;
259           
260           
261           #### create CIM_System.mof
262           CREATE_MOF_FILE CIM_System
263           INSERT_EXTRACTED_INCLUDES CIM_System System ;
264           INSERT_BLANK_LINE CIM_System ;
265           

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2