There are two machines, identical version/arch of SLES.

On machine #A there is a "foo" software installed that we can see using rpm -qa.

On machine #B the "foo" software needs to be installed.

The foo.rpm isn't available from any source, from the internet, etc.


Since the package foo.rpm was installed on machine #A, can we build a foo.rpm file on it from the already installed files?

There are pre/post scripts in the rpm's, too, I think. So then the foo.rpm (with dependencies?) can be installed.


2 Answers 2


It's possible but highly difficult to do this so that it's done correctly. If you're desperate you can create a new RPM .spec file and construct a "fake" source RPM (SRPM) file which you can then use to construct a resulting RPM file using rpmbuild --rebuild.

I would continue searching for the actual RPM instead. You don't state which in your question but it's been my experience that you can find anything on the internet if you know how to search for it. I've found ancient versions of RPMs for Red Hat distros that haven't been in use for 10+ years so I'd find it hard to believe that there is no remnant of this RPM anywhere.

Also you can often times go back to the source of the application that's contained within the RPM and use that to reconstruct the RPM too. Often times the source apps will include a necessary .spec file which is used to rebuild the RPM.

Lastly you could get the source and the .spec file from a build service such as Koji for Red Hat based distros. SuSE maintains similar build services as well so you can search through these to get old build artifacts.

Taking the binaries as are

You can use this method to lift the actual executables from one system and tar them up for deployment on another system.

machine A

$ rpm -ql <packageNameHere> | xargs tar -zcvf /tmp/program.tgz

machine B

$ tar -zxvf /path/to/your/program.tgz

SLES's version of RPM

According to one of the posts in this thread: Re: How to create RPM fron installed packages rpm on SLES is purported to have the switch --repackage. This doesn't exist on the Red Hat version (in Fedora or CentOS). But according to the post you can use it like so:

$ rpm -e --repackage <somepackage>

After that completes you'll find your RPM accessible here:


Using rpmerizor

Rpmerizor is a 3rd party tool/script that you can install which will re-package source files into a corresponding RPM. The usage of this script is accessible here, titled: rpmerizor's man page.


Rpmerizor is a script that allows you to create an RPM package from installed files. You simply have to specify files on the command line and answering a few interactive questions to fill rpm meta-data (package name, version ...). You can also use it in batch mode with command line options for meta-data.

Using rpmrebuild

Not to be confused with the build tool rpmbuild, rpmrebuild is another 3rd party script you can use to do a re-packaging of an already installed RPM.


rpmrebuild is a tool to build an RPM file from a package that has already been installed in a basic use, rpmrebuild use does not require any rpm building knowledge. (On debian, the equivalent product is dpkg-repack).


Say we want to repackage openssh-server.

$ rpm -aq | grep openssh-server

Now package it:

$ rpmrebuild openssh-server-6.2p2-8.fc19.x86_64
/usr/lib/rpmrebuild/rpmrebuild.sh: WARNING: some files have been modified:
..?......  c /etc/ssh/sshd_config
..?......  c /etc/sysconfig/sshd
Do you want to continue ? (y/N) y
Do you want to change release number ? (y/N) n
result: /root/rpmbuild/RPMS/x86_64/openssh-server-6.2p2-8.fc19.x86_64.rpm


  • anyways, it's: jdk-1.6.0_02-fcs.rpm :) It's not on the "internet" Jul 6, 2014 at 12:35
  • You can get official RPMs for any version of JDK from here: oracle.com/technetwork/java/javase/downloads/…. That'll take you to 1.6u2 which is that same version.
    – slm
    Jul 6, 2014 at 14:13
  • how can you know that "jdk-1.6.0_02-fcs.rpm" is "1.6u2"? :O Jul 6, 2014 at 14:17
  • 1
    I found it!! THANKS! it was named: jdk-6u2-linux-i586.rpm THANK YOU! Jul 6, 2014 at 15:40
  • 1
    @evachristine - yup that's the one, glad that solved it.
    – slm
    Jul 6, 2014 at 17:31

As a general rule no.

With a bit of luck rpm -qi and rpm -q --changelog provide insight to where the package came from.

If it was built on the system it's running on you may still have the spec file used to make the actual rpm, if not both.

As a general rule I don't recommend copying files/binaries but most of meta information is in the RPM database and you have the actual files.

rpm -q --list <pkg_name> shows all files a package deploys.

rpm -q --scripts <pkg_name> to show any scripts that get executed by installing (or removing) the package might provide as least as much insight into its purpose as the files that get deployed.

And any dependancies that have to be installed can be found with rpm -q --requires <pkg_name>.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.