You are not logged in.

#1 2008-09-28 23:30:07

solarwind
Member
From: Toronto
Registered: 2008-03-18
Posts: 546

Reinstalling All Packages

Hey all,

Let's say I messed up permissions and things for all my files and libraries. What's the best way to purge and reinstall every installed package so as to get more or less of a clean install? I basically want to reinstall without reinstalling. I can't uninstall packages manually and then reinstall them since that would eventually leave the system in an unusable state ex: when the glibc package gets uninstalled.

Last edited by solarwind (2008-09-28 23:32:18)

Offline

#2 2008-09-28 23:46:11

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,410
Website

Re: Reinstalling All Packages

This should do it...

pacman -Qq > pkglist
for pkg in $(pacman -Qqm); do
  sed -i "s#^${pkg}*##" pkglist
done;
pacman -S $(cat pkglist)

Edit: Corrected commands....  Thank to AD28 for pointing out I was stupid!  tongue

Offline

#3 2008-09-29 00:34:23

solarwind
Member
From: Toronto
Registered: 2008-03-18
Posts: 546

Re: Reinstalling All Packages

Allan wrote:

This should do it...

pacman -S $(pacman -Qqm)

What happens when something like glibc or the kernel or some other library comes around? Wont it crash?

Offline

#4 2008-09-29 00:38:52

AD28
Member
Registered: 2008-09-16
Posts: 161

Re: Reinstalling All Packages

I believe the kernel and drivers and such are loaded into memory when your system boots.. it's not read directly from disk.

Offline

#5 2008-09-29 01:09:14

solarwind
Member
From: Toronto
Registered: 2008-03-18
Posts: 546

Re: Reinstalling All Packages

AD28 wrote:

I believe the kernel and drivers and such are loaded into memory when your system boots.. it's not read directly from disk.

So it's safe to run the above command?

Offline

#6 2008-09-29 02:17:58

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,410
Website

Re: Reinstalling All Packages

Yes, it is exactly the same as updating glibc etc and you probably never think twice about that.   You should keep an eye out for messages regarding bad folder permissions.

Offline

#7 2008-09-29 02:24:22

fukawi2
Ex-Administratorino
From: .vic.au
Registered: 2007-09-28
Posts: 6,224
Website

Re: Reinstalling All Packages

solarwind wrote:

So it's safe to run the above command?

As long as the power doesn't go out half way thru tongue

Even then, you'd have to be unlucky for it ro really stuff things I think. But there's no more 'risk' than if it happened during a normal -Syu update.

Offline

#8 2008-09-29 02:24:56

AD28
Member
Registered: 2008-09-16
Posts: 161

Re: Reinstalling All Packages

Doesn't '-Qqm' only return manually compiled packages?  I think this might be what you're looking for, but I'd wait for confirmation from someone more knowledgeable than I am..

pacman -S $(pacman -Qq)

Offline

#9 2008-09-29 02:25:01

solarwind
Member
From: Toronto
Registered: 2008-03-18
Posts: 546

Re: Reinstalling All Packages

Allan wrote:

Yes, it is exactly the same as updating glibc etc and you probably never think twice about that.   You should keep an eye out for messages regarding bad folder permissions.

You said exactly the same which makes me want to make sure: is it purging the files? Or is it just copying over in which case permissions will be the way they are?

Offline

#10 2008-09-29 02:35:53

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,410
Website

Re: Reinstalling All Packages

AD28 wrote:

Doesn't '-Qqm' only return manually compiled packages?  I think this might be what you're looking for, but I'd wait for confirmation from someone more knowledgeable than I am..

pacman -S $(pacman -Qq)

Crap, I was playing around to stop the attempt at installing foreign packages and cut and pasted wrong....

It is probably best to go:

pacman -Qq > pkglist
for pkg in $(pacman -Qqm); do
  sed -i "s#^${pkg}*##" pkglist
done;
pacman -S $(cat pkglist)

Offline

#11 2008-09-29 02:36:25

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,410
Website

Re: Reinstalling All Packages

solarwind wrote:
Allan wrote:

Yes, it is exactly the same as updating glibc etc and you probably never think twice about that.   You should keep an eye out for messages regarding bad folder permissions.

You said exactly the same which makes me want to make sure: is it purging the files? Or is it just copying over in which case permissions will be the way they are?

It removes the files and reinstalls them.

Offline

#12 2008-09-29 02:56:13

AD28
Member
Registered: 2008-09-16
Posts: 161

Re: Reinstalling All Packages

Hmm just out of curiosity, is there a difference between 's###' and 's///' in sed?

Offline

#13 2008-09-29 02:57:56

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,410
Website

Re: Reinstalling All Packages

AD28 wrote:

Hmm just out of curiosity, is there a difference between 's###' and 's///' in sed?

No, that is just the separator character.  I like #...

Offline

#14 2008-09-29 03:05:33

AD28
Member
Registered: 2008-09-16
Posts: 161

Re: Reinstalling All Packages

Ah I see.. my limited knowledge of sed is just from some very basic tutorials.  I was always under the impression that / was "the" separator syntax recognized by sed.

Offline

Board footer

Powered by FluxBB