You are not logged in.

#1 2006-02-12 15:21:05

Romashka
Forum Fellow
Registered: 2005-12-07
Posts: 1,054

How to redownload installed packages after -Scc

I want to install Arch on my home PC which has no internet connection (yet).
I have only arch-0.7.1-base.iso but want to install all packages that are on my PC at company where I'm working.
I could bring all packages from work to home on my portable HDD, but...
I have only 20-30% of packages on my PC at work (deleted sometime with -Scc so only upgraded packages are in local database). I have Internet connection on my work so I could redownload all missed packages.
Now the question: how can I redownload all installed packages (without forcing reinstall) in easy way?


to live is to die

Offline

#2 2006-02-12 15:32:25

Chman
Member
Registered: 2006-01-31
Posts: 169
Website

Re: How to redownload installed packages after -Scc

From the wiki :

Downloading a package without installing it:

pacman -Sw package_name

This should help you wink

Offline

#3 2006-02-12 15:43:35

Romashka
Forum Fellow
Registered: 2005-12-07
Posts: 1,054

Re: How to redownload installed packages after -Scc

Chman wrote:
pacman -Sw package_name

I know this from the day when I first Installed Arch. smile
But I have very much packages so typing all names by hand would be not easy. Maybe someone already has some little script for doing this?


to live is to die

Offline

#4 2006-02-12 16:08:20

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

Re: How to redownload installed packages after -Scc

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

Offline

#5 2006-02-12 16:31:32

Romashka
Forum Fellow
Registered: 2005-12-07
Posts: 1,054

Re: How to redownload installed packages after -Scc

Thank you very much! I'll try it!


to live is to die

Offline

#6 2006-02-14 10:57:25

Romashka
Forum Fellow
Registered: 2005-12-07
Posts: 1,054

Re: How to redownload installed packages after -Scc

Thank you for pointing me to the right direction. smile
Here is a better version:

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

or as in my redownload.sh:

#!/bin/sh
for package in `pacman -Q | awk '{ print $1 }'`; do
    list="$list $package"
done
pacman -Sw $list

Added this to wiki: http://wiki.archlinux.org/index.php/Red … d_packages


to live is to die

Offline

#7 2006-02-14 14:08:58

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

Re: How to redownload installed packages after -Scc

Romshaka,
I didn't want to do it that way because, if you have too many packages installed, it might cause a the command line to have too many arguments and not succeed.   Then again, I'm not sure what the limit on arguments is, but I know this happened to me once before with a script I was writing.

Your way, but simpler:

yes | pacman -Sw `pacman -Q | awk '{ print $1 }'`

Offline

#8 2006-02-14 14:41:27

brain0
Developer
From: Aachen - Germany
Registered: 2005-01-03
Posts: 1,382

Re: How to redownload installed packages after -Scc

If you want to use the script as a user instead of root, you can replace the last line with

wget $(pacman -Sp $list)

Offline

#9 2006-02-14 14:44:15

Romashka
Forum Fellow
Registered: 2005-12-07
Posts: 1,054

Re: How to redownload installed packages after -Scc

Yes, I thought about the command line length limit. I don't know which max length is allowed, but I've never get an error because of too much arguments. But I suppose that if someone has many packages installed an error may occur.
It is really interesting to know exactly what max allowed length is. Anyone knows where this info can be found? (except sources smile )

Mmm...

yes | pacman -Sw `pacman -Q | awk '{ print $1 }'`

is really much simple. How it didn't came into my mind? :oops:

Thank you for help.

P.S.: corrected Wiki page.


to live is to die

Offline

#10 2006-02-14 17:27:21

Romashka
Forum Fellow
Registered: 2005-12-07
Posts: 1,054

Re: How to redownload installed packages after -Scc

brain0 wrote:

If you want to use the script as a user instead of root, you can replace the last line with

wget $(pacman -Sp $list)

Nice addition, thanks. IMO it is better to use -Sdp to skip useless dependency checks.

There is few problems:
1) pacman will show the size of all installed packages, so user will not know hom many files are missed
2) wget will download all installed packages (pacman will skip packages that already exist in /var/cache/pacman/pkg/)

It would be better to use this:

#!/bin/sh
for line in `pacman -Q | tr ' ' '/'`; do
    name=`echo $line | awk -F '/' '{ print $1 }'`
    file=`echo $line | awk -F '/' '{ print $1 "-" $2 }'`.pkg.tar.gz
    if [ ! -e /var/cache/pacman/pkg/$file ]; do
        list="$list $name"
    fi
done
pacman -Sdw $list

wget version:

for line in `pacman -Q | tr ' ' '/'`; do
    name=`echo $line | awk -F '/' '{ print $1 }'`
    file=`echo $line | awk -F '/' '{ print $1 "-" $2 }'`.pkg.tar.gz
    if [ ! -e /var/cache/pacman/pkg/$file ]; do
        wget `pacman -Sdp $name`
    fi
done

I know that this code is ugly but it works perfectly. Any suggestions how to improve it?


to live is to die

Offline

#11 2006-11-04 14:13:56

TheGrudge
Member
Registered: 2006-06-15
Posts: 206
Website

Re: How to redownload installed packages after -Scc

It tried suggested scripts, but my problem was that pacman failed because some of my packages are foreign ones from the AUR or self made PKGBUILDs.

So I made this little python script, works fine for me:

import string
import os

installed = [pkg.strip().split()[0] for pkg in os.popen("pacman -Q", "r")]
foreign = [pkg.strip().split()[0] for pkg in os.popen("pacman -Qm", "r")]

os.system("pacman -Sydw %s" % string.join(set(installed) - set(foreign)))

digiKam developer - www.digikam.org

Offline

#12 2007-07-13 00:20:43

Back2Cali
Member
From: Germany
Registered: 2006-02-26
Posts: 223

Re: How to redownload installed packages after -Scc

Hi!

Today I wanted to download all packages I had installed to my system because of some corrupted file system. Anyway, I used the following command:

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

but unfortunately the new pacman just runs through every package and doesn't download anything at all. I had to use the command above because I also have packages from AUR installed through Yaourt and with all the other commands the problem always was that every version of pacman stopped the moment a file not existing in any of the repositories was requested.
So is there anything I have to change in order to have pacman download all installed packages again?

Thanks!

Offline

#13 2007-07-13 03:22:04

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

Re: How to redownload installed packages after -Scc

This will download all packages installed on your system to /var/cache/pacman/pkg, assuming the package doesn't exist there yet.  If you want to download all new, fresh copies, sudo pacman -Scc first - that will clean out your cache directory.

for pkg in $(pacman -Q | awk '{ print $1 }'); do sudo pacman -Sdw --noconfirm ${pkg}; done

Last edited by Cerebral (2007-07-13 03:22:42)

Offline

#14 2007-07-16 16:28:31

aRcHaTe
Member
Registered: 2006-10-24
Posts: 646

Re: How to redownload installed packages after -Scc

can anyone make one for aurbuild? to redownload all installed packages, compile them and skipping those in cache?

does aur as a data base showing the installed packages?

thanks in advance! this script as shwn to be very usefull wink

Last edited by sickhate (2007-07-16 18:45:31)


Its a sick world we live in....

Offline

Board footer

Powered by FluxBB