You are not logged in.

#1 2007-07-03 18:25:54

kotyz
Member
Registered: 2007-06-24
Posts: 28

how to reinstall all packages in the system?

I accidentaly remove whole /usr directory, so all installed apps are gone. I then installed the basic system from the install CD, all user and system configuration leave untouched. pacman even remember what packages were installed, when i try install some of the previously installed packages pacman says: this package is up to date, upgrade anyway Y/n? So all I must do to get my system up and running again is reinstall all previsously installed packages. Is there any way how to do this by a single command? Or some script? I don't want to reinstall all the packages one by one ...

Last edited by kotyz (2007-07-03 18:27:21)

Offline

#2 2007-07-03 18:42:21

Mefju
Member
From: Poland
Registered: 2006-07-12
Posts: 104

Re: how to reinstall all packages in the system?

If you're pacman database is not removed, you could use something like this

#! /bin/sh

for pkg in $(pacman -Q | cut -d' ' -f1); do
    pacman -S --noconfirm $pkg
done

Offline

#3 2007-07-03 18:52:10

kotyz
Member
Registered: 2007-06-24
Posts: 28

Re: how to reinstall all packages in the system?

Database isn't removed, it seems to be completely OK. I only cleared cache with pacman -Scc, so I have all packages download again, but this really doesn't matter with my connection.

Offline

#4 2007-07-03 19:09:18

kano
Member
From: Michigan
Registered: 2007-05-04
Posts: 185
Website

Re: how to reinstall all packages in the system?

Mefju wrote:

If you're pacman database is not removed, you could use something like this

#! /bin/sh

for pkg in $(pacman -Q | cut -d' ' -f1); do
    pacman -S --noconfirm $pkg
done

pacman would error out if he's using any non-repo pkgs (like stuff from unsuported AUR)
working on a script now, will edit when i get it working.

#!/bin/bash

pacman -Q | awk '{ print $1 }' > installed.tmp
for i in $(pacman -Qm | awk '{ print $1 }'); do
    cat installed.tmp | sed "s/^$i\$//;" > installed.tmp.1
    mv installed.tmp.1 installed.tmp
done
pacman -S --noconfirm `cat installed.tmp`
rm installed.tmp

i think that'll do the trick... just make sure you backup your /etc before hand, it might overwrite stuff.

Last edited by kano (2007-07-03 19:47:07)


\\ archlinux on a XPS M1530 //

Offline

#5 2007-07-04 01:13:00

kotyz
Member
Registered: 2007-06-24
Posts: 28

Re: how to reinstall all packages in the system?

Problem solved, my system is functional again. I found this advise on forum.archlinux.cz:

sudo pacman -Sy `pacman -Q | awk '{print $1}'`

Offline

#6 2007-07-04 01:44:22

Cerebral
Forum Fellow
From: Waterloo, ON, CA
Registered: 2005-04-08
Posts: 3,108
Website

Re: how to reinstall all packages in the system?

kano wrote:
#!/bin/bash

pacman -Q | awk '{ print $1 }' > installed.tmp
for i in $(pacman -Qm | awk '{ print $1 }'); do
    cat installed.tmp | sed "s/^$i\$//;" > installed.tmp.1
    mv installed.tmp.1 installed.tmp
done
pacman -S --noconfirm `cat installed.tmp`
rm installed.tmp

That could be simplified with the 'comm' command:

#!/bin/bash

pacman -Q | awk '{ print $1 }' | sort > /tmp/pacman-installed.tmp
pacman -Qm | awk '{ print $1 }' | sort | comm -3 /tmp/pacman-installed.tmp - > /tmp/pacman-to-reinstall.tmp

pacman -S --noconfirm $(cat /tmp/pacman-to-reinstall.tmp)
rm /tmp/pacman-{to-reinstall,installed}.tmp

That should do the same thing... I think.

Last edited by Cerebral (2007-07-04 01:51:10)

Offline

#7 2007-07-04 02:04:29

kano
Member
From: Michigan
Registered: 2007-05-04
Posts: 185
Website

Re: how to reinstall all packages in the system?

Cerebral wrote:

That could be simplified with the 'comm' command:

#!/bin/bash

pacman -Q | awk '{ print $1 }' | sort > /tmp/pacman-installed.tmp
pacman -Qm | awk '{ print $1 }' | sort | comm -3 /tmp/pacman-installed.tmp - > /tmp/pacman-to-reinstall.tmp

pacman -S --noconfirm $(cat /tmp/pacman-to-reinstall.tmp)
rm /tmp/pacman-{to-reinstall,installed}.tmp

That should do the same thing... I think.

I'll have to remember that, thanks smile


\\ archlinux on a XPS M1530 //

Offline

#8 2007-10-23 19:10:58

nadman10
Member
From: Erie, PA
Registered: 2005-10-15
Posts: 201

Re: how to reinstall all packages in the system?

Mefju's script worked for me. I had a similar issue. Thanks guys.

Offline

#9 2011-09-19 18:17:20

swiftscythe
Member
Registered: 2009-04-28
Posts: 131

Re: how to reinstall all packages in the system?

No need to use awk

pacman -S $(pacman -Qq) --noconfirm

But this method breaks the database structure, as all packages will be marked as explicitly installed. Not a big issue, but not elegant.

Here's the best way in my opinion (-e option lists explicitly installed packages):

pacman -S $(pacman -Qeq) --noconfirm

Last edited by swiftscythe (2011-09-19 18:23:33)

Offline

#10 2011-09-19 18:30:57

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,193

Re: how to reinstall all packages in the system?

Moderator comment:
swiftscythe,
You do realize you are responding to a four year old thread?  Don't worry, we have all done it -- just remember the policy though.

Closing


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB