1

End state. I want to reformat my / partition, reinstall opensuse tumbleweed, and have the same packages installed then as now.

Problem. I made what appears to be a poor choice, formatting the root filesystem as btrfs. The 20 GB I had for it was plenty previously with, say, ext3, but I can't keep up with the snapshot management with snapper with the large number of updates tumbleweed does.

Partial success. I can export my repository list with sudo zypper lr -u --export repo.list, and add that back to a fresh install with sudo zypper addrepo repo.list. I can export a list of installed pakcages with sudo zypper search --installed-only > installed.packages or rpm -qa | sort.

But I don't know how to install packages from a list, or generate a list of packages that can be used by opensuse at distribution install time.

Edit: autoyast may be the way to go, but is more heavyweight than I was looking for.

2
  • the problem is that - once installed - you don't have the rpm files anymore; they reside on some online repositories or even on the install disk; so there is no guarantee that - given the list - you can reinstall each of those rpms...
    – Chris Maes
    Aug 29, 2016 at 6:23
  • Sure, I'm not too concerned about the particular version, I'd just like a starting point to get close to the packages that I tend to install after a fresh OS install. Sep 2, 2016 at 23:16

3 Answers 3

3

Use --queryformat to list package names without version

rpm -qa --qf "%{NAME}\n" > installed_pkgs.txt

To install, pipe content of the file to xargs

cat installed_pkgs.txt | xargs sudo zypper install
1
1

It might be slow, but you can use this bash script:

IFS=$'\n'

for package in `cat installed.packages`; do
    zypper install $package
done
5
  • I think the issue with that is the number of packages dependent on other packages (kde, python modules ...), and the ones that require license acceptance or other user interaction. Aug 27, 2016 at 16:38
  • Doesn't zypper handle dependencies? And you can still interact with it. I see no reason why it won't work, even if it's not optimal. Aug 27, 2016 at 16:41
  • you are correct; I thought about that as I was mowing the lawn. There are flags like --auto-agree-with-licenses and --no-confirm (to say "yes" automatically). What I was thinking of is there should be a way if you're installing 500 servers to all be the same, to pass in a list of repos and packages either at install or just post-install. Aug 27, 2016 at 17:23
  • @A.R.Diederich Cool. Well, if nobody comes up with something better, you have you're option. Good luck! Aug 27, 2016 at 17:31
  • I'm doing this for a simple desktop change. I found that I also needed to strip the version number and the architecture off the package name. I did it with "package_noarch=${package%.*}" and "package_name=${package_noarch%--}" and it seems to work because the openSUSE version numbers are "package-version-build.arch". (I may have needed to strip versions because I'm on Tumbleweed, so version number change - this may not be necessary for other people).
    – IBBoard
    Jan 18, 2018 at 16:04
0

I have had good results using an exported list (from rpm -qa | cut ...) as a way to snapshot a particular configuration and then replicated it using:

# cat packages.txt | xargs -I {} zypper -n in -l {}

but you need to be sure there are no extra spaces in the list of packages.

I think that a more robust solution might be:

# xargs -a packages.txt -I {} sudo zypper -n in -l {}

as I think it won't have problems w/ stray spaces, but haven't tested it (yet).

Be sure to use sudo if you don't use su!

I didn't see the other solutions mention the -I {} ... {} requirement for this work w/o balking.

The only problem is getting the automatic import and acceptance of GPG keys from my imported list of repos (step 1, before install/update the software is to be sure the repo with the software is actually available...) Not sure why it isn't working as advertised.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .