Unninstall all packages on a system except seleted ones, possible?

16 risposte [Ultimo contenuto]
GNUser
Offline
Iscritto: 07/17/2013

So, in light of some recent talks about vrms and triquelize scripts and how they work and not on certain distros, I thought of something. Is it possible to create a script that will remove EVERYTHING in a system, except a list of pre-selected packages?
I am thinking like Lubuntu on ARM for example. You can't be sure that those images you have running around don't contain some extra non-free packages, some won't be detected by vrms, trisquelize or anything else. So, just have a script that removes all packages except a list of (free) packages that we allow to stay. We could also have the script reinstall the remaining packages from official sources (so we know they are indeed free). The kernel would be taken care of at a later point.

Is it possible? Never tried doing it, so... ?

hack and hack
Offline
Iscritto: 04/02/2015

I have no idea if it's possible.
Maybe something like "IF it's not in this rather big list of programs, THEN sudo apt-get autoremove them, and sudo apt-get clean in the end", or something like that.

Maybe that would be enough.

GNUser
Offline
Iscritto: 07/17/2013

HUm... yes. I think it would work. Wish I had a Ubuntu machine around to test it.
But your idea seems doable. I think it will hardly be the best way but it is doable. First I would have to get a list with ALL the packages in the system. And then run that part.
How can I get an entire list of all packages installed in the system?

hack and hack
Offline
Iscritto: 04/02/2015

Provided it's really complete, you can get it from Synaptic (props to Magic Banana): File > Save selection (or something similar), and that's about it.

Well there's some additional text on each line, so it could be cleaned with regular expressions, but I don't know how.

GNUser
Offline
Iscritto: 07/17/2013

As important as that, we would have to compile a "list" of acceptable packages. Hum... which we might not have to compile ourselves! We could just get the list of Debian/Ubuntu main repository (or maybe a copy of Trisquel repository) and take out every fucking thing that didn't belong to that list!

Yes, I think that could work! Get the full list of packages installed on the system, and run a test to see if each package is part of Trisquel repository. If it is, it just gets reinstalled (from a source available to the architecture we are working on) if it is not, it get totally purged from the system.

Does it seem like a way to free an image? Would it be acceptable in a security/privacy way?

hack and hack
Offline
Iscritto: 04/02/2015

Another way is to simply remove all the packages (i.e. make a minimal install instead), then simply put a selected list back in synaptics.

For example, first you take a standard Lubuntu. Then You save the synaptic file that you edit the way you want to. Alternatively, you can remove the packages you don't want on Synaptic, then you export the list.
From there, you make a minimal netinstall, apt-get install Synaptic, and reload the programs you want.

Much simpler.

Btw, why Lubuntu? You can just make a Trisquel minimal install, and add Lxde+other programs. Same thing, 100% libre.

GNUser
Offline
Iscritto: 07/17/2013

Because I intend to use this with pre-installed images on single board computers, use this with linux distros that are Debian based but might not work with the Trisquelize script, etc.

This is supposed to clean a system that you already have installed, for situations where you can't just install eveything from scratch yourself.

Of course, the best way is to install Trisquel :P

This way will also remove extra packages that might have been installed (even free ones) but are outdated because we just stopped updating the system every so often for example. The reinstallation will provide us with a 100% free system that is updated.

hack and hack
Offline
Iscritto: 04/02/2015

So the goal is to free an OS.
Or more like you don't want to reinstall from scratch.
If it's a full install, you can simply reinstall Trisquel without erasing /home (and backing it up just in case before). And then import a personal Synaptic list.
Fully free, fully personalized, all free, and your previous data is unchanged.

But freeing other Debian-based OS without reinstalling, I wonder if it's that simple.
You'd have at least to modify the software repo.
Plus you have the non-free software recommendations that could be a problem.
What I'm trying to say is that I have no idea if removing non-free programs is enough.

Magic Banana

I am a member!

I am a translator!

Offline
Iscritto: 07/24/2010

All the packages with "trisquel" in their version numbers were modified by the Trisquel project. Often because their Ubuntu counterparts recommend proprietary software.

GNUser
Offline
Iscritto: 07/17/2013

The non-free software recommendations are something I can live with, since I know better and will not fall for them. But of course, in the future we will need fully free repositories for ARM (or any other architecture). Maybe librepup will bring that (I remember reading that they intend to port to ARM).

I just need to make sure that the image has no programs running outside of an "official" source, and they are all free. That would make it dependable. "Trustable".

GNUser
Offline
Iscritto: 07/17/2013

Wait, and even better way to do it is:

get full list of Trisquel packages - List A;
get full list of installed packages List B;
use grep (or something) to remove from List B every package from List A (move those to List C);
purge all packages from new List B;
reinstall all packages from List C from official sources.

What does it look like?

hack and hack
Offline
Iscritto: 04/02/2015

I like it, I don't know how to do it, but it sounds like a great way to get the perfect Synaptic list.

But it's weird to erase everything to load just what you want after. It seems doable ,though.

GNUser
Offline
Iscritto: 07/17/2013

I don't want to remove everything, just the non-free packages. The free packages are just reinstalled.
I think actually that if we remove everything the system just stops working :-P

It could be a decent alternative to the trisquelize script (safer for removing extra non-free packages), and provide a way to free images for single board computers for example.

Magic Banana

I am a member!

I am a translator!

Offline
Iscritto: 07/24/2010

It is a work for 'comm', not 'grep'.

antiesnob
Offline
Iscritto: 08/22/2013

I don't see comm working here. Also, sort | uniq

Both will have problems. See the other post.

GNUser
Offline
Iscritto: 07/17/2013

Are fonts also "installed" or do they just get copied to a certain folder and that's it? We would need to address that problem separately.

antiesnob
Offline
Iscritto: 08/22/2013

I don't see how could it work!!

Imagine this:

super-program-v1.0
Added to list1!!

super-progra-v2.0
Added to list2!!

----------------

super-program-v1.0
Added to list1!!

program-super-v2.0
Added to list2!!

(name of package changed thru versions)

Those doesn't match so you have no package in the end. Or vice-versa, you only accept those not matching the trisquel list and remove them. That's sounds good but there might be references to those removed packages. Sorry, this explanation was tricky I think.