Package: dpkg
Version: 1.3.22
Tags: patch
The attached patch improves the handling of symlinks to directories:
dpkg (1.13.10ubuntu4) breezy; urgency=low
* Don't consider it a file conflict if the package contains
a symlink to a directory where another package already contains the
same symlink/directory and the existing and new symlinks point to the
same place. Ubuntu 16133.
-- Ian Jackson <[EMAIL PROTECTED]> Sat, 24 Sep 2005 18:07:25 +0100
The reference to the Ubuntu bug number is to
http://bugzilla.ubuntu.com/show_bug.cgi?id=16133 aka
https://launchpad.net/distros/ubuntu/+source/x-common/+bug/22340
We deployed this patch in our two most recent releases, and I've
reviewed it for sanity again now, so I'm pretty confident of it.
Apologies for not feeding this one upstream sooner.
Ian.
diff -pruN 1.13.22/src/archives.c 1.13.22ubuntu1/src/archives.c
--- 1.13.22/src/archives.c 2006-04-11 00:49:45.000000000 +0100
+++ 1.13.22ubuntu1/src/archives.c 2006-07-03 19:25:31.000000000 +0100
@@ -325,6 +325,46 @@ struct fileinlist *addfiletolist(struct
return nifd;
}
+static int linktosameexistingdir(const struct TarInfo *ti,
+ const char *fname,
+ struct varbuf *symlinkfn) {
+ struct stat oldstab, newstab;
+ int statr;
+ const char *lastslash;
+
+ statr= stat(fname,&oldstab);
+ if (statr) {
+ if (!(errno==ENOENT || errno==ELOOP || errno==ENOTDIR))
+ ohshite("failed to stat (dereference) existing symlink `%.250s'", fname);
+ return 0;
+ }
+ if (!S_ISDIR(oldstab.st_mode)) return 0;
+
+ /* But is it to the same dir ? */
+ varbufreset(symlinkfn);
+ if (ti->LinkName[0] == '/') {
+ varbufaddstr(symlinkfn, instdir);
+ } else {
+ lastslash= strrchr(fname, '/'); assert(lastslash);
+ varbufaddbuf(symlinkfn, fname, (lastslash - fname) + 1);
+ }
+ varbufaddstr(symlinkfn, ti->LinkName);
+ varbufaddc(symlinkfn, 0);
+
+ statr= stat(symlinkfn->buf, &newstab);
+ if (statr) {
+ if (!(errno==ENOENT || errno==ELOOP || errno==ENOTDIR))
+ ohshite("failed to stat (dereference) proposed new symlink target"
+ " `%.250s' for symlink `%.250s'",
+ symlinkfn->buf, fname);
+ return 0;
+ }
+ if (!S_ISDIR(newstab.st_mode)) return 0;
+ if (newstab.st_dev != oldstab.st_dev ||
+ newstab.st_ino != oldstab.st_ino) return 0;
+ return 1;
+}
+
int tarobject(struct TarInfo *ti) {
static struct varbuf conffderefn, hardlinkfn, symlinkfn;
const char *usename;
@@ -422,6 +462,9 @@ int tarobject(struct TarInfo *ti) {
if (!statr && S_ISDIR(stab.st_mode)) {
debug(dbg_eachfiledetail,"tarobject SymbolicLink exists as directory");
existingdirectory= 1;
+ } else if (!statr && S_ISLNK(stab.st_mode)) {
+ if (linktosameexistingdir(ti, fnamevb.buf, &symlinkfn))
+ existingdirectory= 1;
}
break;
case Directory:
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]