From owner-freebsd-questions@freebsd.org Wed Apr 18 04:30:19 2018 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0AAF5F8E9C2 for ; Wed, 18 Apr 2018 04:30:19 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "mout.kundenserver.de", Issuer "TeleSec ServerPass DE-2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 70D3C76236 for ; Wed, 18 Apr 2018 04:30:18 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de ([92.195.45.149]) by mrelayeu.kundenserver.de (mreue001 [212.227.15.167]) with ESMTPA (Nemesis) id 0MOXED-1f3S4R0d65-005nKW; Wed, 18 Apr 2018 06:30:06 +0200 Date: Wed, 18 Apr 2018 06:30:05 +0200 From: Polytropon To: freebsd@dreamchaser.org Cc: FreeBSD Mailing List Subject: Re: tar xf foo -- how to restore symlink? Message-Id: <20180418063005.056e321d.freebsd@edvax.de> In-Reply-To: <5ff313cf-6148-be90-0195-7d21f1f836ac@dreamchaser.org> References: <5ff313cf-6148-be90-0195-7d21f1f836ac@dreamchaser.org> Reply-To: Polytropon Organization: EDVAX X-Mailer: Sylpheed 3.1.1 (GTK+ 2.24.5; i386-portbld-freebsd8.2) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:V3D+6w4a3f7rZF5WEWHKotv5Ub12ba8T2IQmByN8BfRpfWB4/EV lLFNd+6eOJbRmOqTMNiAcvPNdvxJxzV04jwXhBv6sMDDebZGbxp8eaSfVAalY1j2xXI6jT1 Kmd8vMZBraTyTFAKthfnVRYhFyDc2qXZPkov7XCvOVzpa4x88tpZn2Aj9N3MVjt//3OMtim 7CPRORDzB/AUa0Iserzfg== X-UI-Out-Filterresults: notjunk:1;V01:K0:q4KJvgd9CDg=:7oJSG9epOXCvJwtyp709zu V25KKFBTronVupetyWS25NSBhVb3VjUq1bW9/Eujy+xnFKAXIw2r5TYHnr85+TFvEQSXg+UqG jIPYiKHg3k2JukfeDbaFRC8vH77w/IAwGZGCClzCHaG2j85j2zILsIjEeocWaqIqlcZKHbA// JbrPd9Q5SSakBkb3I77fESmM0ZdC4S/L48u/nNYaGRu3WQdw241H4UEvqzaCcvp1Mx+MsTyAm qIQ3qEEGuKXepjcxwFNNl6HnXx4sVfD7ZRjiJ6TY5FpIfzri6AbhoMUPVwYZmBNzkM0flETbl DZyknxDapDvgM2sCut8hiQU1E0mw/JvYM43CyqT/nVxSk6DdaQNG6GgZYfnjmoA2D0BOAktZp +tcOnhnYrIfKZ9slvVvhdHkgBAVWzIbzf3r/jTzz3xef/9th7s+zDaTkeBm6vXZWkl2ldByt+ PEzfTcS/tBWiCEVgwQDPbMbVWjWCSx2fXEofS03Xx7qyxvRc1bU5/w6lRdTcklhnBJOYPh6VG 5vCnJSdCxiY+Wz4/ceMRQtHgdONNgwk4zjY152FX5KhyqHNzPcK0x+yNwZ3Zm6HaxefgPcT/A U1wufJG3ItAmTw3mmsBjPVWmGusGCIop9FKfHqc7E6fkYOcfxTiXHAKIejahoTjaNvR2LxSmV iohn9WLvPL19hBterk8bCv3y3h/lVq9s1H9QkdKlgL+aKmOLiXUERUeVHTqC4Fieb8Rf5NNNB 0i8vDgexvNrscvzyuiQ6rOTMS614UJjE7UlbbCr3xOLUxMO/0QoWhNbIwsw= X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Apr 2018 04:30:19 -0000 On Tue, 17 Apr 2018 22:20:23 -0600, Gary Aitken wrote: > I've got a tarball with an archived symlink and its contents. > The symlink points to another directory in the tarball, and the > tarball contains copies of the files in the symlinked directory. > > A normal extract fails with the message: > $ tar -xf nufraw-0.41.tar.gz > nufraw-0.41/doc-pak: Can't replace existing directory with non-directory > > What's the right way to deal with this? > > How do I get tar to restore the symlink as a symlink? > -k and --exclude allow tar to continue unpacking, > but don't restore the symlink as such. > > "man tar" doesn't seem to have what I want but I'm probably blind. Have you checked if -P or -U result in the intended behaviour? -P, --absolute-paths Preserve pathnames. By default, absolute pathnames (those that begin with a / character) have the leading slash removed both when creating archives and extracting from them. Also, tar will refuse to extract archive entries whose pathnames contain .. or whose target directory would be altered by a symlink. This option suppresses these behaviors. -U, --unlink, --unlink-first (x mode only) Unlink files before creating them. This can be a minor performance optimization if most files already exist, but can make things slower if most files do not already exist. This flag also causes tar to remove intervening directory symlinks instead of reporting an error. See the SECURITY section below for more details. Check "man tar" for "symlink". :-) -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...