The following commit has been merged in the master branch: commit 53b1f8871fea748e0360bf9183735ab54f7a1f64 Author: Guillem Jover <guil...@debian.org> Date: Fri Feb 27 07:00:17 2009 +0200
libdpkg: Add support for ustar long names using the prefix field The ustar format has been supported up to now except for the long names which use the prefix field that needs to be prepended to the name field if non empty. Closes: #474092 diff --git a/ChangeLog b/ChangeLog index 03fc9a4..43aff28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2009-02-27 Guillem Jover <guil...@debian.org> + * lib/tarfn.c (get_prefix_name): New function. + (DecodeTarHeader): On tar_format_ustar and if Prefix is not empty + call get_prefix_name instead of aborting. + * man/deb.5: Document that ustar format is now properly supported. + +2009-02-27 Guillem Jover <guil...@debian.org> + * lib/tarfn.h (enum tar_format): New type. (struct TarInfo): Add new format member. * lib/tarfn.c (TAR_MAGIC_USTAR, TAR_MAGIC_GNU): New macros. diff --git a/debian/changelog b/debian/changelog index e61d165..7c34446 100644 --- a/debian/changelog +++ b/debian/changelog @@ -62,6 +62,7 @@ dpkg (1.15.0) UNRELEASED; urgency=low IO scheduling class and priority. Closes: #443535 Thanks to Chris Coulson <chrisccoul...@googlemail.com>. * Add tar format detection support to the internal extractor. + * Add support for ustar long names using the prefix field. Closes: #474092 [ Raphael Hertzog ] * Enhance dpkg-shlibdeps's error message when a library can't be found to diff --git a/lib/tarfn.c b/lib/tarfn.c index ecb5acb..8e90491 100644 --- a/lib/tarfn.c +++ b/lib/tarfn.c @@ -74,6 +74,28 @@ StoC(const char *s, int size) return str; } +/* FIXME: Rewrite using varbuf, once it supports the needed functionality. */ +static char * +get_prefix_name(TarHeader *h) +{ + char *prefix, *name, *s; + + /* The size is not going to be bigger than that. */ + s = m_malloc(257); + + prefix = StoC(h->Prefix, sizeof(h->Prefix)); + name = StoC(h->Name, sizeof(h->Name)); + + strcpy(s, prefix); + strcat(s, "/"); + strcat(s, name); + + free(prefix); + free(name); + + return s; +} + static int DecodeTarHeader(char * block, TarInfo * d) { @@ -97,8 +119,9 @@ DecodeTarHeader(char * block, TarInfo * d) if ( *h->GroupName ) group = getgrnam(h->GroupName); + /* Concatenate prefix and name to support ustar style long names. */ if (d->format == tar_format_ustar && h->Prefix[0] != '\0') - abort(); + d->Name = get_prefix_name(h); else d->Name = StoC(h->Name, sizeof(h->Name)); d->LinkName = StoC(h->LinkName, sizeof(h->LinkName)); diff --git a/man/deb.5 b/man/deb.5 index 80e296e..c51ed12 100644 --- a/man/deb.5 +++ b/man/deb.5 @@ -1,4 +1,4 @@ -.TH deb 5 "2009-02-06" "Debian Project" "Debian" +.TH deb 5 "2009-02-27" "Debian Project" "Debian" .SH NAME deb \- Debian binary package format .SH SYNOPSIS @@ -22,7 +22,8 @@ The file names might contain a trailing slash. .PP The \fBtar\fP archives currently allowed are, the old-style (v7) format, the pre-POSIX ustar format, a subset of the GNU format (only the new -style long pathnames and long linknames, supported since dpkg 1.4.1.17). +style long pathnames and long linknames, supported since dpkg 1.4.1.17), +and the POSIX ustar format (long names supported since dpkg 1.15.0). Unrecognized tar typeflags are considered an error. .PP The first member is named -- dpkg's main repository -- To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org