From e002829cfd0851bd62b7a9fdef99b0de2d83f5a3 Mon Sep 17 00:00:00 2001 From: Lorenzo Beretta Date: Wed, 28 Apr 2021 14:20:53 +0200 Subject: [PATCH] recutils: patch to fix recins not working outside of $TMPDIR Details at https://git.savannah.gnu.org/cgit/recutils.git/commit/utils/recutl.c?id=86f662a8202408134a235572ec60141d3082f975 Will no longer be necessary once 1.9 is released; fixes bug #30546 Thanks to ericonr for all the assistance. note to self: bootstrap.conf is not shipped add *temporary* dependency on automake adding gnulib pieces is a real chore... And then the GNU tools (rightfully) decided that the manpages were out of date, because a file has been modified, and insisted on running help2man - I simply told pre_configure to update the timestamps of the manpages. --- Importing qcopy_file_preserving as described above results in a 2kloc path, so just invoke cp(1) until 1.9 is released --- srcpkgs/recutils/patches/copyfile.patch | 37 +++++++++++++++++ srcpkgs/recutils/patches/exdev.patch | 54 +++++++++++++++++++++++++ srcpkgs/recutils/template | 12 +++++- 3 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 srcpkgs/recutils/patches/copyfile.patch create mode 100644 srcpkgs/recutils/patches/exdev.patch diff --git a/srcpkgs/recutils/patches/copyfile.patch b/srcpkgs/recutils/patches/copyfile.patch new file mode 100644 index 000000000000..c00805af2c6e --- /dev/null +++ b/srcpkgs/recutils/patches/copyfile.patch @@ -0,0 +1,37 @@ +--- a/utils/recutl.c ++++ b/utils/recutl.c +@@ -58,6 +58,33 @@ + #include + #include "read-file.h" + ++#include ++#include ++#include ++#include ++ ++static int qcopy_file_preserving(const char *src, const char *dst) ++{ ++ int stat_loc; ++ pid_t pid = fork(); ++ if (pid < 0) { ++ perror("fork"); ++ return -1; ++ } ++ if (pid == 0) { ++ execl("/bin/cp", "--", src, dst, (void *)0); ++ exit(1); ++ } ++ if (pid != waitpid(pid, &stat_loc, 0)) { ++ perror("waitpid"); ++ return -1; ++ } ++ if (!(WIFEXITED(stat_loc) && WEXITSTATUS(stat_loc) == 0)) { ++ return -1; ++ } ++ return 0; ++} ++ + /* + * Global variables. + */ + diff --git a/srcpkgs/recutils/patches/exdev.patch b/srcpkgs/recutils/patches/exdev.patch new file mode 100644 index 000000000000..38fb43498ad0 --- /dev/null +++ b/srcpkgs/recutils/patches/exdev.patch @@ -0,0 +1,54 @@ +From 86f662a8202408134a235572ec60141d3082f975 Mon Sep 17 00:00:00 2001 +From: "Jose E. Marchesi" +Date: Tue, 28 Jan 2020 12:13:42 +0100 +Subject: utils: make utilitis to work with temporary files in a different + filesystem + +2020-01-28 Jose E. Marchesi + + * bootstrap.conf (gnulib_modules): Import the modules copy-file + and remove. + * utils/recutl.c (recutl_write_db_to_file): Copy and remove + instead of rename temporary files. +--- + utils/recutl.c | 14 ++++++++------ + 1 file changed, 8 insertions(+), 6 deletions(-) + +(limited to 'utils/recutl.c') +(copy-file.h commented out to use /bin/cp) + +diff --git a/utils/recutl.c b/utils/recutl.c +index 9cf823d..a814fd8 100644 +--- a/utils/recutl.c ++++ b/utils/recutl.c +@@ -58,6 +58,7 @@ + #include + #include + #include "read-file.h" ++/*#include "copy-file.h"*/ + + /* + * Global variables. +@@ -432,12 +433,13 @@ recutl_write_db_to_file (rec_db_t db, + + if (file_name) + { +- /* Rename the temporary file to file_name. */ +- if (rename (tmp_file_name, file_name) == -1) +- { +- remove (tmp_file_name); +- recutl_fatal (_("renaming file %s to %s\n"), tmp_file_name, file_name); +- } ++ /* Rename the temporary file to file_name. We copy and remove ++ instead of renaming because the later doesn't work across ++ different mount points, and it is getting common for /tmp to ++ be mounted in its own filesystem. */ ++ if (qcopy_file_preserving (tmp_file_name, file_name) != 0) ++ recutl_fatal (_("renaming file %s to %s\n"), tmp_file_name, file_name); ++ remove (tmp_file_name); + + /* Restore the attributes of the original file. */ + if (stat_result != -1) +-- +cgit v1.2.1 + diff --git a/srcpkgs/recutils/template b/srcpkgs/recutils/template index 3e71312c4e25..c8b48e356837 100644 --- a/srcpkgs/recutils/template +++ b/srcpkgs/recutils/template @@ -1,10 +1,11 @@ # Template file for 'recutils' pkgname=recutils version=1.8 -revision=1 +revision=2 build_style=gnu-configure configure_args="--with-bash-headers --disable-rpath" -hostmakedepends="pkg-config" +# TODO remove automake in 1.9; only needed for copy-file +hostmakedepends="automake pkg-config" makedepends="acl-devel libgcrypt-devel libuuid-devel libcurl-devel" short_desc="Utilities to deal with recfiles" maintainer="Orphaned " @@ -12,7 +13,14 @@ license="GPL-3.0-or-later" homepage="https://www.gnu.org/software/recutils/" distfiles="${GNU_SITE}/recutils/recutils-${version}.tar.gz" checksum=df8eae69593fdba53e264cbf4b2307dfb82120c09b6fab23e2dad51a89a5b193 +patch_args=-Np1 +pre_configure() { + # XXX horrible kludge to avoid help2man - remove in 1.9 + touch man/*.1 + # XXX ONLY needed for copy-file - remove in 1.9 + aclocal && automake +} librec1_package() { short_desc+=" - rec1 library" pkg_install() {