1

After a HDD failure I managed to save the list of installed packages on my Fedora 23 box. I have already reinstalled the base system and now want to restore the old packages. I tried

xargs sudo dnf install < packagelist

where packagelist is the output of rpm -qa, but it fails on several points (no match for packages; I guess the version number formatting is not how dnf wants it.

Is there a way to achieve what I want?

GergelyPolonkai
  • 359
  • 1
  • 5
  • 12
  • If you think version numbers are a problem, have you tried removing them? That would be the first obvious place I'd start. –  Jun 06 '16 at 23:49

2 Answers2

2

According to the command reference I'd try feeding dnf the output of

rpm -qa --queryformat "%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}\n"

The default query format is

%{NAME}-%{VERSION}.%{RELEASE}.%{ARCH}\n

Note the dash versus dot between the version and release.

...and now that I've tested it there is a bug in the documentation. :) It should be a dot.

The best option may be to remove the version, release, and arch completely:

rpm -qa --queryformat "%{NAME}\m"
Mark Wagner
  • 17,764
  • 2
  • 30
  • 47
  • That sounds great and next time I will do my “backup” this way. However, this doesn’t solve the problem: I already have a file with the packages listed, which I need to pass to rpm. – GergelyPolonkai Jun 07 '16 at 08:15
  • The problem is that it is impossible to strip off the version from the packagelist. `awk -F. '{ print $1 }' < packagelist | sed 's/-[-0-9]*$//'` is a staring point. – Mark Wagner Jun 07 '16 at 17:54
1

Use DNF with cat

dnf install $(cat packagelist)
Antoan Bull
  • 100
  • 1
  • 13