From owner-freebsd-questions@freebsd.org Thu Apr 19 14:05:23 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 50733FA7F80 for ; Thu, 19 Apr 2018 14:05:23 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.10]) (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 BC48979ED5 for ; Thu, 19 Apr 2018 14:05:22 +0000 (UTC) (envelope-from freebsd@edvax.de) Received: from r56.edvax.de ([92.195.45.149]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.183]) with ESMTPA (Nemesis) id 0MHY8C-1f84mz3PFU-003JT0; Thu, 19 Apr 2018 16:05:05 +0200 Date: Thu, 19 Apr 2018 16:05:03 +0200 From: Polytropon To: freebsd@dreamchaser.org Cc: FreeBSD Mailing List Subject: Re: tar xf foo -- how to restore symlink? Message-Id: <20180419160503.38e1aa75.freebsd@edvax.de> In-Reply-To: <9902b54d-4684-6ba6-a08b-f3d9504c1273@dreamchaser.org> References: <5ff313cf-6148-be90-0195-7d21f1f836ac@dreamchaser.org> <20180418063005.056e321d.freebsd@edvax.de> <9902b54d-4684-6ba6-a08b-f3d9504c1273@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:jh7yHNfirSL2K9HZq2zneQ7rX8b/94a4LjlzzgvgJhjaFUzNdY9 +od6QkPGs/pkyyvgHWsh8BIBgQ3aQHr/x3PThL9ZBeIK3jp045pWGEyg6dtsKr4ScMEkwuT AmPOU/k7KGISNO6msVngMRzhwy58HB80XDo8uBSki52YSSvjevkyc/zoqpz2bpVh2Jwfpye dffaviAfntqUMXX6Ax/Jg== X-UI-Out-Filterresults: notjunk:1;V01:K0:CbOpesMGeJo=:Z6wxsKo0+YgwUVNs2V0Af2 T/LnhxsvN6ZzShTnfYGbAFU4ULoRYkgA8qf4VlsD8xzliRSNZKhwtUenJKa6qfju71NgQ7cFQ laGjO3iQsesCVNYOSGgjxX21DKnKpNF6dRs89PMkL+WwLZ3zdFd5kGNuq0K4dqzoCcSL3DsXL Q1kgol3O8bbQyGv4shdnCxW1SeyGbejtdCS+rPspbZeTMCI6tGFjE7IFJLS/6e7NG6t6rWDZZ fn7FhnOVtU/romwvyHpOclP5UXCzhhgqrvcYNTbtlt+9eLmoVxP1ACKw0dXOIDJoQbCiBh+AU BqCq4ptVV+D7wYouYT7W1tfUCi0M5ss+D6hs3nJCdGct49kfw6OFuKiJu16K3f0GcZXbUjY2L CllWwiCtj30ti5cr4sRoq6w6dWtdSYfWSSQsDDzgLa3lynAH2RgmJg4Kqqt2t56oVfbmOGFHj cgho2G0JqN0fpjd2aUfgynLvXeh3tXADdECPPRyGgNrBQXJFlX6jVVevVcOzlZ/yxhCj67ybt YQdaTwgLfPwSlYg/1zWA2LaLt9z1EH6InMVvm4z42l+etGIPdOzxd8nhQyU1ecMWc/mOopwW0 pva27nINhDIVKrfAN0MCTuf90pPEi+nwi7J30DI9PfVTO0ARYSLkeMLCaNBzBqE+m/4gokZNP C3cQlqsu0zdbX/r4YQWJ+G5y7G9fqh8/s5omY+IsR4Kmb3nBz9bXUBxl+93qz/SPJc5ld0zQy B+IOSjdGG3zqIc/Ot1+xdju/6r7eAGLcjhBa41Hsdl4fDuH1R1OGQGkv960= 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: Thu, 19 Apr 2018 14:05:23 -0000 On Wed, 18 Apr 2018 20:20:30 -0600, Gary Aitken wrote: > On 04/17/18 22:30, Polytropon wrote: > > 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? > > no, they didn't seem appropriate > > > -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. > > The archive is relative, not absolute > > > -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. > > Creates duplicate directories, rather than a symlink. > > > Check "man tar" for "symlink". :-) > > Did that, didn't find anything useful. > But then I don't always read so well, much less comprehend... > That's why I asked :-) Sadly, I do not remember anything specific to help you with tar, but I do remember that cpio has the feature you are searching for. I've been using it probably for exactly that purpose: because it keeps "special entries" in file system hierarchies when restoring from the archive. >From "man cpio": -L (o and p modes) All symbolic links will be followed. Normally, symbolic links are archived and copied as symbolic links. With this option, the target of the link will be archived or copied instead. Maybe if you try to transfer the data in question with cpio, you can achieve the result you are expecting? -- Polytropon Magdeburg, Germany Happy FreeBSD user since 4.0 Andra moi ennepe, Mousa, ...