Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Other Things Gentoo
  • Search

cleaning the world file (wiki) - check the script

Still need help with Gentoo, and your question doesn't fit in the above forums? Here is your last bastion of hope.
Post Reply
Advanced search
84 posts
  • 1
  • 2
  • 3
  • 4
  • Next
Author
Message
Mr. T.
Guru
Guru
Posts: 477
Joined: Mon Dec 26, 2016 4:19 pm

  • Quote

Post by Mr. T. » Fri Jan 05, 2018 6:46 pm

The script checkworldfile seems weird. Normally, the first test mentions if the package is a dependency for other packages so the second test is useless.

Code: Select all

#!/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'
                else
                        echo $i' can be deselected' 
                        echo $i >> /tmp/deselect
                fi
        fi 
done < /var/lib/portage/world
Yamakuzure wrote:There is a very big problem with trying to use qdepends like this: It lists all packages that depend on the package you check, but this includes packages that are *not* in your world file.
The package depends on another package that is a dependency of an installed package (indirect depedency). [post=7902404]I agree with khayyam![/post]
Top
Frautoincnam
Guru
Guru
Posts: 368
Joined: Fri May 19, 2017 5:16 am

  • Quote

Post by Frautoincnam » Fri Jan 05, 2018 9:17 pm

Code: Select all

checking app-editors/vim
app-editors/vim can be deselected

# emerge --deselect vim
>>> Removing app-editors/vim from "world" favorites file...
# emerge --depclean -a

 * 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:

 dev-python/docutils
    selected: 0.13.1 
   protected: none 
     omitted: none 

 dev-python/pygments
    selected: 2.2.0 
   protected: none 
     omitted: none 

 app-vim/gentoo-syntax
    selected: 20170225 
   protected: none 
     omitted: none 


!!! 'app-editors/vim' (virtual/editor) is part of your system profile.
!!! Unmerging it may be damaging to your system.


 app-editors/vim
    selected: 8.0.1298 
   protected: none 
     omitted: none 

 app-eselect/eselect-vi
    selected: 1.1.9 
   protected: none 
     omitted: none 

 app-editors/vim-core
    selected: 8.0.1298 
   protected: none 
     omitted: none 

 dev-util/ctags
    selected: 20161028 
   protected: none 
     omitted: none 

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

All selected packages: =dev-python/docutils-0.13.1 =app-eselect/eselect-ctags-1.18 =dev-util/ctags-20161028 =app-vim/gentoo-syntax-20170225 =app-editors/vim-8.0.1298 =dev-python/pygments-2.2.0 =app-eselect/eselect-vi-1.1.9 =app-editors/vim-core-8.0.1298

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

Would you like to unmerge these packages? [Yes/No] no

Quitting.

Packages installed:   669
Packages in world:    112
Packages in system:   43
Required packages:    661
Number to remove:     8

 * IMPORTANT: 4 news items need reading for repository 'gentoo'.
 * Use eselect news read to view new items.

# emerge --noreplace vim

 * IMPORTANT: 4 news items need reading for repository 'gentoo'.
 * Use eselect news read to view new items.

Calculating dependencies... done!
>>> Recording app-editors/vim in "world" favorites file...
>>> Auto-cleaning packages...

>>> No outdated packages were found on your system.
# emerge --depclean -a

 * 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!
>>> No packages selected for removal by depclean
>>> To see reverse dependencies, use --verbose
Packages installed:   669
Packages in world:    113
Packages in system:   43
Required packages:    669
Number removed:       0
Top
charles17
Advocate
Advocate
Posts: 3686
Joined: Sun Mar 02, 2008 3:20 pm

  • Quote

Post by charles17 » Thu Jan 11, 2018 12:40 pm

helecho,
Please post here your modified complete proposal. So we can cross check.
Top
Mr. T.
Guru
Guru
Posts: 477
Joined: Mon Dec 26, 2016 4:19 pm

cleaning the world file (wiki) - check the script

  • Quote

Post by Mr. T. » Thu Jan 11, 2018 12:52 pm

The script seems odd.

Code: Select all

#!/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'
                else
                        echo $i' can be deselected' 
                        echo $i >> /tmp/deselect
                fi
        fi 
done < /var/lib/portage/world
Could someone explain how does it work?
Top
charles17
Advocate
Advocate
Posts: 3686
Joined: Sun Mar 02, 2008 3:20 pm

Re: cleaning the world file (wiki) - check the script

  • Quote

Post by charles17 » Thu Jan 11, 2018 12:57 pm

helecho wrote:Could someone explain how does it work?
Doesn't it work for you? What output is it giving you?
Top
khayyam
Watchman
Watchman
User avatar
Posts: 6227
Joined: Thu Jun 07, 2012 2:45 am
Location: Room 101

Re: cleaning the world file (wiki) - check the script

  • Quote

Post by khayyam » Thu Jan 11, 2018 1:08 pm

helecho wrote:Could someone explain how does it work?
helecho ... the 'while' loop reads in /var/lib/portage/world asigning each line the variable 'i', each 'i', or package, is then queried for reverse dependencies, if that test is non-zero, then a '--pretend --depclean' is done, if that returns non-zero nothing is done, if zero then write the $i to /tmp/deselect.

best ... khay
Top
Naib
Watchman
Watchman
User avatar
Posts: 6101
Joined: Fri May 21, 2004 9:42 pm
Location: Removed by Neddy
Contact:
Contact Naib
Website

  • Quote

Post by Naib » Thu Jan 11, 2018 1:17 pm

It reads every line of the world file and checks if anything depends on it.
Ideally only user requested packaged reside in the world file
#define HelloWorld int
#define Int main()
#define Return printf
#define Print return
#include <stdio>
HelloWorld Int {
Return("Hello, world!\n");
Print 0;
Top
Mr. T.
Guru
Guru
Posts: 477
Joined: Mon Dec 26, 2016 4:19 pm

  • Quote

Post by Mr. T. » Thu Jan 11, 2018 2:00 pm

The script does not work.

Code: Select all

user $ emerge app-arch/upx-ucl
[ebuild  N    ] dev-libs/ucl-1.03-r1  USE="-static-libs" 
[ebuild  N    ] app-arch/upx-ucl-3.91  USE="zlib -lzma"
# Currently, there aren't obligatory dependencies in my world file.
user $ ./checkworldfile
# I put the dev-libs/ucl dependency in the world file
user $ emerge --noreplace dev-libs/ucl
# checkworlfile detects the dependency is needed
user $ ./checkworldfile
checking dev-libs/ucl
dev-libs/ucl needs to stay in @world
# The package that pulled the dependency is uninstalled.
user $ emerge --unmerge app-arch/upx-ucl
# The package dev-libs/ucl isn't a dependency but the script does not detect it.
user $ ./checkworldfile
helecho.
Top
Mr. T.
Guru
Guru
Posts: 477
Joined: Mon Dec 26, 2016 4:19 pm

  • Quote

Post by Mr. T. » Thu Jan 11, 2018 2:11 pm

A package installed by a user may become a dependency after installing another package.

charles17, qdepends -Q only displays build time dependencies. qdepends -aQ displays build, runtime and "post" dependencies.

I think I do not misunderstand the function of the script by reading Naib's post and khayyam's post.
Top
krinn
Watchman
Watchman
User avatar
Posts: 7476
Joined: Fri May 02, 2003 6:14 am

  • Quote

Post by krinn » Thu Jan 11, 2018 3:42 pm

You misunderstood it :)

Code: Select all

if [ -n "$(qdepends -Q $i)" ]; then \ 
That's the key part you miss, this check if a package in world has a reverse dependency
Why, because you don't need to try guessing what will be result of depclean on a package that nobody use, it's a condition for depclean.

When you remove app-arch/upx-ucl from your system, you end with dev-libs/ucl no more use by anybody, as such the only logic there is: keep it in world or depclean will catch it.

The problem with this script is that to make you happy, it should have an "else" condition to the qdepends check, that just say "keep it".

And the logic is :
-> check if pck-A have a reverse dep
---> no, no more test need, you already know you must keep it in world, else it's a candidate for depclean (and it's there the script miss a "you must keep it" output)
---> yes? ok, pck-B use it, but does pck-B really need it? (which in real is not checking if pck-B need it, but just see if depclean will agree to remove pck-A
----------> yes, it really need it, so depclean will refuse to remove it -> tell user it could remove pck-A from world because pck-B (in real, you don't who protect it, just that it is protect from depclean) protect it
----------> no, pck-B could use pck-C if pck-A is not there -> tell user to keep pck-A in world, else depclean will remove it because pck-B will be happy with pck-C instead. (again in real you have clue who is ok with that, just that depclean is ok to remove pck-A)

And on your test case, when you do --unmerge app-arch/upx-ucl you are making dev-libs/ucl no more use by anyone as it was only that package that use it in your test case.
The qdepends test fail: dev-libs/ucl is not use by anyone, test end here because you already know you must keep it in world, or depclean will catch it.
Top
Mr. T.
Guru
Guru
Posts: 477
Joined: Mon Dec 26, 2016 4:19 pm

  • Quote

Post by Mr. T. » Thu Jan 11, 2018 4:10 pm

krinn, the goal is rather to remove some dependencies placed in the world file. Thus, potential blockages are reduced.
Top
charles17
Advocate
Advocate
Posts: 3686
Joined: Sun Mar 02, 2008 3:20 pm

  • Quote

Post by charles17 » Thu Jan 11, 2018 4:53 pm

helecho wrote:krinn, the goal is rather to remove some dependencies placed in the world file. ....
... and to keep packages added intentionally. How else should I do with e.g. media-sound/mpg123?

Code: Select all

$ qdepends -aQ media-sound/mpg123
 * DEPEND
app-eselect/eselect-mpg123-0.1
 * RDEPEND
app-eselect/eselect-mpg123-0.1
 * PDEPEND
So app-eselect/eselect-mpg123 needs it. But --depclean would like to remove it if not registered in @world:

Code: Select all

$ emerge -pvc  media-sound/mpg123

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

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

 media-sound/mpg123
    selected: 1.25.6 
   protected: none 
     omitted: none 

All selected packages: =media-sound/mpg123-1.25.6

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

Packages installed:   900
Packages in world:    97
Packages in system:   43
Required packages:    899
Number to remove:     1
Top
Mr. T.
Guru
Guru
Posts: 477
Joined: Mon Dec 26, 2016 4:19 pm

  • Quote

Post by Mr. T. » Thu Jan 11, 2018 5:04 pm

charles17, emerge --depclean will remove it because it is an unneeded "dependency".

app-eselect/eselect-mpg-123 is a dependency of media-sound/mpg123.
app-eselect/eselect-mpg-123 Manage /usr/bin/mpg123 symlink
helecho.
Top
Mr. T.
Guru
Guru
Posts: 477
Joined: Mon Dec 26, 2016 4:19 pm

  • Quote

Post by Mr. T. » Thu Jan 11, 2018 5:23 pm

In fact, qdepends sometimes displays wrong dependencies (e.g. soft blockers, choice between various packages, etc.).

Anyway, these limitations must be circumvented.

If I remember correctly: qdepends -aQ tells that dev-lang/vala is a dependency of dev-libs/gobject-introspection although dev-lang/vala is not installed.

Code: Select all

user $ emerge -pv dev-lang/vala
[N] dev-lang/vala
[N] dev-libs/vala-common
user $ qdepends -aQ dev-lang/vala
dev-libs/gobject-introspection
P.S: I have done a test and I got a lot of false dependencies (more than one hundred). Nonetheless, I made an assumption that was not good to test qdepends.

I believe these limitation may be circumvented.

helecho.
Last edited by Mr. T. on Thu Jan 11, 2018 5:40 pm, edited 1 time in total.
Top
Jaglover
Watchman
Watchman
User avatar
Posts: 8291
Joined: Sun May 29, 2005 1:57 am
Location: Saint Amant, Acadiana

  • Quote

Post by Jaglover » Thu Jan 11, 2018 5:38 pm

I personally do not believe some script can decide for me what I want, thus my method is to look at world file and remove everything I haven't explicitly installed by hand. Over years I've learned to use always emerge -1 when troubleshooting, thanks to this my world files stay clean and do not require maintenance.
My Gentoo installation notes.
Please learn how to denote units correctly!
Top
Mr. T.
Guru
Guru
Posts: 477
Joined: Mon Dec 26, 2016 4:19 pm

  • Quote

Post by Mr. T. » Thu Jan 11, 2018 5:42 pm

charles17, you do not want to keep the package (media-sound/mpg123) because it does not depend on another one. In fact, qdepends displays wrong information.

media-sound/mpg123 is a soft blocker and so appears in the RDEPEND variable (look at the app-eselect/eselect-mpg123 ebuild).
Top
charles17
Advocate
Advocate
Posts: 3686
Joined: Sun Mar 02, 2008 3:20 pm

  • Quote

Post by charles17 » Thu Jan 11, 2018 5:51 pm

helecho wrote:charles17, you do not want to keep the package (media-sound/mpg123) because it does not depend on another one.
I am using it, so I'll keep it.

You now understand the checkworldfile script?

Code: Select all

$ while read i ; do qdepends -Q $i; done < /var/lib/portage/world
app-arch/xz-utils-5.2.3
net-misc/dhcpcd-ui-9999
app-office/lyx-2.2.3-r1
app-office/texmacs-1.99.2-r1
app-eselect/eselect-mpg123-0.1
sys-apps/i2c-tools-3.1.1-r1
And I want to keep all of them!
Top
Mr. T.
Guru
Guru
Posts: 477
Joined: Mon Dec 26, 2016 4:19 pm

  • Quote

Post by Mr. T. » Thu Jan 11, 2018 5:58 pm

charles17, the script displays information about what package(s) may be "safely" removed.
Top
krinn
Watchman
Watchman
User avatar
Posts: 7476
Joined: Fri May 02, 2003 6:14 am

  • Quote

Post by krinn » Thu Jan 11, 2018 6:00 pm

It's not a false dependency, first because it's a reverse dependency and second because that reverse dep exists, even if its existence is conditional.

pckA need pckB if use="this"
checking -Q pckA you will get
pckB (with may be true or not depending on "this"/"-this")

because even pckA is not install, pckB will be its reverse dependency if you install it.
but this may not be true once it is install, only if user has set USE="this" with pckB.
and the idea is just a quick lookup, if qdepends tells a reverse deps is on pckA, it might not be "real" if the conditional is not met, and depclean test will answer this.
but if qdepends tells "nobody need it", then you take the shortcut with "none use it, i must keep it safe in world", because you are certain depclean will remove it.

I think you've put too much hope on this script: the script have no idea if vlc is a package you have add in world to use vlc ; but it check if vlc is use by someone else, and if it is, it will suggest : "bah, no need for vlc in world, someone protect it from depclean".
I'm taking vlc, because the script suggest i could remove vlc from world, because it have reverse dep to media-plugins/npapi-vlc-2.0.0, when for me, i care about vlc, and don't care about npapi, i use vlc, so i use npapi because i have vlc, but in real, npapi is just there because i could, while i have no real need of that.
but it's true that if i remove vlc from world, it will remains protect from depclean (lol for me, rock solid protect as i don't use depclean that much) ; but this only as long as that npapi is set (something i could removed anytime because i don't care about it).
and if you forget that: you'll end with npapi remove because you don't care about it, and vlc is now candidate for depclean (which is sole protection that it was in world has been removed if you have follow the script advise).
Top
John R. Graham
Administrator
Administrator
User avatar
Posts: 10898
Joined: Tue Mar 08, 2005 3:39 pm
Location: Somewhere over Winder, Georgia, USA

  • Quote

Post by John R. Graham » Thu Jan 11, 2018 6:15 pm

helecho wrote:charles17, the script displays information about what package(s) may be "safely" removed.
Well, not exactly. "Safely deselected" would be more accurate. But it's more nuanced than that (as per krinn).

- John
I can confirm that I have received between 0 and 499 National Security Letters.
Top
charles17
Advocate
Advocate
Posts: 3686
Joined: Sun Mar 02, 2008 3:20 pm

  • Quote

Post by charles17 » Thu Jan 11, 2018 6:26 pm

John R. Graham wrote:Well, not exactly. "Safely deselected" would be more accurate. ...
And still wrong. Those are packages I am using. If I deselect them, --depclean would remove them.
Top
Mr. T.
Guru
Guru
Posts: 477
Joined: Mon Dec 26, 2016 4:19 pm

  • Quote

Post by Mr. T. » Thu Jan 11, 2018 6:26 pm

krinn, the script should display information. qdepends only displays information about installed packages, otherwise, the software would fail.
Top
Mr. T.
Guru
Guru
Posts: 477
Joined: Mon Dec 26, 2016 4:19 pm

  • Quote

Post by Mr. T. » Thu Jan 11, 2018 6:30 pm

The script does not know if a package is a dependency or if a package is required by a user. Anyway, it displays packages that may be "safely" removed.

Thus, it is easy (using the script) to know if a package can be removed.
Top
charles17
Advocate
Advocate
Posts: 3686
Joined: Sun Mar 02, 2008 3:20 pm

  • Quote

Post by charles17 » Thu Jan 11, 2018 6:36 pm

helecho,

If it makes you happy, go and remove the Keep it clean section from the https://wiki.gentoo.org/wiki/World_set_%28Portage%29 article.
For me it does what I want and I'll keep that script.

ok?
Top
Mr. T.
Guru
Guru
Posts: 477
Joined: Mon Dec 26, 2016 4:19 pm

  • Quote

Post by Mr. T. » Thu Jan 11, 2018 6:44 pm

Your script does not seem correct.
krinn wrote:I'm taking vlc, because the script suggest i could remove vlc from world, because it have reverse dep to media-plugins/npapi-vlc-2.0.0
helecho.
Last edited by Mr. T. on Thu Jan 11, 2018 6:44 pm, edited 1 time in total.
Top
Post Reply

84 posts
  • 1
  • 2
  • 3
  • 4
  • Next

Return to “Other Things Gentoo”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic