1#!/bin/ksh 2# IBM_PROLOG_BEGIN_TAG 3# This is an automatically generated prolog. 4# 5# bos52Q src/bos/usr/sbin/install/insttools/mkinstallp.sh 1.14 6# 7# Licensed Materials - Property of IBM 8# 9# Restricted Materials of IBM 10# 11# (C) COPYRIGHT International Business Machines Corp. 2003,2005 12# All Rights Reserved 13# 14# US Government Users Restricted Rights - Use, duplication or 15# disclosure restricted by GSA ADP Schedule Contract with IBM Corp. 16# 17# IBM_PROLOG_END_TAG 18# @(#)42 1.14 src/bos/usr/sbin/install/insttools/mkinstallp.sh, cmdinstl, bos52Q, q2005_41A1 10/11/05 14:26:08 19 20##############################################################################80 21# # 22# is_numeric # 23# Returns 1 if the input is numeric; 0 otherwise. # 24# # 25################################################################################ 26is_numeric() 27{ 28 if [[ -z "$1" ]]; then 29 return 0 30 else 31 case "$1" in 32 *[!0-9]*) return 0;; 33 *) return 1;; 34 esac 35 fi 36} 37 38##############################################################################80 39# # 40# is_YorN # 41# Returns 1 if the input is affirmative; 0 if negative; 2 if an error occurs. # 42# # 43################################################################################ 44is_YorN() 45{ 46 typeset ANS="$1" # local answer 47 typeset YESSTR 48 typeset NOSTR 49 typeset STR 50 51 [[ -z "$ANS" ]] && return 2 52 53 if [ -x /usr/bin/locale ]; then 54 # We should be able to use yes/no strings. 55 YESSTR=$(/bin/locale yesstr 2> /dev/null) || YESSTR="yes:y:Y:YES:Yes" 56 NOSTR=$(/bin/locale nostr 2> /dev/null) || NOSTR="no:n:N:NO:No" 57 YESSTR="$YESSTR:YES:Yes" 58 NOSTR="$NOSTR:NO:No" 59 else 60 YESSTR="yes:y:Y:YES:Yes" 61 NOSTR="no:n:N:NO:No" 62 fi 63 64 YESSTR="$YESSTR:1" 65 NOSTR="$NOSTR:0" 66 67 # Set the Internal Field Separator (IFS) to ":" 68 typeset IFS=: 69 70 for STR in $YESSTR; do 71 if [[ "$ANS" = "$STR" ]]; then 72 return 1 73 fi 74 done 75 76 for STR in $NOSTR; do 77 if [[ "$ANS" = "$STR" ]]; then 78 return 0 79 fi 80 done 81 82 # If we go here, then something went wrong 83 return 2 84} 85 86##############################################################################80 87# # 88# create_template # 89# Prompts the user for package info and creates the template file based on # 90# the responses. # 91# # 92################################################################################ 93create_template() 94{ 95 # Get an affirmative and negative value 96 if [ -x /usr/bin/locale ]; then 97 # We should be able to use yes/no strings. 98 YES=$(/bin/locale yesstr | awk -F: '{print $3}' 2> /dev/null) || YES="Y" 99 NO=$(/bin/locale nostr | awk -F: '{print $3}' 2> /dev/null) || NO="N" 100 else 101 YES="Y" 102 NO="N" 103 fi 104 105 # Make sure we've got a vaid VRMF number 106 let VALID_VRMF=0 107 while [[ $VALID_VRMF -eq 0 ]]; do 108 case $PACKAGE_VRMF in 109 +([0-9]).+([0-9]).+([0-9]).+([0-9]) ) let VALID_VRMF=1;; 110 *) MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 13 \ 111 "* Package VRMF (1.0.0.0) []: \n"` 112 read PACKAGE_VRMF?"$MESG";; 113 esac 114 done 115 MESG="Package VRMF: $PACKAGE_VRMF" 116 print "$MESG" >> $TEMPLATE_FILE 117 118 119 is_YorN "$UPDATE" 120 while [[ $? -eq 2 ]]; do 121 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 14 "Update ($YES/$NO) [$NO]: \n"` 122 read UPDATE?"$MESG" 123 if [[ -z "$UPDATE" ]]; then 124 UPDATE="$NO" 125 fi 126 is_YorN "$UPDATE" 127 done 128 MESG="Update: $UPDATE" 129 print "$MESG" >> $TEMPLATE_FILE 130 131 132 is_numeric "$NUM_FILESETS" 133 until [[ $? -eq 1 ]]; do 134 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 15 "Number of filesets in %s (1) [1]: \n" "$PACKAGE_NAME"` 135 read NUM_FILESETS?"$MESG" 136 if [[ -z "$NUM_FILESETS" ]]; then 137 let NUM_FILESETS=1 138 fi 139 is_numeric "$NUM_FILESETS" 140 done 141 142 143 # Since we're gonna enter this loop for each fileset, set all the 144 # fileset-specific variables to null right from the onslaught. Otherwise, 145 # subsequent iterations through the loop may try to use values from the 146 # previous time through. 147 while (( NUM_FILESETS > 0 )); do 148 ADD= 149 ADD_NUM= 150 ADD_PATH= 151 ADD_SPACE= 152 BOSBOOT= 153 CONFIG= 154 CONFIG_PATH= 155 COUNT= 156 CREATE_ROOT= 157 FILESET_DESC= 158 FILESET_NAME= 159 FILESET_VRMF= 160 LAF= 161 LAR= 162 LIC_INCLUDED= 163 LIC_REQUIRED= 164 NUM_ADDS= 165 NUM_FILES= 166 NUM_LAFS= 167 NUM_REQS= 168 REQ_FILE= 169 POST= 170 POST_PATH= 171 PRE= 172 PRE_PATH= 173 PRERM= 174 PRERM_PATH= 175 REQUISITES= 176 UNPRE= 177 UNPRE_PATH= 178 UNPOST= 179 UNPOST_PATH= 180 UNCONFIG= 181 UNCONFIG_PATH= 182 183 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 16 \ 184 "\n Gathering info for new fileset (%ld remaining)\n" "$NUM_FILESETS"` 185 print "$MESG" 186 print "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" 187 188 # Start printing the fileset section of the template file. 189 MESG="Fileset" 190 print "$MESG" >> $TEMPLATE_FILE 191 192 193 # General Fileset Info 194 while [[ -z "$FILESET_NAME" ]]; do 195 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 17 "* Fileset Name (%s) []: \n" "${PACKAGE_NAME}.rte"` 196 read FILESET_NAME?"$MESG" 197 if [[ $FILESET_NAME != ${PACKAGE_NAME}* ]]; then 198 FILESET_NAME="" 199 fi 200 done 201 MESG=" Fileset Name: $FILESET_NAME" 202 print "$MESG" >> $TEMPLATE_FILE 203 204 205 # Make sure we've got a valid VRMF 206 let VALID_VRMF=0 207 while [[ $VALID_VRMF -eq 0 ]]; do 208 case $FILESET_VRMF in 209 +([0-9]).+([0-9]).+([0-9]).+([0-9]) ) let VALID_VRMF=1;; 210 *) MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 18 \ 211 "* Fileset VRMF (1.0.0.0) []: \n"` 212 read FILESET_VRMF?"$MESG";; 213 esac 214 done 215 MESG=" Fileset VRMF: $FILESET_VRMF" 216 print "$MESG" >> $TEMPLATE_FILE 217 218 219 while [[ -z "$FILESET_DESC" ]]; do 220 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 19 "* Fileset Description (some text) []: \n"` 221 read FILESET_DESC?"$MESG" 222 done 223 MESG=" Fileset Description: $FILESET_DESC" 224 print "$MESG" >> $TEMPLATE_FILE 225 226 227 # Ask the usrs if they have a pre_i/u script they want to run 228 is_YorN "$PRE" 229 while [[ $? -eq 2 ]]; do 230 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 20 \ 231 "Do you want to include an installp pre_i/u script for this fileset? ($YES/$NO) [$NO]: \n"` 232 read PRE?"$MESG" 233 if [[ -z "$PRE" ]]; then 234 PRE="$NO" 235 fi 236 is_YorN "$PRE" 237 done 238 239 is_YorN "$PRE" 240 if [[ $? -eq 1 ]]; then 241 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 21 \ 242 "Enter the absolute path of the pre_i/u script to include []: \n"` 243 read PRE_PATH?"$MESG" 244 while [[ ! -f /$PRE_PATH ]]; do 245 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 22 \ 246 "0503-846 %s: Script not found. Re-enter the absolute script path [] : \n" "$CMDNAME"` 247 read PRE_PATH?"$MESG" 248 done 249 # if there is no / at the beginning of the path, add one 250 if [[ -z ${PRE_PATH%%/*} ]]; then 251 MESG=" Pre-installation Script: $PRE_PATH" 252 print "$MESG" >> $TEMPLATE_FILE 253 else 254 MESG=" Pre-installation Script: /$PRE_PATH" 255 print "$MESG" >> $TEMPLATE_FILE 256 fi 257 258 # If they gave a pre-i/u script, ask if they want to include an unpre-i/u script 259 is_YorN "$UNPRE" 260 while [[ $? -eq 2 ]]; do 261 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 23 \ 262 "Do you want to include an installp unpre_i/u script for this fileset? ($YES/$NO) [$NO]: \n"` 263 read UNPRE?"$MESG" 264 if [[ -z "$UNPRE" ]]; then 265 UNPRE="$NO" 266 fi 267 is_YorN "$UNPRE" 268 done 269 270 is_YorN "$UNPRE" 271 if [[ $? -eq 1 ]]; then 272 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 24 \ 273 "Enter the absolute path of the unpre_i/u script to include []: \n"` 274 read UNPRE_PATH?"$MESG" 275 while [[ ! -f /$UNPRE_PATH ]]; do 276 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 22 \ 277 "0503-846 %s: Script not found. Re-enter the absolute script path []: \n" "$CMDNAME"` 278 read UNPRE_PATH?"$MESG" 279 done 280 # if there is no /at the beginning of the path, add one / 281 if [[ -z ${UNPRE_PATH%%/*} ]]; then 282 MESG=" Unpre-installation Script: $UNPRE_PATH" 283 print "$MESG" >> $TEMPLATE_FILE 284 else 285 MESG=" Unpre-installation Script: /$UNPRE_PATH" 286 print "$MESG" >> $TEMPLATE_FILE 287 fi 288 fi 289 fi 290 291 292 # Ask the usrs if they have post_i/u script they want to run 293 is_YorN "$POST" 294 while [[ $? -eq 2 ]]; do 295 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 25 \ 296 "Do you want to include an installp post_i/u script for this fileset? ($YES/$NO) [$NO]: \n"` 297 read POST?"$MESG" 298 if [[ -z "$POST" ]]; then 299 POST="$NO"; 300 fi 301 is_YorN "$POST" 302 done 303 304 is_YorN "$POST" 305 if [[ $? -eq 1 ]]; then 306 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 26 \ 307 "Enter the absolute path of the post_i/u script to include []: \n"` 308 read POST_PATH?"$MESG" 309 while [[ ! -f /$POST_PATH ]]; do 310 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 22 \ 311 "0503-846 %s: Script not found. Re-enter the absolute script path []: \n" "$CMDNAME"` 312 read POST_PATH?"$MESG" 313 done 314 # if there is no /at the beginning of the path, add one / 315 if [[ -z ${POST_PATH%%/*} ]]; then 316 MESG=" Post-installation Script: $POST_PATH" 317 print "$MESG" >> $TEMPLATE_FILE 318 else 319 MESG=" Post-installation Script: /$POST_PATH" 320 print "$MESG" >> $TEMPLATE_FILE 321 fi 322 323 # If they gave a post-i/u script, ask if they want to include an unpost-i/u script 324 is_YorN "$UNPOST" 325 while [[ $? -eq 2 ]]; do 326 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 27 \ 327 "Do you want to include an installp unpost_i/u script for this fileset? ($YES/$NO) [$NO]: \n"` 328 read UNPOST?"$MESG" 329 if [[ -z "$UNPOST" ]]; then 330 UNPOST="$NO"; 331 fi 332 is_YorN "$UNPOST" 333 done 334 335 is_YorN "$UNPOST" 336 if [[ $? -eq 1 ]]; then 337 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 28 \ 338 "Enter the absolute path of the unpost_i/u script to include []: \n"` 339 read UNPOST_PATH?"$MESG" 340 while [[ ! -f /$UNPOST_PATH ]]; do 341 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 22 \ 342 "0503-846 %s: Script not found. Re-enter the absolute script path []: \n" "$CMDNAME"` 343 read UNPOST_PATH?"$MESG" 344 done 345 # if there is no /at the beginning of the path, add one / 346 if [[ -z ${UNPOST_PATH%%/*} ]]; then 347 MESG=" Unpost-installation Script: $UNPOST_PATH" 348 print "$MESG" >> $TEMPLATE_FILE 349 else 350 MESG=" Unpost-installation Script: /$UNPOST_PATH" 351 print "$MESG" >> $TEMPLATE_FILE 352 fi 353 fi 354 fi 355 356 357 # Ask the usrs if they have pre_rm script they want to run 358 is_YorN "$PRERM" 359 while [[ $? -eq 2 ]]; do 360 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 89 \ 361 "Do you want to include an installp pre_rm script for this fileset? ($YES/$NO) [$NO]: \n"` 362 read PRERM?"$MESG" 363 if [[ -z "$PRERM" ]]; then 364 PRERM="$NO"; 365 fi 366 is_YorN "$PRERM" 367 done 368 369 is_YorN "$PRERM" 370 if [[ $? -eq 1 ]]; then 371 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 90 \ 372 "Enter the absolute path of the pre_rm script to include []: \n"` 373 read PRERM_PATH?"$MESG" 374 while [[ ! -f /$PRERM_PATH ]]; do 375 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 22 \ 376 "0503-846 %s: Script not found. Re-enter the absolute script path []: \n" "$CMDNAME"` 377 read PRERM_PATH?"$MESG" 378 done 379 # if there is no /at the beginning of the path, add one / 380 if [[ -z ${PRERM_PATH%%/*} ]]; then 381 MESG=" Pre_rm Script: $PRERM_PATH" 382 print "$MESG" >> $TEMPLATE_FILE 383 else 384 MESG=" Pre_rm Script: /$PRERM_PATH" 385 print "$MESG" >> $TEMPLATE_FILE 386 fi 387 fi 388 389 390 # Ask users if they want to include an installp config script 391 is_YorN "$CONFIG" 392 while [[ $? -eq 2 ]]; do 393 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 29 \ 394 "Do you want to include an installp config script for this fileset? ($YES/$NO) [$NO]: \n"` 395 read CONFIG?"$MESG" 396 if [[ -z "$CONFIG" ]]; then 397 CONFIG="$NO"; 398 fi 399 is_YorN "$CONFIG" 400 done 401 402 is_YorN "$CONFIG" 403 if [[ $? -eq 1 ]]; then 404 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 30 \ 405 "Enter the absolute path of the config script to include []: \n"` 406 read CONFIG_PATH?"$MESG" 407 while [[ ! -f /$CONFIG_PATH ]]; do 408 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 22 \ 409 "0503-846 %s: Script not found. Re-enter the absolute script path []: \n" "$CMDNAME"` 410 read CONFIG_PATH?"$MESG" 411 done 412 # if there is no /at the beginning of the path, add one / 413 if [[ -z ${CONFIG_PATH%%/*} ]]; then 414 MESG=" Configuration Script: $CONFIG_PATH" 415 print "$MESG" >> $TEMPLATE_FILE 416 else 417 MESG=" Configuration Script: /$CONFIG_PATH" 418 print "$MESG" >> $TEMPLATE_FILE 419 fi 420 421 # If they gave a config script, ask if they want to include an unconfig script 422 is_YorN "$UNCONFIG" 423 while [[ $? -eq 2 ]]; do 424 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 31 \ 425 "Do you want to include an installp unconfig script for this fileset? ($YES/$NO) [$NO]: \n"` 426 read UNCONFIG?"$MESG" 427 if [[ -z "$UNCONFIG" ]]; then 428 UNCONFIG="$NO"; 429 fi 430 is_YorN "$UNCONFIG" 431 done 432 433 is_YorN "$UNCONFIG" 434 if [[ $? -eq 1 ]]; then 435 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 32 \ 436 "Enter the absolute path of the unconfig script to include []: \n"` 437 read UNCONFIG_PATH?"$MESG" 438 while [[ ! -f /$UNCONFIG_PATH ]]; do 439 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 22 \ 440 "0503-846 %s: Script not found. Re-enter the absolute script path []: \n" "$CMDNAME"` 441 read UNCONFIG_PATH?"$MESG" 442 done 443 # if there is no /at the beginning of the path, add one / 444 if [[ -z ${UNCONFIG_PATH%%/*} ]]; then 445 MESG=" Unconfiguration Script: $UNCONFIG_PATH" 446 print "$MESG" >> $TEMPLATE_FILE 447 else 448 MESG=" Unconfiguration Script: /$UNCONFIG_PATH" 449 print "$MESG" >> $TEMPLATE_FILE 450 fi 451 fi 452 fi 453 454 455 is_YorN "$BOSBOOT" 456 while [[ $? -eq 2 ]]; do 457 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 33 "Bosboot required ($YES/$NO) [$NO]: \n"` 458 read BOSBOOT?"$MESG" 459 if [[ -z "$BOSBOOT" ]]; then 460 BOSBOOT="$NO" 461 fi 462 is_YorN "$BOSBOOT" 463 done 464 MESG=" Bosboot required: $BOSBOOT" 465 print "$MESG" >> $TEMPLATE_FILE 466 467 468 # Fileset Licensing Info 469 is_YorN "$LIC_REQUIRED" 470 while [[ $? -eq 2 ]]; do 471 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 34 "License agreement acceptance required ($YES/$NO) [$NO]: \n"` 472 read LIC_REQUIRED?"$MESG" 473 if [[ -z "$LIC_REQUIRED" ]]; then 474 LIC_REQUIRED="$NO"; 475 fi 476 is_YorN "$LIC_REQUIRED" 477 done 478 MESG=" License agreement acceptance required: $LIC_REQUIRED" 479 print "$MESG" >> $TEMPLATE_FILE 480 481 # If a license agreement is required, get the name of the LAR. 482 is_YorN "$LIC_REQUIRED" 483 if [[ $? -eq 1 ]]; then 484 while [[ -z "$LAR" ]]; do 485 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 35 "* Name of license agreement (/usr/swlag/\%L/LUM.la) []: \n"` 486 read LAR?"$MESG" 487 done 488 # if there is no /at the beginning of the path, add one / 489 if [[ -z ${LAR%%/*} ]]; then 490 MESG=" Name of license agreement: LAR$LAR" 491 print "$MESG" >> $TEMPLATE_FILE 492 else 493 MESG=" Name of license agreement: LAR/$LAR" 494 print "$MESG" >> $TEMPLATE_FILE 495 fi 496 fi 497 498 499 is_YorN "$LIC_INCLUDED" 500 while [[ $? -eq 2 ]]; do 501 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 37 \ 502 "Include license files for %s in this package ($YES/$NO) [$NO]: \n" "$FILESET_NAME"` 503 read LIC_INCLUDED?"$MESG" 504 if [[ -z "$LIC_INCLUDED" ]]; then 505 LIC_INCLUDED="$NO"; 506 fi 507 is_YorN "$LIC_INCLUDED" 508 done 509 MESG=" Include license files in this package: $LIC_INCLUDED" 510 print "$MESG" >> $TEMPLATE_FILE 511 512 # If license files are included in this package, get the LAF pathnames. 513 is_YorN "$LIC_INCLUDED" 514 if [[ $? -eq 1 ]]; then 515 is_numeric "$NUM_LAFS" 516 until [[ $? -eq 1 ]]; do 517 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 38 \ 518 "Number of license files included for %s (1) [1]: \n" "$FILESET_NAME"` 519 read NUM_LAFS?"$MESG" 520 if [[ -z "$NUM_LAFS" ]]; then 521 let NUM_LAFS=1 522 fi 523 is_numeric "$NUM_LAFS" 524 done 525 526 # Set laf path to null each time through the loop. 527 let COUNT=1 528 while (( COUNT <= NUM_LAFS )); do 529 LAF_PATH= 530 531 while [[ -z "$LAF_PATH" ]]; do 532 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 39 \ 533 "* %ld of %ld. License file path (/usr/swlag/en_US/xyz.la) []: \n" "$COUNT" "$NUM_LAFS"` 534 read LAF_PATH?"$MESG" 535 done 536 while [[ ! -f $ROOT_DIR/$LAF_PATH ]]; do 537 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 40 "0503-848 %s: * %s%s does not exist.\n \ 538\tRe-enter license file path []: \n" "$CMDNAME" "$ROOT_DIR" "$LAF_PATH"` 539 read LAF_PATH?"$MESG" 540 done 541 # If there is no / at the beginning of the path, add one / 542 if [[ -z ${LAF_PATH%%/*} ]]; then 543 LAF=`echo "${LAF}LAF${LAF_PATH};"` 544 else 545 LAF=`echo "${LAF}LAF/${LAF_PATH};"` 546 fi 547 let COUNT='COUNT+1' 548 done 549 550 MESG=" License file path: $LAF" 551 print "$MESG" >> $TEMPLATE_FILE 552 fi 553 554 # Ask the users if they want to specify a Requisite file 555 is_YorN "$REQ_FILE" 556 while [[ $? -eq 2 ]]; do 557 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 103 \ 558 "Do you want to specify Requisites using a file for this fileset? ($YES/$NO) [$NO]: \n"` 559 read REQ_FILE?"$MESG" 560 if [[ -z "$REQ_FILE" ]]; then 561 REQ_FILE="$NO"; 562 fi 563 is_YorN "$REQ_FILE" 564 done 565 566 # Get the Requisite file pathname 567 is_YorN "$REQ_FILE" 568 if [[ $? -eq 1 ]]; then 569 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 104 \ 570 "Enter the absolute path of the Requisite file to use []: \n"` 571 read REQUISITES?"$MESG" 572 while [[ ! -z ${REQUISITES%%/*} || ! -f "$REQUISITES" \ 573 || ! -r "$REQUISITES" ]]; do 574 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 105 \ 575 "File not found. Re-enter the absolute Requisite file path []: \n"` 576 read REQUISITES?"$MESG" 577 done 578 print " Requisites: $REQUISITES" >> $TEMPLATE_FILE 579 fi 580 581 # Get the Requisite line(s) if any 582 is_YorN "$REQ_FILE" 583 if [[ $? -eq 0 ]]; then # if not Requisite file 584 # Fileset Requisite Info 585 is_numeric "$NUM_REQS" 586 until [[ $? -eq 1 ]]; do 587 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 41 "Number of Requisites for %s (1) [0]: \n" "$FILESET_NAME"` 588 read NUM_REQS?"$MESG" 589 if [[ -z "$NUM_REQS" ]]; then 590 let NUM_REQS=0 591 fi 592 is_numeric "$NUM_REQS" 593 done 594 595 # Set req-specific vars to null each time through the loop. 596 let COUNT=1 597 while (( COUNT <= NUM_REQS )); do 598 REQ_NAME= 599 REQ_TYPE= 600 REQ_VRMF= 601 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 42 \ 602 "%ld of %ld. Requisite Type (coreq/ifreq/instreq/prereq) [prereq]: \n" "$COUNT" "$NUM_REQS"` 603 read REQ_TYPE?"$MESG" 604 if [[ -z "$REQ_TYPE" ]]; then 605 REQ_TYPE="prereq" 606 fi 607 608 while [[ $REQ_TYPE != "coreq" && $REQ_TYPE != "ifreq" \ 609 && $REQ_TYPE != "instreq" && $REQ_TYPE != "prereq" ]]; do 610 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 42 \ 611 "%ld of %ld. Requisite Type (coreq/ifreq/instreq/prereq) [prereq]: \n" "$COUNT" "$NUM_REQS"` 612 read REQ_TYPE?"$MESG" 613 done 614 while [[ -z "$REQ_NAME" ]]; do 615 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 43 \ 616 "* %ld of %ld. Requisite Name (abc.rte) []: \n" "$COUNT" "$NUM_REQS"` 617 read REQ_NAME?"$MESG" 618 done 619 while [[ -z "$REQ_VRMF" ]]; do 620 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 44 \ 621 "* %ld of %ld. Requisite VRMF (1.0.0.0) []: \n" "$COUNT" "$NUM_REQS"` 622 read REQ_VRMF?"$MESG" 623 done 624 625 let VALID_VRMF=0 626 while [[ $VALID_VRMF -eq 0 ]]; do 627 case $REQ_VRMF in 628 +([0-9]).+([0-9]).+([0-9]).+([0-9]) ) let VALID_VRMF=1;; 629 *) MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 44 \ 630 "* %ld of %ld. Requisite VRMF (1.0.0.0) []: \n" "$COUNT" "$NUM_REQS"` 631 read REQ_VRMF?"$MESG";; 632 esac 633 done 634 635 REQUISITES=`echo "${REQUISITES}*${REQ_TYPE} ${REQ_NAME} ${REQ_VRMF};"` 636 let COUNT='COUNT+1' 637 done 638 MESG=" Requisites: $REQUISITES" 639 print "$MESG" >> $TEMPLATE_FILE 640 fi # if not Requisite file 641 642 643 is_numeric "$ADD_NUM" 644 until [[ $? -eq 1 ]]; do 645 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 96 \ 646 "Number of filesystems requiring additional space for %s [0]: \n" "$FILESET_NAME"` 647 read ADD_NUM?"$MESG" 648 if [[ -z "$ADD_NUM" ]]; then 649 let ADD_NUM=0 650 fi 651 is_numeric "$ADD_NUM" 652 done 653 654 # Gather info about additional file space 655 let COUNT=1 656 while (( COUNT <= ADD_NUM )); do 657 ADD_PATH= 658 ADD_SPACE= 659 while [[ -z "$ADD_PATH" ]]; do 660 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 47 \ 661 "* %ld of %ld. Filesystem path (/tmp) []: \n" "$COUNT" "$ADD_NUM"` 662 read ADD_PATH?"$MESG" 663 done 664 665 is_numeric "$ADD_SPACE" 666 until [[ $? -eq 1 ]]; do 667 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 49 \ 668 "* Required space for this filesystem in 512 byte blocks []: \n"` 669 read ADD_SPACE?"$MESG" 670 is_numeric "$ADD_SPACE" 671 done 672 673 if [[ -z ${ADD_PATH%%/*} ]]; then 674 ADD=`echo "${ADD}${ADD_PATH} ${ADD_SPACE}; "` 675 else 676 ADD=`echo "${ADD}/${ADD_PATH} ${ADD_SPACE}; "` 677 fi 678 let COUNT='COUNT+1' 679 done 680 if [[ $ADD_NUM -gt 0 ]]; then 681 MESG=" Upsize: $ADD" 682 print "$MESG" >> $TEMPLATE_FILE 683 fi 684 685 686 # Fileset USR part Files Info 687 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 50 \ 688 "\nYou should include any directories that you are creating in the file count.\n"` 689 print "$MESG" 690 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 97 \ 691 "(ie: For /usr/proj/myFile, enter 2; 1 for /usr/proj and 1 for /usr/proj/myFile)\n"` 692 print "$MESG" 693 694 is_numeric "$NUM_FILES" 695 until [[ $? -eq 1 ]]; do 696 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 98 \ 697 "Number of USR part Files in %s (1) [0]: \n" "$FILESET_NAME"` 698 read NUM_FILES?"$MESG" 699 if [[ -z "$NUM_FILES" ]]; then 700 let NUM_FILES=0 701 fi 702 is_numeric "$NUM_FILES" 703 done 704 705 MESG=" USRFiles" 706 print "$MESG" >> $TEMPLATE_FILE 707 let COUNT=1 708 while (( COUNT <= NUM_FILES )); do 709 FILE_NAME= 710 AGREE= 711 712 while [[ -z $FILE_NAME ]]; do 713 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 99 \ 714 "* %ld of %ld. Directory or File Path (/usr/proj/myFile) []: \n" "$COUNT" "$NUM_FILES"` 715 read FILE_NAME?"$MESG" 716 done 717 718 # Warn user if they are shipping a file that exists as a part of another fileset 719 # and make sure the file or directory exists in the build root directory 720 if [[ -z ${FILE_NAME%%/*} ]]; then 721 lslpp -w $FILE_NAME >/dev/null 722 else 723 lslpp -w /$FILE_NAME >/dev/null 724 fi 725 if [[ ($? -eq 0) && (! -d /$FILE_NAME) && (! -L /$FILE_NAME) ]]; then 726 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 100 \ 727 "This file exists in another fileset on the system.\n"` 728 print "$MESG" 729 is_YorN "$AGREE" 730 while [[ $? -eq 2 ]]; do 731 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 55 \ 732 "Are you sure you want to include this file? ($YES/$NO) []: \n"` 733 read AGREE?"$MESG" 734 is_YorN "$AGREE" 735 done 736 fi 737 738 # Kill two birds here. If the file doesn't exist, proceed as if the user hadn't agreed 739 # to the check above. This will cause us to reenter the loop at the current count. 740 if [[ ! -e $ROOT_DIR/$FILE_NAME ]]; then 741 AGREE="$NO" 742 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 101 "File or directory does not exist.\n"` 743 print "$MESG" 744 fi 745 746 # Only process this file if user agrees (or isn't affected by the checks above) 747 is_YorN "$AGREE" 748 if [[ $? -ne 0 ]]; then 749 # if there is no / at the beginning of the path, add one 750 if [[ -z ${FILE_NAME%%/*} ]]; then 751 MESG=" $FILE_NAME" 752 print "$MESG" >> $TEMPLATE_FILE 753 else 754 MESG=" /$FILE_NAME" 755 print "$MESG" >> $TEMPLATE_FILE 756 fi 757 758 let COUNT='COUNT+1' 759 fi 760 done 761 MESG=" EOUSRFiles" 762 print "$MESG" >> $TEMPLATE_FILE 763 764 765 # Fileset ROOT part Files Info 766 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 50 \ 767 "\nYou should include any directories that you are creating in the file count.\n"` 768 print "$MESG" 769 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 95 \ 770 "(ie: For /etc/proj/myFile, enter 2; 1 for /etc/proj and 1 for /etc/proj/myFile)\n"` 771 print "$MESG" 772 773 # Clear NUM_FILE again (since USR part above may have set it) 774 NUM_FILES= 775 is_numeric "$NUM_FILES" 776 until [[ $? -eq 1 ]]; do 777 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 48 \ 778 "Number of ROOT part files in %s (1) [0]: \n" "$FILESET_NAME"` 779 read NUM_FILES?"$MESG" 780 if [[ -z "$NUM_FILES" ]]; then 781 let NUM_FILES=0 782 fi 783 is_numeric "$NUM_FILES" 784 done 785 786 if [[ NUM_FILES -eq 0 ]]; then 787 is_YorN "$CREATE_ROOT" 788 while [[ $? -eq 2 ]]; do 789 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 93 \ 790 "Would you like to create an empty ROOT part? ($YES/$NO) [$NO]: \n"` 791 read CREATE_ROOT?"$MESG" 792 if [[ -z "$CREATE_ROOT" ]]; then 793 CREATE_ROOT="$NO"; 794 fi 795 is_YorN "$CREATE_ROOT" 796 done 797 else 798 CREATE_ROOT="$YES" 799 fi 800 MESG=" ROOT Part: $CREATE_ROOT" 801 print "$MESG" >> $TEMPLATE_FILE 802 803 804 MESG=" ROOTFiles" 805 print "$MESG" >> $TEMPLATE_FILE 806 let COUNT=1 807 while (( COUNT <= NUM_FILES )); do 808 FILE_NAME= 809 AGREE= 810 811 while [[ -z "$FILE_NAME" ]]; do 812 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 92 \ 813 "* %ld of %ld. Directory or File Path (/etc/proj/myFile) []: \n" "$COUNT" "$NUM_FILES"` 814 read FILE_NAME?"$MESG" 815 done 816 817 # Warn user if they are shipping a file that exists as a part of another fileset 818 # and make sure the file or directory exists in the build root directory 819 if [[ -z ${FILE_NAME%%/*} ]]; then 820 lslpp -w $FILE_NAME >/dev/null 821 else 822 lslpp -w /$FILE_NAME >/dev/null 823 fi 824 if [[ ($? -eq 0) && (! -d /$FILE_NAME) && (! -L /$FILE_NAME) ]]; then 825 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 54 \ 826 "0503-850 %s: This file exists in another fileset on the system.\n" "$CMDNAME"` 827 print "$MESG" 828 is_YorN "$AGREE" 829 while [[ $? -eq 2 ]]; do 830 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 55 \ 831 "Are you sure you want to include this file? ($YES/$NO) []: \n"` 832 read AGREE?"$MESG" 833 is_YorN "$AGREE" 834 done 835 fi 836 837 # Kill two birds here. If the file doesn't exist, proceed as if the user hadn't agreed 838 # to the check above. This will cause us to reenter the loop at the current count. 839 if [[ ! -e $ROOT_DIR/$FILE_NAME ]]; then 840 AGREE="$NO" 841 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 56 "0503-851 %s: File or directory does not exist.\n" "$CMDNAME"` 842 print "$MESG" 843 fi 844 845 # Only process this file if user agrees (or isn't affected by the checks above) 846 is_YorN "$AGREE" 847 if [[ $? -ne 0 ]]; then 848 # if there is no / at the beginning of the path, add one 849 if [[ -z ${FILE_NAME%%/*} ]]; then 850 MESG=" $FILE_NAME" 851 print "$MESG" >> $TEMPLATE_FILE 852 else 853 MESG=" /$FILE_NAME" 854 print "$MESG" >> $TEMPLATE_FILE 855 fi 856 857 let COUNT='COUNT+1' 858 fi 859 done 860 MESG=" EOROOTFiles" 861 print "$MESG" >> $TEMPLATE_FILE 862 863 let NUM_FILESETS='NUM_FILESETS-1' 864 MESG="EOFileset" 865 print "$MESG" >> $TEMPLATE_FILE 866 867 # Print out a blank line to signify our moving on from this fileset 868 print "" 869 done 870} 871 872 873##############################################################################80 874# # 875# parse_template # 876# Parse the first part of the template file. Once we hit a fileset, pass # 877# it over to the fileset parsing function, ParseFileset. Display a warning if # 878# we don't recognize something in the template file. # 879# # 880################################################################################ 881parse_template() 882{ 883 while read PKG_LINE; do 884 PKG_LINE=${PKG_LINE#[ ]*} # Strip leading spaces 885 PKG_KEYWORD=${PKG_LINE%%:*} # Get keyword (before first colon) 886 REST_PKG_LINE=${PKG_LINE#*:} # Get everything after the first colon 887 888 # Ignore blank lines and comments 889 if [[ ! -z "$PKG_KEYWORD" && "$PKG_KEYWORD" != \#* ]]; then 890 case $PKG_KEYWORD in 891 "Package Name" ) PACKAGE_NAME=${REST_PKG_LINE#[ ]*} ;; 892 "Package VRMF" ) PACKAGE_VRMF=${REST_PKG_LINE#[ ]*} ;; 893 "Update" ) UPDATE=${REST_PKG_LINE#[ ]*} ;; 894 "Fileset" ) parse_fileset ;; 895 * ) MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 58 \ 896 "0503-852 %s: Unknown keyword (%s)\n \ 897 \tin %s\n" "$CMDNAME" "$PKG_KEYWORD" "$TEMPLATE_FILE"` 898 print "$MESG" ;; 899 900 esac 901 fi 902 done 903} 904 905 906##############################################################################80 907# # 908# parse_fileset # 909# Parse the Fileset section of the template file. Write out our list file # 910# after we've got all the info about this fileset. When we hit the Files # 911# section, pass control to the Files parsing function, ParseFiles. Display a # 912# warning if we don't recognize something in the template file. # 913# # 914################################################################################ 915parse_fileset() 916{ 917 # Make sure after reading the first fileset template, make the variables null, 918 # so that it does not try to use the previous fileset values 919 ADD= 920 ADD_PATH= 921 ADD_REMAINING= 922 ADD_SINGLE= 923 ADD_SPACE= 924 BOSBOOT= 925 CONFIG= 926 CONFIG_FILE= 927 CONFIG_PATH= 928 COUNT= 929 CREATE_ROOT= 930 FILESET_DESC= 931 FILESET_NAME= 932 FILESET_VRMF= 933 LAF= 934 LAF_REMAINING= 935 LAF_SINGLE= 936 LAR= 937 LIC_INCLUDED= 938 LIC_REQUIRED= 939 NUM_FILES= 940 NUM_LAFS= 941 NUM_REQS= 942 POST= 943 POST_FILE= 944 POST_PATH= 945 PRE= 946 PRE_FILE= 947 PRE_PATH= 948 PRERM= 949 PRERM_FILE= 950 PRERM_PATH= 951 REQUISITES= 952 REQ_NAME= 953 REQ_REMAINING= 954 REQ_SINGLE= 955 REQ_TYPE= 956 REQ_VRMF= 957 UNCONFIG= 958 UNCONFIG_FILE= 959 UNCONFIG_PATH= 960 UNPOST= 961 UNPOST_FILE= 962 UNPOST_PATH= 963 UNPRE= 964 UNPRE_FILE= 965 UNPRE_PATH= 966 967 # When we reach the EOFileset keyword, write out our info to the list file 968 while read FILESET_LINE; do 969 if [[ $FILESET_LINE = "EOFileset" ]]; then 970 # The list file contains package and fileset definitions 971 LIST_FILE=$CONTROL_FILE_DIR/list 972 973 # Make sure we've got a valid update flag for this package 974 # Set fileset.insize or fileset.upsize if update 975 is_YorN "$UPDATE" 976 RC=$? 977 if [[ $RC -eq 1 ]]; then 978 UPDATE_FLAG="S" 979 SIZE_FILE=$CONTROL_FILE_DIR/${FILESET_NAME##*[ ]}.upsize 980 elif [[ $RC -eq 0 ]]; then 981 UPDATE_FLAG="I" 982 SIZE_FILE=$CONTROL_FILE_DIR/${FILESET_NAME##*[ ]}.insize 983 else 984 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 59 "0503-853 %s: Invalid Update value (%s)\n \ 985\tin %s\n" "$CMDNAME" "$UPDATE" "$TEMPLATE_FILE"` 986 print >&2 "$MESG" 987 exit 1; 988 fi 989 990 # Do some sanity checking; we need to have the following values, so if 991 # they are non-existent or contain unexpected values, exit out. 992 if [[ -z "$PACKAGE_NAME" ]]; then 993 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 60 "0503-854 %s: Package Name is missing\n \ 994\tfrom %s\n" "$CMDNAME" "$TEMPLATE_FILE"` 995 print >&2 "$MESG" 996 exit 1; 997 elif [[ -z "$PACKAGE_VRMF" ]]; then 998 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 61 "0503-855 %s: Package VRMF is missing\n \ 999\tfrom %s\n" "$CMDNAME" "$TEMPLATE_FILE"` 1000 print >&2 "$MESG" 1001 exit 1; 1002 elif [[ -z "$UPDATE" ]]; then 1003 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 62 "0503-856 %s: Update is missing\n \ 1004\tfrom %s\n" "$CMDNAME" "$TEMPLATE_FILE"` 1005 print >&2 "$MESG" 1006 exit 1; 1007 elif [[ -z "$FILESET_NAME" ]]; then 1008 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 63 "0503-857 %s: Fileset Name is missing\n \ 1009\tfrom %s\n" "$CMDNAME" "$TEMPLATE_FILE"` 1010 print >&2 "$MESG" 1011 exit 1; 1012 elif [[ $FILESET_NAME != ${PACKAGE_NAME}* ]]; then 1013 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 102 "0503-888 %s: Fileset Name is invalid\n \ 1014\tin %s\n" "$CMDNAME" "$TEMPLATE_FILE"` 1015 print >&2 "$MESG" 1016 exit 1; 1017 elif [[ -z "$FILESET_VRMF" ]]; then 1018 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 64 "0503-858 %s: Fileset VRMF is missing\n \ 1019\tfrom %s\n" "$CMDNAME" "$TEMPLATE_FILE"` 1020 print >&2 "$MESG" 1021 exit 1; 1022 fi 1023 1024 # Make sure PACKAGE_VRMF and FILESET_VRMF have the correct format 1025 case $PACKAGE_VRMF in 1026 +([0-9]).+([0-9]).+([0-9]).+([0-9]) ) ;; 1027 *) MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 65 \ 1028 "0503-859 %s: Invalid PACKAGE_VRMF (%s)\n \ 1029 \tin %s\n" "$CMDNAME" "$PACKAGE_VRMF" "$TEMPLATE_FILE"` 1030 print >&2 "$MESG" 1031 exit 1 ;; 1032 esac 1033 1034 case $FILESET_VRMF in 1035 +([0-9]).+([0-9]).+([0-9]).+([0-9]) ) ;; 1036 *) MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 66 \ 1037 "0503-860 %s: Invalid FILESET_VRMF (%s)\n \ 1038 \tin %s\n" "$CMDNAME" "$FILESET_VRMF" "$TEMPLATE_FILE"` 1039 print >&2 "$MESG" 1040 exit 1 ;; 1041 esac 1042 1043 # Add a default description if we weren't given one 1044 if [[ -z "$FILESET_DESC" ]]; then 1045 FILESET_DESC="mkinstallp generated fileset" 1046 fi 1047 1048 # For the following installp scripts, copy them to the .info dir if they exist. 1049 # Make sure we've got a valid pre-installation file 1050 if [[ ! -z "$PRE_PATH" ]]; then 1051 if [[ ! -f /$PRE_PATH ]]; then 1052 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 67 "0503-861 %s: installp pre_i/u script not found (%s)\n \ 1053\tin %s\n" "$CMDNAME" "$PRE_PATH" "$TEMPLATE_FILE"` 1054 print >&2 "$MESG" 1055 exit 1; 1056 else 1057 is_YorN "$UPDATE" 1058 if [[ $? -eq 0 ]]; then 1059 PRE_FILE=$CONTROL_FILE_DIR/$FILESET_NAME.pre_i 1060 else 1061 PRE_FILE=$CONTROL_FILE_DIR/$FILESET_NAME.pre_u 1062 fi 1063 cp $PRE_PATH $PRE_FILE 1064 fi 1065 fi 1066 1067 # Make sure we've got a valid unpre-installation file 1068 if [[ ! -z "$UNPRE_PATH" ]]; then 1069 if [[ ! -f /$UNPRE_PATH ]]; then 1070 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 68 "0503-862 %s: installp unpre_i/u script not found (%s)\n \ 1071\tin %s\n" "$CMDNAME" "$UNPRE_PATH" "$TEMPLATE_FILE"` 1072 print >&2 "$MESG" 1073 exit 1; 1074 else 1075 is_YorN "$UPDATE" 1076 if [[ $? -eq 0 ]]; then 1077 UNPRE_FILE=$CONTROL_FILE_DIR/$FILESET_NAME.unpre_i 1078 else 1079 UNPRE_FILE=$CONTROL_FILE_DIR/$FILESET_NAME.unpre_u 1080 fi 1081 cp $UNPRE_PATH $UNPRE_FILE 1082 fi 1083 fi 1084 1085 # Make sure we've got a valid post-installation file 1086 if [[ ! -z "$POST_PATH" ]]; then 1087 if [[ ! -f /$POST_PATH ]]; then 1088 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 69 "0503-863 %s: installp post_i script not found (%s)\n \ 1089\tin %s\n" "$CMDNAME" "$POST_PATH" "$TEMPLATE_FILE"` 1090 print >&2 "$MESG" 1091 exit 1; 1092 else 1093 is_YorN "$UPDATE" 1094 if [[ $? -eq 0 ]]; then 1095 POST_FILE=$CONTROL_FILE_DIR/$FILESET_NAME.post_i 1096 else 1097 POST_FILE=$CONTROL_FILE_DIR/$FILESET_NAME.post_u 1098 fi 1099 cp $POST_PATH $POST_FILE 1100 fi 1101 fi 1102 1103 # Make sure we've got a valid unpost-installation file 1104 if [[ ! -z "$UNPOST_PATH" ]]; then 1105 if [[ ! -f /$UNPOST_PATH ]]; then 1106 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 70 "0503-864 %s: installp unpost_i script not found (%s)\n \ 1107\tin %s\n" "$CMDNAME" "$UNPOST_PATH" "$TEMPLATE_FILE"` 1108 print >&2 "$MESG" 1109 exit 1; 1110 else 1111 is_YorN "$UPDATE" 1112 if [[ $? -eq 0 ]]; then 1113 UNPOST_FILE=$CONTROL_FILE_DIR/$FILESET_NAME.unpost_i 1114 else 1115 UNPOST_FILE=$CONTROL_FILE_DIR/$FILESET_NAME.unpost_u 1116 fi 1117 cp $UNPOST_PATH $UNPOST_FILE 1118 fi 1119 fi 1120 1121 # Make sure we've got a valid pre_rm file 1122 if [[ ! -z "$PRERM_PATH" ]]; then 1123 if [[ ! -f /$PRERM_PATH ]]; then 1124 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 91 "0503-883 %s: installp pre_rm script not found (%s)\n \ 1125\tin %s\n" "$CMDNAME" "$PRERM_PATH" "$TEMPLATE_FILE"` 1126 print >&2 "$MESG" 1127 exit 1; 1128 else 1129 PRERM_FILE=$CONTROL_FILE_DIR/$FILESET_NAME.pre_rm 1130 cp $PRERM_PATH $PRERM_FILE 1131 fi 1132 fi 1133 1134 # Make sure we've got a valid configuration file 1135 if [[ ! -z "$CONFIG_PATH" ]]; then 1136 if [[ ! -f /$CONFIG_PATH ]]; then 1137 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 71 "0503-865 %s: installp config script not found (%s)\n \ 1138\tin %s\n" "$CMDNAME" "$CONFIG_PATH" "$TEMPLATE_FILE"` 1139 print >&2 "$MESG" 1140 exit 1; 1141 else 1142 is_YorN "$UPDATE" 1143 if [[ $? -eq 0 ]]; then 1144 CONFIG_FILE=$CONTROL_FILE_DIR/$FILESET_NAME.config 1145 else 1146 CONFIG_FILE=$CONTROL_FILE_DIR/$FILESET_NAME.config_u 1147 fi 1148 cp $CONFIG_PATH $CONFIG_FILE 1149 fi 1150 fi 1151 1152 # Make sure we've got a valid unconfiguration file 1153 if [[ ! -z "$UNCONFIG_PATH" ]]; then 1154 if [[ ! -f /$UNCONFIG_PATH ]]; then 1155 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 72 "0503-866 %s: installp unconfig script not found (%s)\n \ 1156\tin %s\n" "$CMDNAME" "$UNCONFIG_PATH" "$TEMPLATE_FILE"` 1157 print >&2 "$MESG" 1158 exit 1; 1159 else 1160 is_YorN "$UPDATE" 1161 if [[ $? -eq 0 ]]; then 1162 UNCONFIG_FILE=$CONTROL_FILE_DIR/$FILESET_NAME.unconfig 1163 else 1164 UNCONFIG_FILE=$CONTROL_FILE_DIR/$FILESET_NAME.unconfig_u 1165 fi 1166 cp $UNCONFIG_PATH $UNCONFIG_FILE 1167 fi 1168 fi 1169 1170 # Make sure we've got a valid bosboot flag for this fileset 1171 is_YorN "$BOSBOOT" 1172 RC=$? 1173 if [[ $RC -eq 1 ]]; then 1174 BOSBOOT_FLAG="b" 1175 elif [[ $RC -eq 0 ]]; then 1176 BOSBOOT_FLAG="N" 1177 else 1178 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 73 "0503-867 %s: Invalid Bosboot value (%s)\n \ 1179\tin %s\n" "$CMDNAME" "$BOSBOOT" "$TEMPLATE_FILE"` 1180 print >&2 "$MESG" 1181 exit 1; 1182 fi 1183 1184 is_YorN "$LIC_REQUIRED" 1185 if [[ $? -eq 2 ]]; then 1186 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 74 "0503-868 %s: Invalid LIC_REQUIRED value (%s)\n \ 1187\tin %s\n" "$CMDNAME" "$LIC_REQUIRED" "$TEMPLATE_FILE"` 1188 print >&2 "$MESG" 1189 exit 1; 1190 fi 1191 1192 is_YorN "$LIC_REQUIRED" 1193 if [[ $? -eq 1 ]]; then 1194 if [[ ! -z "$LAR" ]]; then 1195 if [[ (-z ${LAR#LAR*}) || (! -z ${LAR%%LAR*}) ]]; then 1196 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 75 "0503-869 %s: Invalid LAR value (%s)\n \ 1197\tin %s\n" "$CMDNAME" "${LAR#LAR*}" "$TEMPLATE_FILE"` 1198 print >&2 "$MESG" 1199 exit 1; 1200 fi 1201 fi 1202 fi 1203 1204 # Make sure we've got a valid license file 1205 is_YorN "$LIC_INCLUDED" 1206 if [[ $? -eq 2 ]]; then 1207 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 76 "0503-870 %s: Invalid LIC_INCLUDED value (%s)\n \ 1208\tin %s\n" "$CMDNAME" "$LIC_INCLUDED" "$TEMPLATE_FILE"` 1209 print >&2 "$MESG" 1210 exit 1; 1211 fi 1212 1213 is_YorN "$LIC_INCLUDED" 1214 if [[ $? -eq 1 ]]; then 1215 if [[ ! -z "$LAF" ]]; then 1216 LAF_SINGLE=${LAF%%;*} 1217 LAF_REMAINING=${LAF#*;} 1218 if (( ${#LAF_SINGLE} == ${#LAF_REMAINING} )) then LAF_REMAINING=""; fi 1219 while [[ ! -z $LAF_SINGLE ]]; do 1220 if [[ (! -z ${LAF_SINGLE%%LAF*}) || \ 1221 ((! -f $ROOT_DIR/${LAF_SINGLE#LAF*}) && \ 1222 (! -f $ROOT_DIR/${LAF_SINGLE#LAF\<??_??\>*})) ]]; then 1223 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 77 "0503-871 %s: Invalid LAF value (%s)\n \ 1224\tin %s\n" "$CMDNAME" "${LAF_SINGLE#LAF*}" "$TEMPLATE_FILE"` 1225 print >&2 "$MESG" 1226 exit 1; 1227 fi 1228 LAF_SINGLE=${LAF_REMAINING%%;*} 1229 LAF_REMAINING=${LAF_REMAINING#*;} 1230 if (( ${#LAF_SINGLE} == ${#LAF_REMAINING} )) then LAF_REMAINING=""; fi 1231 done 1232 fi 1233 fi 1234 1235 # Make sure we've got a valid requisites 1236 if [[ ! -z "$REQUISITES" ]]; then 1237 REQ_SINGLE=${REQUISITES%%;*} 1238 REQ_REMAINING=${REQUISITES#*;} 1239 if [[ -z ${REQUISITES%%/*} ]]; then # Requisite file 1240 if [[ ! -f "$REQUISITES" || ! -r "$REQUISITES" ]]; then 1241 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 106 "0503-889 %s: Invalid Requisite file (%s)\n \ 1242\tin %s\n" "$CMDNAME" "$REQUISITES" "$TEMPLATE_FILE"` 1243 print >&2 "$MESG" 1244 exit 1; 1245 fi 1246 # Copy the requisite file to the .info dir 1247 cp $REQUISITES $CONTROL_FILE_DIR/$FILESET_NAME.prereq 1248 REQUISITES="*.info/$FILESET_NAME.prereq" 1249 REQ_SINGLE="" 1250 fi 1251 if (( ${#REQ_SINGLE} == ${#REQ_REMAINING} )) then REQ_REMAINING=""; fi 1252 while [[ ! -z "$REQ_SINGLE" ]]; do 1253 REQ_TYPE=${REQ_SINGLE%%[ ]*} 1254 if [[ $REQ_TYPE != "*coreq" && $REQ_TYPE != "*ifreq" && $REQ_TYPE != "*instreq" && $REQ_TYPE != "*prereq" ]]; then 1255 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 78 "0503-872 %s: Invalid Requisite Type (%s)\n \ 1256\tin %s\n" "$CMDNAME" "$REQ_TYPE" "$TEMPLATE_FILE"` 1257 print >&2 "$MESG" 1258 exit 1; 1259 fi 1260 1261 REQ_SINGLE=${REQ_SINGLE#*[ ]} 1262 1263 REQ_NAME=${REQ_SINGLE%%[ ]*} 1264 if [[ -z "$REQ_NAME" ]]; then 1265 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 79 "0503-873 %s: Invalid Requisite Name (%s)\n \ 1266\tin %s\n" "$CMDNAME" "$REQ_NAME" "$TEMPLATE_FILE"` 1267 print >&2 "$MESG" 1268 exit 1; 1269 fi 1270 1271 REQ_VRMF=${REQ_SINGLE#*[ ]} 1272 if [[ -z "$REQ_VRMF" ]]; then 1273 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 80 "0503-874 %s: Invalid Requisite VRMF (%s)\n \ 1274\tin %s\n" "$CMDNAME" "$REQ_VRMF" "$TEMPLATE_FILE"` 1275 print >&2 "$MESG" 1276 exit 1; 1277 fi 1278 1279 # Make sure we've got correct VRMF value 1280 case $REQ_VRMF in 1281 +([0-9]).+([0-9]).+([0-9]).+([0-9]) ) ;; 1282 *) MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 81 \ 1283 "0503-875 %s: Invalid REQ_VRMF (%s)\n \ 1284 \tin %s\n" "$CMDNAME" "$REQ_VRMF" "$TEMPLATE_FILE"` 1285 print >&2 "$MESG" 1286 exit 1;; 1287 esac 1288 1289 REQ_SINGLE=${REQ_REMAINING%%;*} 1290 REQ_REMAINING=${REQ_REMAINING#*;} 1291 if (( ${#REQ_SINGLE} == ${#REQ_REMAINING} )) then REQ_REMAINING=""; fi 1292 done 1293 fi 1294 1295 # Make sure we've got a valid ROOT Part answer 1296 is_YorN "$CREATE_ROOT" 1297 RC=$? 1298 if [[ $RC -eq 1 ]]; then 1299 touch $CONTROL_FILE_DIR/.create_root 1300 elif [[ $RC -eq 2 ]]; then 1301 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 94 "Invalid ROOT Part value (%s)\n \ 1302\tin %s\n" "$CREATE_ROOT" "$TEMPLATE_FILE"` 1303 print >&2 "$MESG" 1304 exit 1; 1305 fi 1306 1307 # If our file already exists, just update it with this fileset's info. 1308 # Otherwise, it's our first time, so also include the package info. 1309 # Also strip out the leading spaces if they appear. 1310 if [[ -f $LIST_FILE ]]; then 1311 cat >> $LIST_FILE << EOF 1312${FILESET_NAME#[ ]*}:${FILESET_VRMF#[ ]*}:${FILESET_DESC#[ ]*}:${BOSBOOT_FLAG#[ ]*} 1313${LAF#[ ]*} 1314${LAR#[ ]*} 1315${REQUISITES#[ ]*} 1316EOF 1317 else 1318 cat > $LIST_FILE << EOF 1319${PACKAGE_NAME#[ ]*}:${PACKAGE_VRMF#[ ]*}:${UPDATE_FLAG#[ ]*} 1320${FILESET_NAME#[ ]*}:${FILESET_VRMF#[ ]*}:${FILESET_DESC#[ ]*}:${BOSBOOT_FLAG#[ ]*} 1321${LAF#[ ]*} 1322${LAR#[ ]*} 1323${REQUISITES#[ ]*} 1324EOF 1325 fi 1326 1327 # If the upsize or insize file already exists, just append the 1328 # fileset's information. Otherwise, create the file and include 1329 # the directory of the file system needed to increase size and 1330 # the number of 512 byte blocks for each fileset 1331 if [[ ! -z "$ADD" ]]; then 1332 ADD=${ADD%*[ ]} 1333 ADD_SINGLE=${ADD%%;*} 1334 ADD_REMAINING=${ADD#*;} 1335 if (( ${#ADD_SINGLE} == ${#ADD_REMAINING} )) then ADD_REMAINING=""; fi 1336 while [[ ! -z "$ADD_SINGLE" ]]; do 1337 ADD_PATH=${ADD_SINGLE%[ ]*} 1338 if [[ -z "$ADD_PATH" ]]; then 1339 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 82 "0503-876 %s: Invalid In/Upsize path (%s)\n \ 1340\tin %s\n" "$CMDNAME" "$ADD_PATH" "$TEMPLATE_FILE"` 1341 print >&2 "$MESG" 1342 exit 1; 1343 fi 1344 1345 ADD_SPACE=${ADD_SINGLE##*[ ]} 1346 # Make sure ADD_SPACE is a number 1347 is_numeric "$ADD_SPACE" 1348 if [[ $? -ne 1 ]]; then 1349 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 83 "0503-877 %s: Invalid In/Upsize (%s)\n \ 1350\tin %s\n" "$CMDNAME" "$ADD_SPACE" "$TEMPLATE_FILE"` 1351 print >&2 "$MESG" 1352 exit 1 1353 else 1354 cat >> $SIZE_FILE << EOF 1355$ADD_PATH $ADD_SPACE 1356EOF 1357 ADD_SINGLE=${ADD_REMAINING#[ ]*} 1358 ADD_REMAINING=${ADD_SINGLE#*;} 1359 ADD_SINGLE=${ADD_SINGLE%%;*} 1360 if (( ${#ADD_SINGLE} == ${#ADD_REMAINING} )) then ADD_REMAINING=""; fi 1361 fi 1362 done 1363 fi 1364 1365 return 1366 else 1367 FILESET_KEYWORD=${FILESET_LINE%%:*} # Get keyword 1368 REST_FILESET_LINE=${FILESET_LINE#*:} # Get everything else 1369 1370 # Ignore blank lines and comments 1371 if [[ ! -z "$PKG_KEYWORD" && "$PKG_KEYWORD" != \#* ]]; then 1372 case $FILESET_KEYWORD in 1373 "Fileset Name" ) FILESET_NAME=${REST_FILESET_LINE#[ ]*} ;; 1374 "Fileset VRMF" ) FILESET_VRMF=${REST_FILESET_LINE#[ ]*} ;; 1375 "Fileset Description" ) FILESET_DESC=${REST_FILESET_LINE#[ ]*} ;; 1376 "Pre_rm Script" ) PRERM_PATH=${REST_FILESET_LINE#[ ]*} ;; 1377 "Pre-installation Script" ) PRE_PATH=${REST_FILESET_LINE#[ ]*} ;; 1378 "Unpre-installation Script" ) UNPRE_PATH=${REST_FILESET_LINE#[ ]*} ;; 1379 "Post-installation Script") POST_PATH=${REST_FILESET_LINE#[ ]*} ;; 1380 "Unpost-installation Script") UNPOST_PATH=${REST_FILESET_LINE#[ ]*} ;; 1381 "Configuration Script") CONFIG_PATH=${REST_FILESET_LINE#[ ]*} ;; 1382 "Unconfiguration Script") UNCONFIG_PATH=${REST_FILESET_LINE#[ ]*} ;; 1383 "Bosboot required" ) BOSBOOT=${REST_FILESET_LINE#[ ]*} ;; 1384 "License agreement acceptance required" ) 1385 LIC_REQUIRED=${REST_FILESET_LINE#[ ]*} ;; 1386 "Name of license agreement" ) 1387 LAR=${REST_FILESET_LINE#[ ]*} ;; 1388 "Include license files in this package" ) 1389 LIC_INCLUDED=${REST_FILESET_LINE#[ ]*} ;; 1390 "License file path" ) LAF=${REST_FILESET_LINE#[ ]*} ;; 1391 "Requisites" ) REQUISITES=${REST_FILESET_LINE#[ ]*} ;; 1392 "Upsize" ) ADD=${REST_FILESET_LINE#[ ]*} ;; 1393 "USRFiles" ) parse_usr_files ;; 1394 "ROOT Part" ) CREATE_ROOT=${REST_FILESET_LINE#[ ]*} ;; 1395 "ROOTFiles" ) parse_root_files ;; 1396 * ) MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 84 \ 1397 "0503-878 %s: Unknown keyword (%s)\n \ 1398 \tin %s\n" "$CMDNAME" "$FILESET_KEYWORD" "$TEMPLATE_FILE"` 1399 print "$MESG";; 1400 esac 1401 fi 1402 fi 1403 done 1404} 1405 1406 1407##############################################################################80 1408# # 1409# parse_usr_files # 1410# Parse the USR Files section of the template file. Write out our .al file # 1411# which is a list of files to be packaged for an individual fileset (every # 1412# fileset has it's own .al file). Display a warning if we don't recognize # 1413# something in the template file. # 1414# # 1415################################################################################ 1416parse_usr_files() 1417{ 1418 # Each fileset will have it's own .al file 1419 AL_FILE=$CONTROL_FILE_DIR/${FILESET_NAME##*[ ]}.al 1420 1421 # Write out our info to the .al file until we reach the EOUSRFiles keyword 1422 while read FILE_LINE; do 1423 if [[ $FILE_LINE != "EOUSRFiles" ]]; then 1424 # Make sure we have the filename for our .al file. 1425 if [[ -z ${FILE_LINE#[ ]*} ]]; then 1426 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 85 "0503-879 %s: A blank filename was found\n \ 1427\tin %s\n" "$CMDNAME" "$TEMPLATE_FILE"` 1428 print >&2 "$MESG" 1429 exit 1; 1430 fi 1431 1432 # Warn usrs if the files they entered is a part of the system file 1433 if [[ -z ${FILE_LINE%%/*} ]]; then 1434 lslpp -w ${FILE_LINE#[ ]*} >/dev/null 1435 else 1436 lslpp -w /${FILE_LINE#[ ]*} >/dev/null 1437 fi 1438 if [[ ($? -eq 0) && (! -d /${FILE_LINE#[ ]*}) && (! -L /${FILE_LINE#[ ]*}) ]]; then 1439 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 86 "0503-880 %s: Warning: %s exists in another fileset on the system.\n" \ 1440 "$CMDNAME" "${FILE_LINE#[ ]*}"` 1441 print "$MESG" 1442 fi 1443 1444 # Make sure we have a valid file 1445 if [[ ! -e $ROOT_DIR/${FILE_LINE#[ ]*} ]]; then 1446 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 87 "0503-881 %s: Invalid filename (%s)\n \ 1447\tin %s\n" "$CMDNAME" "${FILE_LINE#[ ]*}" "$TEMPLATE_FILE"` 1448 print >&2 "$MESG" 1449 exit 1; 1450 fi 1451 1452 # Write out the al file, stripping leading spaces if they appear. Note 1453 # that the file paths are relative, so prepend a dot to the filename. 1454 cat >> $AL_FILE << EOF 1455.${FILE_LINE#[ ]*} 1456EOF 1457 else 1458 return 1459 fi 1460 done 1461} 1462 1463 1464##############################################################################80 1465# # 1466# parse_root_files # 1467# Parse the ROOT Files section of the template file. Write out our .al file # 1468# which is a list of files to be packaged for an individual fileset (every # 1469# fileset has it's own .al file). Display a warning if we don't recognize # 1470# something in the template file. # 1471# # 1472################################################################################ 1473parse_root_files() 1474{ 1475 # Update the USR part .al and create a ROOT part .al 1476 USR_AL_FILE=$CONTROL_FILE_DIR/${FILESET_NAME##*[ ]}.al 1477 ROOT_AL_FILE=$CONTROL_FILE_DIR/root/${FILESET_NAME##*[ ]}.al 1478 mkdir -p $CONTROL_FILE_DIR/root 1479 1480 # Write out our info to the .al file until we reach the EOROOTFiles keyword 1481 while read FILE_LINE; do 1482 if [[ $FILE_LINE != "EOROOTFiles" ]]; then 1483 # Make sure we have the filename for our .al file. 1484 if [[ -z ${FILE_LINE#[ ]*} ]]; then 1485 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 85 "0503-879 %s: A blank filename was found\n \ 1486\tin %s\n" "$CMDNAME" "$TEMPLATE_FILE"` 1487 print >&2 "$MESG" 1488 exit 1; 1489 fi 1490 1491 # Warn usrs if the files they entered is a part of the system file 1492 if [[ -z ${FILE_LINE%%/*} ]]; then 1493 lslpp -w ${FILE_LINE#[ ]*} >/dev/null 1494 else 1495 lslpp -w /${FILE_LINE#[ ]*} >/dev/null 1496 fi 1497 if [[ ($? -eq 0) && (! -d /${FILE_LINE#[ ]*}) && (! -L /${FILE_LINE#[ ]*}) ]]; then 1498 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 86 "0503-880 %s: Warning: %s exists in another fileset on the system.\n" \ 1499 "$CMDNAME" "${FILE_LINE#[ ]*}"` 1500 print "$MESG" 1501 fi 1502 1503 # Make sure we have a valid file 1504 if [[ ! -e $ROOT_DIR/${FILE_LINE#[ ]*} ]]; then 1505 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 87 "0503-881 %s: Invalid filename (%s)\n \ 1506\tin %s\n" "$CMDNAME" "${FILE_LINE#[ ]*}" "$TEMPLATE_FILE"` 1507 print >&2 "$MESG" 1508 exit 1; 1509 fi 1510 1511 # Write out the al file, stripping leading spaces if they appear. Note 1512 # that the file paths are relative, so prepend a dot to the filename. 1513 # Also copy any root part files to an inst_root dir structure. 1514 INST_ROOT_FILE= 1515 is_YorN "$UPDATE" 1516 if [[ $? -eq 0 ]]; then 1517 INST_ROOT_FILE="./usr/lpp/${PACKAGE_NAME##*[ ]}/inst_root${FILE_LINE#[ ]*}" 1518 else 1519 INST_ROOT_FILE="./usr/lpp/${PACKAGE_NAME##*[ ]}/${FILESET_NAME##*[ ]}/${FILESET_VRMF##*[ ]}/inst_root${FILE_LINE#[ ]*}" 1520 fi 1521 1522 # Make sure they wanted a ROOT part before actually writing out this stuff. 1523 is_YorN "$CREATE_ROOT" 1524 if [[ $? -eq 1 ]]; then 1525 if [[ ! -d ".${FILE_LINE##*[ ]}" ]]; then 1526 mkdir -p `dirname "$INST_ROOT_FILE"` 1527 cp .${FILE_LINE##*[ ]} `dirname "$INST_ROOT_FILE"` 1528 fi 1529 cat >> $USR_AL_FILE << EOF 1530$INST_ROOT_FILE 1531EOF 1532 cat >> $ROOT_AL_FILE << EOF 1533.${FILE_LINE##*[ ]} 1534EOF 1535 fi 1536 else 1537 return 1538 fi 1539 done 1540} 1541 1542 1543##############################################################################80 1544# # 1545# Main Script Execution Begins Here # 1546# # 1547################################################################################ 1548CMDNAME="mkinstallp" 1549 1550# Process command line args 1551if (( $# > 4 )); then 1552 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 1 "0503-841 %s: usage: \n\ 1553\t%s [-d BaseDirectory] [-T TemplateFile] \n" "$CMDNAME" "$CMDNAME"` 1554 print >&2 "$MESG" 1555 exit 1; 1556fi 1557 1558while (( $# > 0 )); do 1559 # Make sure we have enough args 1560 if (( $# % 2 != 0 )); then 1561 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 1 "0503-841 %s: usage: \n\ 1562\t%s [-d BaseDirectory] [-T TemplateFile] \n" "$CMDNAME" "$CMDNAME"` 1563 print >&2 "$MESG" 1564 exit 1; 1565 fi 1566 1567 case "$1" in 1568 -d) ROOT_DIR="$2"; shift;; 1569 -T) TEMPLATE_FILE="$2"; shift;; 1570 *) MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 1 "0503-841 %s: usage: \n\ 1571\t%s [-d BaseDirectory] [-T TemplateFile] \n" "$CMDNAME" "$CMDNAME"` 1572 print >&2 "$MESG" 1573 exit 1;; 1574 esac 1575 shift 1576done 1577 1578# Set our root build dir as pwd if we didn't get one from the command line 1579if [[ -z "$ROOT_DIR" ]]; then 1580 ROOT_DIR="$PWD" 1581fi 1582 1583# Set control file directory (stores template, al files, inventory files, and list file) 1584CONTROL_FILE_DIR=$ROOT_DIR/.info 1585 1586# Print status messages based on our build environment 1587if [[ -d $ROOT_DIR ]]; then 1588 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 2 \ 1589 "Using %s as the base package directory. \n" "$ROOT_DIR"` 1590 print "$MESG" 1591 if [[ ! -d $CONTROL_FILE_DIR ]]; then 1592 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 3 \ 1593 "Cannot find %s. Attempting to create. \n" "$CONTROL_FILE_DIR"` 1594 print "$MESG" 1595 mkdir $CONTROL_FILE_DIR 1596 fi 1597 1598 # Check if our mkdir worked 1599 if [[ -d $CONTROL_FILE_DIR ]]; then 1600 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 4 \ 1601 "Using %s to store package control files. \n" "$CONTROL_FILE_DIR"` 1602 print "$MESG" 1603 1604 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 5 \ 1605 "Cleaning intermediate files from %s. \n" "$CONTROL_FILE_DIR"` 1606 print "$MESG" 1607 1608 rm -f $CONTROL_FILE_DIR/list 1609 rm -f $CONTROL_FILE_DIR/.create_root 1610 rm -f $CONTROL_FILE_DIR/*.al 1611 rm -f $CONTROL_FILE_DIR/*.config* 1612 rm -f $CONTROL_FILE_DIR/*.insize 1613 rm -f $CONTROL_FILE_DIR/*.inventory 1614 rm -f $CONTROL_FILE_DIR/*.pre_[!d]* 1615 rm -f $CONTROL_FILE_DIR/*.post_* 1616 rm -f $CONTROL_FILE_DIR/*.size 1617 rm -f $CONTROL_FILE_DIR/*.unconfig* 1618 rm -f $CONTROL_FILE_DIR/*.unpre_* 1619 rm -f $CONTROL_FILE_DIR/*.unpost_* 1620 rm -f $CONTROL_FILE_DIR/*.upsize 1621 rm -f $CONTROL_FILE_DIR/root/*.al 1622 rm -f $CONTROL_FILE_DIR/root/*.config* 1623 rm -f $CONTROL_FILE_DIR/root/*.insize 1624 rm -f $CONTROL_FILE_DIR/root/*.inventory 1625 rm -f $CONTROL_FILE_DIR/root/*.pre_[!d]* 1626 rm -f $CONTROL_FILE_DIR/root/*.post_* 1627 rm -f $CONTROL_FILE_DIR/root/*.size 1628 rm -f $CONTROL_FILE_DIR/root/*.unconfig* 1629 rm -f $CONTROL_FILE_DIR/root/*.unpre_* 1630 rm -f $CONTROL_FILE_DIR/root/*.unpost_* 1631 rm -f $CONTROL_FILE_DIR/root/*.upsize 1632 else 1633 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 6 \ 1634 "0503-842 %s: %s creation failed. \n" "$CMDNAME" "$CONTROL_FILE_DIR"` 1635 print >&2 "$MESG" 1636 exit 1; 1637 fi 1638else 1639 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 7 \ 1640 "0503-843 %s: Base package directory %s does not exist. \n" "$CMDNAME" "$ROOT_DIR"` 1641 print >&2 "$MESG" 1642 exit 1; 1643fi 1644 1645# Create a new template file if we didn't get one from the command line 1646if [[ -z "$TEMPLATE_FILE" ]]; then 1647 print "\n************************************************************" 1648 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 8 \ 1649 "| Beginning interactive package input | \n"` 1650 print "$MESG" 1651 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 9 \ 1652 "| * - required; () - example value; [] - default value | \n"` 1653 print "$MESG" 1654 print "************************************************************\n" 1655 1656 while [[ -z "$PACKAGE_NAME" ]]; do 1657 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 10 "* Package Name (xyz.net) []: \n"` 1658 read PACKAGE_NAME?"$MESG" 1659 done 1660 1661 # Set our template filename based on the package name 1662 TEMPLATE_FILE=$CONTROL_FILE_DIR/$PACKAGE_NAME.template 1663 1664 # Make sure the template file doesn't already exist. 1665 if [[ -f $TEMPLATE_FILE ]]; then 1666 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 11 "0503-844 %s: Cannot overwrite existing \n\ 1667\t%s file.\n " "$CMDNAME" "$TEMPLATE_FILE"` 1668 print >&2 "$MESG" 1669 exit 1; 1670 else 1671 # Make sure we can create our template file; we don't want users to enter 1672 # all their package info only to find out the template file cannot be created. 1673 MESG="Package Name: $PACKAGE_NAME" 1674 print "$MESG" > $TEMPLATE_FILE 1675 if [[ ! -f $TEMPLATE_FILE ]]; then 1676 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 12 \ 1677 "0503-845 %s: %s creation failed.\n" "$CMDNAME" "$TEMPLATE_FILE"` 1678 print >&2 "$MESG" 1679 exit 1; 1680 fi 1681 fi 1682 1683 # Get package data and make a tempalte file 1684 create_template 1685fi 1686 1687# By now we should have a good template file. Parse it to get everything ready to 1688# exec the makebff script. 1689if [[ -f $TEMPLATE_FILE ]]; then 1690 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 57 \ 1691 "\nUsing %s as the template file.\n" "$TEMPLATE_FILE"` 1692 print "$MESG" 1693 parse_template < $TEMPLATE_FILE 1694else 1695 MESG=`/usr/bin/dspmsg -s 20 cmdinstl_e.cat 88 \ 1696 "0503-882 %s: Template file %s does not exist.\n" "$CMDNAME" "$TEMPLATE_FILE"` 1697 print >&2 "$MESG" 1698 exit 1; 1699fi 1700 1701# Change to our root package build directory, and execute makebff 1702cd "$ROOT_DIR" 1703exec makebff.pl 1704cd - 1705