perl-openpkg.pl 22 KB

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