aboutsummaryrefslogtreecommitdiffstats
path: root/main/abuild
diff options
context:
space:
mode:
authorWilliam Pitcock <nenolod@dereferenced.org>2017-02-25 19:26:44 +0000
committerWilliam Pitcock <nenolod@dereferenced.org>2017-02-25 19:26:44 +0000
commit9f897e6ac76f2b78e4e966a6b23a2769b27e34ba (patch)
treec2b407e39ab025eaf2f1aa48653fba0a69e6ff8d /main/abuild
parentb2644dd18cf12090ce8b06676b2e9cd3e7c12aea (diff)
downloadaports-9f897e6ac76f2b78e4e966a6b23a2769b27e34ba.tar.bz2
aports-9f897e6ac76f2b78e4e966a6b23a2769b27e34ba.tar.xz
main/abuild: backport check() support
Diffstat (limited to 'main/abuild')
-rw-r--r--main/abuild/APKBUILD6
-rw-r--r--main/abuild/abuild-check.patch349
2 files changed, 353 insertions, 2 deletions
diff --git a/main/abuild/APKBUILD b/main/abuild/APKBUILD
index f4684ee878..be53402cbb 100644
--- a/main/abuild/APKBUILD
+++ b/main/abuild/APKBUILD
@@ -2,7 +2,7 @@
pkgname=abuild
pkgver=2.29.0
_ver=${pkgver%_git*}
-pkgrel=8
+pkgrel=9
pkgdesc="Script to build Alpine Packages"
url="http://git.alpinelinux.org/cgit/abuild/"
arch="all"
@@ -28,6 +28,7 @@ source="http://dev.alpinelinux.org/archive/abuild/abuild-$_ver.tar.xz
0001-abuild-preserve-xattrs-when-creating-dbg.patch
0001-functions-fix-cross-compile-triplet-for-armhf-archit.patch
0001-abuild-unset-md5-and-sha256-sums-when-updating-check.patch
+ abuild-check.patch
"
_builddir="$srcdir/$pkgname-$_ver"
@@ -78,4 +79,5 @@ fb7d65b1c65368dfddf7e3b55774a699169eb1de63e1aa619d5a210773e912e66c6a573d7fb98d57
99a260d2c1ebc625fece8fc0a6d31357c1695825da6357b67c138cf2d738507640a3b1873cf3a4ba1ed502a7d6f29fe7a9898ebc3005faf27353c989b3c340c1 0001-abuild-use-only-sha512sum.patch
37f9de0e6f160f3ccbee56a973e08fcf9b4c27318023eacb47bf5ff1ee0d7f3710bef368d998a65bff0420fb73e6e05963b05af95e4beacf6a39cfe1bee95ec1 0001-abuild-preserve-xattrs-when-creating-dbg.patch
4a626c1213fa09a8000200c093b6209a57eb31be90c5cc7b4cb18eeb27c9e65fa60a92969f05dd80aa99cd91cab7c7ac16760b9aae72c5aa20883375c5c726df 0001-functions-fix-cross-compile-triplet-for-armhf-archit.patch
-8390c080d6e4f90ca7d3aeb5244cc920d277f52bca9db2a42b3758a147baf045b1a95314955ba11182d635a7d90de01d5bc96f42e318ed32d6b5315b691a6ad5 0001-abuild-unset-md5-and-sha256-sums-when-updating-check.patch"
+8390c080d6e4f90ca7d3aeb5244cc920d277f52bca9db2a42b3758a147baf045b1a95314955ba11182d635a7d90de01d5bc96f42e318ed32d6b5315b691a6ad5 0001-abuild-unset-md5-and-sha256-sums-when-updating-check.patch
+d69d19b7788daba045d32ef8720c1ad64d68561e49792628ea621bd7ac81bc10280eea059c56f0e01efa0590b6f5186b0dba0240df80ea803a01e52c293ac305 abuild-check.patch"
diff --git a/main/abuild/abuild-check.patch b/main/abuild/abuild-check.patch
new file mode 100644
index 0000000000..f65d437909
--- /dev/null
+++ b/main/abuild/abuild-check.patch
@@ -0,0 +1,349 @@
+From ea1db36f1f62889ddcf4dbf8ca85409619d4424c Mon Sep 17 00:00:00 2001
+From: William Pitcock <nenolod@dereferenced.org>
+Date: Sun, 29 Jan 2017 09:47:25 +0000
+Subject: [PATCH 1/3] abuild: implement check and $checkdepends support.
+
+The check() function is an APKBUILD overridable function which runs a testsuite. The packages listed in
+$checkdepends are packages which will be installed at build time only if check() will be run.
+---
+ abuild.in | 32 ++++++++++++++++++++++++++++----
+ 1 file changed, 28 insertions(+), 4 deletions(-)
+
+diff --git a/abuild.in b/abuild.in
+index 2b2d23b..aa1fe09 100644
+--- a/abuild.in
++++ b/abuild.in
+@@ -66,6 +66,12 @@ cross_compiling() {
+ test "$CBUILD" != "$CHOST" -a -n "$CBUILDROOT"
+ }
+
++want_check() {
++ cross_compiling && return 1
++ options_has "!check" && return 1
++ return 0
++}
++
+ cleanup() {
+ local i=
+ [ -z "$subpkgdir" ] && set_xterm_title ""
+@@ -199,6 +205,7 @@ default_sanitycheck() {
+ [ -n "$pkguser" ] && spell_error pkguser pkgusers
+ [ -n "$pkggroup" ] && spell_error pkggroup pkggroups
+ [ -n "$subpackage" ] && spell_error subpackage subpackages
++ [ -n "$checkdepend" ] && spell_error checkdepend checkdepends
+
+ check_maintainer || die "Provide a valid RFC822 maintainer address"
+
+@@ -1365,18 +1372,21 @@ create_apks() {
+ }
+
+ build_abuildrepo() {
+- local d apk _build=build
++ local d apk _build=build _check=check
+ if ! is_function package; then
+ # if package() is missing then build is called from rootpkg
+ _build=true
+ fi
++ if ! want_check; then
++ _check=true
++ fi
+ if ! apk_up2date || [ -n "$force" ]; then
+ # check early if we have abuild key
+ abuild-sign --installed || return 1
+ logcmd "building $repo/$pkgname-$pkgver-r$pkgrel"
+ sanitycheck && builddeps && clean && fetch && unpack \
+- && prepare && mkusers && $_build && rootpkg \
+- && cleanup $CLEANUP \
++ && prepare && mkusers && $_build && $_check \
++ && rootpkg && cleanup $CLEANUP \
+ || return 1
+ fi
+ update_abuildrepo_index
+@@ -1417,6 +1427,15 @@ update_abuildrepo_index() {
+ done
+ }
+
++# predefined function check
++default_check() {
++ warning "APKBUILD does not run any tests - define a check() function!"
++}
++
++check() {
++ default_check
++}
++
+ # predefined splitfunc doc
+ default_doc() {
+ depends="$depends_doc"
+@@ -1715,11 +1734,14 @@ parse_aports_makedepends() {
+ subpackages=
+ depends=
+ makedepends=
++ checkdepends=
+ . $i
+ dir=${i%/APKBUILD}
+ deps=
+ # filter out conflicts from deps and version info
+- for j in $depends $makedepends; do
++ wantdepends="$depends $makedepends"
++ want_check && wantdepends="$wantdepends $checkdepends"
++ for j in $wantdepends; do
+ case "$j" in
+ !*) continue;;
+ esac
+@@ -1792,6 +1814,7 @@ calcdeps() {
+ done
+ else
+ [ -z "$makedepends" ] && makedepends="$makedepends_build $makedepends_host"
++ want_check && makedepends="$makedepends $checkdepends"
+ for i in $1 $depends $makedepends; do
+ [ "$pkgname" = "${i%%[<>=]*}" ] && continue
+ list_has $i $builddeps && continue
+@@ -2147,6 +2170,7 @@ usage() {
+
+ Commands:
+ build Compile and install package into \$pkgdir
++ check Run any defined tests concerning the package
+ checksum Generate checksum to be included in APKBUILD
+ clean Remove temp build and install dirs
+ cleancache Remove downloaded files from \$SRCDEST
+--
+2.11.1
+
+From 7c1609b1bb4b6b7219b21b0d2750fcfaf02d63bc Mon Sep 17 00:00:00 2001
+From: William Pitcock <nenolod@dereferenced.org>
+Date: Sun, 29 Jan 2017 09:50:29 +0000
+Subject: [PATCH 2/3] sample apkbuild: document check() function usage
+
+---
+ sample.APKBUILD | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/sample.APKBUILD b/sample.APKBUILD
+index a95fec2..30184c5 100644
+--- a/sample.APKBUILD
++++ b/sample.APKBUILD
+@@ -43,4 +43,11 @@ package() {
+ # install -m644 -D "$srcdir"/$pkgname.confd "$pkgdir"/etc/conf.d/$pkgname
+ }
+
++check() {
++ # uncomment the 2 lines below if there is a testsuite. we assume the testsuite
++ # is run using "make check", which is the default for autotools-based build systems.
++ # cd "$builddir"
++ # make check || return 1
++}
++
+ md5sums="" #generate with 'abuild checksum'
+--
+2.11.1
+
+From 14f8fcfb372f9f9ab877c33f309431aa2043c097 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Timo=20Ter=C3=A4s?= <timo.teras@iki.fi>
+Date: Tue, 31 Jan 2017 10:20:14 +0200
+Subject: [PATCH 3/3] apkbuild-cpan: fix warnings, improve recreate, add check
+ support
+
+---
+ apkbuild-cpan.in | 62 ++++++++++++++++++++++++++++++++++++++++++--------------
+ 1 file changed, 47 insertions(+), 15 deletions(-)
+
+diff --git a/apkbuild-cpan.in b/apkbuild-cpan.in
+index 5566f8e..688df6e 100644
+--- a/apkbuild-cpan.in
++++ b/apkbuild-cpan.in
+@@ -3,7 +3,10 @@
+
+ use strict;
+ use warnings;
+-use feature qw(:5.10);
++use 5.016;
++use feature "switch";
++no if $] >= 5.018, warnings => "experimental::smartmatch";
++
+ use LWP::UserAgent;
+ use LWP::ConnCache;
+ use CPAN::Meta;
+@@ -21,9 +24,8 @@ my $package_mappings = {
+ };
+ our $packager = "";
+ my $template = <<'EOF';
+-# Automatically generated by apkbuild-cpan, template 1
+-# Contributor: [% packager %]
+-# Maintainer: [% packager %]
++# Automatically generated by apkbuild-cpan, template 2
++[% authors %]
+ pkgname=[% pkgname %]
+ _pkgreal=[% pkgreal %]
+ pkgver=[% pkgver %]
+@@ -34,8 +36,10 @@ arch="noarch"
+ license="GPL PerlArtistic"
+ cpandepends=""
+ cpanmakedepends=""
++cpancheckdepends=""
+ depends="$cpandepends"
+ makedepends="perl-dev $cpanmakedepends"
++checkdepends="$cpancheckdepends"
+ subpackages="$pkgname-doc"
+ source="[% source %]"
+ builddir="$srcdir/$_pkgreal-$pkgver"
+@@ -59,6 +63,10 @@ package() {
+ :
+ }
+
++check() {
++ :
++}
++
+ EOF
+
+ our $ua = LWP::UserAgent->new();
+@@ -66,8 +74,7 @@ our $json = JSON->new;
+ $ua->env_proxy;
+ $ua->conn_cache(LWP::ConnCache->new());
+
+-sub read_file
+-{
++sub read_file {
+ my ($filename) = @_;
+ local $/;
+ open my $fh, "<", $filename or die "could not open $filename: $!";
+@@ -76,10 +83,15 @@ sub read_file
+
+ sub read_assignments_from_file {
+ my ($filename) = @_;
++ return () if ( ! -e $filename );
+ my $text = read_file($filename);
+ my %sline = $text =~ /^(\w+)\s*=\s*([^\"\n]*)$/mg;
+ my %mline = $text =~ /^(\w+)\s*=\s*\"([^\"]*)\"$/mg;
+ my %hash = ( %sline, %mline );
++
++ my $authors = join("\n", $text =~ /^# Contributor: .*$/mg, $text =~ /^# Maintainer: .*$/mg);
++ $hash{'authors'} = $authors if length($authors) > 1;
++
+ return \%hash;
+ }
+
+@@ -96,12 +108,13 @@ sub read_apkbuild {
+ }
+
+ sub write_apkbuild {
+- my ($distdata) = @_;
++ my ($distdata, $authors) = @_;
+
+ my $cpanid = $distdata->{releases}[0]->{cpanid};
+ $cpanid = substr($cpanid, 0, 1) . "/" . substr($cpanid, 0, 2) . "/$cpanid";
++
+ my %repl = (
+- packager => $packager,
++ authors => ($authors or "# Contributor: $packager\n# Maintainer: $packager"),
+ pkgname => map_cpan_to_apk($distdata->{name}),
+ pkgreal => $distdata->{name},
+ pkgver => $distdata->{releases}[0]->{version},
+@@ -147,7 +160,8 @@ sub parse_deps {
+ my $pkgname = map_cpan_to_apk($distdata->{name});
+ $deps .= "$pkgname ";
+ }
+- $deps =~ s/\s+$//;
++ $deps =~ s/\h+/ /g;
++ $deps =~ s/ $//;
+ return $deps;
+
+ }
+@@ -162,6 +176,7 @@ sub update_functions {
+ my $metaprefix = "src/" . $apkbuild->{'_pkgreal'} . "-" . $apkbuild->{'pkgver'} . "/";
+ my $prepare_func;
+ my $build_func;
++ my $check_func;
+ my $package_func;
+
+ my $text = read_file "APKBUILD";
+@@ -203,7 +218,7 @@ EOF
+ build() {
+ cd "$builddir"
+ export CFLAGS=$(perl -MConfig -E 'say $Config{ccflags}')
+- make && make test
++ make
+ }
+ EOF
+ $package_func = <<'EOF';
+@@ -213,6 +228,13 @@ package() {
+ find "$pkgdir" \( -name perllocal.pod -o -name .packlist \) -delete
+ }
+ EOF
++ $check_func = <<'EOF';
++check() {
++ cd "$builddir"
++ export CFLAGS=$(perl -MConfig -E 'say $Config{ccflags}')
++ make test
++}
++EOF
+ }
+
+ $text =~ s/^prepare\(\) \{.*?^\}\n/$prepare_func/smg or
+@@ -221,6 +243,8 @@ EOF
+ die "Can't replace build function APKBUILD";
+ $text =~ s/^package\(\) \{.*?^\}\n/$package_func/smg or
+ die "Can't replace package function APKBUILD";
++ $text =~ s/^check\(\) \{.*?^\}\n/$check_func/smg or
++ die "Can't replace check function APKBUILD";
+
+ open my $fh, '>', "APKBUILD" or die;
+ print $fh $text;
+@@ -251,11 +275,13 @@ sub do_depends {
+ say "CPAN deps: $deps";
+ say "Recommend: " . parse_deps $meta->effective_prereqs->requirements_for('runtime', 'recommends');
+
+- my $makedeps = parse_deps $meta->effective_prereqs->requirements_for('build', 'requires');
+- $makedeps .= ' ' . parse_deps $meta->effective_prereqs->requirements_for('build', 'recommends');
+- $makedeps .= ' ' . parse_deps $meta->effective_prereqs->requirements_for('test', 'requires');
+- $makedeps .= ' ' . parse_deps $meta->effective_prereqs->requirements_for('test', 'recommends');
++ my $makedeps = parse_deps($meta->effective_prereqs->requirements_for('build', 'requires'), $meta->effective_prereqs->requirements_for('build', 'recommends'));
+ say "CPAN build deps: $makedeps";
++ say "CPAN requires: " . parse_deps($meta->effective_prereqs->requirements_for('build', 'requires'));
++ say "CPAN recommds: " . parse_deps($meta->effective_prereqs->requirements_for('build', 'recommends'));
++
++ my $checkdeps = parse_deps($meta->effective_prereqs->requirements_for('test', 'requires'), $meta->effective_prereqs->requirements_for('test', 'recommends'));
++ say "CPAN check deps: $makedeps";
+
+ my $text = read_file "APKBUILD";
+ if ($abstract) {
+@@ -274,6 +300,8 @@ sub do_depends {
+ die "Can't find cpandepends line in APKBUILD";
+ $text =~ s/^cpanmakedepends=\"([^\"]*)\"$/cpanmakedepends=\"$makedeps\"/mg or
+ die "Can't find cpanmakedepends line in APKBUILD";
++ $text =~ s/^cpancheckdepends=\"([^\"]*)\"$/cpancheckdepends=\"$checkdeps\"/mg or
++ die "Can't find cpancheckdepends line in APKBUILD";
+
+ open my $fh, '>', "APKBUILD" or die;
+ print $fh $text;
+@@ -282,6 +310,7 @@ sub do_depends {
+
+ sub get_data {
+ my $apkbuild = read_apkbuild;
++ $apkbuild->{_pkgreal} or die "Not apkbuild-cpan generated APKBUILD";
+ my $response = $ua->get("http://search.cpan.org/api/dist/$apkbuild->{_pkgreal}");
+ $response->is_success or die $response->status_line;
+ my $distdata = $json->decode($response->decoded_content);
+@@ -293,6 +322,9 @@ sub get_data {
+ my $abuild_conf = read_assignments_from_file("/etc/abuild.conf");
+ $packager = $abuild_conf->{PACKAGER} if $abuild_conf->{PACKAGER};
+
++my $user_abuild_conf = read_assignments_from_file($ENV{"HOME"} . "/.abuild/abuild.conf");
++$packager = $user_abuild_conf->{PACKAGER} if $user_abuild_conf->{PACKAGER};
++
+ given ( $ARGV[0] ) {
+ when ("create") {
+ my $module = $ARGV[1];
+@@ -319,7 +351,7 @@ given ( $ARGV[0] ) {
+ }
+ when ("recreate") {
+ my ($apkbuild, $distdata) = get_data;
+- write_apkbuild($distdata);
++ write_apkbuild($distdata, $apkbuild->{authors});
+ prepare_tree;
+ update_functions;
+ do_depends;
+--
+2.11.1
+