Repair auto-installed state of packages

If none of the more specific forums is the right place to ask

Repair auto-installed state of packages

Postby TaaTT4 » 2018-01-22 18:34

I need to fix package dependencies of a system of which I became administrator.
The former sysadmin has broken many of the auto-installed relationships between packages for apparently no reason.

I want to automate (with a script) the repair process as much as possible.
The idea is to build a list of the installed packages which are dependency (because recommended or dependent/pre-dependent) of another package.
Subsequently, calling aptitude markauto on every package of the list should bring back the system to a saner configuration.

A command to retrieve the dependent packages is:
Code: Select all
aptitude search '~i !~M !~E (~Rpredepends:~i | ~Rdepends:~i | ~Rrecommends:~i)'

Unfortunately, this doesn't take in account recursive dependencies (e.g. apport Depends python3-apport, but python3-apport recommends apport).
How can I intercept this loop and exclude those packages from the list?


Thanks,
Raffaele.
TaaTT4
 
Posts: 2
Joined: 2018-01-22 13:56

Re: Repair auto-installed state of packages

Postby bw123 » 2018-01-22 20:55

TaaTT4 wrote:I need to fix package dependencies of a system of which I became administrator. The former sysadmin has broken many of the auto-installed relationships between packages for apparently no reason.


It's really not that hard to break this functionality. I have had to repair mine several times on different installs. Using dpkg -i with several packages, removing/purging specific pkgs and I know not what else can get them out of whack.

I like your idea, but I haven't found an easy way to do it. I usually use aptitude-curses and fix them the way I want. I don't like recommends marked auto, but that's just my preference. I don't like 'required' priority marked auto either. Also, I don't consider pkgs that 'provide' a virtual pkg as automatic because that was a choice.

I usually open the pkgs listed in aptitude one-by-one and 'M' on the depends list. Yeah, it takes a long time, I hope you can get me a script working that is an awesome idea.

Be sure and search the forum, there are some members on here that are real geniuses with apt/aptitude. There may be some help in older posts.

Good Luck!
User avatar
bw123
 
Posts: 3265
Joined: 2011-05-09 06:02
Location: TN_USA

Re: Repair auto-installed state of packages

Postby TaaTT4 » 2018-01-22 22:36

bw123 wrote:I usually open the pkgs listed in aptitude one-by-one and 'M' on the depends list. Yeah, it takes a long time, I hope you can get me a script working that is an awesome idea.

Yes, I could do it by hand, but there are over 1000 packages installed and just about 300 are marked as auto.
It would be a long, tedious and error prone task.

bw123 wrote:Be sure and search the forum, there are some members on here that are real geniuses with apt/aptitude. There may be some help in older posts.

I looked before posting (both in Debian forum and with Google), but I haven't find anything useful :(
TaaTT4
 
Posts: 2
Joined: 2018-01-22 13:56

Re: Repair auto-installed state of packages

Postby bw123 » 2018-01-22 22:51

TaaTT4 wrote:Yes, I could do it by hand, but there are over 1000 packages installed and just about 300 are marked as auto.
It would be a long, tedious and error prone task.


Well, I just did it last month on 1875 pkgs that all were marked manual. It took me about 3 martinis and by the third one I was ready to take a nap.. It really wasn't that bad. A couple or four hours... even if you had a script, I'd probably want to go back in and check them all anyway.


oh yeah, btw have you seen this /var/log/apt/eipp.log.xz file? I have been wondering what the heck it is. It lists a lot of depends and conflicts for installed pkgs. A List like that might be helpful...
User avatar
bw123
 
Posts: 3265
Joined: 2011-05-09 06:02
Location: TN_USA

Re: Repair auto-installed state of packages

Postby dryden » 2018-02-09 14:49

I don't know if this is useful, but this shows all packages that have no packages that depend on them:

Code: Select all
dpkg -l | grep ^ii | awk '{print $2}' | while read p; do [ $(apt-rdepends -r $p -f Depends,Recommends --state-follow=Installed --state-show=Installed 2> /dev/null | wc -l) -eq 1 ] && echo $p; done


Note: if something was installed using a meta-package, and then the meta-package was removed, this list might show those items.
dryden
 
Posts: 80
Joined: 2015-02-04 08:54

Re: Repair auto-installed state of packages

Postby emariz » 2018-03-03 23:27

The former administrator might have faced a situation were he used the 'Keep All' command when after removing a meta-package or updating/removing a core package.

First, let us make sure that the system is in a 'correct' state.
Code: Select all
cat /etc/apt/sources.list
apt-cache policy

dpkg --audit

aptitude --simulate -f install
aptitude --simulate full-upgrade


Assuming everything there seems right, within Aptitude's graphic interface, select 'Limit view' (press lowercase L) and try these patterns:

- On a 'finished' system (i.e. that is not in the building process), all Libraries of priority Optional should be flagged as 'Automatically installed' even if they are not (it is a limitation of the Debian Installer.) So, use this pattern and flag them all at once (press uppercase M on them.)

Code: Select all
?installed ?priority(optional) ?section(lib)


- List the installed packages that are not already flagged as 'Automatically installed' and are also reverse dependencies ('hard' ones or recommendations) of other installed packages.
One can ignore packages with priorities Required or Important, since they all should be flagged as 'Manually installed' anyway.

Code: Select all
?installed ?not(?automatic) ?not(?priority(required)) ?not(?priority(important)) ?reverse-depends(?installed)

Code: Select all
?installed ?not(?automatic) ?not(?priority(required)) ?not(?priority(important)) ?reverse-recommends(?installed)


You still need to check the listed packages, but this should provide you with some leads.

Once the dependency chains of the system are tidier, deborphan (orphaner) will ease you list the remaining orphan packages.

This message might help you too viewtopic.php?p=499596#p499596
emariz
 
Posts: 2904
Joined: 2008-10-17 07:59


Return to General Questions

Who is online

Users browsing this forum: wizard10000 and 11 guests

fashionable