You are not logged in.

#1 2008-05-05 12:37:18

_Marco_
Member
Registered: 2008-04-21
Posts: 242

Redownload installed packages

hi,
I'd like to know how to redownload (without install) all my installed packages, I've found this:
http://bbs.archlinux.org/viewtopic.php?id=18728

and tried the script:

for package in `pacman -Q | awk '{ print $1 }'`; do yes | pacman -Sw $package; done

but it doesn't download anything in my pacman cache...
the thread is old (2006) and I'm sure there have been a lot of modifications in pacman, so can someone help me correcting that script?
thanks for your help
_Marco_

Offline

#2 2008-05-05 12:40:37

Allan
Developer
From: Brisbane, AU
Registered: 2007-06-09
Posts: 9,939
Website

Re: Redownload installed packages

pacman -Sw $(pacman -Q | cut -f1 -d' ')

Edit: that will run into problems if you have packages installed from outside the main repos (e.g. from the AUR)

You can always do this by

pacman -Q | cut -f1 -d' ' > packages.txt
pacman -Sw $(cat packages.txt)

and remove the offending packages from packages.txt as pacman fails.

Last edited by Allan (2008-05-05 12:43:22)

Offline

#3 2008-05-05 12:43:02

_Marco_
Member
Registered: 2008-04-21
Posts: 242

Re: Redownload installed packages

wow, thank you very much for the really fast reply smile
I'm try it now
thanks

Offline

#4 2008-05-05 12:46:53

_Marco_
Member
Registered: 2008-04-21
Posts: 242

Re: Redownload installed packages

uhm.. there is a problem...
if it find a package that is not in the official repos (example built with AUR) it returns an error and exits.
any idea?

Offline

#5 2008-05-05 13:04:17

Allan
Developer
From: Brisbane, AU
Registered: 2007-06-09
Posts: 9,939
Website

Re: Redownload installed packages

See my edit above.

Offline

#6 2008-05-05 13:06:12

_Marco_
Member
Registered: 2008-04-21
Posts: 242

Re: Redownload installed packages

ok I'll try, thanks for the help!

Offline

#7 2008-05-06 19:58:40

kjon
Member
From: Temuco, Chile
Registered: 2008-04-16
Posts: 398

Re: Redownload installed packages

pacman -Sc --noconfirm
pacman -Q | awk '{print $1}' > /tmp/lista
pacman -Qm | awk '{print $1}' > /tmp/washones

if [ -n "`cat /tmp/washones`" ];
then
    for washon in `cat /tmp/washones`
    do
        cat /tmp/lista | grep -v -i $washon > /tmp/lista.filtro
        mv /tmp/lista.filtro /tmp/lista
    done
fi

pacman -Sdw --noconfirm `cat /tmp/lista`
rm /tmp/lista /tmp/washones
echo "oko"

That's my approach to solve that problem


They say that if you play a Win cd backward you hear satanic messages. That's nothing! 'cause if you play it forwards, it installs windows.

Offline

#8 2008-05-06 20:03:26

_Marco_
Member
Registered: 2008-04-21
Posts: 242

Re: Redownload installed packages

wow, really impressive smile
I'll give it a try as soon as possible
Thanks

Offline

#9 2008-05-06 20:26:42

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: Redownload installed packages

This works for me:

pacman -Sw $(pacman -Qq | grep -v "$(pacman -Qmq)")

pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#10 2008-05-07 10:05:12

_Marco_
Member
Registered: 2008-04-21
Posts: 242

Re: Redownload installed packages

shining Thanks, I must tell you that I spent "some" time to understand your script tongue

Offline

#11 2008-05-07 10:08:10

Allan
Developer
From: Brisbane, AU
Registered: 2007-06-09
Posts: 9,939
Website

Re: Redownload installed packages

I'm ashamed to say I did not know the "pacman -Qq" option...  I can forget about cut forever more!

Offline

#12 2008-05-07 17:59:23

kjon
Member
From: Temuco, Chile
Registered: 2008-04-16
Posts: 398

Re: Redownload installed packages

@shining: die! tongue

You made my "poetry" worth crap.

T_T

Those were completly different approaches... The very long one, and the arch one...

I feel despicable... I'm going to commit suicide... No one try to stop me! I'm going to jump to /dev/null!!


They say that if you play a Win cd backward you hear satanic messages. That's nothing! 'cause if you play it forwards, it installs windows.

Offline

#13 2008-05-08 13:21:26

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: Redownload installed packages

Allan wrote:

I'm ashamed to say I did not know the "pacman -Qq" option...  I can forget about cut forever more!

Well, that --quiet option is practical indeed; but what about the power of combining unix tools together? smile
cut is still a nice and neat tool to use, so no problem.


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

#14 2008-05-08 13:43:35

shining
Pacman Developer
Registered: 2006-05-10
Posts: 2,043

Re: Redownload installed packages

kjon wrote:

You made my "poetry" worth crap.

Those were completely different approaches... The very long one, and the arch one...

You can start by writing a long approach that works, and then try to find a more elegant one, no problem with that.
But generally speaking, it's very easy to write a script longer than necessary, because writing short ones require both knowledge
of all the neat tools like grep,sed,cut,tr,find, etc and experience of combining them all together.

To be honest, this need of reinstalling or re-downloading all installed packages comes up regularly, so you can find that my solution
was already suggested before in this forum, but that there were also several more verbose solutions similar to yours.


pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))

Offline

Board footer

Powered by FluxBB