You are not logged in.

#1 2007-12-03 15:08:23

Micha
Member
Registered: 2007-11-16
Posts: 20

Pacman packages list export without version number

Hi all!

I'd like to know if there is a way to export a package-list without the version of every package to be able to export the installed packages, edit the exported file and after that have a list which I can use to setup another computer with the same packages.

pacman -Q

just gives me the packages with version info and I need the package names separated by only one space.

Or is there another solution to export and then install the packages in a text-file?

For example:
Computer A: -> generate package-list
Computer B: -> import/read package-list from Computer A and tell pacman to install all those packages as well.

Thanks in advance for your help!
Micha

Offline

#2 2007-12-03 15:38:44

kumico
Member
Registered: 2007-09-28
Posts: 224
Website

Re: Pacman packages list export without version number

pacman -Q|cut -f 1 -d " "

gets you the list of installed packages, with the version bit cut off

Offline

#3 2007-12-03 15:43:36

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

Re: Pacman packages list export without version number

All you need is simple shell manipulations.  Any of these will give you what you want:

$ pacman -Q | cut -d' ' -f1
$ pacman -Q | awk '{ print $1 }'
$ pacman -Q | sed 's/ .*//'

-edit- Seems I took too long to finish my reply, and was beaten to the punch tongue

Last edited by Cerebral (2007-12-03 15:44:11)

Offline

#4 2007-12-03 16:57:34

Micha
Member
Registered: 2007-11-16
Posts: 20

Re: Pacman packages list export without version number

Thanks guys! That's already a lot.
But do you know how I could "import" the list or install a new system from a "package.list" containing the package-names generated by one of the commands above?

Offline

#5 2007-12-03 16:59:36

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

Re: Pacman packages list export without version number

Again, fairly straightforward shell scripting works in your favour.  Assuming you have a list of packages named package.list, you could just use $(cat package.list) to get it.  Example:

$ cat package.list
apache
aspell
aspell-eng
pidgin
gtk
$ sudo pacman -S $(cat package.list)

Last edited by Cerebral (2007-12-03 17:00:47)

Offline

#6 2007-12-03 17:18:36

Micha
Member
Registered: 2007-11-16
Posts: 20

Re: Pacman packages list export without version number

Ahhh, thanks again! big_smile

I should get into the shell a bit deeper soon wink
And to give something as well, here's the detailed reason I was asking. I put a little script into the ~/.kde/Autostart folder that creates that list of packages after each boot so when something "happenes" to the system (I know, it's not likely wink, I have a fairly recent package-list.

The script now looks like this:

sudo pacman -Q|cut -f 1 -d " " > packages.`date +%y%m%d%H%M`

and that list I will gladly "import" with your last command!

I don't know if this is useful for anyone else but me, but... anyhow wink
Thanks again!

Last edited by Micha (2007-12-05 17:43:06)

Offline

#7 2007-12-03 18:12:33

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

Re: Pacman packages list export without version number

You don't need sudo for pacman -Q, you can run it as a regular user. wink

Offline

#8 2007-12-03 20:23:09

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

Re: Pacman packages list export without version number

See also http://bugs.archlinux.org/task/8470

parsing the -Q output with cut is trivial, but maybe some users will prefer this way in 3.1 :

> pacman -Qh |grep quiet
  -q  --quiet          show less information for query and search
> pacman -Qq | head -n 2
a52dec
aalib

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

Offline

Board footer

Powered by FluxBB