Bug#1014476: /usr/bin/dpkg: dpkg --skip-same-version should look at arch too

2022-09-22 Thread Ian Jackson
Guillem Jover writes ("Re: Bug#1014476: /usr/bin/dpkg: dpkg --skip-same-version 
should look at arch too"):
> On Wed, 2022-07-06 at 18:50:08 +0100, Ian Jackson wrote:
> Thanks for the patch! So while I think the new behavior makes more
> sense, my main concern has been mostly about the long option now feeling
> somehow inaccurate. :/ I guess if this becomes bothersome or confusing
> we can always add a new alias or similar.

Yes.  I agree it's a bit infelicitous but I think changing the option
name would probably be worse.

Thanks!

Ian.

-- 
Ian JacksonThese opinions are my own.  

Pronouns: they/he.  If I emailed you from @fyvzl.net or @evade.org.uk,
that is a private address which bypasses my fierce spamfilter.



Bug#1014476: /usr/bin/dpkg: dpkg --skip-same-version should look at arch too

2022-09-17 Thread Guillem Jover
Hi!

On Wed, 2022-07-06 at 18:50:08 +0100, Ian Jackson wrote:
> Package: dpkg
> Version: 1.20.10
> Severity: normal
> File: /usr/bin/dpkg
> Tags: patch

> Recently, I did a complex semi-manual crossgrade.  Runes like
>   dpkg -iGEOB
> were frequently involved.  But I discovered that dpkg -E would
> skip a package if the same version, but a different architecture,
> was involved.
> 
> I don't think that's right.  I think that for a normal
> (non-coinstallable) package,
>   dpkg --skip-same-version foo_otherarch.deb
> should crossgrade it.
> 
> For a coinstallable package, it should coinstall it.
> 
> I think that the attached patch achieves this behaviour.  I used it[1]
> during my crossgrade it and functioned well.

Thanks for the patch! So while I think the new behavior makes more
sense, my main concern has been mostly about the long option now feeling
somehow inaccurate. :/ I guess if this becomes bothersome or confusing
we can always add a new alias or similar.

In any case I've merged this locally, with a small fix to the --help
output to make it fit under 80 chars, and this addition to the man
page to clarify the behavior change:

,---
Since dpkg 1.21.10, the architecture is also taken into account,
which makes it possible to cross-grade packages or install additional
co-installable instances with the same version, but different architecture.
`---

And I'm going to be pushing this to git.

Thanks,
Guillem



Bug#1014476: /usr/bin/dpkg: dpkg --skip-same-version should look at arch too

2022-07-06 Thread Ian Jackson
Package: dpkg
Version: 1.20.10
Severity: normal
File: /usr/bin/dpkg
Tags: patch

Recently, I did a complex semi-manual crossgrade.  Runes like
  dpkg -iGEOB
were frequently involved.  But I discovered that dpkg -E would
skip a package if the same version, but a different architecture,
was involved.

I don't think that's right.  I think that for a normal
(non-coinstallable) package,
  dpkg --skip-same-version foo_otherarch.deb
should crossgrade it.

For a coinstallable package, it should coinstall it.

I think that the attached patch achieves this behaviour.  I used it[1]
during my crossgrade it and functioned well.

[1] The version I tested had only the hunk for src/archives.c, and
soemthing to adjust the changelog.

-- Package-specific info:

-- System Information:
Debian Release: 11.3
  APT prefers stable-security
  APT policy: (500, 'stable-security'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.10.0-15-amd64 (SMP w/8 CPU threads)
Locale: LANG=C.UTF-8, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /bin/dash
Init: sysvinit (via /sbin/init)
LSM: AppArmor: enabled

Versions of packages dpkg depends on:
ii  libbz2-1.0   1.0.8-4
ii  libc62.31-13+deb11u3
ii  liblzma5 5.2.5-2.1~deb11u1
ii  libselinux1  3.1-3
ii  tar  1.34+dfsg-1
ii  zlib1g   1:1.2.11.dfsg-2+deb11u1

dpkg recommends no packages.

Versions of packages dpkg suggests:
ii  apt2.2.4
pn  debsig-verify  

-- no debconf information
>From bae0373d9672cae241a06530bb50b935976149b3 Mon Sep 17 00:00:00 2001
From: Ian Jackson 
Date: Wed, 6 Jul 2022 18:44:21 +0100
Subject: [PATCH] dpkg --skip-same-version looks at the architecture too, so -E
 can be used for an idempotent crossgrade.

---
 debian/changelog | 7 +++
 man/dpkg.pod | 4 ++--
 src/archives.c   | 2 +-
 src/main.c   | 2 +-
 4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 6ffe4019b..b6aef0ab8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+dpkg (1.20.9.iwj) unstable; urgency=medium
+
+  * dpkg --skip-same-version looks at the architecture too, so -E
+can be used for an idempotent crossgrade.
+
+ -- Ian Jackson   Sun, 26 Jun 2022 15:33:59 
+0100
+
 dpkg (1.20.9) unstable; urgency=medium
 
   [ Guillem Jover ]
diff --git a/man/dpkg.pod b/man/dpkg.pod
index 712f4608f..18f400af9 100644
--- a/man/dpkg.pod
+++ b/man/dpkg.pod
@@ -859,8 +859,8 @@ be marked selected for deinstallation.
 
 =item B<-E>, B<--skip-same-version>
 
-Don't install the package if the same version of the package is already
-installed.
+Don't install the package if the same version and architecture
+of the package is already installed.
 
 =item B<--pre-invoke=>I
 
diff --git a/src/archives.c b/src/archives.c
index aa56e9e9c..7e8eaa444 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -1648,7 +1648,7 @@ wanttoinstall(struct pkginfo *pkg)
 return true;
   } else if (rc == 0) {
 /* Same version fully installed. */
-if (f_skipsame) {
+if (f_skipsame && pkg->available.arch == pkg->installed.arch) {
   notice(_("version %.250s of %.250s already installed, skipping"),
  versiondescribe(>installed.version, vdew_nonambig),
  pkg_name(pkg, pnaw_nonambig));
diff --git a/src/main.c b/src/main.c
index 04b5799f8..80f45b4bd 100644
--- a/src/main.c
+++ b/src/main.c
@@ -151,7 +151,7 @@ usage(const struct cmdinfo *ci, const char *value)
 "  --path-exclude=   Do not install paths which match a shell 
pattern.\n"
 "  --path-include=   Re-include a pattern after a previous 
exclusion.\n"
 "  -O|--selected-only Skip packages not selected for 
install/upgrade.\n"
-"  -E|--skip-same-version Skip packages whose same version is installed.\n"
+"  -E|--skip-same-version Skip packages whose same version and arch is 
installed.\n"
 "  -G|--refuse-downgrade  Skip packages with earlier version than 
installed.\n"
 "  -B|--auto-deconfigure  Install even if it would break some other 
package.\n"
 "  --[no-]triggersSkip or force consequential trigger 
processing.\n"
-- 
2.20.1