Can zypper ?

In debian based systems once my system was set I’d do something like this to create a list of applications and be able to wipe-install base then reinstall my favorite apps and servers with one command. Is there a way to do this with zypper?

dpkg --get-selections | grep -v deinstall > installed-packages
Then, after reinstalling Kubuntu, you can use this list to reinstall those packages:
Code:
sudo apt-get update
sudo apt-get dist-upgrade
dpkg --set-selections < installed-packages
sudo dselect

  1. Reinstall base system
  2. Copy necessary files from backup - entire network directory copied back to /etc/, sources.list copied back to etc/apt/
  3. Open network config window and enter encryption key. You now have internet access and the proper source.list to reinstall your packages.
  4. sudo apt-get update
  5. sudo apt-get dist-upgrade
  6. dpkg --set-selections < /media/disk/backup/installed-packages
  7. sudo apt-get install dselect
  8. sudo dselect
  9. When prompted, choose to install packages

It’s not a complete solution but to get a list of package names you can use the following (note the dashes and the space after %{name})

rpm -qa --qf "%{name} "

So I think what you want to do is (warning untested, probably wrong, I have never used “dup”)

rpm -qa --qf "%{name} " > /media/disk/installed-packages
sudo zypper dup
sudo zypper in `cat /media/disk/installed-packages`

I’ve done something similar in the past (replace “zypper dup” with “install from dvd”).

You can probably get smarter and get a list of the installed packages after the upgrade and to some shell magic to reduce the list of installed-packages but I think zypper is smart enough just to ignore already installed packages.

There might be several ways to achieve that. Here’s one, fast (I guess), untested though :

zypper search -t pattern -i  | awk '/pattern/ { print $3 }' > patternsToInstall.lst
zypper search -t package -i  | awk '/package/ { print $3 }' | sed '/packages/d' > packagesToInstall.lst

reinstall .....

zypper search -t pattern -i  | awk '/pattern/ { print $3 }' > patternsInstalled.lst
zypper in -t pattern  `diff patternsInstalled.lst patternsToInstall.lst | awk '/&gt;/ { print $2 }' | tr "
" " "`

zypper search -t package -i  | awk '/ package/ { print $3 }' | sed '/packages/d' > packagesInstalled.lst
zypper in  `diff packagesInstalled.lst packagesToInstall.lst | awk '/&gt;/ { print $2 }' | tr "
" " "`

As I read form the cpackham’s post, the last pipe (tr…) should not be necessary.

Thank you both when I get done rebuilding my install I’ll give this a try. Not intending to bork it again but its been my proven track record lately. SUSE is teaching me a lot. But a venture onto 11.4 milestone might be irresistible!

Hi,

worked fine for me :slight_smile: thanks.

I use now:


...
rpm -qa --qf "%{name}
"
...

which puts a newline after each line. it’s better for the eyes :wink:

cheers,
guddl

Another way (tested):

rpm -qa --queryformat '%{name}
' | grep -v gpg-pubkey | tr '
' ' ' > packagelist.txt
zypper in $(cat packagelist.txt)

Doesn’t create new lines for each package, but I don’t see why that is needed. Always worked well for me.

Edit: Before one reinstalls a system like that, I recommend to run a systemwide update with the default repositories first, then reboot, then activate the repositories used on the old system, then install the remaining packages.

On 2010-09-04 02:36, sixonetonoffun wrote:
>
> In debian based systems once my system was set I’d do something like
> this to create a list of applications and be able to wipe-install base
> then reinstall my favorite apps and servers with one command. Is there a
> way to do this with zypper?

Not with zypper, but with YaST. It is called autoyast, it is used to replicate installations. It can
use a configuration file, very configurable. I haven’t used it personally, tough.

There is an option while installing to save an autoyast file precisely for this purpose. I think it
can do way more than simply installing a list of packages, I think it will do things like
partitioning and such automatically.


Cheers / Saludos,

Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)