Sunday, 14 October 2012

RHCE dump questions ??........

How to create a rpm package that i can distribute to others as intallable file ?

RHCE is one of the prestigious certifications in open source domain.Upto my knowledge it doesnt have any dump questions as any other famous certification programs have,so that we can clear the examination easily.Thanks to the non-availability of those dump questions.

    I am really enjoying  RHCE course presently.As for as examination point is concerned one can practice its exercieses and gain confidence..Here in my blog i am providing solutions which i have worked on.Please post ur doubts as comments, i will try to clear it or come lets discuss it.

How to create a rpm package that i can distribute to others as an intallable file ?

Let me go in step by step order.

For people who try this for first time,please try to do using root user or sudoers privilages.

1.The softwares needed to perform this exercise: rpm-build
yum install   rpm-build


2.Now write your own shell program and save it.In my case my shell program file name is krish.
 Create a tar roll like krish-1.0.tar.gz which should contain your script .

3.Now create spec file ,for that follow the procedure below,
note: in my case my spec file name is krishna

vim krishna.spec

note: please open it in vim not vi ,because vim creates a default specification template.

now the spec file template and its settings are shown below.

Name:           krish
Version:        1.0
Release:        1%{?dist}
Summary:        just a sample echo

Group:          applications
License:        EULA
Source0:        krish-1.0.tar.gz
BuildRoot:      %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)

BuildRequires:  /bin/rm,/bin/cp,/bin/mkdir
Requires:       /bin/bash,/bin/date

a demo package
%setup -q
#make %{?_smp_mflags}

mkdir -p $RPM_BUILD_ROOT/usr/local/bin
cp krish $RPM_BUILD_ROOT/usr/local/bin



krish --> script name which is contained in krish-1.0.tar.gz.
Name : krish
version: 1.0

these two are merged and hence it expects the source to be : krish-1.0.tar.gz.Configure this spec file with the names of ur tar file ,name and version.

4.Now our spec file is follow the command below,

rpmbuild  -ba krishna.spec

now it can say that it cant find ur tar.gz inside rpmbuild/SOURCES

   --> move your tar.gz source file to the path it specifies like in my case as root user,


    --> move your spec file  to /root/rpmbuild/SPECS/

now use

 rpmbuild -ba  krishna.spec


Here the package is created inside RPMS directory..we can note it from wrote keyword that is highlighted.


rpm -ivh  *.rpm

Please find the screenshot below..

you can find the screenshot the ' krish '  program can now be used as any other command.

Now this is rpm package you can distribute.
Please post any errors you face ,we will discuss it.Happy learning.....

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...