I want to port my installed packages on a SLES SP1 System to another SLES System without an internet connection. So I got the idea to use
rpmrebuild packagename
to pack all installed packages back into rpms and then copy those to the other machine.
So I am searching for a way to loop through the names of all installed packages.
If I understood your question correctly, you can always loop through the list of installed packages on any system having RPM package manager by using below shell script -
#!/bin/bash
while read -r package; do echo "This package is $package"; done < <(rpm -qa)
Output -
This package is ethtool-3.15-2.27.amzn1.x86_64
This package is libXau-1.0.6-4.9.amzn1.x86_64
This package is libXcomposite-0.4.3-4.6.amzn1.x86_64
This package is libblkid-2.23.2-33.28.amzn1.x86_64
....................................................