openbsd-ports/www/pear/files/run-go-pear
sthen 31654e1851 Switch pear to a newer version. We previously used a tarball with a slightly
modified version of the go-pear php script but this was awkward to generate
and newer versions no longer support recent PHP. So instead I have changed
to using an unmodified go-pear.phar archive (mirrored to include a version
number, but there are no changes to the upstream file).

go-pear.phar is normally interactive and doesn't allow presetting parameters
or just piping a simple list of answers, so I am driving it with Expect.pm
instead.

Some bumps/updates to follow as XML-Util moved to the main pear distro.

ok robert@
2016-04-01 18:46:06 +00:00

41 lines
1.6 KiB
Perl

#!/usr/bin/perl -W
use Cwd;
use Expect;
my $wrkinst = shift;
my $prefix = $wrkinst . shift;
my $varwww = $wrkinst . '/var/www';
my $phpbin = shift;
my $spawn = new Expect;
$spawn = Expect->spawn("$phpbin -d suhosin.executor.include.whitelist=phar go-pear.phar");
$spawn->log_file("/tmp/go-pear.log.$$");
my $ret = $spawn->expect(
10,
'-re', "^1-12, 'all' or Enter", sub { $spawn->send("all\n"); }
);
$ret = $spawn->expect(
10,
'-re', "^Installation base", sub { $spawn->send("$prefix\n"); exp_continue; },
'-re', "^Temporary dir", sub { $spawn->send(cwd."/tmp\n"); exp_continue; },
'-re', "^Binaries dir", sub { $spawn->send("\n"); exp_continue; },
'-re', "^PHP code dir", sub { $spawn->send("$varwww/pear/lib\n"); exp_continue; },
'-re', "^Documentation dir", sub { $spawn->send("$prefix/share/doc/pear\n"); exp_continue; },
'-re', "^Data dir", sub { $spawn->send("$varwww/pear/data\n"); exp_continue; },
'-re', "^User-modifiable config", sub { $spawn->send("$varwww/pear/cfg\n"); exp_continue; },
'-re', "^Public Web Files dir", sub { $spawn->send("$varwww/pear/htdocs\n"); exp_continue; },
'-re', "^System manual pages", sub { $spawn->send("$prefix/man\n"); exp_continue; },
'-re', "^Tests dir", sub { $spawn->send("$varwww/pear/tests\n"); exp_continue; },
'-re', "^Name of config", sub { $spawn->send(cwd."/tmp.pearrc\n"); exp_continue; },
'-re', "^1-12, 'all' or Enter", sub { $spawn->send("\n"); exp_continue; },
'-re', "^Would you like to alter php.ini", sub { $spawn->send("n\n"); exp_continue; },
'-re', "^Press Enter to continue:", sub { $spawn->send("\n"); }
);
print "\n...done...\n";
exit;