2 ################################################################################
5 # Description: Applies a label to the vob, creating the lbtype if needed.
6 # Author: Andrew@DeFaria.com
7 # Created: Wed Jun 11 13:22:11 PDT 2003
11 # (c) Copyright 2003, Andrew@DeFaria.com, all rights reserved
13 ################################################################################
14 # Set me to command name
17 # Source /etc/site_parms
18 if [ -f /etc/site_parms ]; then
21 echo "$me: WARNING: /etc/site_parms does not exist!"
25 adm_base="$SITE_TOOLS_PATH/adm"
28 adm_fpath=${adm_fpath:-$adm_base/functions}
36 # Set a logfile for the merge
37 logfile=/tmp/$me.$$.log
40 if [ ! -z "$1" ]; then
43 display "Usage: $me: -l|abel <label> [-da|ted] [-lo|ck] [-m|ove]"
44 display "\t [-v|erbose] [-d|ebug] [-u|sage]"
45 display "\t [-r|ecurse] <path> [[-r|ecurse] <path>]"
48 display "\t-label:\t\tLabel to apply"
49 display "\t-dated:\t\tAppend date (format _MM_DD_YYYY) to label"
50 display "\t-lock:\t\tLock label (-nusers \$USER)"
51 display "\t-move:\t\tMove labels"
52 display "\t-verbose:\tTurn on verbose mode"
53 display "\t-debug:\t\tTurn on debug mode"
54 display "\t-usage:\t\tDisplay usage"
55 display "\t-recurse:\tRecursively apply label from <path>"
56 display "\t<path>:\t\tPathname in vob to start labeling process"
58 display "NOTE: Multiple path names can be supplied either with or without the"
59 display " -recurse option."
66 display "$1" >> $logfile
78 while [ $# -ge 1 ]; do
97 label="$(echo $1 | tr [:lower:] [:upper:])"
114 if [ $# -le 1 ]; then
115 usage "Recurse must be associated with a path"
125 # Assume a path name with no valid recurse before it
134 if [ $dated = "yes" ]; then
135 label="${label}_$(date +%d_%m_%Y)"
139 cat /dev/null > $logfile
141 # Check if label type already exists
142 cleartool lstype lbtype:$label > /dev/null 2>&1
144 if [ $? -ne 0 ]; then
146 log "Creating new label $label"
147 cleartool mklbtype -nc $label >> $logfile 2>&1
149 if [ $? -ne 0 ]; then
150 log "Unable to create label type $label"
151 error "Unable to create label type $label" 1
156 if [ $lock = "yes" ]; then
157 log "Locking label $label"
158 cleartool lock -nc -replace -nusers $USER lbtype:$label >> $logfile 2>&1
160 if [ $? -ne 0 ]; then
161 log "Unable to lock label $label"
162 error "Unable to lock label $label" 2
169 while [[ ! -z ${recurse[$i]} ]]; do
170 if [ ${recurse[$i]} = "yes" ]; then
171 if [[ -z $move ]]; then
172 log "Applying label $label to ${paths[$i]} (recursively)"
174 log "Replacing label $label to ${paths[$i]} (recursively)"
176 cleartool mklabel $move -nc -recurse lbtype:$label ${paths[$i]} >> $logfile 2>&1
178 if [[ -z $move ]]; then
179 log "Applying label $label to ${paths[$i]} (non-recursively)"
181 log "Replacing label $label to ${paths[$i]} (non-recursively)"
183 cleartool mklabel $move -nc lbtype:$label ${paths[$i]} >> $logfile 2>&1
187 if [ $? -ne 0 ]; then
188 error "Unable to apply label: $label" 3