how to completely remove <app> after apt-get install <app>;apt-get source <app>;apt-get build-dep <app>

Asked by Charlie Shaw

 I have read quit a few of the other posts here & other forums re use of apt-get, and understand that:

i. if I only install an application binary, that binary as well as the package is removed by apt-get remove <app>

ii. if that application had dependencies on other packages that were also therefore automatically installed, the orphaned dependency packages can be removed with apt-get autoremove.

iii. if I install the application sources, and sources of the dependency packages with apt-get source <app>; apt-get build-dep <app>, then neither i. or ii. above apply; the apt-get [auto]remove only removes the package reference(s) in the local apt data base & maybe the actual .deb file(s).uer

This seems to be happening on a Lubuntu 12.10 system; source and executable files are left behind; and dpkg-query -S <left_over_file> reveals that it is not 'owned' by any package known to dpkg.

Easy enough to delete the 'top level' application files, as they are all in a convenient directory of the user who installed the package sources initially ..

QUESTION is; how about all the header files etc related to the dependency packages that seem to be left in /usr/include ?

Is the only way to make a note of the dependent packages at install time, then look for corresponding directories in /usr/include; verify with dpkg-query -S that they are not 'owned' by any other still-installed package, and delete manually ??

thanks..

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
N1ck 7h0m4d4k15
Solved:
Last query:
Last reply:
Revision history for this message
Jeet (gour-jitendrasingh) said :
#1

Best :

sudo apt-get --purge remove <package name>

sudo apt-get --purge autoremove <package name > (if you want to delete their systemwide configuration files too)

Revision history for this message
Best N1ck 7h0m4d4k15 (nicktux) said :
#2

Well , the

apt-get build-dep

command downloads and installs all the dependencies of a package , if you want to build it. There is not exist a command that will revert the exact installation of these dependencies.

What I do ? , I just copy and paste to a txt document all the dependency packages and when I finish (or I fail) with the building , then I remove them (just a copy-paste again).

Now a tricky - hack command maybe helps you to delete the dependencies which installed with build-dep. Try it

First you need to install aptitude

sudo apt-get install aptitude

Then run the command below (is ONE command)

sudo aptitude markauto $(apt-cache showsrc PACKAGE_NAME | grep Build-Depends | perl -p -e 's/(?:[\[(].+?[\])]|Build-Depends:|,|\|)//g')

Where PACKAGE_NAME replace it with the package you used to install the dependencies. (in apt-get build-dep PACKAGE_NAME).

Of course for the SOURCE (apt-get source) you can just delete the folder (or files) and you are OK.

And for apt-get install , use

sudo apt-get purge PACKAGE_NAME

to remove the package and its configuration files.

Thank you.

Revision history for this message
Charlie Shaw (n2924-dotcom) said :
#3

Thanks NikTh, that solved my question.

Revision history for this message
Charlie Shaw (n2924-dotcom) said :
#4

Additional comments to the auto-comment above:

- that is no 'hack' command, it is a great example of the power of complex Linux compound commands..

- I understand this works and will not 'break' other installed BINARIES provided that none of the Build-Depends packages are required by those binaries.

- I also understand that the package management applications know 'nothing' about additional files that are generated by the application build process; in this particular case (building cheese), a load of files are left in /usr/local/ .
           BUT these can be easily identified by the file date (if you take note of when you last built the app); and if you accidentally delete a wrong file, this will only 'break' the build process of other source packages (ie not affect system operation as far as installed binaries are concerned).