#!/usr/bin/perl
BEGIN {
or
die
'CPANPLUS::Dist::Arch must be installed for this script to work.'
}
my
$force
;
GetOptions(
force
=> \
$force
);
my
$modname
=
shift
@ARGV
or pod2usage;
die
<<
'END_ERROR'
if
( -f
'PKGBUILD'
&& !
$force
);
PKGBUILD already
exists
in current directory. Use -f to force overwrite.
END_ERROR
my
$cb
= CPANPLUS::Backend->new;
my
$modobj
=
$cb
->module_tree(
$modname
)
or
die
qq{module '$modname' not found in CPANPLUS}
;
$cb
->configure_object->set_conf(
'prereqs'
, 0 );
$ENV
{PERL_AUTOINSTALL} =
'--skipdeps'
;
$modobj
->fetch (
verbose
=> 0 );
$modobj
->extract(
verbose
=> 0 );
my
$distobj
=
$modobj
->dist(
target
=>
'prepare'
,
format
=>
'CPANPLUS::Dist::Arch'
)
or
die
q{failed to prepare distribution object}
;
my
$pkgbuild_txt
=
$distobj
->get_pkgbuild()
or
die
q{ERROR get_pkgbuild() returned an empty string}
;
open
my
$pkgbuild_file
,
'>'
,
'PKGBUILD'
or
die
qq{ERROR creating PKGBUILD: $OS_ERROR}
;
print
$pkgbuild_file
$pkgbuild_txt
;
close
$pkgbuild_file
or
die
qq{ERROR closing new PKGBUILD: $OS_ERROR}
;
print
"Created PKGBUILD.\n"
;
exit
0;