udbParseLib.awk 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  1. # Awk Library file for parsing UDB files
  2. #
  3. function parseUdb() {
  4. # nawk has already read the initial line.
  5. # Tokenize it before doing anything else.
  6. tokenize()
  7. readDefaults(defaults)
  8. # assign hp-ux ".db" file src and link defaults
  9. # if none were designated.
  10. if ( SrcDefault == "" )
  11. SrcDefault = "a_out_location"
  12. if ( LnkDefault == "" )
  13. LnkDefault = "link_source"
  14. if ( TypDefault == "" )
  15. TypDefault = "type"
  16. if ( DestDefault == "" )
  17. DestDefault = "install_target"
  18. if ( ModeDefault == "" )
  19. ModeDefault = "mode"
  20. if ( OwnerDefault == "" )
  21. OwnerDefault = "owner"
  22. if ( GroupDefault == "" )
  23. GroupDefault = "group"
  24. readData()
  25. }
  26. # -------------------------------------------------------------
  27. # readDefaults
  28. # This routine reads the defaults at the front section
  29. # of the universal database and salts the defaults away.
  30. #
  31. # -------------------------------------------------------------
  32. function readDefaults(dflts)
  33. {
  34. if ( DeBug > 0 ) {
  35. Depth++
  36. for ( i=1; i < Depth; i++ )
  37. printf(" ") > DeBugFile
  38. print "Entering function readDefaults" > DeBugFile
  39. }
  40. do {
  41. os = getOS()
  42. if ( osQual != "defaults" )
  43. syntaxError("No defaults for: " BlockToken)
  44. if ( os == BlockToken || os == "default" )
  45. break
  46. skipToToken("}")
  47. } while ( 1 )
  48. fillDefaults()
  49. if ( DeBug > 1 )
  50. print "Skipping remaining defaults" > DeBugFile
  51. # skip remaining default specs
  52. while ( lookAhead() == "{" ) {
  53. # This should be another default spec
  54. # skip it. (watch out for syntax errors)
  55. os = getOS()
  56. if ( osQual != "defaults" )
  57. syntaxError("Expected os:defaults found: \"" os ":" osQual "\"")
  58. if ( os == BlockToken && fileName == FILENAME )
  59. syntaxError("Only one \"defaults\" record allowed per os" )
  60. skipToToken("}");
  61. }
  62. if ( DeBug > 0 ) Depth--
  63. }
  64. # -------------------------------------------------------------
  65. # syntaxError
  66. # bail out
  67. #
  68. # (optionally) mail a message to an administrator if a syntax
  69. # error occurs in a database.
  70. #
  71. # -------------------------------------------------------------
  72. function syntaxError(reason) {
  73. if ( DeBug > 0 ) {
  74. Depth++
  75. for ( i=1; i < Depth; i++ )
  76. printf(" ") > DeBugFile
  77. print "Entering function syntaxError:" > DeBugFile
  78. }
  79. print "Syntax ERROR line: " NR " of file: " FILENAME
  80. if (reason)
  81. print " " reason
  82. system( "rm -f /tmp/SyntaxError" )
  83. system( "touch /tmp/SyntaxError" )
  84. print "Syntax ERROR line: " NR " of file: " FILENAME > "/tmp/SyntaxError"
  85. if (reason)
  86. print " " reason >> "/tmp/SyntaxError"
  87. close( "/tmp/SyntaxError" )
  88. if ( mailTo != "" ) {
  89. system( "mailx -s \"database syntax error\" "mailTo" < /tmp/SyntaxError" )
  90. }
  91. system( "rm -f /tmp/SyntaxError" )
  92. exit 1
  93. }
  94. # -------------------------------------------------------------
  95. # fillDefaults
  96. # This routine reads the defaults in the OS
  97. # defaults section of the database. It saves the defaults
  98. # in the "defaults" awk-style string array.
  99. #
  100. # -------------------------------------------------------------
  101. function fillDefaults() {
  102. if ( DeBug > 0 ) {
  103. Depth++
  104. for ( i=1; i < Depth; i++ )
  105. printf(" ") > DeBugFile
  106. print "Entering function fillDefaults:" > DeBugFile
  107. }
  108. tempDflt = ""
  109. NumEntries = 1
  110. do {
  111. if ( tempDflt != "" ) {
  112. keyword = tempDflt
  113. tempDflt = ""
  114. }
  115. else
  116. keyword = nextToken()
  117. if ( keyword == "}" )
  118. break;
  119. if ( "=" != nextToken())
  120. syntaxError("Keyword: " keyword " not followed by \"=\" ");
  121. tempDflt = nextToken();
  122. if ( lookAhead() == "=" )
  123. defaults[keyword]=""
  124. else {
  125. if ( tempDflt == "<SRC>" ) {
  126. SrcDefault = keyword;
  127. tempDflt = ""
  128. }
  129. if ( tempDflt == "<LNK>" ) {
  130. LnkDefault = keyword;
  131. tempDflt = ""
  132. }
  133. if ( tempDflt == "<TYPE>" ) {
  134. TypDefault = keyword;
  135. tempDflt = "file"
  136. }
  137. if ( tempDflt == "<DEST>" ) {
  138. DestDefault = keyword;
  139. tempDflt = ""
  140. }
  141. if ( tempDflt == "<MODE>" ) {
  142. ModeDefault = keyword;
  143. tempDflt = "0444"
  144. }
  145. if ( tempDflt == "<OWNER>" ) {
  146. OwnerDefault = keyword;
  147. tempDflt = "bin"
  148. }
  149. if ( tempDflt == "<GROUP>" ) {
  150. GroupDefault = keyword;
  151. tempDflt = "bin"
  152. }
  153. defaults[keyword]= tempDflt
  154. tempDflt = ""
  155. }
  156. defOrder[NumEntries++] = keyword;
  157. } while ( 1 )
  158. if ( DeBug > 3 ) {
  159. DBGprintArray(defaults,"defaults")
  160. print "SrcDefault =" SrcDefault > DeBugFile
  161. print "LnkDefault =" LnkDefault > DeBugFile
  162. print "TypDefault =" TypDefault > DeBugFile
  163. }
  164. if ( DeBug > 0 ) Depth--
  165. }
  166. # -------------------------------------------------------------
  167. # getOS
  168. # This routine scans the database for an
  169. # open brace, then a token, then a ":" indicating
  170. # the start of an OS defaults section.
  171. #
  172. # -------------------------------------------------------------
  173. function getOS()
  174. {
  175. if ( DeBug > 0 ) {
  176. Depth++
  177. for ( i=1; i < Depth; i++ )
  178. printf(" ") > DeBugFile
  179. print "Entering function getOS:" > DeBugFile
  180. }
  181. osQual = ""
  182. gotOS = 0
  183. if ( "{" != nextToken() )
  184. syntaxError("Missing initial {")
  185. os = nextToken();
  186. if ( lookAhead() == ":" ) {
  187. nextToken();
  188. osQual= nextToken();
  189. } else
  190. osQual= ""
  191. if ( DeBug > 0 ) Depth--
  192. return os
  193. }
  194. # -------------------------------------------------------------
  195. # nextToken
  196. # parse the incoming data stream into tokens.
  197. #
  198. # -------------------------------------------------------------
  199. function nextToken() {
  200. if ( DeBug > 0 ) {
  201. Depth++
  202. for ( i=1; i < Depth; i++ )
  203. printf(" ") > DeBugFile
  204. print "Entering function nextToken:" > DeBugFile
  205. }
  206. if ( EOF_Reached == 1 )
  207. syntaxError("Premature EOF");
  208. tmpToken=tokens[TK++]
  209. while ( TK > Ntokens || tokens[TK] == ";" ) {
  210. TK++
  211. if ( TK > Ntokens )
  212. if ( newLine() <= 0 ) {
  213. EOF_Reached = 1;
  214. break;
  215. }
  216. }
  217. if ( DeBug > 2 )
  218. print "Returning token: " tmpToken > DeBugFile
  219. if ( DeBug > 0 ) Depth--
  220. return tmpToken
  221. }
  222. # -------------------------------------------------------------
  223. # lookAhead
  224. # return the token at the head of the current list of
  225. # tokens, but do not bump the token count in TK
  226. #
  227. # -------------------------------------------------------------
  228. function lookAhead() {
  229. if ( DeBug > 0 ) {
  230. Depth++
  231. for ( i=1; i < Depth; i++ )
  232. printf(" ") > DeBugFile
  233. print "Entering function lookAhead" > DeBugFile
  234. }
  235. if ( DeBug > 0 ) Depth--
  236. return tokens[TK];
  237. }
  238. # -------------------------------------------------------------
  239. # newLine, tokenize
  240. # read a new line of input and tokenize it.
  241. #
  242. # -------------------------------------------------------------
  243. function newLine() {
  244. if ( DeBug > 0 ) {
  245. Depth++
  246. for ( i=1; i < Depth; i++ )
  247. printf(" ") > DeBugFile
  248. print "Entering function newLine:" > DeBugFile
  249. }
  250. if ( (retval = getline) <= 0 ) {
  251. if ( DeBug > 0 ) Depth--
  252. return retval
  253. }
  254. retval = tokenize()
  255. if ( DeBug > 0 ) Depth--
  256. return retval
  257. }
  258. function tokenize() {
  259. if ( DeBug > 0 ) {
  260. Depth++
  261. for ( i=1; i < Depth; i++ )
  262. printf(" ") > DeBugFile
  263. print "Entering function tokenize:" > DeBugFile
  264. }
  265. # Workaround for a strange awk bug, seen on FreeBSD
  266. # and results in .db files generated with
  267. # Syntax ERROR line: 10 of file: CDE-INC.udb
  268. # Missing initial {
  269. #
  270. DUMMY = $0
  271. # Skip blank/comment lines
  272. while ( NF == 0 || $0 ~ /^[ ]*#/ ) {
  273. if ( (getline) <= 0 ) {
  274. if ( DeBug > 0 ) Depth--
  275. return 0
  276. }
  277. }
  278. #
  279. # Make sure syntactically meaningful characters are surrounded by
  280. # white space. (I gave up on gsub for this purpose).
  281. #
  282. last=1
  283. Str="" # temp string for modified input line
  284. tstStr=$0 # part of input line being tested
  285. newStr=$0 # current input line image with modifications
  286. ##########################################################################
  287. # REPLACE THE FOLLOWING LINE WITH A WORK_AROUND FOR A PROBLEM WITH
  288. # THE MATCH FUNCTION FOR THE SUN VERSION OF "nawk"
  289. #
  290. # while ( match(tstStr,"[^\\\][:=}{;]") ) {
  291. #
  292. while ( match(tstStr,"[:=}{;]") ) {
  293. if ( RSTART-1 > 0 && substr(tstStr,RSTART-1,1) != "\\") {
  294. RSTART=RSTART-1
  295. LENGTH=LENGTH+1
  296. } else {
  297. #
  298. # The character was escaped with a backslash.
  299. # Patch things up -- continue testing the rest
  300. # of the line.
  301. #
  302. Str=Str substr($0,last,RSTART+1)
  303. last = last + RSTART + 1
  304. tstStr =substr($0,last)
  305. newStr = Str tstStr
  306. continue;
  307. }
  308. ####################### end of workaround ################################
  309. ############################################################################
  310. if ( DeBug > 1 ) {
  311. print "Tokenize: Match found in: " tstStr
  312. print "RSTART= " RSTART " ; RLENGTH = " RLENGTH
  313. }
  314. # match found --
  315. # the temp string is now modified to contain:
  316. # 1) all characters up to the match and the first char of match
  317. # 2) blank before the syntactically significant char
  318. # 3) the significant character
  319. # 4) blank following the significant character
  320. Str=Str substr($0,last,RSTART) " " substr($0,last+RSTART,1) " "
  321. last = last + RSTART + 1;
  322. #
  323. # Test remaining part of input line for additional occurances
  324. # of syntactically significant characters.
  325. #
  326. tstStr=substr($0,last)
  327. #
  328. # Our best guess for the new string is the part of the
  329. # input line already tested plus the part yet to be tested.
  330. #
  331. newStr=Str tstStr
  332. }
  333. #
  334. # Check for any instances of syntax chars at the start of the line
  335. #
  336. sub("^[:=}{;]","& ",newStr);
  337. $0 = newStr
  338. #
  339. # allow escaping of significant syntax characters
  340. #
  341. gsub("[\\][{]","{")
  342. gsub("\\:",":")
  343. gsub("\\;",";")
  344. gsub("\\=","=")
  345. gsub("[\\][}]","}")
  346. #
  347. # Having insured that interesting chars are surrounded by blanks
  348. # now tokenize the input line.
  349. #
  350. Ntokens = split($0,tokens)
  351. TK = 1
  352. if ( DeBug > 3 )
  353. DBGprintTokens()
  354. if ( DeBug > 0 ) Depth--
  355. return Ntokens
  356. }
  357. function DBGprintTokens()
  358. {
  359. for ( i = 1; i <= Ntokens ; i++ )
  360. print "tokens[" i "] = " tokens[i] > DeBugFile
  361. return 0
  362. }
  363. function DBGprintArray(array,name) {
  364. for ( i in array) {
  365. print name "[" i "] = " array[i] > DeBugFile
  366. }
  367. }
  368. # -------------------------------------------------------------
  369. # skipToToken
  370. # read until the passed in token is encountered
  371. #
  372. # -------------------------------------------------------------
  373. function skipToToken(tok)
  374. {
  375. if ( DeBug > 0 ) {
  376. Depth++
  377. for ( i=1; i < Depth; i++ )
  378. printf(" ") > DeBugFile
  379. print "Entering function skipToToken:" > DeBugFile
  380. }
  381. while ( nextToken() != tok )
  382. ;
  383. if ( DeBug > 0 ) Depth--
  384. }
  385. # -------------------------------------------------------------
  386. # readData
  387. #
  388. # -------------------------------------------------------------
  389. function readData() {
  390. if ( DeBug > 0 ) {
  391. Depth++
  392. for ( i=1; i < Depth; i++ )
  393. printf(" ") > DeBugFile
  394. print "Entering function readData" > DeBugFile
  395. }
  396. while ( EOF_Reached == 0 ) {
  397. if ( fileName != FILENAME ) {
  398. if ( DeBug > 1 ) {
  399. print "====>Files Changed" > DeBugFile
  400. print "fileName= " fileName > DeBugFile
  401. print "FILENAME= " FILENAME > DeBugFile
  402. }
  403. fileName = FILENAME
  404. # skip over defaults section of the new file
  405. while ( lookAhead() == "{" ) {
  406. # This should be another default spec
  407. # skip it. (watch out for syntax errors)
  408. os = getOS()
  409. if ( osQual != "defaults" )
  410. syntaxError("Expected os:defaults found: \"" os ":" osQual "\"")
  411. #
  412. # Relax this restriction since we are
  413. # ignoring this defaults record
  414. #if ( os == BlockToken )
  415. # syntaxError("Only one \"defaults\" record allowed per os" )
  416. skipToToken("}");
  417. }
  418. }
  419. if ( getNextRecord(record) > 0 )
  420. PRTREC(record);
  421. # skip remaining os entries for this source
  422. # sorry no error checking.
  423. while ( EOF_Reached == 0 && lookAhead() == "{" )
  424. skipToToken("}")
  425. if ( DeBug > 1 )
  426. print "EOF_Reached = " EOF_Reached > DeBugFile
  427. }
  428. if ( DeBug > 0 ) Depth--
  429. }
  430. # -------------------------------------------------------------
  431. # getNextRecord
  432. #
  433. # this function fills the rec[] array with defaults
  434. #
  435. # then it scans for a block that has a token maching
  436. # BlockToken, or accepts a block with the "default"
  437. # token. The "default" token is not accepted if
  438. # defaults are disallowed.
  439. #
  440. # finally fillRecord is called to read in the lines
  441. # in the block and override the entries in the rec[] array.
  442. #
  443. # -------------------------------------------------------------
  444. function getNextRecord(rec) {
  445. if ( DeBug > 0 ) {
  446. Depth++
  447. for ( i=1; i < Depth; i++ )
  448. printf(" ") > DeBugFile
  449. print "Entering function getNextRecord:" > DeBugFile
  450. }
  451. # fill with defaults
  452. for ( i in defaults )
  453. rec[i] = defaults[i];
  454. do {
  455. src = nextToken()
  456. if ( DeBug > 2 )
  457. print "src=" src > DeBugFile
  458. # Allow special characters to appear in src names if they have been backslashed
  459. # if ( src ~ /[{:=}]/ )
  460. # syntaxError("Invalid source: \"" src "\"");
  461. do {
  462. os = getOS()
  463. if ( DeBug > 1 ) {
  464. print "Got os " os " and qual= " osQual > DeBugFile
  465. print "NR= " NR " : " $0 > DeBugFile
  466. }
  467. if (( os != BlockToken || osQual == "not" ) \
  468. && ( os != "default" || UseDefaultBlocks != "Y" ) ) {
  469. if ( DeBug > 2)
  470. print "Skipping to end of os rec" > DeBugFile
  471. skipToToken("}");
  472. }
  473. if ( EOF_Reached == 1 || fileName != FILENAME ){
  474. if ( DeBug > 0 ) Depth--
  475. return 0
  476. }
  477. if ( DeBug > 2 )
  478. print "Look Ahead is: " tokens[TK] > DeBugFile
  479. } while ( lookAhead() == "{" )
  480. } while (( os != BlockToken ) && ( os != "default" || UseDefaultBlocks != "Y"))
  481. if ( DeBug > 2)
  482. print "About to call fillRecord" > DeBugFile
  483. fillRecord(rec)
  484. if ( DeBug > 0 ) Depth--
  485. return 1
  486. }
  487. function fillRecord(rec) {
  488. if ( DeBug > 0 ) {
  489. Depth++
  490. for ( i=1; i < Depth; i++ )
  491. printf(" ") > DeBugFile
  492. print "Entering fillRecord:" > DeBugFile
  493. }
  494. tempEntry = ""
  495. do {
  496. if ( tempEntry != "" ) {
  497. keyword = tempEntry;
  498. tempEntry = ""
  499. } else
  500. keyword = nextToken();
  501. if ( keyword == "}" )
  502. break;
  503. if ( "=" != nextToken())
  504. syntaxError("Keyword: " keyword " not followed by \"=\"");
  505. tempEntry = nextToken();
  506. if ( lookAhead() == "=" )
  507. rec[keyword] = ""
  508. else {
  509. rec[keyword] = tempEntry
  510. tempEntry = ""
  511. }
  512. } while (1)
  513. #
  514. # check for source entry
  515. # THIS IMPLIES KNOWLEDGE OF .db FILE ENTRIES!!
  516. if ( DeBug > 2)
  517. print "TYPE= " rec[TypDefault] > DeBugFile
  518. if ( src == "-" )
  519. if ( rec[TypDefault]=="directory" || rec[TypDefault]=="empty_dir")
  520. {
  521. # no source required for a directory
  522. if ( rec[SrcDefault] != "" )
  523. syntaxError(SrcDefault " \"" rec[SrcDefault] "\" specified for a directory.")
  524. if ( rec[LnkDefault] != "" )
  525. syntaxError(LnkDefault " \"" rec[LnkDefault] "\" specfied for a directory.")
  526. rec[SrcDefault] = src;
  527. } else if ( rec["status"] == "---cu-" ) {
  528. # This is used for some reason (X11-SERV.db)
  529. if ( rec[SrcDefault] != "" )
  530. syntaxError( "File: \"" rec["install_target"] "\" with special status: \"---cu-\" should have no source.");
  531. } else
  532. syntaxError("Invalid source: \"" src "\" for type: \"" rec[TypDefault] )
  533. else if ( rec[TypDefault] ~ /link/ )
  534. if ( src ~ /^\// || src ~ /^\./ ) {
  535. if ( rec[SrcDefault] != "")
  536. syntaxError( SrcDefault ": \"" rec[SrcDefault] "\" specified for link: \"" src "\"")
  537. if ( rec[LnkDefault] == "" )
  538. rec[LnkDefault]=src;
  539. } else
  540. syntaxError("Invalid source: \"" src "\" for type: \"" rec[TypDefault] "\"")
  541. else if ( rec[TypDefault] == "file" || rec[TypDefault] == "control" )
  542. rec[SrcDefault] = src;
  543. else
  544. syntaxError("Unrecognized type:\"" rec[TypDefault] "\"")
  545. if ( DeBug > 0 ) Depth--
  546. }
  547. # -------------------------------------------------------------
  548. # printDB
  549. # Print records in ".db" format
  550. # -------------------------------------------------------------
  551. function printDb(rec) {
  552. if ( DeBug > 0 ) {
  553. Depth++
  554. for ( i=1; i < Depth; i++ )
  555. printf(" ") > DeBugFile
  556. print "Entering printDb:" > DeBugFile
  557. }
  558. # NumEntries should be one greater than the number of defaults
  559. # read in.
  560. for ( i = 1; i< NumEntries; i++ ) {
  561. printf("%-40s %s %s\n",defOrder[i], ":",rec[defOrder[i]])
  562. }
  563. print "#"
  564. if ( DeBug > 0 ) Depth--
  565. }
  566. # -------------------------------------------------------------
  567. # printLst
  568. # Print records in ".lst" format
  569. # -------------------------------------------------------------
  570. function printLst(rec) {
  571. if ( DeBug > 0 ) {
  572. Depth++
  573. for ( i=1; i < Depth; i++ )
  574. printf(" ") > DeBugFile
  575. print "Entering printLst:" > DeBugFile
  576. }
  577. if ( rec[TypDefault] ~ /link/ )
  578. Source = LnkDefault
  579. else
  580. Source = SrcDefault
  581. printf("%s %s %s %s %s %s %s %s %s\n",
  582. rec[ DestDefault],
  583. rec[ ModeDefault ],
  584. rec[ Source ],
  585. rec[ TypDefault ],
  586. rec[ OwnerDefault ],
  587. rec[ GroupDefault ],
  588. rec[ "status" ],
  589. rec[ "processor" ],
  590. rec[ "responsible_project" ] )
  591. if ( DeBug > 0 ) Depth--
  592. }
  593. # -------------------------------------------------------------
  594. # printGather
  595. # print records in one of the formats expected by Gather.ksh
  596. # (Jim Andreas print routine).
  597. # -------------------------------------------------------------
  598. function printGather(rec) {
  599. # print "Entering printRecord: "
  600. if (( BlockToken == "hp-ux" ) && ( rec[ "processor" ] != "378" ))
  601. {
  602. if ( index( rec[ "processor" ], Machine ) == 0 )
  603. {
  604. #printf( "skipping %s, Machine %s machines %s\n", src, Machine, rec[ "processor" ] );
  605. return
  606. }
  607. }
  608. if ( action == "toSDD" )
  609. {
  610. if ( rec[ "type" ] == "file" )
  611. {
  612. printf("%s:F:%s:%s:%s:*::\n",
  613. rec[ "install_target" ], rec[ "owner" ],
  614. rec[ "group" ], rec[ "mode" ])
  615. }
  616. }
  617. else if ( action == "toReleaseTree" )
  618. {
  619. if ( ( rec[ "type" ] == "hard_link" ) ||
  620. ( rec[ "type" ] == "sym_link" ) ||
  621. ( rec[ "type" ] == "file" ) )
  622. {
  623. #
  624. # if this is a link, then fudge a source file for Gather.ksh
  625. # to check on. Really we are linking two dest files together
  626. # so the hack is to get around the check in Gather.ksh
  627. #
  628. if ( ( rec[ "type" ] == "hard_link" ) ||
  629. ( rec[ "type" ] == "sym_link" ) )
  630. {
  631. printf( " {s}%s {d}%s\n", "-", rec[ "install_target" ] );
  632. }
  633. else if ( length( src ) > 34 )
  634. printf( " {s}%s {d}%s\n", src, rec[ "install_target" ] );
  635. else
  636. printf( " {s}%-34s {d}%s\n", src, rec[ "install_target" ] );
  637. if ( rec[ "install_rule_name" ] == "c-" )
  638. {
  639. printf( "compress -c < {s}%s > {d}%s\n", src,
  640. rec[ "install_target" ] );
  641. }
  642. else if ( rec[ "type" ] == "sym_link" )
  643. {
  644. printf( "ln -s %s {d}%s\n", src,
  645. rec[ "install_target" ] );
  646. }
  647. else if ( rec[ "type" ] == "hard_link" )
  648. {
  649. printf( "ln {d}%s {d}%s\n", src,
  650. rec[ "install_target" ] );
  651. }
  652. else if ( rec[ "uncompress" ] == "true" )
  653. {
  654. printf( "uncompress -c < {s}%s > {d}%s\n", src,
  655. rec[ "install_target" ] );
  656. }
  657. else if ( length( src ) > 34 )
  658. {
  659. printf( "cp {s}%s {d}%s\n", src,
  660. rec[ "install_target" ] );
  661. }
  662. else
  663. {
  664. printf( "cp {s}%-34s {d}%s\n", src,
  665. rec[ "install_target" ] );
  666. }
  667. printf( "%s %s %s\n", rec[ "owner" ], rec[ "group" ], rec[ "mode" ])
  668. rec[ "install_rule_name" ] = "";
  669. rec[ "uncompress" ] = "";
  670. }
  671. }
  672. else if ( action == "toDeliverArgs" )
  673. {
  674. temp = rec[ "install_target" ];
  675. m = n = index( temp, "/" );
  676. while ( n != 0 )
  677. {
  678. temp = substr( temp, n+1 );
  679. n = index( temp, "/" );
  680. m += n;
  681. }
  682. dirnametarget = substr( rec[ "install_target" ], 1, m-1 );
  683. if ( length( rec[ "install_target" ] ) > 40 )
  684. {
  685. printf("%s -d .%s\n", rec[ "install_target" ], dirnametarget );
  686. }
  687. else
  688. {
  689. printf("%-40s -d .%s\n", rec[ "install_target" ], dirnametarget );
  690. }
  691. }
  692. else if ( action == "toCheckBuild" )
  693. {
  694. # print "Entering printRecord - toCheckBuild: "
  695. #
  696. # skip any link info
  697. #
  698. if ( rec[ "type" ] == "file" )
  699. {
  700. #
  701. # just print the source path for the checker tool
  702. #
  703. printf("%s\n", src );
  704. }
  705. }
  706. else if ( action == "toFileList" )
  707. {
  708. #
  709. # skip any link info
  710. #
  711. if ( rec[ "type" ] == "file" )
  712. {
  713. #
  714. # print the source and install_target for the human person
  715. #
  716. if ( length( src ) > 40 || length( rec[ "install_target" ] ) > 40 )
  717. {
  718. printf("%s -> %s %s\n", src,
  719. rec[ "install_target" ], rec[ "mode" ] );
  720. }
  721. else
  722. {
  723. printf("%-40s -> %-40s %s\n", src,
  724. rec[ "install_target" ], rec[ "mode" ] );
  725. }
  726. }
  727. }
  728. else if ( action == "toTargetList" )
  729. {
  730. #
  731. # skip any link info
  732. #
  733. if ( rec[ "type" ] == "file" )
  734. {
  735. #
  736. # just print the install_target
  737. #
  738. printf("%s\n", rec[ "install_target" ] );
  739. }
  740. }
  741. }