From owner-freebsd-stable@FreeBSD.ORG Fri Apr 15 09:30:52 2011 Return-Path: Delivered-To: stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 240B8106564A; Fri, 15 Apr 2011 09:30:52 +0000 (UTC) (envelope-from jhellenthal@gmail.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id BDF4A8FC21; Fri, 15 Apr 2011 09:30:51 +0000 (UTC) Received: by iwn33 with SMTP id 33so2684681iwn.13 for ; Fri, 15 Apr 2011 02:30:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:date:from:to:cc:subject:message-id :references:mime-version:content-type:content-disposition :in-reply-to:x-openpgp-key-id:x-openpgp-key-fingerprint :x-openpgp-key-url; bh=1dexQGbI/2uH7zZvlYyUhulISVp/omx5F2AgwlnDCNQ=; b=WdfYFmsBmNNvScj1R/exBn0Bs6qgd9Hy0l1WYSwToC4w0yNLMaFcFnEEzamFZmELba U3zFo8oPx0GancatM6FkGXlGfhSd7rrD6vYV5Kh4Is3r5gGFZ3oomyW1cYpx+l3HxD50 VGmb0nvkehSBkTDRqVNg2MDR86SiVx34sepEI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:x-openpgp-key-id :x-openpgp-key-fingerprint:x-openpgp-key-url; b=BFbgmVK4BsC+OGkJydh8Aktbpf+qsY0ByxFIvJdMA5Ru6kkrq03i478KdT9FZcA3Kf vL3hp+TifbxZGxHhR1me/rW89wByQcUNsl6tOhJUT2TFTerkLQD1/CLSL9b6gkdL4Kga nWuELCJB/e+vWcer8itUKBwHT/EgN0rsaGd8g= Received: by 10.42.161.7 with SMTP id r7mr2555970icx.228.1302859851001; Fri, 15 Apr 2011 02:30:51 -0700 (PDT) Received: from DataIX.net (adsl-99-19-43-8.dsl.klmzmi.sbcglobal.net [99.19.43.8]) by mx.google.com with ESMTPS id gx2sm1656086ibb.9.2011.04.15.02.30.48 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 15 Apr 2011 02:30:49 -0700 (PDT) Sender: "J. Hellenthal" Received: from DataIX.net (localhost [127.0.0.1]) by DataIX.net (8.14.4/8.14.4) with ESMTP id p3F9Uj6c092018 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 15 Apr 2011 05:30:45 -0400 (EDT) (envelope-from jhell@DataIX.net) Received: (from jhell@localhost) by DataIX.net (8.14.4/8.14.4/Submit) id p3F9UjMo092017; Fri, 15 Apr 2011 05:30:45 -0400 (EDT) (envelope-from jhell@DataIX.net) Date: Fri, 15 Apr 2011 05:30:45 -0400 From: "J. Hellenthal" To: Pan Tsu Message-ID: <20110415093044.GA91283@DataIX.net> References: <201104140922.p3E9M246053052__4754.10261792621$1302775251$gmane$org@DataIX.net> <86fwpjc2ok.fsf@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="nFreZHaLTZJo0R7j" Content-Disposition: inline In-Reply-To: <86fwpjc2ok.fsf@gmail.com> X-OpenPGP-Key-Id: 0x89D8547E X-OpenPGP-Key-Fingerprint: 85EF E26B 07BB 3777 76BE B12A 9057 8789 89D8 547E X-OpenPGP-Key-URL: http://bit.ly/0x89D8547E Cc: stable@FreeBSD.org, FreeBSD-gnats-submit@FreeBSD.org Subject: Re: conf/156396: Make 220.backup-pkgdb cd(1) and backup only the package database. X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Apr 2011 09:30:52 -0000 --nFreZHaLTZJo0R7j Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Apr 15, 2011 at 12:57:15PM +0400, Pan Tsu wrote: >"J. Hellenthal" writes: > >[...] >> @@ -33,7 +33,8 @@ >> =20 >> new_bak_file=3D`mktemp ${bak_file}-XXXXX` >> =20 >> - if tar -cjf "${new_bak_file}" "$pkg_dbdir"; then >> + cd $pkg_dbdir/.. >> + if tar -cjf "${new_bak_file}" "$(basename $pkg_dbdir)"; then > >Why not use `-s' (substitution) option of bsdtar(1)? > > if tar -cjf "${new_bak_file}" -s "|$pkg_dbdir||" "$pkg_dbdir"; then > >$(basename $pkg_dbdir) is technically wrong as PKG_DBDIR points not to >/var/db but to /var/db/pkg by default and is not guaranteed to contain >`pkg' at the tail, e.g. I think you misunderstood how this works. You should test it... With a pkg_dbdir pointing to /var/db/pkg basename strips off "/var/db/". The cd(1) you notice before that line makes sure your in the directory just before the actual pkg_dbdir so therefore calling tar on $(basename $pkg_dbdir) tar's up only the actual name of the 'pkg' directory and not the path before it. I suppose this could also be achieved simply by: tar -C $pkg_dbdir/.. -cjf "${new_bak_file}" "$(basename $pkg_dbdir)" which is equivalent to: tar -C /var/db/pkg/.. -cvjf /tmp/foo.tbz `basename /var/db/pkg` '-v' added for show. But I don't think the author is willing to take any improvements and has the wrong impression of why the '/..' is where it is and how that suffices for the same motive behind archiving a direct path. PS: The PR says this was committed... It was not AFAIK. --=20 Regards, J. Hellenthal --nFreZHaLTZJo0R7j Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (FreeBSD) Comment: http://bit.ly/0x89D8547E iQEcBAEBAgAGBQJNqBBEAAoJEJBXh4mJ2FR+4LAH+wTJLhwQRvyMRiXSDia+r6OM FiKiehPPvADtp33MpoC9r7iJrw7oUkt19RFeDHkRePe32b0Mav3tsAHXDEzHw/JI TJMoDiNZX9IIcx3zgKhd8ITEzXvdZ6rKAKusjKTDR3o/z8eFFc/TRxUo8KfT2OTy MWhZh4PTGK4H7cS0/hv2tj/o+/88mTmsag/viV4N4iQXJuPkfF5hSCIWH2p8+6zK qe7+UNFX2zilCNnAo4LiijNEsJWy3mFY9ZcRB81RJliVMplpxwL3Tqd8TczK4FtB YzQxxw08J0+uZeRsbYCPWUBzmyDwe2N7NSqdZrJ4NfuATulwIrZe+Uvm0Q5pO8o= =szKz -----END PGP SIGNATURE----- --nFreZHaLTZJo0R7j--