diff --git a/aclocal.m4 b/aclocal.m4 index 7c220f0d1..ab7ef458e 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -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 ; 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]) diff --git a/configure b/configure index 3c7a37ce6..2effc6862 100755 --- a/configure +++ b/configure @@ -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 ; 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 diff --git a/configure.ac b/configure.ac index 687929cf3..940c67669 100644 --- a/configure.ac +++ b/configure.ac @@ -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 diff --git a/src/macports1.0/macports.tcl b/src/macports1.0/macports.tcl index 610b1665a..73a5ba83a 100644 --- a/src/macports1.0/macports.tcl +++ b/src/macports1.0/macports.tcl @@ -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" diff --git a/src/macports1.0/macports_autoconf.tcl.in b/src/macports1.0/macports_autoconf.tcl.in index 3da558762..81acbc352 100644 --- a/src/macports1.0/macports_autoconf.tcl.in +++ b/src/macports1.0/macports_autoconf.tcl.in @@ -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@"