Wednesday, June 24, 2020

How to build rpms

prepare the source file

first of all, you need all your source files ready under ~/RPMBUILD/SOURCES dircetory
For example if you wan to build jkd1.8.0 rpm, you may want the java8-local_policy.jar and java8-US_export_policy.jar from java 8 JCE and the jre-8u111-linux-x64.tar.gz from oracle website.

prepare the .spec file

once the source files are in place, you need to write a mybuild.spec file to instruct the rpm command how to pre, build, install, clean, files, preun, post the files in the rpm package.
this file has to be put in the ~/RPMBUILD/SPECS directory.

build rpm

now you can run the following command to build the rpm
rpmbuild -ba ~/RPMBUILD/SPECS/mybuild.spec

this command will put the resulting rpm in ~/RPMBUILD/RPMS/x86_64.

post to yum repo

You can optional set the rpm to be managed by yum.
Assuming you plan to place the repository in /var/www/html which is the default directory for Red Hat based Apache installations.
Also assuming you have run 

yum install yum-utils;
reposync -p /var/www/html/;

so that you can present this directory with apache.

now all you have to do is copy the rpm into /var/www/html/fedora/jdk8/
then run command
run createrepo /var/www/html/fedora/jdk8/

If your apache server is running, your new rpm should now be managed by yum.
If not, run it:
yum install httpd;
chekconfig httpd on;
service httpd start;


config yum client

On the client host you need to point the yum repo to the yum server you just setup,

for simplicity, lets use the yum server itself as client

create a /etc/yum.repos.d/local.repo file
[Local-Repository]
name=mylocal
baseurl=http://ip-of-my-server/fedora/jdk8
enabled=1
gpgcheck=0

final result

now once you type 
yum install rpm-name-set-in-spec-file

the rpm will be intalled




No comments:

Post a Comment

Why I stopped publishing blog posts as information provider

Now the AI can generate content. Does that mean the web publishing industry reaches the end? ChatGPT said: ChatGPT Not at all. While AI can ...