Date: Fri, 15 Apr 2011 05:30:45 -0400 From: "J. Hellenthal" <jhell@DataIX.net> To: Pan Tsu <inyaoo@gmail.com> 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. Message-ID: <20110415093044.GA91283@DataIX.net> In-Reply-To: <86fwpjc2ok.fsf@gmail.com> References: <201104140922.p3E9M246053052__4754.10261792621$1302775251$gmane$org@DataIX.net> <86fwpjc2ok.fsf@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
On Fri, Apr 15, 2011 at 12:57:15PM +0400, Pan Tsu wrote:
>"J. Hellenthal" <jhell@DataIX.net> writes:
>
>[...]
>> @@ -33,7 +33,8 @@
>>
>> new_bak_file=`mktemp ${bak_file}-XXXXX`
>>
>> - 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.
--
Regards,
J. Hellenthal
[-- Attachment #2 --]
-----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-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110415093044.GA91283>
