Subject: [PATCH] testing/hdf4: new aport

From: Edd Salkield <[email-masked]>
Date: Thu, 25 Nov 2021 18:56:54 +0000

https://www.hdfgroup.org/solutions/hdf4/
HDF4 is a data model, library, and file format for storing and managing data
---
This is my first package for Alpine - I hope this work will be useful for
others processing NASA data files too.

Like community/hdf5, I've had to add some additional flags to get this to
build, because the default autoconf setup is fairly broken.

Unfortunately the test suite also appears pretty broken, with it segfaulting
a fair amount.  I'm not sure I have the time to fully diagnose this issue
at the moment, thoughts on how to proceed appreciated.

This package comes with a patch that removes some type definitions where
the author was assuming glibc.  I would appreciate comments on whether
and how to patch this upstream in a way that doesn't break glibc builds.

Also, the source archive comes containing autogenerated autoconf files.
I've used these in the build, but would the package ideally invoke autoconf
to generate ./configure before running it?

Finally, I've only been able to test this on x86-64.  What's the procedure
for making sure this builds on other architectures as well?

Thanks!

 testing/hdf4/10-musl.patch | 14 +++++++++++++
 testing/hdf4/APKBUILD      | 41 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 55 insertions(+)
 create mode 100644 testing/hdf4/10-musl.patch
 create mode 100644 testing/hdf4/APKBUILD

diff --git a/testing/hdf4/10-musl.patch b/testing/hdf4/10-musl.patch
new file mode 100644
index 0000000000..5e7979e358
--- /dev/null
+++ b/testing/hdf4/10-musl.patch
@@ -0,0 +1,14 @@
++++ hdf-4.2.15/mfhdf/xdr/types.h
+@@ -55,12 +55,6 @@
+ #ifndef u_long
+ typedef unsigned long u_long;
+ #endif
+-#ifndef u_quad_t
+-typedef uint64_t      u_quad_t;
+-#endif
+-#ifndef quad_t
+-typedef int64_t       quad_t;
+-#endif
+ #ifndef caddr_t
+ typedef char *        caddr_t;
+ #endif
diff --git a/testing/hdf4/APKBUILD b/testing/hdf4/APKBUILD
new file mode 100644
index 0000000000..73bb822b7a
--- /dev/null
+++ b/testing/hdf4/APKBUILD
@@ -0,0 +1,41 @@
+# Contributor: Edd Salkield <[email-masked]>
+# Maintainer: Edd Salkield <[email-masked]>
+pkgname=hdf4
+pkgver=4.2.15
+pkgrel=0
+pkgdesc="HDF4 is a data model, library, and file format for storing and managing data"
+url="https://www.hdfgroup.org/solutions/hdf4/"
+arch="all"
+license="custom"
+options="!check" # Upstream tests appear broken
+depends_dev="zlib-dev jpeg-dev portablexdr-dev" # Since it's linked to portablexdr-dev, is this required here?
+makedepends="$depends_dev gfortran bison flex"
+checkdepends="diffutils" # Flags not supported by busybox diff are used
+subpackages="$pkgname-dev $pkgname-doc"
+source="https://support.hdfgroup.org/ftp/HDF/releases/HDF"$pkgver"/src/hdf-"$pkgver".tar.bz2 10-musl.patch"
+builddir="$srcdir"/"hdf-$pkgver"
+
+build() {
+	# This flag required to treat Fortran argument mismatch as a warning,
+	# not an error.
+	# This got fixed in master https://github.com/HDFGroup/hdf4/issues/1
+	# but isn't fixed yet in the latest release.
+	export FFLAGS="$FFLAGS -fallow-argument-mismatch"
+	export LIBS="$LIBS -lportablexdr"
+	./configure --prefix=/usr
+	make
+}
+
+check() {
+	make check
+}
+
+package() {
+	make DESTDIR="$pkgdir" install-recursive
+	install -Dm644 COPYING "$pkgdir"/usr/share/licenses/"$pkgname"/COPYING
+}
+
+sha512sums="
+7d4037800ef8950ed74f225355ef5458444bed26fc189fbbd2ce7d36009998013ac1f6ba5d4e60834acf8f6f73550357238745acc35e162679919400a48191e9  hdf-4.2.15.tar.bz2
+c373d5130ce1d01145735b6a9e3bfe242d2f26d7cddf2324152c92347e95d359ca54048760126a48bcc8b207391a323734a7407dfa5d0db96eb619766db35588  10-musl.patch
+"
-- 
2.34.1