Author Topic: [SOLVED] Listing Installed Packages with Full Filenames  (Read 1745 times)

skyhawk

  • Guest
[SOLVED] Listing Installed Packages with Full Filenames
« on: December 02, 2009, 04:26:44 PM »
A search of the PCLinuxOS Forum showed me a way to pipe a listing of installed package names to a text file. From the command-line as root:

rpm -qa --qf '%10{size}\t%{name}\n' | sort -k1,1n > installed.txt

This works very nicely, listing packages from smallest to largest in alphabetical order. However, the package names are listed in short form. I would like to list packages by their full filenames as they were installed. Is there a way to do this? If so, how can I use the command-line to modify the text file so that package names are each separated by a space, rather than each being listed on separate lines?
« Last Edit: December 11, 2009, 04:28:25 PM by skyhawk »

smcs_steve

  • Guest
Re: Listing Installed Packages with Full Filenames
« Reply #1 on: December 02, 2009, 08:32:54 PM »
Something like this? >
rpm -qa --qf '\t%{name}\' | sort -k1,1n > installed.txt
>Steve

skyhawk

  • Guest
Re: Listing Installed Packages with Full Filenames
« Reply #2 on: December 03, 2009, 12:48:44 PM »
Something like this? >
rpm -qa --qf '\t%{name}\' | sort -k1,1n > installed.txt
>Steve
Thanks for your reply, Steve. Your suggested command-line will not do the job, however. It will list the installed packages in alphabetical order, but the package names will be in short-form, while omitting the filesizes of the packages. I think using a queryformat that includes {packagename} might bring me closer to what I want to do, but I will need to print-out the rpm man pages first to carefully look over the multitude of options. I very seldom used the rpm command when I was running Mandriva Free 2007.0, so I don't know a lot about what all it can do. A brief Google search did not reveal many details about all the queryformat tags that are available. If I have success, I will post my solution.

Offline aherkey

  • Full Member
  • ***
  • Posts: 109
Re: Listing Installed Packages with Full Filenames
« Reply #3 on: December 03, 2009, 03:37:15 PM »
For the full file name you need to re-assemble the name from the rpm database.

This will output all the packages on a single line with a space in between.
rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}.rpm '

sample:
xgamma-1.0.2-1pclos2007.i586.rpm make-3.81-2pclos2007.i586.rpm fonts-ttf-bitstream-vera-1.10-5pclos2007.noarch.rpm


- Andy

skyhawk

  • Guest
Re: Listing Installed Packages with Full Filenames
« Reply #4 on: December 03, 2009, 04:31:49 PM »
For the full file name you need to re-assemble the name from the rpm database.

This will output all the packages on a single line with a space in between.
rpm -qa --qf '%{name}-%{version}-%{release}.%{arch}.rpm '

sample:
xgamma-1.0.2-1pclos2007.i586.rpm make-3.81-2pclos2007.i586.rpm fonts-ttf-bitstream-vera-1.10-5pclos2007.noarch.rpm


- Andy
Thanks very much, Andy. I will add your command-line to my scripts "cheat" file. I have several other "esoteric" topics in mind, related to the inner workings of PCLinuxOS, but I will post them in another place at another time.

Offline Old-Polack

  • Administrator
  • Super Villain
  • *****
  • Posts: 11591
  • ----IOFLU----
Re: Listing Installed Packages with Full Filenames
« Reply #5 on: December 03, 2009, 05:58:27 PM »
A search of the PCLinuxOS Forum showed me a way to pipe a listing of installed package names to a text file. From the command-line as root:

rpm -qa --qf '%10{size}\t%{name}\n' | sort -k1,1n > installed.txt

This works very nicely, listing packages from smallest to largest in alphabetical order. However, the package names are listed in short form. I would like to list packages by their full filenames as they were installed. Is there a way to do this? If so, how can I use the command-line to modify the text file so that package names are each separated by a space, rather than each being listed on separate lines?


I have a file with some of these commands, with an explanation as to their use, as well as instructions for creating a script to reinstall all your current applications, using apt-get, in case of application breakage from file system corruption, or for use when installing to another drive, or another computer, to duplicate the same packages you had on the first installation.

You might find it interesting, so here's a copy/paste of my "package.list.commands", with a bit of color for clarity. ;D

========================================================

[For a simple list of installed packages]

rpm -qa --qf '%{NAME}\n' | sort > installed.txt

or

[For a list of installed packages to be used with apt-get to reinstall all packages]

rpm -qa --qf ' %{NAME}' > reinstall.txt


## Add the following lines at the beginning of reinstall.txt

#! /bin/bash
apt-get update
apt-get install --reinstall



## Do not put a linefeed at the end of the 3rd line so the file now looks like this:

#! /bin/bash
apt-get update
apt-get install --reinstall package1 package2 package3 ........ packageX


## End the file with a new line, then save.

## Make the script executable:

chmod +x reinstall.txt

## Rename the file, to drop the .txt extension.

## Then run it, as root, from the directory where the script is saved:

[root@localhost <directory>]# ./reinstall


[To see the package list, with package sizes...]

rpm -qa --qf '%10{SIZE}\t%{NAME}\n' | sort -k1,1n > SW_List.txt

[To see the package list, full name, with package sizes...]

rpm -qa --qf '%10{size}\t%{name}-%{version}-%{release}\n' |sort -k1,1n > installed.txt

[To see the installed package list, with version included, sorted alphabetically...]

rpm -qa |sort > pkg-version.txt
Old-Polack

Of what use be there for joy, if not for the sharing thereof?



Lest we forget...

skyhawk

  • Guest
Re: Listing Installed Packages with Full Filenames
« Reply #6 on: December 04, 2009, 07:50:11 AM »
Very useful, Old-Polack. Thanks very much. I have added those "goodies" to my cheat-sheet. My present PCLinuxOS project is building my own local repository so that I can pull packages for install from my Linux machine's hard drive. Doing this is relatively easy because I purchased DVD discs with the complete repo (05.18.2009) from On-Disk.com. I am also thankful that I live in the age of usb flash drives which make the transfer of files from one machine to another relatively painless. Of course, if I could have both my computers up-and-running at the same time, things would be even easier.