summaryrefslogtreecommitdiffstats
path: root/apkbuild-cpan.in
diff options
context:
space:
mode:
authorTimothy Legge <timlegge@gmail.com>2020-03-25 00:33:43 +0000
committerTimothy Legge <timlegge@gmail.com>2020-03-27 02:02:24 +0000
commitb60dd09b3b1d80529249a28f419644f1f66bc0e0 (patch)
treeade50105a237fd5cd832706c1c13e9ca9ae54aaf /apkbuild-cpan.in
parentb9f6741f11095ae01848120bc0056a44fcd94273 (diff)
downloadabuild-b60dd09b3b1d80529249a28f419644f1f66bc0e0.tar.bz2
abuild-b60dd09b3b1d80529249a28f419644f1f66bc0e0.tar.xz
apkbuild-cpan.in: keep provides and replaces on recreate and deal with pkgrel
Diffstat (limited to 'apkbuild-cpan.in')
-rwxr-xr-xapkbuild-cpan.in34
1 files changed, 29 insertions, 5 deletions
diff --git a/apkbuild-cpan.in b/apkbuild-cpan.in
index 1fd76aa..0a7a8fc 100755
--- a/apkbuild-cpan.in
+++ b/apkbuild-cpan.in
@@ -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;