apkbuild-cpan.in: keep provides and replaces on recreate and deal with pkgrel
This commit is contained in:
parent
b9f6741f11
commit
b60dd09b3b
|
@ -32,10 +32,13 @@ my $template = <<'EOF';
|
|||
# Automatically generated by apkbuild-cpan, template 3
|
||||
[% authors %]
|
||||
pkgname=[% pkgname %]
|
||||
#_pkgreal is used by apkbuild-cpan to find modules at MetaCpan
|
||||
_pkgreal=[% pkgreal %]
|
||||
pkgver=[% pkgver %]
|
||||
pkgrel=0
|
||||
pkgrel=[% pkgrel %]
|
||||
pkgdesc="Perl module for [% pkgreal %]"
|
||||
provides="[% provides %]"
|
||||
replaces="[% replaces %]"
|
||||
url="https://metacpan.org/release/[% pkgreal %]/"
|
||||
arch="noarch"
|
||||
license="GPL-1.0-or-later OR Artistic-1.0-Perl"
|
||||
|
@ -83,8 +86,12 @@ sub read_assignments_from_file {
|
|||
my $authors = join("\n", $text =~ /^# Contributor: .*$/mg, $text =~ /^# Maintainer: .*$/mg);
|
||||
$hash{'authors'} = $authors if length($authors) > 1;
|
||||
|
||||
my $tmplver = $text =~ m/^# Automatically generated by apkbuild-cpan, template (.*)/;
|
||||
$hash{'tmplver'} = $1 if length($tmplver) >= 1;
|
||||
my $provides = $text =~ m/^provides=\"(.*)\"".*$/mg;
|
||||
$hash{'provides'} = $1 if length($provides) >= 1;
|
||||
|
||||
my $requires = $text =~ m/^requires=\"(.*)\"".*$/mg;
|
||||
$hash{'requires'} = $1 if length($requires) >= 1;
|
||||
|
||||
return \%hash;
|
||||
}
|
||||
|
||||
|
@ -101,18 +108,34 @@ sub read_apkbuild {
|
|||
}
|
||||
|
||||
sub write_apkbuild {
|
||||
my ($distdata, $authors, $moddata) = @_;
|
||||
my ($distdata, $apkbuild, $moddata) = @_;
|
||||
|
||||
my $cpanid = $distdata->{id};
|
||||
$cpanid = substr($cpanid, 0, 1) . "/" . substr($cpanid, 0, 2) . "/$cpanid";
|
||||
|
||||
my $authors = undef;
|
||||
my $replaces = undef;
|
||||
my $provides = undef;
|
||||
my $pkgrel = 0;
|
||||
if (defined $apkbuild) {
|
||||
$authors = $apkbuild->{authors};
|
||||
$provides = $apkbuild->{provides};
|
||||
$replaces = $apkbuild->{replaces};
|
||||
$pkgrel = $apkbuild->{pkgrel};
|
||||
if ($apkbuild->{pkgver} eq $moddata->{version}) {
|
||||
$pkgrel++;
|
||||
}
|
||||
}
|
||||
my %repl = (
|
||||
authors => ($authors or "# Contributor: $packager\n# Maintainer: $packager"),
|
||||
pkgname => map_cpan_to_apk($moddata->{distribution}),
|
||||
pkgreal => $moddata->{distribution},
|
||||
pkgver => $moddata->{version} =~ s/^[^0-9]+//r,
|
||||
pkgrel => $pkgrel,
|
||||
source => $moddata->{download_url},
|
||||
pkgdesc => $distdata->{abstract},
|
||||
provides => ($provides or ''),
|
||||
replaces => ($replaces or ''),
|
||||
);
|
||||
$repl{source} =~ s/$repl{pkgver}/\$pkgver/g;
|
||||
$template =~ s/\[% (.*?) %\]/$repl{$1}/g;
|
||||
|
@ -282,6 +305,7 @@ sub do_depends {
|
|||
say "License: $license";
|
||||
|
||||
my $deps = parse_deps $meta->effective_prereqs->requirements_for('runtime', 'requires');
|
||||
|
||||
if ($deps eq '') {
|
||||
$deps = "perl";
|
||||
} else {
|
||||
|
@ -460,7 +484,7 @@ given ( $ARGV[0] ) {
|
|||
say "Upgrading CPAN module from $apkbuild->{pkgver} to $pkgver";
|
||||
$apkbuild->{pkgrel}=0;
|
||||
}
|
||||
write_apkbuild($distdata, $apkbuild->{authors}, $moddata);
|
||||
write_apkbuild($distdata, $apkbuild, $moddata);
|
||||
prepare_tree;
|
||||
update_functions;
|
||||
do_depends;
|
||||
|
|
Loading…
Reference in New Issue