Re: conf/156396: Make 220.backup-pkgdb cd(1) and backup only the

看板FB_stable作者時間15年前 (2011/04/15 17:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
--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" <jhell@DataIX.net> 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--
文章代碼(AID): #1Dg12JDO (FB_stable)
文章代碼(AID): #1Dg12JDO (FB_stable)