Bug 254050 - pkgbase: pkg autoremove is removing packages it shouldn't
Summary: pkgbase: pkg autoremove is removing packages it shouldn't
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-pkgbase (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-03-05 22:46 UTC by Mina Galić
Modified: 2021-04-21 23:53 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mina Galić 2021-03-05 22:46:47 UTC
setting up a jail with pkgbase:

meena@beastix ~> sudo pkg -r /isolates/pkg-auto-remove-bug/root install -r FreeBSD-base FreeBSD-clibs \
                                              FreeBSD-clibs-dev FreeBSD-libexecinfo FreeBSD-rc \
                                              FreeBSD-runtime FreeBSD-utilities FreeBSD-vi \
                                              FreeBSD-zoneinfo
Updating FreeBSD-base repository catalogue...
Fetching meta.conf: 100%    164 B   0.2kB/s    00:01
Fetching packagesite.tzst: 100%   30 KiB  31.0kB/s    00:01
Processing entries: 100%
FreeBSD-base repository update completed. 332 packages processed.
All repositories are up to date.
The following 25 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        FreeBSD-clibs: 14.snap20210302214559 [FreeBSD-base]
        FreeBSD-clibs-dev: 14.snap20210302214559 [FreeBSD-base]
        FreeBSD-libarchive: 14.snap20210225154922 [FreeBSD-base]
        FreeBSD-libbegemot: 14.snap20210220023449 [FreeBSD-base]
        FreeBSD-libbsdxml: 14.snap20210220023449 [FreeBSD-base]
        FreeBSD-libbsm: 14.snap20210220023449 [FreeBSD-base]
        FreeBSD-libbz2: 14.snap20210220023449 [FreeBSD-base]
        FreeBSD-libdwarf: 14.snap20210220023449 [FreeBSD-base]
        FreeBSD-libefivar: 14.snap20210225154922 [FreeBSD-base]
        FreeBSD-libevent1: 14.snap20210220023449 [FreeBSD-base]
        FreeBSD-libexecinfo: 14.snap20210220023449 [FreeBSD-base]
        FreeBSD-libldns: 14.snap20210220023449 [FreeBSD-base]
        FreeBSD-liblzma: 14.snap20210220023449 [FreeBSD-base]
        FreeBSD-libmagic: 14.snap20210220023449 [FreeBSD-base]
        FreeBSD-libnetmap: 14.snap20210220023449 [FreeBSD-base]
        FreeBSD-libopie: 14.snap20210220023449 [FreeBSD-base]
        FreeBSD-libregex: 14.snap20210220023449 [FreeBSD-base]
        FreeBSD-libsmb: 14.snap20210220023449 [FreeBSD-base]
        FreeBSD-libsqlite3: 14.snap20210220023449 [FreeBSD-base]
        FreeBSD-libucl: 14.snap20210220023449 [FreeBSD-base]
        FreeBSD-rc: 14.snap20210227073719 [FreeBSD-base]
        FreeBSD-runtime: 14.snap20210302214559 [FreeBSD-base]
        FreeBSD-utilities: 14.snap20210302214559 [FreeBSD-base]
        FreeBSD-vi: 14.snap20210227073719 [FreeBSD-base]
        FreeBSD-zoneinfo: 14.snap20210220023449 [FreeBSD-base]

Number of packages to be installed: 25

The process will require 263 MiB more space.
66 MiB to be downloaded.

Proceed with this action? [y/N]: y
<snip>

so, everything looks fine!
we can chroot into this jail and test basic things out:


meena@beastix ~> sudo chroot /isolates/pkg-auto-remove-bug/root
root@beastix:/ # su -
root@beastix:~ # logout
root@beastix:/ # exit

cool. sh works, su works, let's remove ""unneeded"" packages:

meena@beastix ~> sudo pkg -r /isolates/pkg-auto-remove-bug/root autoremove
Checking integrity... done (0 conflicting)
Deinstallation has been requested for the following 17 packages:

Installed packages to be REMOVED:
        FreeBSD-libarchive: 14.snap20210225154922
        FreeBSD-libbegemot: 14.snap20210220023449
        FreeBSD-libbsdxml: 14.snap20210220023449
        FreeBSD-libbsm: 14.snap20210220023449
        FreeBSD-libbz2: 14.snap20210220023449
        FreeBSD-libdwarf: 14.snap20210220023449
        FreeBSD-libefivar: 14.snap20210225154922
        FreeBSD-libevent1: 14.snap20210220023449
        FreeBSD-libldns: 14.snap20210220023449
        FreeBSD-liblzma: 14.snap20210220023449
        FreeBSD-libmagic: 14.snap20210220023449
        FreeBSD-libnetmap: 14.snap20210220023449
        FreeBSD-libopie: 14.snap20210220023449
        FreeBSD-libregex: 14.snap20210220023449
        FreeBSD-libsmb: 14.snap20210220023449
        FreeBSD-libsqlite3: 14.snap20210220023449
        FreeBSD-libucl: 14.snap20210220023449

Number of packages to be removed: 17

The operation will free 11 MiB.

Proceed with deinstalling packages? [y/N]: y

and try again:

meena@beastix ~> sudo chroot /isolates/pkg-auto-remove-bug/root
root@beastix:/ # su -
ld-elf.so.1: Shared object "libbsm.so.3" not found, required by "su"
root@beastix:/ #

we just broke a jail that was working perfectly fine a second ago.
Comment 1 Mark Millard 2021-03-06 01:47:02 UTC
(In reply to Mina Galić from comment #0)

I wonder if the pkg command for automremove should
have been using -c to operate in a chroot context
instead of using -r, -c making it more likely see
a self consistent context?

sudo pkg -c /isolates/pkg-auto-remove-bug/root autoremove

For reference:

     -c ⟨chroot path⟩, --chroot ⟨chroot path⟩
             pkg will chroot in the ⟨chroot path⟩ environment.

(I had to look it up to notice the -c vs -r
distinction.)
Comment 2 Mina Galić 2021-03-06 06:13:40 UTC
that's a very good point! 

i should see if pkg -c or pkg -j make any other decisions