RPM build with single file

OS: RHEL 6

There is script /usr/sbin/khmel.sh
Simple way to build RPM file, that will install this scrip on another systems.

Install

yum install rpmdevtools

Create directory structure

rpmdev-setuptree

Copy template

cp /etc/rpmdevtools/spectemplate-minimal.spec /root/rpmbuild/SPECS/khmel.org.spec

Remove and edit strings in .spec file to get such result:

Name:        khmel
Version:     1.0
Release:     4
Summary:     Print different words
Group:       Misc
License:     GPL
URL:         http://khmel.org
%description
This package contain script, that print different words.
%files
/usr/sbin/khmel.sh

Trying to build rpm

rpmbuild -bb /root/rpmbuild/SPECS/khmel.org.spec
Processing files: khmel-1.0-4.i686
error: File not found: /root/rpmbuild/BUILDROOT/khmel-1.0-4.i386/usr/sbin/khmel.sh

According error message creating subdirectory and copy script

mkdir -p /root/rpmbuild/BUILDROOT/khmel-1.0-4.i386/usr/sbin/
cp -ar /usr/sbin/khmel.sh /root/rpmbuild/BUILDROOT/khmel-1.0-4.i386/usr/sbin/khmel.sh

Build RPM again

rpmbuild -bb /root/rpmbuild/SPECS/khmel.org.spec

New rpm is located here

/root/rpmbuild/RPMS/i686/khmel-1.0-4.i686.rpm

Installation on another system

rpm -iv khmel-1.0-4.i686.rpm

Leave a Reply

Your email address will not be published. Required fields are marked *