You are not logged in.

#1 2012-07-18 00:26:28

Duca
Member
Registered: 2009-01-12
Posts: 23

archrefresh - cleans out your arch installation leaving only core pkgs

Hi all, i finished rewriting archrefresh which is a tool to uninstall all your packages except those belonging to core and libfetch which is required by pacman to work.

The code can be found here and only works on python2 for now.

Run it as root:

#python2 archrefresh.py options
-v    verbose mode
-h    help message

As usual, comments, patches and constructive cricticism are welcome.

EDIT: replaced pacman2 for python2 smile

Last edited by Duca (2012-07-18 06:05:45)

Offline

#2 2012-07-18 00:36:27

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: archrefresh - cleans out your arch installation leaving only core pkgs

I probably read this wrong, but it only runs on pacman 2?


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2012-07-18 01:15:04

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Re: archrefresh - cleans out your arch installation leaving only core pkgs

s/pacman2/python2/ ?


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#4 2012-07-18 01:17:18

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: archrefresh - cleans out your arch installation leaving only core pkgs

Xyne wrote:

s/pacman2/python2/ ?

That makes a lot more sense smile


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2012-07-18 02:26:45

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: archrefresh - cleans out your arch installation leaving only core pkgs

Wouldn't

# pacman -Rs $(comm -23 <(pacman -Qeq | sort) <((for i in $(pacman -Sl core | grep installed | cut -d ' ' -f 2); do pactree -ul $i; done) | sort -u | cut -d ' ' -f 1))

do the same?
It removes all explicitly installed packages and their dependencies but keeps the packages that are currently in the core repo and their dependencies.
I think.


Edit: libfetch is gone

Last edited by karol (2012-07-18 02:29:11)

Offline

#6 2012-07-18 03:37:17

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: archrefresh - cleans out your arch installation leaving only core pkgs

Awfully lengthy... Assuming we're doing our job and staying on top of the repo hierarchy rules...

$ pacman -Qq | grep -vxFf <(pacman -Slq core) | pacman -R -

Offline

#7 2012-07-18 03:53:51

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: archrefresh - cleans out your arch installation leaving only core pkgs

I did try similar shorter ones, but I always get the same error

$ pacman -Qq | grep -vxFf <(pacman -Slq core) | pacman -R -
checking dependencies...
error: failed to prepare transaction (could not satisfy dependencies)
:: logrotate: requires cron

I use dcron :-)

Last edited by karol (2012-07-18 03:55:01)

Offline

#8 2012-07-18 04:01:40

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,965
Website

Re: archrefresh - cleans out your arch installation leaving only core pkgs

karol wrote:

I did try similar shorter ones, but I always get the same error

$ pacman -Qq | grep -vxFf <(pacman -Slq core) | pacman -R -
checking dependencies...
error: failed to prepare transaction (could not satisfy dependencies)
:: logrotate: requires cron

I use dcron :-)

pacman -Qq | grep -vxFf <(pacman -Slq core) | pacman -Ru -

My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#9 2012-07-18 04:08:04

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: archrefresh - cleans out your arch installation leaving only core pkgs

Heh, seems I was lazy the wrong way and I should have thought for a second instead of just modifying a pacman tip from the wiki.

Offline

#10 2012-07-18 06:15:06

Duca
Member
Registered: 2009-01-12
Posts: 23

Re: archrefresh - cleans out your arch installation leaving only core pkgs

Thanks for pointing me to the pacman2 error.

Thanks also for the bash alternatives and i'll write them down. I experimented with one of them already but still felt like coding for learning reasons (and most of the work was reused from another project).

Offline

#11 2012-07-18 13:18:24

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: archrefresh - cleans out your arch installation leaving only core pkgs

Ooh, were you influenced to write this by the ridiculous experience I recently wrote about on my blog? big_smile

The Arch Linux wiki wrote:

If it is ever necessary to remove all packages except the base group, try this one liner:

The Arch Linux wiki entry doesn't instill the best of confidence... hmm

Offline

#12 2012-07-18 16:53:45

Duca
Member
Registered: 2009-01-12
Posts: 23

Re: archrefresh - cleans out your arch installation leaving only core pkgs

Nice entry and it's funny we used the same word - refresh!

But no, my first time was someday back in 2011 before i made my first commit to bitbucket. I felt i ended up keeping more packages than i would feel comfortable with and started to code. At that time i didnt consider commenting out the other repos and wipe foreign packages as you did, perhaps if i have had the same idea as you i would have not coded anything at all.

I was working on a project which required to save as much space as i could (we had an upper limit and no extra work was needed to shrink further) and that tool helped me. I was still learning OOP and never issued commands from a program and parsed their results because most of my work was number crunching in fortran, so writing archrefresh seemed a nice idea.

Offline

#13 2012-07-19 03:24:49

Anonymo
Member
Registered: 2005-04-07
Posts: 427
Website

Re: archrefresh - cleans out your arch installation leaving only core pkgs

Does it remove itself?

Offline

#14 2012-07-19 06:45:47

Duca
Member
Registered: 2009-01-12
Posts: 23

Re: archrefresh - cleans out your arch installation leaving only core pkgs

in some sense it does for it uninstalls python2

Offline

Board footer

Powered by FluxBB