2

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.

  • Repositories: 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.
  • Packages: 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.

4 Answers4

4

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

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

IFS=$'\n'

for package in cat installed.packages; do zypper install $package done

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.

DrKC
  • 11
0

I think the easiest way is to use a GUI tool, YAST to be precise. Open YAST, -> choose Software Management -> go to File and click on export ... choose a place to keep the .xml file.

That's it, instantaneous.

If you wish to recreate your installed system simply go to YAST on another computer. Open Software Management and from there go to File and choose import ... choose your file and ... that's it.

Could not be simpler.