Making an RPM that contains only text files
I wanted to make an RPM file that contained a few configuration files for Cfengine (namely failsafe.cf and update.cf) so that this RPM file could be quickly deployed on many servers with minimal effort and no errors. Here is how I did it, hopefully you can easily adapt it to your needs.
These instructions assume you already have the RPM and RPMbuild tools installed and the ~/rpmbuild/{BUILD,SOURCES,RPM,SPECS} directories ready for use.
- Make a directory for the files under your ~/rpmbuild/SOURCES directory that contains the package name and version number:
mkdir ~/rpmbuild/SOURCES/cfengine-bootstrap-1.0
- If all the files go into a single directory then you can just put them all here. Otherwise, create the directory structure you need, e.g.,
mkdir -p ~/rpmbuild/SOURCES/cfengine-bootstrap-1.0/var/cfengine/inputs
- Copy the files into the directory or directories:
cp -a ~/.cfagent/inputs/{failsafe.cf,update.cf} \ ~/rpmbuild/SOURCES/cfengine-bootstrap-1.0/ - Create a SPEC file (example below) in ~/rpmbuild/SPECS/.
- Build your RPM:
rpmbuild -bb ~/rpmbuild/SPECS/cfengine-bootstrap-1.0.spec
- Check that your RPM file contains the files you expect:
~$ rpm -qlp ~/rpmbuild/RPMS/x86_64/cfengine-bootstrap-1.0-1.x86_64.rpm /var/cfengine /var/cfengine/inputs /var/cfengine/inputs/failsafe.cf /var/cfengine/inputs/update.cf
- Move the RPM file to your repository.
- Run createrepo on your repository directory.
- Run yum makecache to update YUM's file list.
- Type “yum search cfengine” (or whatever the name of your file is) and you should see it.
$ yum search cfengine ========================== Matched: cfengine ========================== cfengine.x86_64 : Server configuration administration tool cfengine-community.x86_64 : The Cfengine Configuration System cfengine-docs.x86_64 : Cfengine documentation cfengine-bootstrap.noarch : Cfengine files for boot-strapping
SPEC file sample
Here is my SPEC file for the above example:
Summary: Cfengine failsafe and update files for boot-strapping
Name: cfengine-bootstrap
Version: 1.0
Release: 1%{?dist}
License: None
Group: System Environment/Base
URL: http://www.ispltd.com/
Source: %{name}-%{version}.tgz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
BuildArch: noarch
%description
Basic files to get a new server running with Cfengine.
Once a server has these it can contact the master policy
server and retrieve the full set of policy files.
%prep
%setup
%build
%install
%{__install} -d -m0775 %{buildroot}%{_localstatedir}/cfengine/inputs/
cp -a *.cf %{buildroot}%{_localstatedir}/cfengine/inputs/
%post
%preun
%clean
%files
%defattr(-, root, root, 0755)
# %config(noreplace) /var/cfengine/inputs/*.cf
%{_localstatedir}/cfengine/
%changelog
* Fri Nov 03 2010 Angelo Babudro <tech. support`@`ispltd. c`om> - 1.0
- First release (remove back-ticks & spaces in e-mail to write to me)