Check if tar -k errors on existing files

Closes: https://trac.macports.org/ticket/73467
(cherry picked from commit cf8e6d5526)
This commit is contained in:
Joshua Root
2026-02-05 16:21:03 +11:00
parent 511b8d91a1
commit ca27e67a9f
5 changed files with 44 additions and 2 deletions
Vendored
+17
View File
@@ -1043,6 +1043,23 @@ AC_DEFUN([MP_TAR_FAST_READ],[
AC_SUBST(TAR_Q)
])
dnl This macro tests for tar support of -k (keep existing files)
dnl without erroring when files exist.
AC_DEFUN([MP_TAR_KEEP_OLD],[
AC_MSG_CHECKING([whether tar -k works])
mkdir -p conftest_dir
touch conftest_dir/file
$TAR -cf conftest.tar conftest_dir
if $TAR -xkf conftest.tar </dev/null 2>/dev/null ; then
AC_MSG_RESULT([yes])
TAR_K='k'
else
AC_MSG_RESULT([no])
TAR_K=
fi
AC_SUBST(TAR_K)
])
dnl This macro tests for tar support of --no-same-owner
AC_DEFUN([MP_TAR_NO_SAME_OWNER],[
AC_PATH_PROG(TAR, [tar])
Vendored
+18
View File
@@ -718,6 +718,7 @@ CFLAGS_WERROR
CFLAGS_PEDANTIC
CFLAGS_QUICHEEATERS
TAR_CMD
TAR_K
TAR_Q
ZIP
XZ
@@ -6453,6 +6454,23 @@ printf "%s\n" "no (gnutar)" >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether tar -k works" >&5
printf %s "checking whether tar -k works... " >&6; }
mkdir -p conftest_dir
touch conftest_dir/file
$TAR -cf conftest.tar conftest_dir
if $TAR -xkf conftest.tar </dev/null 2>/dev/null ; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
TAR_K='k'
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
TAR_K=
fi
# Extract the first word of "tar", so it can be a program name with args.
set dummy tar; ac_word=$2
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+1
View File
@@ -189,6 +189,7 @@ if test "x$MTREE" = "x"; then
fi
MP_TAR_FAST_READ
MP_TAR_KEEP_OLD
MP_TAR_NO_SAME_OWNER
MP_PATCH_GNU_VERSION
+7 -2
View File
@@ -3756,8 +3756,13 @@ proc mportsync {{options {}}} {
}
}
file delete -force ${extractdir}/tmp
# use -k to skip extracting files that exist
set kflag k
# use -k if supported to skip extracting files that exist
global macports::prefix_frozen
if {[string match ${prefix_frozen}/bin/* $tar]} {
set kflag k
} else {
set kflag $macports::autoconf::tar_k
}
}
set tar_cmd "$tar -C ${extractdir} -x${zflag}${kflag}f $tarball"
+1
View File
@@ -55,6 +55,7 @@ namespace eval macports::autoconf {
variable signify_path "@prefix_expanded@/libexec/macports/bin/signify"
variable tar_command "@TAR_CMD@"
variable tar_path "@TAR@"
variable tar_k "@TAR_K@"
variable tar_q "@TAR_Q@"
variable tclsh_path "@TCLSH@"
variable unzip_path "@UNZIP@"