perl-openpkg.pl 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. #!@l_prefix@/bin/perl -w
  2. ##
  3. ## perl-openpkg -- OpenPKG Perl Module Build Utility
  4. ## Copyright (c) 2000-2004 The OpenPKG Project <http://www.openpkg.org/>
  5. ## Copyright (c) 2000-2004 Ralf S. Engelschall <rse@engelschall.com>
  6. ## Copyright (c) 2000-2004 Cable & Wireless <http://www.cw.com/>
  7. ##
  8. ## Permission to use, copy, modify, and distribute this software for
  9. ## any purpose with or without fee is hereby granted, provided that
  10. ## the above copyright notice and this permission notice appear in all
  11. ## copies.
  12. ##
  13. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  14. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  15. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  16. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  17. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  18. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  19. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  20. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  21. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  22. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  23. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  24. ## SUCH DAMAGE.
  25. ##
  26. require 5;
  27. use strict;
  28. use Getopt::Long;
  29. use IO qw(Handle Seekable File Pipe Socket Dir);
  30. # program information
  31. my $ME = {
  32. prog_path => $0,
  33. prog_name => "perl-openpkg",
  34. prog_vers => "2.0.0",
  35. prog_date => "26-Jan-2004"
  36. };
  37. # program configuration
  38. my $CF = {
  39. path_prefix => '@l_prefix@',
  40. path_libdir => "",
  41. path_tmpdir => ($ENV{"TMPDIR"} || "/tmp"),
  42. path_wrkdir => "",
  43. path_buildroot => ($ENV{"RPM_BUILD_ROOT"} || ""),
  44. path_buildwork => ($ENV{"RPM_BUILD_DIR"} || ""),
  45. pkg_name => ($ENV{"RPM_PACKAGE_NAME"} || ""),
  46. perl_schema => "vendor",
  47. perl_args => [],
  48. perl_stdin => "/dev/null",
  49. files_file => "-",
  50. files_unquoted => 0,
  51. prog_rpm => '%path_prefix%/bin/rpm',
  52. prog_perl => '%path_prefix%/bin/perl',
  53. mode_quiet => 0,
  54. mode_verbose => 0,
  55. run_version => 0,
  56. run_help => 0,
  57. };
  58. # cleanup support
  59. my @cleanup = ();
  60. sub cleanup_remember {
  61. my ($cmd) = @_;
  62. push(@cleanup, $cmd);
  63. }
  64. sub cleanup_perform {
  65. foreach my $cmd (reverse @cleanup) {
  66. &runcmd($cmd);
  67. }
  68. }
  69. # exception handling support
  70. $SIG{__DIE__} = sub {
  71. my ($err) = @_;
  72. $err =~ s|\s+at\s+.*||s if (not $CF->{mode_verbose});
  73. print STDERR "$ME->{prog_name}:ERROR: $err ". ($! ? "($!)" : "") . "\n";
  74. &cleanup_perform() if (not $CF->{mode_verbose});
  75. exit(1);
  76. };
  77. # verbose message printing
  78. sub verbose {
  79. my ($msg) = @_;
  80. print STDERR "++ $msg\n" if (not $CF->{mode_quiet});
  81. }
  82. # expand into a full filesystem path
  83. sub fullpath {
  84. my ($prog) = @_;
  85. my $fullprog = '';
  86. foreach my $path (split(/:/, $ENV{PATH})) {
  87. if (-x "$path/$prog") {
  88. $fullprog = "$path/$prog";
  89. last;
  90. }
  91. }
  92. return $fullprog;
  93. }
  94. # execution of external commands
  95. sub runcmd {
  96. my ($cmd) = @_;
  97. print STDERR "\$ $cmd\n" if ($CF->{mode_verbose});
  98. $cmd = "($cmd) >/dev/null 2>&1" if ($CF->{mode_quiet});
  99. return (system($cmd) == 0);
  100. }
  101. # create a directory (plus its missing parent dirs)
  102. sub mkdirp {
  103. my ($dir) = @_;
  104. my $pdir = $dir;
  105. $pdir =~ s|/[^/]*$||s;
  106. if (not -d $pdir) {
  107. &mkdirp($pdir, 0755);
  108. }
  109. if (not -d $dir) {
  110. &runcmd("umask 022 && mkdir $dir");
  111. }
  112. }
  113. # command line parsing
  114. Getopt::Long::Configure("bundling");
  115. my $result = GetOptions(
  116. 'p|prefix=s' => \$CF->{path_prefix},
  117. 'l|libdir=s' => \$CF->{path_libdir},
  118. 't|tmpdir=s' => \$CF->{path_tmpdir},
  119. 'd|wrkdir=s' => \$CF->{path_wrkdir},
  120. 'r|buildroot=s' => \$CF->{path_buildroot},
  121. 'w|buildwork=s' => \$CF->{path_buildwork},
  122. 'R|rpm=s' => \$CF->{prog_rpm},
  123. 'P|perl=s' => \$CF->{prog_perl},
  124. 's|schema=s' => \$CF->{perl_schema},
  125. 'A|args=s' => \@{$CF->{perl_args}},
  126. 'I|stdin=s' => \$CF->{perl_stdin},
  127. 'F|files=s' => \$CF->{files_file},
  128. 'U|unquoted' => \$CF->{files_unquoted},
  129. 'n|pkgname=s' => \$CF->{pkg_name},
  130. 'q|quiet' => \$CF->{mode_quiet},
  131. 'v|verbose' => \$CF->{mode_verbose},
  132. 'V|version' => \$CF->{run_version},
  133. 'h|help' => \$CF->{run_help}
  134. ) || die "option parsing failed";
  135. if ($CF->{run_help}) {
  136. print "Usage: $ME->{prog_name} [options]\n" .
  137. "Available options:\n" .
  138. "\n" .
  139. " -p, --prefix <dir-path> filesystem path to OpenPKG instance\n" .
  140. " -l, --libdir <dir-path> filesystem path to Perl lib directory\n" .
  141. " -t, --tmpdir <dir-path> filesystem path to temporary directory\n" .
  142. " -d, --wrkdir <dir-path> filesystem path to working directory\n" .
  143. " -r, --buildroot <dir-path> filesystem path to RPM build root directory\n" .
  144. " -w, --buildwork <dir-path> filesystem path to RPM build work directory\n" .
  145. " -R, --rpm <file-path> filesystem path to RPM program\n" .
  146. " -P, --perl <file-path> filesystem path to Perl program\n" .
  147. "\n" .
  148. " -s, --schema <schema> Perl INSTALLDIRS schema\n" .
  149. " -A, --args <arguments> Perl Makefile.PL passed through arguments\n" .
  150. " -I, --stdin <file-path> filesystem path to connect to stdin\n" .
  151. " -F, --files <file-path> filesystem path to write RPM \%files list to\n" .
  152. " -U, --unquoted output RPM \%files list in unquoted format\n" .
  153. " -n, --pkgname <package-name> name of involved RPM package\n" .
  154. "\n" .
  155. " -q, --quiet operate in quiet run-time mode\n" .
  156. " -v, --verbose operate in verbose run-time mode\n" .
  157. "\n" .
  158. " -V, --version print out program version\n" .
  159. " -h, --help print out program usage help\n";
  160. exit(0);
  161. }
  162. if ($CF->{run_version}) {
  163. print "OpenPKG $ME->{prog_name} $ME->{prog_vers} ($ME->{prog_date})\n";
  164. exit(0);
  165. }
  166. # fix configuration parameters
  167. foreach my $cf (keys(%{$CF})) {
  168. $CF->{$cf} =~ s|\%([A-Za-z_][A-Za-z0-9_]*)\%|$CF->{$1}|sge;
  169. }
  170. # determine operation steps
  171. my @steps_exist = qw(prolog prepare configure build install fixate cleanup epilog);
  172. my @steps_run = ();
  173. if (@ARGV > 0) {
  174. foreach my $step (@ARGV) {
  175. if (not grep { $_ eq $step } @steps_exist) {
  176. die "operation step \"$step\" not existing";
  177. }
  178. push(@steps_run, $step);
  179. }
  180. my $steps_exist = "-".join("-", @steps_exist)."-";
  181. my $steps_run = "-".join("-", @steps_run)."-";
  182. if ($steps_exist !~ m|^.*${steps_run}.*$|s) {
  183. die "invalid operation step order \"".join(" ", @ARGV)."\"";
  184. }
  185. }
  186. else {
  187. @steps_run = @steps_exist;
  188. }
  189. # friendly header ;-)
  190. &verbose("OpenPKG $ME->{prog_name} $ME->{prog_vers} ($ME->{prog_date})");
  191. # determine RPM program
  192. if (not -x $CF->{prog_rpm}) {
  193. $CF->{prog_rpm} = &fullpath($CF->{prog_rpm});
  194. }
  195. my $V = `$CF->{prog_rpm} --version 2>/dev/null`;
  196. $V =~ s/^(RPM version|OpenPKG RPM)\s+([0-9.]+)\s*$/$2/s ||
  197. die "program '$CF->{prog_rpm}' seems to be not RPM";
  198. &verbose("determined RPM program: $CF->{prog_rpm} ($V)");
  199. # determine Perl program
  200. if (not -x $CF->{prog_perl}) {
  201. $CF->{prog_perl} = &fullpath($CF->{prog_perl});
  202. }
  203. $V = `$CF->{prog_perl} --version 2>/dev/null`;
  204. $V =~ s|^.*This is perl, v?([\d+.]+) .*$|$1|s ||
  205. die "program '$CF->{prog_perl}' seems to be not Perl";
  206. &verbose("determined Perl program: $CF->{prog_perl} ($V)");
  207. # check for existing paths
  208. if ($CF->{path_buildroot} eq '') {
  209. die "RPM build root directory not known (specify one with option --buildroot)";
  210. }
  211. if ($CF->{path_buildwork} eq '') {
  212. die "RPM build work directory not known (specify one with option --buildwork)";
  213. }
  214. mkdir($CF->{path_buildroot}, 0700);
  215. mkdir($CF->{path_buildwork}, 0700);
  216. ##
  217. ## OPERATION SEQUENCE
  218. ##
  219. # establish standard environment
  220. umask(022);
  221. # determine name of temporary directory
  222. my $tmpdir = $CF->{path_tmpdir};
  223. $tmpdir =~ s|/+$||s;
  224. my $user = (getlogin() || getpwuid($<) || $ENV{LOGNAME} || $ENV{USERNAME} || "unknown");
  225. my $program = $ME->{prog_name};
  226. my $package = ($CF->{pkg_name} || "unknown");
  227. $tmpdir .= "/$user-$program-$package";
  228. # determine name of perl wrapper script
  229. my $perlwrap = "$tmpdir/perl.sh";
  230. # optionally change working directory
  231. my $dir = $CF->{path_wrkdir};
  232. if ($dir ne '') {
  233. if (not -d $dir) {
  234. # be smart and guess correct directory to
  235. # reduce special cases during packaging
  236. $dir =~ s|^.+/||s;
  237. my $parent = "";
  238. my $child = $dir;
  239. $child =~ s|^(.+/)([^/]+)$|$parent = $1, $2|se;
  240. LOOP: while ($child ne '') {
  241. foreach my $dir (glob("${parent}${child}*")) {
  242. if (-d "$parent$dir") {
  243. $child = $dir;
  244. last LOOP;
  245. }
  246. }
  247. $child =~ s|\W\w+$||s || last;
  248. last if (-d "$parent$child");
  249. }
  250. $dir = "$parent$child";
  251. }
  252. chdir($dir) || die "cannot change to working directory \"$dir\"";
  253. }
  254. # determine Perl configuration
  255. my $pcfg = {};
  256. my $cmd = "$CF->{prog_perl}" .
  257. " -V:installarchlib -V:installprivlib" .
  258. " -V:installsitearch -V:installsitelib -V:sitelib_stem" .
  259. " -V:installvendorarch -V:installvendorlib -V:vendorlib_stem";
  260. my $out = `$cmd 2>/dev/null || true`;
  261. $out =~ s|^(\S+)='([^'']*)';$|$pcfg->{$1} = $2, ''|mge;
  262. # ==== COMPAT prolog/epilog ====
  263. if (grep { $_ eq "prolog" or $_ eq "epilog" } @steps_run) {
  264. print "This is the perl-openpkg >= 20040126 version.\n" .
  265. "It was redesigned and is incompatible to previous\n" .
  266. "versions. It does not support prolog/epilog steps.\n" .
  267. "Please upgrade the package that uses perl-openpkg\n" .
  268. "or, as a temporary workaround, downgrade perl-openpkg\n";
  269. die "package/perl-openpkg incompatiblity";
  270. }
  271. # ==== STEP: 1. prepare ====
  272. if (grep { $_ eq "prepare" } @steps_run) {
  273. &verbose("step 1: prepare");
  274. # establish temporary directory
  275. system("rm -rf $tmpdir >/dev/null 2>&1");
  276. mkdir($tmpdir, 0700) || die "cannot create temporary directory '$tmpdir'";
  277. # create Perl executable wrapper script
  278. my $io = new IO::File ">$perlwrap"
  279. || die "unable to open \"$perlwrap\" for writing";
  280. print $io
  281. "#!/bin/sh\n" .
  282. "exec $CF->{prog_perl} \\\n" .
  283. " -I$CF->{path_buildroot}$pcfg->{installarchlib} \\\n" .
  284. " -I$CF->{path_buildroot}$pcfg->{installprivlib} \\\n" .
  285. " -I$CF->{path_buildroot}$pcfg->{installsitearch} \\\n" .
  286. " -I$CF->{path_buildroot}$pcfg->{installsitelib} \\\n" .
  287. " -I$CF->{path_buildroot}$pcfg->{installvendorarch} \\\n" .
  288. " -I$CF->{path_buildroot}$pcfg->{installvendorlib} \\\n" .
  289. " \"\$@\"\n";
  290. $io->close();
  291. &runcmd("chmod 755 $perlwrap");
  292. # establish Perl module installation areas
  293. &mkdirp("$CF->{path_buildroot}$pcfg->{installarchlib}");
  294. &mkdirp("$CF->{path_buildroot}$pcfg->{installprivlib}");
  295. &mkdirp("$CF->{path_buildroot}$pcfg->{installsitearch}");
  296. &mkdirp("$CF->{path_buildroot}$pcfg->{installsitelib}");
  297. &mkdirp("$CF->{path_buildroot}$pcfg->{installvendorarch}");
  298. &mkdirp("$CF->{path_buildroot}$pcfg->{installvendorlib}");
  299. }
  300. # ==== STEP: 2. configure ====
  301. if (grep { $_ eq "configure" } @steps_run) {
  302. &verbose("step 2: configure");
  303. # sanity check
  304. if (not -f "Makefile.PL") {
  305. die "file \"Makefile.PL\" not found in working directory";
  306. }
  307. # determine Makefile.PL arguments
  308. my $perl_args = " PERL=$perlwrap FULLPERL=$perlwrap";
  309. $perl_args .= " INSTALLDIRS=$CF->{perl_schema}";
  310. $perl_args .= " INSTALLMAN3DIR=none INSTALLSITEMAN3DIR=none INSTALLVENDORMAN3DIR=none";
  311. $perl_args .= " DESTDIR=$CF->{path_buildroot} PREFIX=$CF->{path_prefix}";
  312. if ($CF->{path_libdir} ne '') {
  313. $perl_args .= " LIB=$CF->{path_libdir}";
  314. }
  315. if ($#{@{$CF->{perl_args}}} >= 0) {
  316. my $user_args = join(" ", @{$CF->{perl_args}});
  317. if ($user_args =~ m|#|) {
  318. $user_args =~ s|#| $perl_args |;
  319. $perl_args = $user_args;
  320. }
  321. else {
  322. $perl_args .= " " . $user_args;
  323. }
  324. }
  325. # fixate Makefile.PL
  326. &runcmd("chmod -R u+rw Makefile.PL");
  327. &runcmd("cp Makefile.PL Makefile.PL.orig");
  328. &runcmd("sed -e \"s:\\\$^X:'$perlwrap':g\" <Makefile.PL.orig >Makefile.PL");
  329. # determine stdin
  330. if ($CF->{perl_stdin} ne "-") {
  331. $perl_args .= " <$CF->{perl_stdin}";
  332. }
  333. # execute Makefile.PL
  334. &runcmd("$perlwrap Makefile.PL $perl_args");
  335. }
  336. # ==== STEP: 3. build ====
  337. if (grep { $_ eq "build" } @steps_run) {
  338. &verbose("step 3: build");
  339. # sanity check
  340. if (not -f "Makefile") {
  341. die "file \"Makefile\" not found in working directory";
  342. }
  343. # determine make(1) command and flags
  344. my $make = `$CF->{prog_rpm} --eval '\%{l_make} \%{l_mflags}'`;
  345. $make =~ s|\n+$||s;
  346. my $make_args = "PERL=$perlwrap FULLPERL=$perlwrap";
  347. # execute make(1)
  348. &runcmd("$make $make_args pure_all");
  349. }
  350. # ==== STEP: 4. install ====
  351. if (grep { $_ eq "install" } @steps_run) {
  352. &verbose("step 4: install");
  353. # sanity check
  354. if (not -f "Makefile") {
  355. die "file \"Makefile\" not found in working directory";
  356. }
  357. # determine make(1) command and flags
  358. my $make = `$CF->{prog_rpm} --eval '\%{l_make} \%{l_mflags}'`;
  359. $make =~ s|\n+$||s;
  360. my $make_args = "PERL=$perlwrap FULLPERL=$perlwrap";
  361. # execute make(1)
  362. &runcmd("$make $make_args pure_install");
  363. }
  364. # ==== STEP: 5. fixate ====
  365. if (grep { $_ eq "fixate" } @steps_run) {
  366. &verbose("step 5: fixate");
  367. # prune installation files
  368. my $libdir;
  369. if ($CF->{path_libdir} ne '') {
  370. $libdir = "$CF->{path_buildroot}$CF->{path_libdir}";
  371. }
  372. else {
  373. $libdir = "$CF->{path_buildroot}$CF->{path_prefix}/lib/perl";
  374. }
  375. &runcmd("find $libdir -name perllocal.pod -print | xargs rm -f");
  376. &runcmd("find $libdir -name .packlist -print | xargs rm -f");
  377. &runcmd("find $libdir -type d -depth -print | (xargs rmdir >/dev/null 2>&1 || true)");
  378. # determine RPM installation file list
  379. my @files = ();
  380. if ($CF->{path_libdir} eq '') {
  381. push(@files, '%not %dir '.$CF->{path_prefix}.'/lib/perl');
  382. push(@files, '%not %dir '.$pcfg->{installarchlib}.'/auto');
  383. push(@files, '%not %dir '.$pcfg->{installarchlib});
  384. push(@files, '%not %dir '.$pcfg->{installprivlib}.'/auto');
  385. push(@files, '%not %dir '.$pcfg->{installprivlib});
  386. push(@files, '%not %dir '.$pcfg->{sitelib_stem});
  387. push(@files, '%not %dir '.$pcfg->{installsitearch}.'/auto');
  388. push(@files, '%not %dir '.$pcfg->{installsitearch});
  389. push(@files, '%not %dir '.$pcfg->{installsitelib}.'/auto');
  390. push(@files, '%not %dir '.$pcfg->{installsitelib});
  391. push(@files, '%not %dir '.$pcfg->{vendorlib_stem});
  392. push(@files, '%not %dir '.$pcfg->{installvendorarch}.'/auto');
  393. push(@files, '%not %dir '.$pcfg->{installvendorarch});
  394. push(@files, '%not %dir '.$pcfg->{installvendorlib}.'/auto');
  395. push(@files, '%not %dir '.$pcfg->{installvendorlib});
  396. }
  397. # output RPM installation file list
  398. my $out;
  399. if ($CF->{files_file} eq "-") {
  400. $out = new IO::Handle;
  401. $out->fdopen(fileno(STDOUT), "w");
  402. }
  403. else {
  404. $out = new IO::File ">$CF->{files_file}";
  405. }
  406. if ($CF->{files_unquoted}) {
  407. print $out join("\n", @files) . "\n";
  408. }
  409. else {
  410. print $out '"'. join('"'."\n".'"', @files).'"'."\n";
  411. }
  412. $out->close();
  413. }
  414. # ==== STEP: 6. cleanup ====
  415. if (grep { $_ eq "cleanup" } @steps_run) {
  416. &verbose("step 6: cleanup");
  417. # remove temporary directory and its contents
  418. &runcmd("rm -rf $tmpdir");
  419. }
  420. # die gracefully...
  421. &verbose("cleaning up environment");
  422. &cleanup_perform();
  423. exit(0);
  424. __END__
  425. ##
  426. ## UNIX MANUAL PAGE
  427. ##
  428. =pod
  429. =head1 NAME
  430. B<perl-openpkg> - B<OpenPKG Perl Module Build Utility>
  431. =head1 SYNOPSIS
  432. B<perl-openpkg>
  433. [B<-p>|B<--prefix> I<dir-path>]
  434. [B<-D>|B<--libdir> I<dir-path>]
  435. [B<-t>|B<--tmpdir> I<dir-path>]
  436. [B<-d>|B<--wrkdir> I<dir-path>]
  437. [B<-r>|B<--buildroot> I<dir-path>]
  438. [B<-w>|B<--buildwork> I<dir-path>]
  439. [B<-R>|B<--rpm> I<file-path>]
  440. [B<-P>|B<--perl> I<file-path>]
  441. [B<-s>|B<--schema> I<schema>
  442. [B<-A>|B<--args> I<arguments>]
  443. [B<-I>|B<--stdin> I<file-path>]
  444. [B<-F>|B<--files> I<file-path>]
  445. [B<-U>|B<--unquoted>]
  446. [B<-n>|B<--pkgname> I<name>]
  447. [B<-q>|B<--quiet>]
  448. [B<-v>|B<--verbose>]
  449. [I<step> ...]
  450. B<perl-openpkg>
  451. [B<-v>|B<--version>]
  452. [B<-h>|B<--help>]
  453. =head1 DESCRIPTION
  454. The B<perl-openpkg> program is an internal B<OpenPKG> packaging utility
  455. for building C<ExtUtils::MakeMaker> based Perl modules during the build
  456. procedure of Perl module based B<OpenPKG> packages. It provides an
  457. adjustable C<ExtUtils::MakeMaker> environment.
  458. =head1 OPTIONS
  459. The following command line options are available:
  460. =head2 Filesystem Paths
  461. The following command-line options set various filesystem paths.
  462. =over 4
  463. =item B<-p>, B<--prefix> I<dir-path>
  464. Filesystem path to OpenPKG instance. Default is C<@l_prefix@>.
  465. =item B<-l>, B<--libdir> I<dir-path>
  466. Filesystem path to Perl lib directory. Default is
  467. "I<prefix>C</lib/perl>".
  468. =item B<-t>, B<--tmpdir> I<dir-path>
  469. Filesystem path to temporary directory. Default is C<$TMPDIR>,
  470. as provided by the RPM build-time environment.
  471. =item B<-d>, B<--wrkdir> I<dir-path>
  472. Filesystem path to working directory. Default is current working directory
  473. as provided by the RPM build-time environment.
  474. =item B<-r>, B<--buildroot> I<dir-path>
  475. Filesystem path to RPM build root directory. Default is C<$RPM_BUILD_ROOT>,
  476. as provided by the RPM build-time environment.
  477. =item B<-w>, B<--buildwork> I<dir-path>
  478. Filesystem path to RPM build work directory. Default is C<$RPM_BUILD_DIR>,
  479. as provided by the RPM build-time environment.
  480. =item B<-R>, B<--rpm> I<file-path>
  481. Filesystem path to RPM program. Default is I<prefix>C</bin/rpm>.
  482. =item B<-P>, B<--perl> I<file-path>
  483. Filesystem path to Perl program. Default is I<prefix>C</bin/perl>.
  484. =back
  485. =head2 OpenPKG Package Information
  486. The following command-line options set various package information.
  487. =over 4
  488. =item B<-s>, B<--schema> I<schema>
  489. Sets the Perl C<INSTALLDIRS> schema. Allowed values are
  490. "C<perl>", "C<site>" and "C<vendor>". The default is "C<vendor>".
  491. =item B<-A>, B<--args> I<arguments>
  492. Sets additional arguments which are passed through on the "C<perl
  493. Makefile.PL>" command line. This option can be specified multiple times,
  494. args are joined with a space between them. If joined args contain a '#' then
  495. it is substituted by the automatically generated args otherwise joined args
  496. are appended to automatically generated args. Default is empty.
  497. =item B<-I>, B<--stdin> I<file-path>
  498. Filesystem path to connect to F<stdin> on the "C<perl Makefile.PL>"
  499. command line. Default is "C</dev/null>". A value of "C<->" means reading
  500. from F<stdin>.
  501. =item B<-F>, B<--files> I<file-path>
  502. Filesystem path to write the RPM C<%files> entries to describing the
  503. packaging list of all installed files. The default is "C<->" meaning
  504. that the list is written to F<stdout>.
  505. =item B<-U>, B<--unquoted>
  506. By default the RPM <%files> list is written with each path entry
  507. enclosed in quotation marks. For raw post-processing, this option allows
  508. the list to be written without enclosing quotation marks.
  509. =item B<-n>, B<--pkgname> I<name>
  510. Name of involved RPM package.
  511. =back
  512. =head2 Run-Time Modes
  513. The following command-line options set various run-time modes.
  514. =over 4
  515. =item B<-q>, B<--quiet>
  516. Operate in quiet run-time mode.
  517. =item B<-v>, B<--verbose>
  518. Operate in verbose run-time mode.
  519. =back
  520. =head2 Stand-Alone Operations
  521. The following command-line options trigger various stand-alone operations.
  522. =over 4
  523. =item B<-V>, B<--version>
  524. Print program version only.
  525. =item B<-h>, B<--help>
  526. Print program usage help only.
  527. =back
  528. =head1 OPERATION STEPS
  529. The operation procedure of B<perl-openpkg> is divided into the following
  530. six distinguished steps:
  531. =over 3
  532. =item B<1. prepare>
  533. This prepares the build environment by optionally creating a temporary
  534. directory and establishing a Perl wrapper script.
  535. This step can be shared between the configuration, building and installation
  536. of multiple modules.
  537. =item B<2. configure>
  538. This configures the Perl module by performing the equivalent of
  539. the command "C<perl Makefile.PL>". This step has to be performed
  540. individually for each particular module.
  541. =item B<3. build>
  542. This builds the Perl module by performing the equivalent of the command
  543. "C<make all>". This step has to be performed individually for each
  544. particular module.
  545. =item B<4. install>
  546. This installs the Perl module by performing the equivalent of the
  547. command "C<make install>". This step has to be performed individually
  548. for each particular module.
  549. =item B<5. fixate>
  550. This fixates the installed files by removing unnecessary ones, fixing
  551. permissions and determining the resulting file list. This step can be
  552. shared between the configuration, building and installation of multiple
  553. modules.
  554. =item B<6. cleanup>
  555. This cleans up the build environment by removing all temporary files.
  556. This step can be shared between the configuration, building and
  557. installation of multiple modules.
  558. =back
  559. By default all operation steps are performed in sequence. Alternatively,
  560. the sequence of steps can be individually specified on the command
  561. line as one or more I<step> arguments. The given sequence of I<step>s
  562. has to be exactly a contiguous sub-sequence of the sequence listed
  563. above. As the extrem cases, it can be "C<prepare configure build install
  564. fixate cleanup>" (the same as not specifying any steps) or just perhaps
  565. "C<build>" (for executing only a particular step).
  566. =head1 EXAMPLE
  567. # packaging of single module
  568. perl-openpkg
  569. # packaging of multiple modules
  570. perl-openpkg prepare
  571. perl-openpkg -d Foo-1 configure build install
  572. perl-openpkg -d Bar-2 configure build install
  573. perl-openpkg -d Baz-3 configure build install
  574. perl-openpkg fixate cleanup
  575. =head1 HISTORY
  576. The B<perl-openpkg> utility was originally implemented as a small
  577. Bourne-Shell script for use in OpenPKG 1.1. It was later rewritten from
  578. scratch in Perl for OpenPKG 2.0 and especially made more flexible to
  579. reduce the complexity in numerious packages.
  580. =head1 SEE ALSO
  581. perl(1), "C<perldoc ExtUtils::MakeMaker>".
  582. =head1 AUTHORS
  583. Ralf S. Engelschall E<lt>rse@engelschall.comE<gt>.
  584. =cut