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:

rpm
|-- BUILD
|-- RPMS
|   |-- i386
|   |-- i586
|   `-- noarch
|-- SOURCES
|-- SPECS
|-- SRPMS
`-- 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 <[email protected]>
%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

or..

rpm -i source-<version>.rpm

this one will create the spec into SPECS folder.

else…

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 hostname.net

cd public_html/repository/i386

mkdir repodata

mkdir headers

mput *.rpm

cd headerslcd headers

mput *

lcd ../repodata

cd ../repodata

mput *

9.now create some repos conf.

[namran-CentOS-Misc]
name=CentOS.namran-EL$releasever - Stable
gpgcheck=0
enabled=1
baseurl=http://my.namran.net/repository/centos$releasever/misc/$basearch/

http://my.namran.net/repository/namran-CentOs-misc.repo

10 . so that the end user

can just ..

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

“wget” http://my. namran.net/repository/namran-CentOs-misc.repo

References :

1. jpackage.org

2. openvpn.org

Get Free Email Updates!

Signup now and receive an email once I publish new content.

I will never give away, trade or sell your email address. You can unsubscribe at any time.

Like

Related Post

24 Responses

  1. ahstod says:

    … how long did you manage to get away without installing this one? 😎

    Reply
  2. namran says:

    approximately within 48hours.. hahaha.. (very slow-pace mode) as the file exist since..

    Mon Mar 9 15:28:31 2009 UTC (32 hours, 49 minutes ago) by ..

    quite weird when most of the item are just disappeared..
    .. at first thought some config problem.. removing the whole project directory and re-checkout.. still the same..
    then only figured one by one.. lol..

    Reply
  3. Andre says:

    Worked for me. Many thanks!

    Reply
    • HawkEYE says:

      @Andre : you’re welcome.. hopefully it help those in need.

      Reply
  4. Spyder461 says:

    I’m still having this problem. If done the yum install php-xml, but I still get the error about missing DomDocument class. I have read some posts that talk about executing a enable lib-xml extension command, but when I do this command, I get a error that lib-xml and extension is not a builtin command. Any suggestions would be appreciated.

    Reply
  5. danyal says:

    really very helpful it works

    Reply
  6. sachin says:

    Good, It worked

    Reply
  7. nszumowski says:

    Awesome! Everywhere else I was looking referenced libxml2 which I had already installed. This fixed my issue!

    Reply
  8. nico says:

    Awesome! thanks so much.

    Reply
  9. battisti says:

    Thx, after a lot of hours spend in the source the problem was in the server! 🙁

    Reply
  10. dungkal says:

    Updating the php-xml (note: it had already been installed long before the problem cropped up) on my CentOS server did the trick.

    Thanks for the help.

    Reply
  11. wika says:

    Thanks, it worked !!

    Reply
  12. rc says:

    Just a note, if you’re on centos and you had to do a custom install of php 5.3, yum install php53-xml will do the trick

    Reply
  13. elliot says:

    @rc – thank you!

    Reply
  14. Andrea says:

    Woooow, thank you!
    U save my ass…

    Reply
  15. littleguy says:

    This worked great, thanks!

    Reply
  16. mark says:

    Thank you , was baffled with this error, your post saved the day

    Reply
  17. Smoker says:

    It worked for me like a charm. Thank you verry much.

    Reply
  18. Thanga says:

    ANSWER IS HANDY :)THANKS A LOT

    Reply
  19. axlotl says:

    Thank you, sir.

    Reply
  20. dduane says:

    I also had to add the line:
    extension=dom.so
    to my php.ini file and restart apache. I’m using Fedora 16.

    Reply
  21. vb says:

    Thanks. saved a lot of time. Had that issue with owncloud

    Reply
  22. khyox says:

    Thank you very much indeed! It solved my issue viewing the internal wiki syntax page with dokuwiki running over lighttpd in Scientific Linux.

    Reply
  23. Andre says:

    Muito obrigado valeu muito o bizu de instalar esta yum install php-xml, excelente ajuda, estava precisando muito

    Reply

Anything to add?

X