Friday, May 3, 2024
13
rated 0 times [  13] [ 0]  / answers: 1 / hits: 14486  / 3 Years ago, fri, september 24, 2021, 11:58:31

I have made a dpkg --clear-selections command and found that all my packages are selected for removal. As the man pages is saying




--clear-selections : Set the requested state of every non-essential package to deinstall.




and I later knew, If I do a sudo apt-get dselect-upgrade all packages will be removed.



I checked this question in Ask Ubuntu, and read the meaning of each various flags in dpkg -l command. There says, The first column shows "desired package state" or selection state and second column shows "current state".



Since, I have no dependency problem now, I want to set my selection state as the desired state in dpkg database. How can I do this?



I haven't given the output of dpkg -l because of large output. The output is all ri columns.



Also when I did the command sudo apt-get dselect-upgrade, it gave me this message,




......... After a long list of package names to be removed...
WARNING: The following essential packages will be removed.
This should NOT be done unless you know exactly what you are doing!
apt ubuntu-keyring (due to apt) libapt-pkg4.12 (due to apt) libstdc++6 (due
to apt) gnupg (due to apt) base-files bash
4 upgraded, 0 newly installed, 1764 to remove and 1 not upgraded.
Need to get 0 B/1,359 kB of archives.
After this operation, 3,078 MB disk space will be freed.
You are about to do something potentially harmful.
To continue type in the phrase 'Yes, do as I say!'
?]


Is there any way to reset the packages selection state to the current installed state?


More From » package-management

 Answers
5

Try this command to change package status -



echo "<package-name> <status>" | sudo dpkg --set-selections


Say you have set status of package zip to deinstall. To rollback to original status install run this command-



echo "zip install" | sudo dpkg --set-selections 


To change more packages at once use this command



dpkg --get-selections | sed -n 's/<<current-status>$/<status>/p' | sudo dpkg --set-selections


for example, to change all packages with status deinstall to install use -



dpkg --get-selections | sed -n 's/<deinstall$/install/p' | sudo dpkg --set-selections

[#36705] Sunday, September 26, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ingwhin

Total Points: 332
Total Questions: 112
Total Answers: 115

Location: Burkina Faso
Member since Tue, Apr 26, 2022
2 Years ago
;