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



No comments:

Post a Comment