3 #=======================================================================
5 # File ID: 5dad39ac-f742-11dd-a5bf-000475e441b9
6 # Creates various pristine setups for all kind of things — documents,
7 # source code and so on.
10 # ©opyleft 2006– Øyvind A. Holm <sunny@sunbase.org>
11 # License: GNU General Public License version 2 or later, see end of
12 # file for legal stuff.
13 #=======================================================================
34 $progname =~ s/^.*\/(.*?)$/$1/;
35 our $VERSION = "0.00";
38 my $CMD_STD = "$ENV{'HOME'}/bin/std";
39 my $CMD_KEYW = "$ENV{'HOME'}/bin/keyw";
41 Getopt
::Long
::Configure
("bundling");
44 "debug" => \
$Opt{'debug'},
45 "help|h" => \
$Opt{'help'},
46 "no-svn|n" => \
$Opt{'no-svn'},
47 "verbose|v+" => \
$Opt{'verbose'},
48 "version" => \
$Opt{'version'},
50 ) || die("$progname: Option error. Use -h for help.\n");
52 $Opt{'debug'} && ($Debug = 1);
53 $Opt{'help'} && usage
(0);
54 if ($Opt{'version'}) {
59 if (!defined($ARGV[1])) {
60 die("$progname: Not enough parameters, use -h for help.\n");
63 my ($Type, $Name) = (shift, shift);
65 if ($Type =~ /^article$/) {
66 mkdir($Name) || die("$progname: mkdir $Name: $!\n");
67 system("$CMD_STD db-article >$Name/$Name.xml");
68 if (open(OutFP
, ">", "$Name/Makefile")) {
69 my $svn_str_update = !$Opt{'no-svn'} && "\tsvn update \$(HTML_TARGET)\n" || "";
78 XHTML_XSL = \$(HOME)/xsl/xhtml/docbook.xsl
79 HTML_TARGET = $Name.html
82 \t\$(MAKE) \$(HTML_TARGET)
84 \$(HTML_TARGET): $Name.xml
85 \t\$(XSLTPROC) -o \$(HTML_TARGET) \$(XSLTOPTS) \$(XHTML_XSL) $Name.xml
86 \txmllint --format --encode UTF-8 \$(HTML_TARGET) >$Name.tmp
87 \tmv $Name.tmp \$(HTML_TARGET)
90 \t\@(for _f in *.xml; do \\
91 \t\techo ==== \$\$_f ====; \\
92 \t\txmllint --valid --noout \$\$_f; \\
97 \trm -f \$(HTML_TARGET)
107 warn("$progname: $Name/Makefile: Cannot create file: $!\n");
109 $Opt{'no-svn'} || my_system
($CMD_SVN, "add", $Name);
110 $Opt{'no-svn'} || my_system
($CMD_KEYW, "$Name/Makefile", "$Name/$Name.xml");
112 die("$progname: $Type: Unknown type\n");
117 my $cmd_txt = join(" ", @Cmd);
118 print("======== $progname: Executing \"$cmd_txt\"... ========\n");
124 # Print program version {{{
125 print("$progname v$VERSION\n");
130 # Send the help message to stdout {{{
133 if ($Opt{'verbose'}) {
139 Usage: $progname type directory
146 Don’t use Subversion commands (svn add, etc)
148 Increase level of verbosity. Can be repeated.
150 Print version information.
152 Print debugging messages.
165 # Print a status message to stderr based on verbosity level {{{
166 my ($verbose_level, $Txt) = @_;
168 if ($Opt{'verbose'} >= $verbose_level) {
169 print(STDERR
"$progname: $Txt\n");
175 # Print a debugging message {{{
177 my @call_info = caller;
178 chomp(my $Txt = shift);
179 my $File = $call_info[1];
181 $File =~ s
#^.*/(.*?)$#$1#;
182 print(STDERR
"$File:$call_info[2] $$ $Txt\n");
189 # Plain Old Documentation (POD) {{{
199 [options] [file [files [...]]]
209 =item B<-h>, B<--help>
211 Print a brief help summary.
213 =item B<-v>, B<--verbose>
215 Increase level of verbosity. Can be repeated.
219 Print version information.
223 Print debugging messages.
233 Made by Øyvind A. Holm S<E<lt>sunny@sunbase.orgE<gt>>.
237 Copyleft © Øyvind A. Holm E<lt>sunny@sunbase.orgE<gt>
238 This is free software; see the file F<COPYING> for legalese stuff.
242 This program is free software: you can redistribute it and/or modify it
243 under the terms of the GNU General Public License as published by the
244 Free Software Foundation, either version 2 of the License, or (at your
245 option) any later version.
247 This program is distributed in the hope that it will be useful, but
248 WITHOUT ANY WARRANTY; without even the implied warranty of
249 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
250 See the GNU General Public License for more details.
252 You should have received a copy of the GNU General Public License along
254 If not, see L<http://www.gnu.org/licenses/>.
262 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :