#!/usr/bin/perl
# Script to make doc target lists (*.auto files) which are
# ref'd in the spec. Make sure there are rpm entries for
# online and print for every lang in the spec file, or the
# targets won't get picked up.
#
# Basic process is...
# - open the Makefile and make lists of the books in various formats,
# as well as grabbing some other basic info about the product, etc
# - loop through the book list for each format and spit out book targets
# into appropriately named .auto files; naming conventions are...
# - html_targets<$LANG>.auto
# - print_targets<$LANG>.auto
# - $LANG = "" for English
open (MAKEFILE, "Makefile");
while (<MAKEFILE>) {
if (s/^HTML_SUBDIRS\s*=\s*//) { $FORMAT_LIST{html} = $_; }
if (s/^PDF_SUBDIRS\s*=\s*//) { $FORMAT_LIST{pdf} = $_; }
if (s/^PS_SUBDIRS\s*=\s*//) { $FORMAT_LIST{ps} = $_; }
if (s/^SGML_SUBDIRS\s*=\s*//) { $FORMAT_LIST{sgml} = $_; }
if (s/^RPM_ROOT\s*=\s*([^\s]*)\s*$/$1/) {
$RPM_ROOT = $1;
$SPEC_NAME = "$RPM_ROOT.spec";
}
if (s/^PROD_NAME\s*=\s*([^\s]*)\s*$/$1/) { $PROD_NAME = $1; }
}
close (Makefile);
# Nuke existing .auto files before starting, since we're appending
system ("rm -f *.auto");
foreach $FORMAT (keys(%FORMAT_LIST)) {
foreach $BOOK (split (/\s+/, $FORMAT_LIST{$FORMAT})) {
($LANG = $BOOK) =~ s/.*-\d\d\d//;
if ("$FORMAT" eq "html") {
$MEDIA = "html";
} elsif ("$FORMAT" eq "sgml") {
$MEDIA = "sgml";
} else {
$MEDIA = "print";
}
$TARGFILE = "${MEDIA}_targets${LANG}.auto";
open (TARGFILE,">>$TARGFILE");
foreach $DIR (`find usr/doc/sgi/$PROD_NAME/$BOOK/$FORMAT -type d -print`) {
print TARGFILE "%attr(0755,root,root) %dir /$DIR"; }
foreach $FILE (`find usr/doc/sgi/$PROD_NAME/$BOOK/$FORMAT -type f -print`) {
print TARGFILE "%attr(0644,root,root) /$FILE"; }
close(TARGFILE);
}
}
print "targets generated!\n";