17 GetOptions
('force' => \
$force);
19 # These are directories. The canonpath method removes any cruft
20 # like doubled slashes.
21 my ($source, $target) = map { File
::Spec
->canonpath($_) } @ARGV;
23 die "Need a source and target\n"
24 unless defined $source && defined $target;
27 my $usr_file_name = '.svn_user_name';
29 my %possible_names = map { $_ => 1 } qw(
40 if (-e
($usr_file_name) && -s _
) {
41 open($usr_file,$usr_file_name);
42 $usr_name = <$usr_file>;
45 $usr_name = '' if (!exists($possible_names{$usr_name}));
48 if ($usr_name eq '') {
50 print "Enter your username for SourceForge (to be used in footers of html docs): ";
53 } until ($usr_name =~ m{ \A [a-zA-Z0-9]+ [-\w]* \Z }xms);
55 if (exists($possible_names{$usr_name})) {
56 open($usr_file,">",$usr_file_name);
57 print $usr_file "$usr_name";
59 print "Your username for SourceForge is kept in file src/.svn_user_name as $usr_name\n";
62 print "Supplied username for SourceForge does not match a list of OpenXPKI developers. \n";
63 print " If you are a new developer then: \n";
64 print " edit src/generate_html.pl, \n";
65 print " rerun gmake from src directory, \n";
66 print " commit src/generate_html.pl. \n";
71 $ENV{'SVN_USER_NAME'} = $usr_name;
74 my @svn_output = `svn status`;
75 my $mason_files_changed = 0;
76 foreach my $line (@svn_output) {
78 $line =~ m/ \A \s* ([ACDIMRX?!~]) \s* ([^\s]+?) \s* \Z /xms;
79 $files_status{$2} = $1;
80 $mason_files_changed = 1 if ($2 =~ m/ \A lib\/.*\
.mas \Z
/xms
);
83 # Make target absolute because File::Find changes the current working
84 # directory as it runs.
85 $target = File
::Spec
->rel2abs($target);
88 HTML
::Mason
::Interp
->new( comp_root
=> File
::Spec
->rel2abs(cwd
) );
90 find
( \
&convert
, $source );
93 # We want to split the path to the file into its components and
94 # join them back together with a forward slash in order to make
95 # a component path for Mason
97 # $File::Find::name has the path to the file we are looking at,
98 # relative to the starting directory
99 my $comp_path = join '/', File
::Spec
->splitdir($File::Find
::name
);
101 # Strip off leading part of path that matches source directory
102 my $name = $File::Find
::name
;
103 my $name_with_source = $name;
104 $name =~ s/^$source//;
106 # We dont want to copy subversion dirs
107 if ($name =~ /\.svn/) {
111 # Generate absolute path to output file
112 my $out_file = File
::Spec
->catfile( $target, $name );
115 # We don't want to try to convert our autohandler or .mas
116 # components. $_ contains the filename
117 # old: if (/(\.html|\.css)$/) {
120 # This will save the component's output in $buffer
121 if ((exists($files_status{$name_with_source}) || $force || $mason_files_changed )) {
122 if ((exists($files_status{$name_with_source})) && ($files_status{$name_with_source} =~ m/ \A \? \Z /xms)) {
123 # file is not under version control
124 print STDERR
"WARNING: $name_with_source ignored (not under version control)\n";
128 $interp->out_method(\
$buffer);
129 $interp->exec("/$comp_path");
132 else { # file was not changed
136 # old: } elsif (/(\.png|\.txt)$/) {
137 } elsif (/(\.png|\.txt|\.css)$/) {
138 # don't process, just copy
139 $buffer = do { local $/;
140 open my $FH, "<$_" or die "Could not open $_. Stopped";
144 # ignore mason components et al.
148 # In case the directory doesn't exist, we make it
149 mkpath
(dirname
($out_file));
152 open my $RESULT, "> $out_file" or die "Cannot write to $out_file: $!";
153 print $RESULT $buffer or die "Cannot write to $out_file: $!";
154 close $RESULT or die "Cannot close $out_file: $!";