How to rebuild rpm for centos4 / el4

in order to rebuild rpm package for centos4 or RHEL4 equivalent..

Step :
1. create the directory structure as required for building rpm.

You may already have one in /usr/src/RPM, but as rebuilding package as root is evil, we recommend that you create one to a place where your normal user account allows you to write, such as your home directory. This build tree should have the following structure:

|-- RPMS
|   |-- i386
|   |-- i586
|   `-- noarch
`-- tmp

2. create simple rpm-macro ..for a normal user.

because compiling using root is devil. hahahaha.

Now you need to do some rpm configuration. A simple ~/.rpmmacros with the following contents should be enough:

%_topdir        %(echo ${HOME}/rpm)
%_tmppath       %{_topdir}/tmp

%packager       Firstname Lastname <your.address@here>
%distribution JPackage
%vendor JPackage Project

# Uncomment to have built RPMs land in RPMS/ instead of RPMS/<arch>/
#%_rpmfilename  %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm

# Uncomment for signing your packages with GPG
#%_gpg_name FirstName LastName <email address>
#%_gpg_path /path/to/keys

Of course, substitute your own name to the above. Note that all macros are only default values for tags not explicitly filled in spec files.

3.get the source tgz or rpm.

4. rpmbuild -ba source-<version>-.tgz


rpm -i source-<version>.rpm

this one will create the spec into SPECS folder.


Normal command for rebuilding a standard source package (.src.rpm) is:
rpmbuild --rebuild foo-x.y.z-wjpp.src.rpm If you are using an older (pre-4.0.2?) version of rpm, substitute rpmbuild with rpm in the command. Note that rpmbuild is usually part of the rpm-build package.

Further, packages from non-free section are actually .nosrc.rpm, meaning that they don’t contain all sources due to legal issues (prohibited redistribution). So, you’ll have to proceed in several steps here.

  1. Install the source package:
    rpm -i foo-x.y.z-wjpp.nosrc.rpm
  2. Get the missing sources from their original location. File names and base URLs can be found in the spec file, installed into rpm/SPECS/foo.spec by the above command.
  3. Put the sources you’ve downloaded to rpm/SOURCES.
  4. Build package from spec file:
    rpmbuild -ba rpm/SPECS/foo.spec
    (again, substituting rpmbuild with rpm if necessary)

Unless something fails in the process, you should obtain the source package in rpm/SRPMS and binary package in relevant subdirectory of rpm/RPMS.

5. rebuild for SPECS.

rpmbuild -ba SPECS/source-<version>.spec

6. create a repos directory folder which will hold all the file that you want to publish.

let say /home/user/repos

copy all the necessary rpms and SRPMS into this folder..

if want to divide by the architecture also can.

so that we will have something like /home/user/repos/i386/

will all the RPMs and SRPMs.

7. now create all necessary file to make it as a valid yum/repos

cd /home/user/repos/i386

yum-arch .

createrepo .

Basically is done.

8. publish it into your ftp folder.

cd /home/user/repos/i386

ftp -i

cd public_html/repository/i386

mkdir repodata

mkdir headers

mput *.rpm

cd headerslcd headers

mput *

lcd ../repodata

cd ../repodata

mput * create some repos conf.

name=CentOS.namran-EL$releasever - Stable

10 . so that the end user

can just ..

cd /e tc/y um.repos.d/

“wget” http://my.

References :



Related Post

7 Responses

  1. Harvey says:

    It is the best time to make some plans for the future and it’s time to be happy. I’ve read this post and if I could I want to suggest you some interesting things or advice. Maybe you can write next articles referring to this article. I desire to read even more things about it!

  2. Rachel says:

    Thanks for sharing your info. I really appreciate your efforts and I am waiting for your further write ups thank you once again.

  3. Brittney says:

    I do not even know the way I ended up here, however I thought this put up used to be great. I don’t recognize who you might be but certainly you’re going to a well-known blogger in case you are not already. Cheers!

  4. website says:

    What’s up, after reading this amazing article i am too delighted to share my knowledge here with colleagues.

  5. says:

    Do you mind if I quote a couple of your articles as long as I provide
    credit and sources back to your site? My blog site is in the very same niche as yours
    and my users would genuinely benefit from some
    of the information you present here. Please let me know if this okay with you.
    Many thanks!

  6. calvin klein underwear uk says:

    Incredible! This blog looks just like my old one! It’s on a completely different subject but it has pretty much the same page layout and design. Great choice of colors!

  7. calvin klein underwear uk says:

    I really like what you guys are usually up too. Such clever work and coverage!
    Keep up the amazing works guys I’ve included you guys to my own blogroll.


Leave a Reply

Your email address will not be published. Required fields are marked *