On Fri, Apr 15, 2011 at 12:57:15PM +0400, Pan Tsu wrote:
>"J. Hellenthal" <jh...@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: pgpe6VAW3ejRr.pgp
Description: PGP signature

Reply via email to