Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[regression] pkg lock and unlock complains about already locked or unlocked #2059

Closed
hselasky opened this issue Jul 28, 2022 · 9 comments
Closed

Comments

@hselasky
Copy link
Contributor

Reproduction:

# pkg -v
1.18.3
# pkg lock -l
Currently locked packages:
drm-510-kmod-5.10.113_1
gpu-firmware-kmod-20220511,1
# pkg unlock drm-510-kmod-5.10.113_1
drm-510-kmod-5.10.113_1: unlock this package? [y/N]: y
Unlocking drm-510-kmod-5.10.113_1
drm-510-kmod-5.10.113_1: already unlocked
# pkg lock -l
Currently locked packages:
gpu-firmware-kmod-20220511,1
# pkg lock drm-510-kmod-5.10.113_1
drm-510-kmod-5.10.113_1: lock this package? [y/N]: y
Locking drm-510-kmod-5.10.113_1
drm-510-kmod-5.10.113_1: already locked
@bapt
Copy link
Member

bapt commented Jul 28, 2022

I cannot reproduce that here

@hselasky
Copy link
Contributor Author

hselasky commented Sep 1, 2022

Can you try again?

Still an issue here:

pkg lock virtualbox-ose-kmod-6.1.36
virtualbox-ose-kmod-6.1.36: lock this package? [y/N]: y
Locking virtualbox-ose-kmod-6.1.36
virtualbox-ose-kmod-6.1.36: already locked

@ghost
Copy link

ghost commented Sep 8, 2022

Hello,

i can reproduce it aswell.

===>  Installing for drm-510-kmod-5.10.113_4
===>  Checking if drm-510-kmod is already installed
===>   Registering installation for drm-510-kmod-5.10.113_4
Installing drm-510-kmod-5.10.113_4...
The drm-510-kmod port can be enabled for amdgpu (for AMD
GPUs starting with the HD7000 series / Tahiti) or i915kms (for Intel
APUs starting with HD3000 / Sandy Bridge) through kld_list in
/etc/rc.conf. radeonkms for older AMD GPUs can be loaded and there are
some positive reports if EFI boot is NOT enabled (similar to amdgpu).

For amdgpu: kld_list="amdgpu"
For Intel: kld_list="i915kms"
For radeonkms: kld_list="radeonkms"

Please ensure that all users requiring graphics are members of the
"video" group.

===>  Cleaning for drm-510-kmod-5.10.113_4
doas pkg lock drm-510-kmod
drm-510-kmod-5.10.113_4: lock this package? [y/N]: y
Locking drm-510-kmod-5.10.113_4
drm-510-kmod-5.10.113_4: already locked

@grahamperrin
Copy link
Contributor

A lazy guess: is multiple repos sometimes a factor?

root@mowa219-gjp4-8570p-freebsd:~ # pkg -vv | grep -e url -e enabled -e priority
    url             : "pkg+http://pkg0.pkt.freebsd.org/FreeBSD:14:amd64/latest",
    enabled         : yes,
    priority        : 4,
    url             : "https://alpha.pkgbase.live/current/FreeBSD:14:amd64/latest",
    enabled         : no,
    priority        : 0,
    url             : "file:///usr/local/poudriere/data/packages/main-default",
    enabled         : yes,
    priority        : 3
root@mowa219-gjp4-8570p-freebsd:~ # date ; uname -aKU
Sat Oct  8 20:13:12 BST 2022
FreeBSD mowa219-gjp4-8570p-freebsd 14.0-CURRENT FreeBSD 14.0-CURRENT #23 main-n258470-661faa1f77c0: Thu Oct  6 21:47:17 BST 2022     grahamperrin@mowa219-gjp4-8570p-freebsd:/usr/obj/usr/src/amd64.amd64/sys/GENERIC-NODEBUG amd64 1400072 1400072
root@mowa219-gjp4-8570p-freebsd:~ # pkg unlock drm-510-kmod
drm-510-kmod-5.10.113_7: unlock this package? [y/N]: y
Unlocking drm-510-kmod-5.10.113_7
drm-510-kmod-5.10.113_7: already unlocked
root@mowa219-gjp4-8570p-freebsd:~ # pkg lock drm-510-kmod
drm-510-kmod-5.10.113_7: lock this package? [y/N]: y
Locking drm-510-kmod-5.10.113_7
drm-510-kmod-5.10.113_7: already locked
root@mowa219-gjp4-8570p-freebsd:~ # 

@hselasky
Copy link
Contributor Author

I only see this:

    url             : "pkg+http://pkg.FreeBSD.org/FreeBSD:13:amd64/latest",
    enabled         : yes,
    priority        : 0,

@hselasky
Copy link
Contributor Author

GDB is your friend, look at this:

(gdb) print *it
$1 = {type = PKGDB_IT_LOCAL, db = 0x800c302d0, un = {remote = 0x800c6f008, local = {sqlite = 0x800c6f008, stmt = 0x800cb2a88, 
      flags = 2, finished = 0, pkg_type = 8}}}
(gdb) print *pkg
$2 = {direct = false, locked = false, automatic = false, vital = false, id = 10560, scripts = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0}, lua_scripts = {{head = 0x0, tail = 0x0, length = 0}, {head = 0x0, tail = 0x0, length = 0}, {head = 0x0, tail = 0x0, 
      length = 0}, {head = 0x0, tail = 0x0, length = 0}, {head = 0x0, tail = 0x0, length = 0}}, name = 0x800cde390 "drm-510-kmod", 
  origin = 0x800cb5ac0 "graphics/drm-510-kmod", version = 0x800cde380 "5.10.113_7", old_version = 0x0, 
  maintainer = 0x800cde480 "x11@FreeBSD.org", www = 0x800c32490 "https://github.com/freebsd/drm-kmod/", 
  arch = 0x800cb5b80 "freebsd:13:x86:64", abi = 0x800cb5b20 "FreeBSD:13:amd64", uid = 0x800cde360 "drm-510-kmod", digest = 0x0, 
  old_digest = 0x0, message = {head = 0x800cb5b40, tail = 0x800cb5b40, length = 1}, prefix = 0x800cde490 "/usr/local", 
  comment = 0x800cb5ae0 "DRM drivers modules", 
  desc = 0x800cdbc00 "amdgpu, i915, and radeon DRM drivers modules.\nCurrently corresponding to Linux 5.10 DRM.\nThis version is for FreeBSD 13.1 and above.\n\nWWW: https://github.com/freebsd/drm-kmod/\n", sum = 0x0, repopath = 0x0, reponame = 0x0, repourl = 0x0, 
  reason = 0x0, dep_formula = 0x0, licenselogic = LICENSE_AND, pkgsize = 0, flatsize = 13269198, old_flatsize = 0, 
  timestamp = 1665948517, depshash = 0x0, depends = 0x0, rdepshash = 0x0, rdepends = 0x0, categories = {head = 0x0, tail = 0x0, 
    length = 0}, licenses = {head = 0x0, tail = 0x0, length = 0}, filehash = 0x0, files = 0x0, dirhash = 0x0, dirs = 0x0, 
  optionshash = 0x0, options = 0x0, users = {head = 0x0, tail = 0x0, length = 0}, groups = {head = 0x0, tail = 0x0, length = 0}, 
  shlibs_required = {head = 0x0, tail = 0x0, length = 0}, shlibs_provided = {head = 0x0, tail = 0x0, length = 0}, 
  conflictshash = 0x0, conflicts = 0x0, provides = {head = 0x0, tail = 0x0, length = 0}, requires = {head = 0x0, tail = 0x0, 
    length = 0}, config_files_hash = 0x0, config_files = 0x0, annotations = {head = 0x0, tail = 0x0, length = 0}, flags = 0, 
  rootfd = -1, rootpath = '\000' <repeats 1023 times>, dir_to_del = {head = 0x0, tail = 0x0, length = 0}, type = PKG_INSTALLED, 
  repo = 0x0}
(gdb) c
Continuing.
drm-510-kmod-5.10.113_7: lock this package? [y/N]: y
Locking drm-510-kmod-5.10.113_7

Breakpoint 1, do_lock (db=0x800c302d0, pkg=0x800d15000) at lock.c:59
59		if (pkg_is_locked(pkg)) {
(gdb) frame 1
#1  0x00000000003e5b73 in do_lock_unlock (db=0x800c302d0, match=1, pkgname=0x7fffffffebfa "drm-510-kmod", action=LOCK) at lock.c:119
119				retcode = do_lock(db, pkg);
(gdb) print *it
$3 = {type = PKGDB_IT_LOCAL, db = 0x800c302d0, un = {remote = 0x800c6f008, local = {sqlite = 0x800c6f008, stmt = 0x800cb2a88, 
      flags = 2, finished = 0, pkg_type = 8}}}
(gdb) print *pkg
$4 = {direct = false, locked = true, automatic = false, vital = false, id = 10560, scripts = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 
    0x0, 0x0}, lua_scripts = {{head = 0x0, tail = 0x0, length = 0}, {head = 0x0, tail = 0x0, length = 0}, {head = 0x0, tail = 0x0, 
      length = 0}, {head = 0x0, tail = 0x0, length = 0}, {head = 0x0, tail = 0x0, length = 0}}, name = 0x800cde490 "drm-510-kmod", 
  origin = 0x800cb5b40 "graphics/drm-510-kmod", version = 0x800cde480 "5.10.113_7", old_version = 0x0, 
  maintainer = 0x800cde4d0 "x11@FreeBSD.org", www = 0x800c32460 "https://github.com/freebsd/drm-kmod/", 
  arch = 0x800cb5ba0 "freebsd:13:x86:64", abi = 0x800cb5b20 "FreeBSD:13:amd64", uid = 0x800cde360 "drm-510-kmod", digest = 0x0, 
  old_digest = 0x0, message = {head = 0x800cb5b80, tail = 0x800cb5b80, length = 1}, prefix = 0x800cde4c0 "/usr/local", 
  comment = 0x800cb5b00 "DRM drivers modules", 
  desc = 0x800cdbc00 "amdgpu, i915, and radeon DRM drivers modules.\nCurrently corresponding to Linux 5.10 DRM.\nThis version is for FreeBSD 13.1 and above.\n\nWWW: https://github.com/freebsd/drm-kmod/\n", sum = 0x0, repopath = 0x0, reponame = 0x0, repourl = 0x0, 
  reason = 0x0, dep_formula = 0x0, licenselogic = LICENSE_AND, pkgsize = 0, flatsize = 13269198, old_flatsize = 0, 
  timestamp = 1665948517, depshash = 0x0, depends = 0x0, rdepshash = 0x0, rdepends = 0x0, categories = {head = 0x0, tail = 0x0, 
    length = 0}, licenses = {head = 0x0, tail = 0x0, length = 0}, filehash = 0x0, files = 0x0, dirhash = 0x0, dirs = 0x0, 
  optionshash = 0x0, options = 0x0, users = {head = 0x0, tail = 0x0, length = 0}, groups = {head = 0x0, tail = 0x0, length = 0}, 
  shlibs_required = {head = 0x0, tail = 0x0, length = 0}, shlibs_provided = {head = 0x0, tail = 0x0, length = 0}, 
  conflictshash = 0x0, conflicts = 0x0, provides = {head = 0x0, tail = 0x0, length = 0}, requires = {head = 0x0, tail = 0x0, 
    length = 0}, config_files_hash = 0x0, config_files = 0x0, annotations = {head = 0x0, tail = 0x0, length = 0}, flags = 0, 
  rootfd = -1, rootpath = '\000' <repeats 1023 times>, dir_to_del = {head = 0x0, tail = 0x0, length = 0}, type = PKG_INSTALLED, 
  repo = 0x0}
(gdb) 

When you set a package locked it immediately shows up in the search results. I suggest that the lock field has 3 states:

0: unlocked
1: locked
2: selected for modification

And to iterate the database two times.

When you lock all lock fields should go to 2 first and if you see 1 output a warning.

Then iterate again and change 2->1

Same for going to unlocked.

locked = 2 can be treated as locked though.

Or just skip the warning for already locked/unlocked packages!

@bapt : Any comments?

@bapt
Copy link
Member

bapt commented Oct 18, 2022

no I would prefer that we fix the regression, this is caused by the following commit ade813b

@bapt bapt closed this as completed in b51485a Oct 18, 2022
@hselasky
Copy link
Contributor Author

Thank you for fixing!

@grahamperrin
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants