On Wed, Apr 18, 2012 at 02:42:02PM +0200, Guillem Jover wrote: > On Wed, 2012-04-18 at 11:38:20 +0100, Colin Watson wrote: > > We ran into this in Ubuntu due to chaos with linker conflicts in > > libc6-i386 vs. libc6:i386, and wished that we'd had this in advance. > > > > How about something like this for a C version? I'd appreciate review as > > I'm not entirely familiar with all the internal interfaces here. > > I had this one on my list of bugs to look to get fixed for 1.16.3 or > 1.16.4 anyway, so let's see:
Great, thanks for the help. > > /* If the source file is not present and we are not going to do > > @@ -202,6 +205,24 @@ check_rename(struct file *src, struct file *dst) > > " different file `%s', not allowed"), > > dst->name, src->name); > > > > + if (set) { > > + for (pkg = &set->pkg; pkg; pkg = pkg->arch_next) { > > + struct fileinlist *file; > > + > > + ensure_packagefiles_available(pkg); > > + file = pkg->clientdata->files; > > + while (file) { > > + if (strcmp (file->namenode->name, > > + src->name) == 0) { > > + /* Owned by the same package as > > + * given in --package; don't rename. > > + */ > > + return false; > > + } > > + } > > This loop will only work for packages with exactly one matching file, > or none. :) Whoops, yes! > I'm attaching a preliminary patch I just cooked, but not tested which > would do what I describe above. This at least passes the test suite in conjunction with the following test patch. Steve, I think I missed the specifics of what you wanted to do with libc6-i386/libc6:i386. Would dpkg-divert exiting non-zero have been a problem here? diff --git a/src/t/100_dpkg_divert.t b/src/t/100_dpkg_divert.t index 6d62fe5..e4f5079 100644 --- a/src/t/100_dpkg_divert.t +++ b/src/t/100_dpkg_divert.t @@ -33,11 +33,12 @@ if (! -x "@dd") { exit(0); } -plan tests => 251; +plan tests => 257; sub cleanup { system("rm -rf $tmpdir && mkdir -p $testdir"); - system("mkdir -p $admindir/updates && touch $admindir/status"); + system("mkdir -p $admindir/updates && rm -f $admindir/status && touch $admindir/status"); + system("rm -rf $admindir/info && mkdir -p $admindir/info"); } sub install_diversions { @@ -47,6 +48,27 @@ sub install_diversions { close(O); } +sub install_filelist { + my ($pkg, $arch, @files) = @_; + open(L, "> $admindir/info/$pkg.list"); + for my $file (@files) { + print L "$file\n"; + } + close(L); + # Only installed packages have their files list considered. + open(S, ">> $admindir/status"); + print S <<EOF; +Package: $pkg +Status: install ok installed +Version: 0 +Architecture: $arch +Maintainer: dummy +Description: dummy + +EOF + close(S); +} + sub call { my ($prog, $args, %opts) = @_; @@ -392,6 +414,23 @@ EOF cleanup(); +note("Adding diversion of file owned by --package"); + +install_filelist("coreutils", "i386", "$testdir/foo"); +system("cat $admindir/info/coreutils.list >&2"); +install_diversions(''); +system("touch $testdir/foo"); + +call_divert(['--quiet', '--rename', '--add', '--package', 'coreutils', "$testdir/foo"], + expect_failure => 1, + expect_stderr_like => qr/owned by same package/, + expect_stdout => ''); +ok(-e "$testdir/foo", "foo not renamed"); +ok(!-e "$testdir/foo.distrib", "foo renamed"); +diversions_eq(''); + +cleanup(); + note("Remove diversions"); install_diversions(''); -- Colin Watson [cjwat...@ubuntu.com] -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org