Bug 266386 - ports-mgmt/portupgrade:hangs on deinstall
Summary: ports-mgmt/portupgrade:hangs on deinstall
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Bryan Drewery
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-09-12 21:22 UTC by andy
Modified: 2022-10-31 00:31 UTC (History)
7 users (show)

See Also:
bugzilla: maintainer-feedback? (bdrewery)


Attachments
pkg_deinstall.diff (211 bytes, patch)
2022-09-18 08:35 UTC, Katsuyuki Miyoshi
no flags Details | Diff
pkg_deinstall.2.diff (432 bytes, patch)
2022-09-18 14:30 UTC, Katsuyuki Miyoshi
no flags Details | Diff
pkg_deinstall.3.diff (547 bytes, patch)
2022-09-18 18:08 UTC, Katsuyuki Miyoshi
no flags Details | Diff
Modified patch to fit into ports files directory (768 bytes, patch)
2022-09-24 06:54 UTC, Tomoaki AOKI
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description andy 2022-09-12 21:22:31 UTC
Portupgrade seems to be broken.  It works to the step of deinstallation and then stops, need to hit Ctrl-c to stop it.


FreeBSD FBSD14 14.0-CURRENT FreeBSD 14.0-CURRENT #32 main-n257873-dfd37770855: Wed Sep  7 10:44:45 EDT 2022     root@FBSD14:/usr/obj/usr/src/amd64.amd64/sys/MYKERNEL amd64 1400066

====> Compressing man pages (compress-man)
--->  Build of archivers/libdeflate ended at: Mon, 12 Sep 2022 16:57:49 -0400 (consumed 00:00:03)
--->  Updating dependency info
--->  Uninstallation of libdeflate-1.13 started at: Mon, 12 Sep 2022 16:57:49 -0400
--->  Fixing up dependencies before creating a package
--->  Backing up the old version
pkg: unknown format pkg, using the default
--->  Uninstalling the old version
[Reading data from pkg(8) ... - 814 packages found - done]
--->  Deinstalling 'libdeflate-1.13'
^C
Interrupted.

Interrupted.
** None has been installed or upgraded.
[Reading data from pkg(8) ... --->  Uninstallation of libdeflate-1.13 ended at: Mon, 12 Sep 2022 17:04:11 -0400 (consumed 00:06:21)
--->  Upgrade of archivers/libdeflate ended at: Mon, 12 Sep 2022 17:04:11 -0400 (consumed 00:06:25)
--->  Session ended at: Mon, 12 Sep 2022 17:04:11 -0400 (consumed 00:07:47)
[root@FBSD14 /usr/ports]# - 814 packages found - done]
stty: tcsetattr: Input/output error
Comment 1 Tomoaki AOKI 2022-09-15 09:55:07 UTC
I've already reported the same issue for ports-mgmt/portupgrade-devel as Bug 266362.
You should have been bitten by src main git bced4d8b3e99efd46b5496c83e11755b25913c90, which is before where you are at.

For now, manually reverting the offending commit should workaround it.

[1] https://cgit.freebsd.org/src/commit/?id=bced4d8b3e99efd46b5496c83e11755b25913c90
Comment 2 Katsuyuki Miyoshi 2022-09-17 08:21:59 UTC
For the time being, it can be avoided by using the -u option.
(However, old shared libraries are not saved when using the -u option.)
Comment 3 Katsuyuki Miyoshi 2022-09-18 08:35:41 UTC
Created attachment 236658 [details]
pkg_deinstall.diff

This is a patch for pkg_deinstall.
I don't know much about ruby, so I'm not sure if this works.

Thanks.
Comment 4 Tomoaki AOKI 2022-09-18 11:59:00 UTC
(In reply to Katsuyuki Miyoshi from comment #3)

Thanks for trying for fix.
But unfortunately, patched pkg_deinstall didn't help.


On trying known-to-be-affected graphics/libdrm with -f option set (as it is on latest version), encountered an error as below.
This happenes regardless offending src commit is reverted or not.
(Tested on stable/13, amd64 at git 7e04dc0797f3265a10975cac2670f0407487a925.


#portupgrade -c -v -m 'DISABLE_VULNERABILITIES=yes' -f -b graphics/libdrm

     (snip)

--->  Uninstalling the old version
[Reading data from pkg(8) ... - 2085 packages found - done]
--->  Deinstalling 'libdrm-2.4.113,1'
--->  Preserving /usr/local/lib/libdrm.so.2 as /usr/local/lib/compat/pkg/libdrm.so.2
[Reading data from pkg(8) ... - 2085 packages found - done]
** Listing the failed packages (-:ignored / *:skipped / !:failed)
        ! libdrm-2.4.113,1      (not opened for writing)
--->  Uninstallation of libdrm-2.4.113,1 ended at: Sun, 18 Sep 2022 20:46:30 +0900 (consumed 00:00:00)
--->  Reinstallation of graphics/libdrm ended at: Sun, 18 Sep 2022 20:46:30 +0900 (consumed 00:00:05)
--->  ** Upgrade tasks 1: 0 done, 0 ignored, 0 skipped and 1 failed
--->  Listing the results (+:done / -:ignored / *:skipped / !:failed)
        ! graphics/libdrm (libdrm-2.4.113,1)    (uninstall error)
--->  Packages processed: 0 done, 0 ignored, 0 skipped and 1 failed
--->  Session ended at: Sun, 18 Sep 2022 20:46:30 +0900 (consumed 00:00:09)
Comment 5 Katsuyuki Miyoshi 2022-09-18 13:34:00 UTC
(In reply to Tomoaki AOKI from comment #4)
That's right. When processing multiple files, 'close_write' in this patch is not good.
I need to think more about how to code here.
Comment 6 Katsuyuki Miyoshi 2022-09-18 14:30:07 UTC
Created attachment 236668 [details]
pkg_deinstall.2.diff

Will this patch work?
Comment 7 Tomoaki AOKI 2022-09-18 16:03:21 UTC
(In reply to Katsuyuki Miyoshi from comment #6)

Thanks. Looks working for graphics/libdrm case.
Would need more testing, including some actual updates (with appropriate size).
 *For tooo large ports such as libreoffice or chromium, failure are too painful.

For 3 cases below had shown the same output after "--->  Uninstalling the old version".

 a) With offending commit intact, with uploaded 2nd patch applied.
 b) With offending commit reverted, with uploaded 2nd patch applied.
 c) With offending commit reverted, without uploaded 2nd patch applied.

Outputs of all 3 above are as follows. Only times differ.

--->  Uninstalling the old version
[Reading data from pkg(8) ... - 2085 packages found - done]
--->  Deinstalling 'libdrm-2.4.113,1'
--->  Preserving /usr/local/lib/libdrm.so.2 as /usr/local/lib/compat/pkg/libdrm.so.2
--->  Preserving /usr/local/lib/libdrm.so.2.4.0 as /usr/local/lib/compat/pkg/libdrm.so.2.4.0
--->  Preserving /usr/local/lib/libdrm_amdgpu.so.1 as /usr/local/lib/compat/pkg/libdrm_amdgpu.so.1
--->  Preserving /usr/local/lib/libdrm_amdgpu.so.1.0.0 as /usr/local/lib/compat/pkg/libdrm_amdgpu.so.1.0.0
--->  Preserving /usr/local/lib/libdrm_intel.so.1 as /usr/local/lib/compat/pkg/libdrm_intel.so.1
--->  Preserving /usr/local/lib/libdrm_intel.so.1.0.0 as /usr/local/lib/compat/pkg/libdrm_intel.so.1.0.0
--->  Preserving /usr/local/lib/libdrm_radeon.so.1 as /usr/local/lib/compat/pkg/libdrm_radeon.so.1
--->  Preserving /usr/local/lib/libdrm_radeon.so.1.0.1 as /usr/local/lib/compat/pkg/libdrm_radeon.so.1.0.1
Updating database digests format: 100%
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 1 packages (of 0 packages in the universe):

Installed packages to be REMOVED:
        libdrm: 2.4.113,1

Number of packages to be removed: 1
[1/1] Deinstalling libdrm-2.4.113,1...
[1/1] Deleting files for libdrm-2.4.113,1: 100%
vidcontrol: getting active vty: Inappropriate ioctl for device
vidcontrol: getting active vty: Inappropriate ioctl for device
[Reading data from pkg(8) ... - 2084 packages found - done]
--->  Uninstallation of libdrm-2.4.113,1 ended at: Mon, 19 Sep 2022 00:00:19 +0900 (consumed 00:00:02)
--->  Installation of graphics/libdrm started at: Mon, 19 Sep 2022 00:00:19 +0900
--->  Installing the new version via the port with make flags: DISABLE_VULNERABILITIES=yes
===>  Deinstalling for libdrm
===>   libdrm not installed, skipping
===>  Installing for libdrm-2.4.113,1
===>   Registering installation for libdrm-2.4.113,1 as automatic
Installing libdrm-2.4.113,1...
vidcontrol: getting active vty: Inappropriate ioctl for device
vidcontrol: getting active vty: Inappropriate ioctl for device
--->  Removing temporary files and directories
--->  Keeping old package in '/usr/ports/packages/All'
--->  Installation of graphics/libdrm ended at: Mon, 19 Sep 2022 00:00:20 +0900 (consumed 00:00:01)
--->  Cleaning out obsolete shared libraries
No such file or directory @ rb_check_realpath_internal - /usr/local/lib/compat/pkg/libXaw6.so.6
No such file or directory @ rb_check_realpath_internal - /usr/local/lib/compat/pkg/libXaw.so.7
No such file or directory @ rb_check_realpath_internal - /usr/local/lib/compat/pkg/libclutter-1.0.so.0
--->  Reinstallation of graphics/libdrm ended at: Mon, 19 Sep 2022 00:00:29 +0900 (consumed 00:00:16)
--->  ** Upgrade tasks 1: 1 done, 0 ignored, 0 skipped and 0 failed
--->  Listing the results (+:done / -:ignored / *:skipped / !:failed)
        + graphics/libdrm (libdrm-2.4.113,1 -> libdrm-2.4.113,1)
--->  Packages processed: 1 done, 0 ignored, 0 skipped and 0 failed
--->  Session ended at: Mon, 19 Sep 2022 00:00:29 +0900 (consumed 00:00:20)
Comment 8 Katsuyuki Miyoshi 2022-09-18 18:08:29 UTC
Created attachment 236672 [details]
pkg_deinstall.3.diff

Thank you. It was good.

If you can do more tests, I would like you to apply pkg_deinstall.3.diff.
Almost the same as pkg_deinstall.2.diff, but better coded.

Sorry for changing so many times.
Comment 9 Tomoaki AOKI 2022-09-18 22:30:36 UTC
(In reply to Katsuyuki Miyoshi from comment #8)

Behaved just as 2nd patch did, at least for the same test (graphics/libdrm case).
As the log was the same without time, didn't pasted it.
Thanks!
Comment 10 Terry Kennedy 2022-09-23 20:34:08 UTC
Subscribing because I'm seeing this too.
Comment 11 Tomoaki AOKI 2022-09-24 06:54:56 UTC
Created attachment 236783 [details]
Modified patch to fit into ports files directory

Modified the proposed patch for already-installed pkg_deinstall to fit into files/ directory.

Create ports-mgmt/portupgrade/files directory (default nonexistent) and place this into it and forcibly update ports-mgmt/portupgrade.

 *I myself apply it to ports-mgmt/portupgrade-devel.

Beware! This includes another fix for "Preserving old files" phase.
Unfortunately, I've lost track with from where/whom I've taken the fix, but it should be around Oct 10, 2018. (The timestamp of my old local patch.)

The first hunk of the patch is the proposed patch.

The second hunk of the patch looks working OK for me, but not sure it's harmless for others.
Comment 12 Tomoaki AOKI 2022-09-24 06:58:26 UTC
The another bug I've mentioned above would be the same as Bug 248019, IIUC.
I've never noticed that until now...
Comment 13 Tomoaki AOKI 2022-09-24 07:39:46 UTC
Finally I found where I've got the another fix by grep'ping my maildir.
Bug223943 Comment13 was the source, and I've hand-crafted the patch much later.
Missed that as there was no patch uploaded there.
Comment 14 Fernando Apesteguía freebsd_committer freebsd_triage 2022-10-27 09:02:23 UTC
This has been recently committed:

https://cgit.freebsd.org/src/commit/?id=07dfb236c81483c2f08a3976f6d44ce307f4ceaf

It should be MFC'ed really soon.

Could you try that if you are running -CURRENT and in 3 days if you are running -STABLE?

Thanks!
Comment 15 Tomoaki AOKI 2022-10-27 12:59:33 UTC
(In reply to Fernando Apesteguía from comment #14)

Tried on stable/13 by
  cherry-picking the commit
  build and install on /usr/src/usr.bin/file/
  back out my proposed patch here and re-apply unrelated part (for Bug 248019)
  rebuild /reinstall portupgrade-devel
  try forcible upgrade with portupgrade-devel for some known-to-fail ports
and worked fine for me. Thanks!

As the same patch (my version) can be sanely applicable for both portupgrade and portupgrade-devel, portupgrade would be OK, too. Can someone actually test?
Comment 16 Fernando Apesteguía freebsd_committer freebsd_triage 2022-10-30 10:27:38 UTC
The patch is in stable now.
Comment 17 Eugene Grosbein freebsd_committer freebsd_triage 2022-10-31 00:31:57 UTC
Fixed in all supported branches restoring regression in file(1) utility. The fix will be included in upcoming 12.4-RC1 and 12.4-RELEASE.