Showing posts with label rpm. Show all posts
Showing posts with label rpm. Show all posts

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

Saturday, June 11, 2011

Creating a Simple RPM

Create your simple script
mkdir testrpm-1.0
vi ~/testrpm-1.0/testrpm.sh


#!/bin/bash
#hello.sh
echo 'this is a test rpm'
exit 0

Install rpm build tools
yum install -y rpmlint rpmdevtools rpm-build

Create the rpmbuild directories as regular user
rpmdev-setuptree
This command will automatically create~/rpmbuild/{BUILD  BUILDROOT  RPMS  SOURCES  SPECS  SRPMS} directories

Create the skeletal spec file 
rpmdev-newspec -o testrpm.spec

edit testrpm.spec
Name:           testrpm
Version:        1.0
Release:        1%{?dist}
Summary:        testrpm

Group:          Development/Tools
License:        GPL
Source0:        testrpm-1.0.tar.gz
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}

%description
this is a test rpmpackage
%prep
%setup -q


%install
rm -rf $RPM_BUILD_ROOT
install -D testrpm.sh $RPM_BUILD_ROOT/opt/testrpm.sh

%clean
rm -rf $RPM_BUILD_ROOT


%files
%attr (770,root,root) /opt


%changelog

Build your rpm
rpmbuild -v -bb ~/SPECS/testrpm.spec

RPM package can be located under ~/rpmbuild/RPMS