I developed a DCL procedure the other day to stamp build version information in image headers. Perhaps others may find this useful as a starting point in writing their own.
$! See bottom of file for comments
$ old_verify = f$verify (0)
$ set noon
$ say := write sys$output
$ status = 44
$ p1 = f$parse (p1,,,"name")
$ if p1 .eqs. ""
$ then
$ say "P1 must specify the image name (don't include .EXE)"
$ goto exit
$ endif
$ vers = ""
$ gen = ""
$ if f$trnlnm ("CMS$LIB") .eqs. ""
$ then
$ say "CMS library must be defined! Abort."
$ goto exit
$ endif
$!
$ if f$search ("version.h") .eqs. ""
$ then
$ say "version.h not found! Abort."
$ goto exit
$ endif
$ open/error=error in version.h
$vers_loop:
$ read in record/end=end_vers_loop/error=error
$ if f$element (0, " ", record) .eqs. "#define" .and. -
f$element (1, " ", record) .eqs. "SW_VERSION"
$ then
$ vers = f$element (2, " ", record)
$ goto end_vers_loop
$ endif
$ goto vers_loop
$end_vers_loop:
$ close in
$ if f$edit (vers, "collapse") .eqs. ""
$ then
$ say "Could not determine version from version.h! Abort."
$ goto exit
$ endif
$ vers = vers - """" - """"
$ gen_file = p1 + "." + vers
$ len = f$length (vers)
$dash_loop:
$ dash = f$locate ("-", vers)
$ if dash .lt. len
$ then
$ vers = f$extract (0, dash, vers) + "." + -
f$extract (dash + 1, len - dash, vers)
$ goto dash_loop
$ endif
$!
$ gen_file_exists = 1
$ define/user sys$output nl:
$ define/user sys$error nl:
$ cms reserve 'gen_file' ""/nohist/nolog
$ if .not. $status
$ then
$ gen_file_exists = 0
$ open/write/error=error out 'gen_file'
$ write/error=error out "0"
$ close out
$ endif
$ open/error=error in 'gen_file'
$ read in record/end=badgen/error=error
$ close in
$ delete/nolog 'gen_file';*
$ gen = f$string (f$integer (record) + 1)
$ open/write/error=error out 'gen_file'
$ write/error=error out gen
$ close out
$ if gen_file_exists
$ then
$ cms replace 'gen_file' ""/nolog
$ else
$ cms create element 'gen_file' ""/nolog
$ endif
$!
$ open/write/error=error out 'p1'.pcsi$desc
$ write/error=error out "product jfd axpvms ''p1' ''vers' full ;"
$ write/error=error out " file [sysexe]''p1'.exe generation ''gen' ;"
$ write/error=error out "end product ;"
$ close out
$ create/dir [.kit]
$ if .not. $status
$ then
$ goto error
$ endif
$ define/user sys$output nl:
$ define/user sys$error nl:
$ product package -
/options=noconfirm -
/format=ref/mat=[]/sourc='p1'.pcsi$desc/dest=[.kit] 'p1'
$ if .not. $status
$ then
$ goto error
$ endif
$ delete/nolog 'p1'.exe;*
$ rename/nolog [.kit.sysexe]'p1'.exe []
$ set prot=o:rwed [.kit]*.*
$ set prot=o:rwed kit.dir
$ delete/nolog [.kit]*.*;*
$ delete/nolog kit.dir;*
$ delete/nolog 'p1'.pcsi$desc;*
$ status = 1
$ goto exit
$error:
$ status = $status
$ say "An unexpected error occured!"
$ say f$message (status)
$ goto exit
$badgen:
$ close in
$ say "Corrupt generation file!"
$ goto exit
$exit:
$ if .not. status
$ then
$ delete/nolog 'p1'.exe;*
$ endif
$ exit (status + 0 * f$verify (old_verify))
$!++
$!
$! DESCRIPTION
$!
$! This procedure uses a feature of PRODUCT PACKAGE to set the
$! "Image file build identification" string in an image header. The
$! command procedure is designed to be called from MMS build scripts,
$! thus recording the "build number" in the image.
$!
$! The script takes a number of things as input:
$!
$! P1 is the image name for the image to be worked on. Note
$! that the file name shouldn't include the ".EXE" part of
$! the name
$!
$! VERSION.H must exist in the current directory and contain a
$! line of the form #define SW_VERSION "X00-00"
$!
$! Your CMS library must be set to the correct one (duh)
$!
$! An element called GENERATION.X00-00 (or whatever the
$! SW_VERSION from VERSION.H is) must be an existing element
$! in the CMS library, and it must contain exactly one line
$! with a digit in the range of 0 through 4294967295.
$! If the file doesn't exist, it will be created.
$!
$! AUTHOR
$!
$! James F. Duff
$!
$! DATE
$!
$! 05-Mar-2007
$!
$! HISTORY
$!
$! 05-Mar-2007 JFD Original version
$! 12-Mar-2007 JFD Exit with status. If failure, delete
$! the exe so MMS will recreate it.
$! 14-Mar-2007 JFD Better error handling.
$!--
Comments are closed