C'è un modo per verificare manualmente quali pacchetti extra verranno rimossi?


8

Ad esempio, supponiamo che provi a rimuovere "libopenshot11", ottengo:

The following packages will be REMOVED:
  libopenshot11 openshot-qt python3-openshot

Come posso scoprirlo senza eseguire prima apt apt remove?


apt-get remove libopenshot11 -s
grooveplex

Risposte:


11

L' API APT Python può essere utilizzata per scrivere uno script breve per questo:

#! /usr/bin/python3
import sys
from apt import cache

c = cache.Cache()
for pkg in sys.argv[1:]:
    c[pkg].mark_delete()   

print('\n'.join(pkg.name for pkg in c.get_changes() if pkg.marked_delete))

Esempio:

$ apt-get remove -s bash | grep Remv  
Remv winusb [1.0.11+saucy1]
Remv gdm [3.18.3-0ubuntu2]
Remv gdm3 [3.18.3-0ubuntu2]
Remv bash [4.3-14ubuntu1.2] [inxi:amd64 lightdm:amd64 bash-completion:amd64 ]
Remv bash-completion [1:2.1-4.2ubuntu1.1] [inxi:amd64 lightdm:amd64 ]
Remv inxi [2.2.35-0ubuntu1] [lightdm:amd64 ]
Remv lightdm [1.18.3-0ubuntu1.1]

$ apt-cache rdepends bash --installed | sed '1,2d' | sort -u
  bash-completion
    bash:i386
  gdm3
  inxi
  lightdm
  winusb

$ ./check.py bash                                             
inxi
winusb
gdm
gdm3
bash
lightdm
bash-completion

La soluzione Python è molto pulita. Grazie!
answerSeeker,

19

Puoi usare l' opzione --simulateo -s, che ti mostrerà cosa farà APT quando eseguirai un comando senza fare nulla, ad esempio ...

$ sudo apt remove -s file
Reading package lists... Done
Building dependency tree        
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libfile-stripnondeterminism-perl libltdl-dev libmail-sendmail-perl libsys-hostname-long-perl po-debconf
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED
  cracklib-runtime debhelper dh-autoreconf dh-strip-nondeterminism file gdebi gdebi-core libtool lintian ubuntu-standard
0 to upgrade, 0 to newly install, 10 to remove and 0 not to upgrade.
Remv cracklib-runtime [2.9.2-3]
Remv dh-autoreconf [13] [debhelper:amd64 ]
Remv debhelper [10.2.2ubuntu1] [dh-strip-nondeterminism:amd64 ]
Remv dh-strip-nondeterminism [0.032-1]
Remv gdebi [0.9.5.7+nmu1]
Remv gdebi-core [0.9.5.7+nmu1]
Remv ubuntu-standard [1.379]
Remv file [1:5.29-3] [lintian:amd64 libtool:amd64 ]
Remv libtool [2.4.6-2] [lintian:amd64 ]
Remv lintian [2.5.50.1]

Possiamo vedere che rimuovere il filepacchetto sarebbe una pessima idea ...


Chi ha pubblicato per primo tu o Alban?
NoOneIsHere

@NoOneIs: Eccomi di qualche secondo: /
Zanna,

OK, ho annullato entrambe le risposte perché la tua ha i dettagli di utilizzo e la sua (presumo) ha la pagina man, ma penso che le due risposte combinate siano migliori di quella accettata.
NoOneIsHere

@NoOneIsHere se Alban non avesse pubblicato avrei potuto aggiungere i dettagli della pagina man alla mia risposta. Penso che questa semplice soluzione abbia più probabilità di essere ciò che le persone useranno rispetto a quella accettata, ma accettare è la discrezione di OP, e la risposta di Muru è la classe avanzata :)
Zanna,

1
La maggior parte di questi pacchetti non è in realtà importante, anche se mi sono trovato in una situazione in cui la rimozione di Ubuntu standard fa impazzire un successivo autoremove.
Casuale 832,

13

L' opzione -so --simulateviene utilizzata per simulare qualsiasi attività APT senza eseguirla effettivamente.

Dalle manpage ufficiali :

 -s, --simulate, --just-print, --dry-run, --recon, --no-act
       No action; perform a simulation of events that would occur based on
       the current system state but do not actually change the system.
       Locking will be disabled (Debug::NoLocking) so the system state
       could change while apt-get is running. Simulations can also be
       executed by non-root users which might not have read access to all
       apt configuration distorting the simulation. A notice expressing
       this warning is also shown by default for non-root users
       (APT::Get::Show-User-Simulation-Note). Configuration Item:
       APT::Get::Simulate.
Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.