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.

A. R. Diederich
  • 121
  • 1
  • 5
  • 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 '16 at 06: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. – A. R. Diederich Sep 02 '16 at 23:16

2 Answers2

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

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

IFS=$'\n'

for package in `cat installed.packages`; do
    zypper install $package
done
IBBoard
  • 155
  • 6
Ryan Babchishin
  • 6,160
  • 2
  • 16
  • 36
  • 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. – A. R. Diederich Aug 27 '16 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. – Ryan Babchishin Aug 27 '16 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. – A. R. Diederich Aug 27 '16 at 17:23
  • @A.R.Diederich Cool. Well, if nobody comes up with something better, you have you're option. Good luck! – Ryan Babchishin Aug 27 '16 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 '18 at 16:04