Recovered from the older tannerjc.net wiki snapshot dated January 23, 2016.

General Preparation

sysstat: patching and rebuilding

  • Install the source rpm package rpm -ivh ftp://ftp.redhat.com/redhat/linux/enterprise/5Server/en/os/SRPMS/sysstat-7.0.2-3.el5.src.rpm

  • Find the file that needs to be patched find sysstat-7.0.2 | xargs fgrep -iH sadc -F

  • Backup existing file(s) that are going to be modified, then make appropriate changes cp sysstat-7.0.2/sa1.in sysstat-7.0.2/sa1.in.bak vi sysstat-7.0.2/sa1.in

  • Create a patch file with a header that specifies the executed diff command diff -up sysstat-7.0.2/sa1.in.bak sysstat-7.0.2/sa1.in

  • Examine the first line in the existing patches to see the first line examples head -n1 *.patch | fgrep diff

  • Examine final patch file

diff -up sysstat-7.0.2/sa1.in.bak sysstat-7.0.2/sa1.in
--- sysstat-7.0.2/sa1.in.bak    2010-05-28 12:50:48.000000000 -0400
+++ sysstat-7.0.2/sa1.in        2010-05-28 12:54:08.000000000 -0400
@@ -10,8 +10,8 @@ then
 # Note: Stats are written at the end of previous file *and* at the
 # beginning of the new one (when there is a file rotation) only if
 # outfile has been specified as '-' on the command line...
-       exec ${ENDIR}/sadc -F -L 1 1 -
+       exec ${ENDIR}/sadc -d -F -L 1 1 -
 else
-       exec ${ENDIR}/sadc -F -L $* -
+       exec ${ENDIR}/sadc -d -F -L $* -
 fi
  • Copy and rename patch cp /tmp/diskmod.patch /usr/src/redhat/SOURCES/sysstat-7.0.2-diskmod.patch

  • Examine existing patch directives in spec file for a point of reference

Patch0: sysstat-4.0.1-config.patch
Patch3: sysstat-5.0.5-statreset.patch
Patch6: sysstat-5.0.5-append-msg.patch
Patch8: sysstat-7.0.0-nfs.patch
Patch9: sysstat-7.0.0-nfs2.patch
Patch10: sysstat-7.0.2-debuginfo.patch
Patch11: sysstat-7.0.2-close.patch
Patch12: sysstat-7.0.2-hotplug.patch
Patch13: sysstat-7.0.2-devmap_name.patch
Patch14: sysstat-7.0.2-sr.patch
Patch15: sysstat-7.0.2-ia64.patch
Patch16: sysstat-7.0.2-nfs_ext.patch
%patch0 -p1 -b .config
%patch3 -p1 -b .statreset
%patch6 -p1 -b .append-msg
%patch8 -p1 -b .nfs
%patch9 -p1 -b .nfs2
%patch10 -p1 -b .deb
%patch11 -p1 -b .clo
%patch12 -p1 -b .hp
%patch13 -p1 -b .dmn
%patch14 -p1 -b .sr
%patch15 -p1 -b .ia64
%patch16 -p1 -b .nfs3
  • Add information to ~/packagebuild/SPECS/sysstat.spec
Patch17: sysstat-7.0.2-diskmod.patch
%patch17 -p1 -b .diskmod
  • Build the new rpm
[root@localhost redhat]# rpmbuild -bb /usr/src/redhat/SPECS/sysstat.spec
...
Wrote: /usr/src/redhat/RPMS/x86_64/sysstat-7.0.2-3.x86_64.rpm
...
  • Install RPM and check that the patches were applied
[root@localhost ~]# rpm -ivh /home/jtanner/packagebuild/RPMS/x86_64/sysstat-7.0.2-3.x86_64.rpm
[root@localhost ~]# fgrep exec  /usr/lib64/sa/sa1
	exec ${ENDIR}/sadc -d -F -L 1 1 -
	exec ${ENDIR}/sadc -d -F -L $* -

makeme: deploying files

  • Create the files that are going to go in the source tarball**
mkdir -p /tmp/makeme-1.0/dir1
mkdir -p /tmp/makeme-1.0/dir2
touch /tmp/makeme-1.0/dir1/1
touch /tmp/makeme-1.0/dir1/2
touch /tmp/makeme-1.0/dir1/3
touch /tmp/makeme-1.0/dir2/4
touch /tmp/makeme-1.0/dir2/5
  • Build the source tarball**
cd /tmp
tar -czvf makeme-1.0.tar.gz makeme-1.0
cp makeme-1.0.tar.gz /usr/src/redhat/SOURCES/
  • Create /usr/src/redhat/SPECS/makeme.spec**
Summary: rpm file deployment demonstration
Name: makeme
Version: 1.0
Release: 1
Group: Files/Text
License: Freely distributable
BuildArch: noarch
Source: %{name}-%{version}.tar.gz

#Buildroot: %{_tmppath}/%{name}-%{version}-root
Buildroot: %{_tmppath}/%{name}-%{version}

%description
makeme puts empty files in /tmp/makeme-1.0

%prep
%setup -q

%build

%install
install -d $RPM_BUILD_ROOT
install --verbose -d $RPM_BUILD_ROOT/tmp/makeme-1.0
install --verbose -d $RPM_BUILD_ROOT/tmp/makeme-1.0/dir1
install --verbose -d $RPM_BUILD_ROOT/tmp/makeme-1.0/dir2
install --verbose /tmp/makeme-1.0/dir1/1 $RPM_BUILD_ROOT/tmp/makeme-1.0/dir1/1
install --verbose /tmp/makeme-1.0/dir1/2 $RPM_BUILD_ROOT/tmp/makeme-1.0/dir1/2
install --verbose /tmp/makeme-1.0/dir1/3 $RPM_BUILD_ROOT/tmp/makeme-1.0/dir1/3
install --verbose /tmp/makeme-1.0/dir2/4 $RPM_BUILD_ROOT/tmp/makeme-1.0/dir2/4
install --verbose /tmp/makeme-1.0/dir2/5 $RPM_BUILD_ROOT/tmp/makeme-1.0/dir2/5

%files
%defattr(-,root,root)
%dir /tmp/makeme-1.0/dir1
%dir /tmp/makeme-1.0/dir2
%attr(0644,-,-) /tmp/makeme-1.0/dir1/1
%attr(0644,-,-) /tmp/makeme-1.0/dir1/2
%attr(0644,-,-) /tmp/makeme-1.0/dir1/3
%attr(0644,-,-) /tmp/makeme-1.0/dir2/4
%attr(0644,-,-) /tmp/makeme-1.0/dir2/5

%clean
rm -rf $RPM_BUILD_ROOT

%changelog
  • Build the RPM**

rpmbuild -bb /usr/src/redhat/SPECS/makeme.spec