How to create spec file ( RPM)
linux, rpm, shell
Solution
Had to do this just yesterday.
Create your build directory in your home as a normal user don't use root, just smart that way.
mkdir -p ~/rpmbuild/BUILD
mkdir -p ~/rpmbuild/BUILDROOT
mkdir -p ~/rpmbuild/RPMS
mkdir -p ~/rpmbuild/SOURCES
mkdir -p ~/rpmbuild/SPECS
mkdir -p ~/rpmbuild/SRPMCS
mkdir -p ~/rpmbuild/tmp
Next create rpmmacros so that rpmbuild knows where to build, contents of ~/.rpmmacros should contains the following
%packager Chris Hinshaw
%_topdir /home/chinshaw/rpmbuild
%_tmppath /home/chinshaw/rpmbuild/tmp
Next create the rpm spec found in ~/rpmbuild/SPECS/ . This example spec file will handle a script called demo script, it's configuration file that goes in etc and a third cron script that will schedule the script to run hourly.
~/rpmbuild/SPECS/demoproject.spec
Name: demoproject
Version: 0.1
Release: 1%{?dist}
Summary: Demo script for doing something cool
Group: DemoGroup
License: GPL
Source0: demoproject-0.1.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
%description
Demo project that does something interesting
%prep
%setup -q
%build
%install
install --directory $RPM_BUILD_ROOT/usr/sbin
install --directory $RPM_BUILD_ROOT/etc
install --directory $RPM_BUILD_ROOT/etc/cron.d/
install -m 0755 demoscript $RPM_BUILD_ROOT/usr/sbin
install -m 0744 demoscript.conf $RPM_BUILD_ROOT/etc
install -m 0744 cron/democronscript $RPM_BUILD_ROOT/etc/cron.d/
%clean
rm -rf $RPM_BUILD_ROOT
%files
/usr/sbin/demoscript
/etc/demoscript.conf
/etc/cron.d/democronscript
%changelog
The only quirk I found was that I really needed to tar up my 3 source files in a tarball which seemed like a good idea anyway.
The contents or the rpmbuild/SOURCES directory should look like this.
$ cd ~/rpmbuild/SOURCES
$ ls
demoproject-0.1.tar.gz
$ tar -tvzf demoproject-0.1.tar.gz
demoproject-0.1/
demoproject-0.1/demoscript.conf
demoproject-0.1/demoscript
demoproject-0.1/cron/
demoproject-0.1/cron/democronscript
then all you have to do is build it rpmbuild -ba ~/rpmbuild/SPECS/demoproject.spec
This will create arch rpms and srpms and land them in the ~/rpmbuild/RPMS and ~/rpmbuild/SRPMS directories.
Problem
I've 2 files which include shell command to be execute ,, and I've one `iptables-save` which include chain need to installed How can I write the spec file to: - copy my 2 shell files to /etc/ - execute `iptables-restore < /home/iptables-save` P.S: I went through this how-to. Unfortunately I'm newbie in this, I couldn't find the solution.