Saturday, August 13, 2011

Creating Simple RPM Part 2


Needed packages
1. rpm-build
2. rpmdevtools


Create RPM Howto
* run rpmdev-setuptree creates rpmbuild directories
1. create directory and the file inside the created dir

mkdir ~/Hello-1.0
touch ~/Hello-1.0/hello
chmod +x ~/Hello-1.0/hello

2. create the gzip-compressed tar and copy to the SOURCE dir

tar cvzf Hello-1.0.tar.gz ~/Hello-1.0
cp Hello-1.0.tar.gz ~/rpmbuild/SOURCES


3. create the spec file
rpmdev-newspec

4. copy the sample spec file to the package spec
cp newpackage.spec hello.spec

5. Edit hello.spec
Name: Hello
Version: 1.0
Release: 1%{?dist}
Summary: Hellow RPM

Group: Miscellaneous
License: GPL
URL: www.penoycentral.net
Source0: Hello-1.0.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

%description
A sample RPM for RHCE exam

%prep
%setup -q


%build


%install
rm -rf $RPM_BUILD_ROOT
install -d -m 0755 $RPM_BUILD_ROOT/opt/Hello-1.0
install -m 0755 hello $RPM_BUILD_ROOT/opt/Hello-1.0/hello

%clean
rm -rf $RPM_BUILD_ROOT


%files
%dir /opt/Hello-1.0
%defattr(-,root,root,-)
/opt/Hello-1.0/hello


6. Build the source rpm
rpmbuild -ba ~/rpmbuild/SPECS/hello.spec

7. RPM package can now be found in ~/rpmbuild/RPMS/x86_64/Hello-1.0.rpm

1 comment:

  1. You can type the follow command it is faster : rpmdev-newspec hello.spec :)

    ReplyDelete