Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
to query all those packages with no dependent?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
guyuming
Apprentice
Apprentice


Joined: 19 Nov 2020
Posts: 253

PostPosted: Wed Nov 16, 2022 5:17 am    Post subject: to query all those packages with no dependent? Reply with quote

background:

https://forums.gentoo.org/viewtopic-t-1158257-highlight-.html
https://forums.gentoo.org/viewtopic-t-1158521-highlight-.html

i had unpacked stage3 on existing system by mistake.
and i had run something like
Code:
emerge (eix_limit=0 eix -I#)




Now, if i run emerge --depclean, i can see that

Code:
Packages installed:   1031
Packages in world:    967
Packages in system:   43
Required packages:    1031


That is, almost every packages install are in world. I think this is because of emerge $(eix_limit=0 eix -I#).

I think that packages in portage is organized as a DAG(directed acyclic graph). I want only those packages with no dependent to appear in the world, is it possible?

Are there any commands to select all those packages with no dependent (Top level packages)?

[/list]


Last edited by guyuming on Wed Nov 16, 2022 11:34 pm; edited 1 time in total
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3477

PostPosted: Wed Nov 16, 2022 10:53 am    Post subject: Reply with quote

Quote:
Are there any commands to select all those packages with no dependent (Top level packages)?
Those packages are recorded in /var/lib/portage/world
The command to list them is "cat" :)

You can try to repair your system using earlier backup and possibly that stage3 to determine which files need to be recovered/deleted. And possibly run your next update with -e to rebuild everything.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54691
Location: 56N 3W

PostPosted: Wed Nov 16, 2022 8:05 pm    Post subject: Reply with quote

guyuming,

There are a few world cleaning scripts on the wiki.
There is cleaning the world file (wiki) - check the script too.

Its only an advisory as its not an error to have more than the bare minimum in your world file.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3462
Location: Canada

PostPosted: Thu Nov 17, 2022 4:07 am    Post subject: Reply with quote

Honestly, I just clean the /var/lib/portage/world with ordinary editor like vi :)
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54691
Location: 56N 3W

PostPosted: Thu Nov 17, 2022 4:57 pm    Post subject: Reply with quote

dmpogo,

emerge --deselect is designed for that.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
guyuming
Apprentice
Apprentice


Joined: 19 Nov 2020
Posts: 253

PostPosted: Fri Nov 18, 2022 12:54 am    Post subject: Reply with quote

I run the query to generate /tmp/WorldDeselect

Code:

#!/bin/bash

while read i ; do \
        if [ -n "$(qdepends -Q $i)" ]; then \
                echo '' ; echo 'checking '$i ;
                if [ -n "$(emerge -p --quiet --depclean $i)" ]; then \
                        echo $i' needs to stay in @world'
                        echo $i >> /tmp/WorldStay
                else
                        echo $i' can be deselected'
                        echo $i >> /tmp/WorldDeselect
                fi
        else
                echo '' ; echo 'checking '$i ;echo 'qdepends null'
                echo $i >> /tmp/WorldQdependsNull
        fi
done < /var/lib/portage/world



And deselected them
Code:
 emerge --ask --deselect $(cat /tmp/WorldDeselect)



Then i run depclean, the packages in world number looks normal now, but there are 23 packages to remove, which include xorg-server. Obviously, i should not remove xorg-server.
Code:

root@localhost /home/guyuming # emerge -p --depclean
/usr/lib/python3.10/site-packages/portage/package/ebuild/_config/KeywordsManager.py:86: UserWarning: /etc/portage/package.keywords is deprecated, use /etc/portage/package.accept_keywords instead
  warnings.warn(

 * Always study the list of packages to be cleaned for any obvious
 * mistakes. Packages that are part of the world set will always
 * be kept.  They can be manually added to this set with
 * `emerge --noreplace <atom>`.  Packages that are listed in
 * package.provided (see portage(5)) will be removed by
 * depclean, even if they are part of the world set.
 *
 * As a safety measure, depclean will not remove any packages
 * unless *all* required dependencies have been resolved.  As a
 * consequence of this, it often becomes necessary to run
 * `emerge --update --newuse --deep @world` prior to depclean.

Calculating dependencies... done!
>>> Calculating removal order...

>>> These are the packages that would be unmerged:

 x11-drivers/xf86-video-fbdev
    selected: 0.5.0-r1
   protected: none
     omitted: none

 app-editors/emacs
    selected: 29.0.9999
   protected: none
     omitted: none

 app-emacs/emacs-common
    selected: 1.8
   protected: none
     omitted: none

 dev-libs/jansson
    selected: 2.14
   protected: none
     omitted: none

 app-eselect/eselect-emacs
    selected: 1.19
   protected: none
     omitted: none

 app-eselect/eselect-ctags
    selected: 1.19
   protected: none
     omitted: none

 x11-base/xorg-drivers
    selected: 21.1-r1
   protected: none
     omitted: none

 x11-drivers/xf86-input-libinput
    selected: 1.2.1
   protected: none
     omitted: none

 x11-drivers/xf86-video-amdgpu
    selected: 22.0.0
   protected: none
     omitted: none

 x11-drivers/xf86-video-dummy
    selected: 0.4.0
   protected: none
     omitted: none

 x11-drivers/xf86-video-nouveau
    selected: 1.0.17
   protected: none
     omitted: none

 x11-drivers/xf86-video-ati
    selected: 19.1.0-r1
   protected: none
     omitted: none

 x11-drivers/xf86-video-vesa
    selected: 2.5.0
   protected: none
     omitted: none

 x11-base/xorg-server
    selected: 21.1.4
   protected: none
     omitted: none

 x11-apps/iceauth
    selected: 1.0.9
   protected: none
     omitted: none

 gui-libs/display-manager-init
    selected: 1.0-r4
   protected: none
     omitted: none

 x11-apps/rgb
    selected: 1.0.6-r1
   protected: none
     omitted: none

 x11-apps/xinit
    selected: 1.4.1-r1
   protected: none
     omitted: none

 x11-apps/xrdb
    selected: 1.2.1
   protected: none
     omitted: none

 media-video/wireplumber
    selected: 0.4.11-r3
   protected: none
     omitted: none

 media-video/pipewire
    selected: 0.3.56
   protected: none
     omitted: none

 dev-lang/lua
    selected: 5.4.4-r103
   protected: none
     omitted: none

 app-eselect/eselect-lua
    selected: 4-r1
   protected: none
     omitted: none

All selected packages: =app-eselect/eselect-ctags-1.19 =x11-drivers/xf86-video-ati-19.1.0-r1 =x11-apps/xrdb-1.2.1 =app-emacs/emacs-common-1.8 =app-editors/emacs-29.0.9999 =x11-drivers/xf86-video-vesa-2.5.0 =x11-apps/xinit-1.4.1-r1 =gui-libs/display-manager-init-1.0-r4 =app-eselect/eselect-emacs-1.19 =app-eselect/eselect-lua-4-r1 =dev-libs/jansson-2.14 =x11-apps/iceauth-1.0.9 =x11-apps/rgb-1.0.6-r1 =media-video/pipewire-0.3.56 =x11-base/xorg-server-21.1.4 =media-video/wireplumber-0.4.11-r3 =x11-drivers/xf86-video-nouveau-1.0.17 =x11-drivers/xf86-video-fbdev-0.5.0-r1 =x11-drivers/xf86-input-libinput-1.2.1 =x11-drivers/xf86-video-amdgpu-22.0.0 =x11-base/xorg-drivers-21.1-r1 =dev-lang/lua-5.4.4-r103 =x11-drivers/xf86-video-dummy-0.4.0

>>> 'Selected' packages are slated for removal.
>>> 'Protected' and 'omitted' packages will not be removed.

Packages installed:   1031
Packages in world:    252
Packages in system:   43
Required packages:    1008
Number to remove:     23




If i depclean xorg-server alone, it is not said to be removed. Then, why depclean would remove the 23 packages above? How can i prevent them from been removed inadvertently? Is it any flaw in the query that made them into the /tmp/WorldDeselect file which actually they should be in /tmp/WorldStay?

Code:


root@localhost /home/guyuming # emerge -p --depclean --verbose x11-base/xorg-server
/usr/lib/python3.10/site-packages/portage/package/ebuild/_config/KeywordsManager.py:86: UserWarning: /etc/portage/package.keywords is deprecated, use /etc/portage/package.accept_keywords instead
  warnings.warn(

Calculating dependencies... done!
  x11-base/xorg-server-21.1.4 pulled in by:
    x11-base/xorg-drivers-21.1-r1 requires >=x11-base/xorg-server-21.1[-minimal], >=x11-base/xorg-server-21.1[udev]
    x11-drivers/xf86-input-libinput-1.2.1 requires x11-base/xorg-server:0/21.1.4=, >=x11-base/xorg-server-1.20[xorg], x11-base/xorg-server:=
    x11-drivers/xf86-video-amdgpu-22.0.0 requires x11-base/xorg-server[-minimal], x11-base/xorg-server:0/21.1.4=, >=x11-base/xorg-server-1.20[xorg], x11-base/xorg-server:=
    x11-drivers/xf86-video-ati-19.1.0-r1 requires x11-base/xorg-server[-minimal], x11-base/xorg-server:0/21.1.4=, >=x11-base/xorg-server-1.20[xorg], x11-base/xorg-server:=
    x11-drivers/xf86-video-dummy-0.4.0 requires x11-base/xorg-server:0/21.1.4=, >=x11-base/xorg-server-1.20[xorg], x11-base/xorg-server:=
    x11-drivers/xf86-video-fbdev-0.5.0-r1 requires x11-base/xorg-server, x11-base/xorg-server:0/21.1.4=, >=x11-base/xorg-server-1.20[xorg], x11-base/xorg-server:=
    x11-drivers/xf86-video-nouveau-1.0.17 requires x11-base/xorg-server[-minimal], x11-base/xorg-server:0/21.1.4=, x11-base/xorg-server:=, >=x11-base/xorg-server-1.20[xorg]
    x11-drivers/xf86-video-vesa-2.5.0 requires x11-base/xorg-server:0/21.1.4=, >=x11-base/xorg-server-1.20[xorg], x11-base/xorg-server:=, >=x11-base/xorg-server-1.6

>>> No packages selected for removal by depclean
Packages installed:   1031
Packages in world:    252
Packages in system:   43
Required packages:    1031
Number to remove:     0
root@localhost /home/guyuming #
Back to top
View user's profile Send private message
axl
Veteran
Veteran


Joined: 11 Oct 2002
Posts: 1146
Location: Romania

PostPosted: Fri Nov 18, 2022 1:52 am    Post subject: Reply with quote

Uhm, I think when he unpacked a stage 3, world file was overwrited. So now, there's a tone of dangling packages that are not part of world and should be depcleaned. Also, probably @system is consistent, but @world isn't. We can also prolly assume make.conf lost a bunch of USE flags.

First thing first. I think you should start with trying to restore USE flags as close to the original as possible.

Second thing, should work to repopulate world file. You do not need to add every other dependency, but the big things have to be in world. For instance, you do not need to add xorg-drivers, and every other driver, or X for that matter, but you do prolly need to add at least the window managers you used. Something like gnome, or kde-meta or whatever you use, will prolly be enough. So what I would do is "emerge --depclean --pretend", and start selecting from there, the big things. The things that were in @world before. It will take to run the same thing a few times, and then just add them with a text editor in world file. You don't actually need to compile them, just add them. For now.

Third, update. There could be inconsistencies. Dependencies broken at the level of @world (not system). Meaning gcc/glibc/binutils all came from stage3, and are ok with each other, but that doesn't mean one of the binaries from @world isn't dependent on a newer glibc for instance and it's broken atm. So after you are happy with a relatively large enough world file, you should do emerge -NuavD --with-bdeps=y @world. Let that finish.

And then to finish, revdep-rebuild should find those packages that are still broken and that have inconsistencies, and then to top it all off, you could do equery k \* (equery is part of gentoolkit) which should tell you which packages have changed files since they were installed.

That's what I would do.
Back to top
View user's profile Send private message
Genone
Retired Dev
Retired Dev


Joined: 14 Mar 2003
Posts: 9621
Location: beyond the rim

PostPosted: Fri Nov 18, 2022 9:49 am    Post subject: Reply with quote

guyuming wrote:
If i depclean xorg-server alone, it is not said to be removed. Then, why depclean would remove the 23 packages above?

Answer is pretty obvious if you check the output: depclean would remove all listed packages depending on xorg-server, which isn't the case if you run depclean just for xorg-server.

Quote:
How can i prevent them from been removed inadvertently? Is it any flaw in the query that made them into the /tmp/WorldDeselect file which actually they should be in /tmp/WorldStay?

Check the actual output of the queries involved for the packages in question? Testing for non-empty command output isn't the most reliable check in general.
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3477

PostPosted: Fri Nov 18, 2022 4:50 pm    Post subject: Reply with quote

Quote:
Uhm, I think when he unpacked a stage 3, world file was overwrited.
O_o, I was pretty sure world wasn't in the stage3 tarbal, yet here we are.
Anyway.... You don't have any backups, do you?
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54691
Location: 56N 3W

PostPosted: Fri Nov 18, 2022 5:20 pm    Post subject: Reply with quote

guyuming,

xorg-drivers should be pulled in by your VIDEO_CARDS and INPUT_DEVICES in make.conf.

The entries there will decide which x11-drivers/xf86-video-* and x11-drivers/xf86-input-* will be retained.
If you don't know what x11-drivers/xf86-video-dummy is for, you don't need it.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
guyuming
Apprentice
Apprentice


Joined: 19 Nov 2020
Posts: 253

PostPosted: Sat Nov 19, 2022 1:04 am    Post subject: Reply with quote

@NeddySeagoon, thanks!

turned out my assumption that portage package is organized as DAG(directed acyclic graph) is NOT correct.

There are cycles in dependency.

for example, app-editors/emacs and app-editors/emacs depends on each other, so if i emerge --depclean any of them alone, it won't be removed. But if i emerge --depclean both of them in a single command, both will be removed.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 54691
Location: 56N 3W

PostPosted: Sat Nov 19, 2022 10:54 am    Post subject: Reply with quote

guyuming,

That's why portage complains about circular dependencies from time to time. :)
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum