From 68054a2c8e009b6914f28d8fb51ea57853f383d8 Mon Sep 17 00:00:00 2001 From: Joshua Root Date: Mon, 7 Oct 2024 17:53:50 +1100 Subject: [PATCH] sparse file detection test --- math/pari/Portfile | 21 +++++++++++++++++---- math/pari/files/findholes.c | 28 ++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 math/pari/files/findholes.c diff --git a/math/pari/Portfile b/math/pari/Portfile index ee83598f156ee..5c0b16e068c85 100644 --- a/math/pari/Portfile +++ b/math/pari/Portfile @@ -26,10 +26,23 @@ checksums rmd160 3381ba95fdc5b807b82516253dca029a4cf9c45f \ # System's tar on at least macOS Ventura is broken # See: https://trac.macports.org/ticket/67336 -pre-install { - if {[getuid] == 0 && [file exists /usr/sbin/purge]} { - system "/usr/sbin/purge" - } +#pre-install { +# if {[getuid] == 0 && [file exists /usr/sbin/purge]} { +# system "/usr/sbin/purge" +# } +#} + +pre-build { + system -W $workpath "${configure.cc} ${configure.optflags} -o findholes ${filespath}/findholes.c" +} + +post-destroot { + system -W $workpath "./findholes ${destroot}${prefix}/lib/libpari-gmp.dylib" + ui_msg "destroot libpari-gmp.dylib is binary? [fileIsBinary ${destroot}${prefix}/lib/libpari-gmp.dylib]" +} + +post-activate { + ui_msg "activated libpari-gmp.dylib is binary? [fileIsBinary ${prefix}/lib/libpari-gmp.dylib]" } depends_lib port:gmp \ diff --git a/math/pari/files/findholes.c b/math/pari/files/findholes.c new file mode 100644 index 0000000000000..db680afd3896f --- /dev/null +++ b/math/pari/files/findholes.c @@ -0,0 +1,28 @@ +#include +#include +#include + +int main(int argc, char *argv[]) +{ + off_t seekpos = 0; + + if (argc < 2) { + printf("usage: %s file\n", argv[0]); + return 1; + } + + int fd = open(argv[1], O_RDONLY); + if (fd < 0) { + perror("open"); + return 1; + } + + seekpos = lseek(fd, 0, SEEK_SET); + seekpos = lseek(fd, 0, SEEK_HOLE); + printf("SEEK_HOLE: seekpos = %lld\n", seekpos); + seekpos = lseek(fd, 0, SEEK_DATA); + printf("SEEK_DATA: seekpos = %lld\n", seekpos); + + close(fd); + return 0; +}