Sunday, April 1, 2007

what sent me on my search of rpmbuild in the first place

I found myself trying to use cfdisk on the fedora core 5 (fc5) system, only to find that it didn't exist and there were no precompiled packages for it that I could see. I did some searching, finding out that cfdisk comes with the util-linux package (on a NORMAL system ;p) ... however, it was nowhere to be found in the fc5 util-linux package. I searched google for some answers and found that the redhat team had removed cfdisk from the build of util-linux because it 'sucked' back in 2001. I personally find cfdisk handy for both editing and viewing partitions. I continued on to get the util-linux source package and then tried to rebuild it, finding the system was missing rpmbuild by default (probably because I didn't install the development options during the installation).

I after the whole problem of finding rpmbuild missing and not in the package I expected, I got that sorted out, and continued on to try and rebuild util-linux with cfdisk included.

// note: first here's a few other steps I took before getting to the rebuild part

// to get the yumdownloader program
yum install yum-utils

// to get the util-linux source package from the repositories
yumdownloader --source util-linux --enablerepo core-source --enablerepo extras-source --enablerepo updates-source

// and finally, editing the spec file and trying to build the source package

cd /usr/src/redhat/SPECS

nano -wb util-linux.spec

// find any spots that remove cfdisk functionality (hint: CTRL-W for search in nano, and put in cfdisk and then remove those references to cfdisk, README.cfdisk and one other one I don't recall what)

// I then proceeded with my first attempt to rebuild the package (while in the SPECS dir still):

// -bb just builds the binary pacakge, as we don't really need a modified version of the source package

rpmbuild -bb util-linux.spec
error: Failed build dependencies: pam-devel is needed by util-linux-2.13-0.20.4.i386 ncurses-devel is needed by util-linux-2.13-0.20.4.i386 libtermcap-devel is needed by util-linux-2.13-0.20.4.i386 zlib-devel is needed by util-linux-2.13-0.20.4.i386 slang-devel is needed by util-linux-2.13-0.20.4.i386 texinfo is needed by util-linux-2.13-0.20.4.i386 gettext-devel is needed by util-linux-2.13-0.20.4.i386 libselinux-devel is needed by util-linux-2.13-0.20.4.i386 e2fsprogs-devel >= 1.36 is needed by util-linux-2.13-0.20.4.i386 audit-libs-devel >= 1.0.6 is needed by util-linux-2.13-0.20.4.i386

// followed by: (to fix the problems, which also installed other dependencies)

yum install pam-devel ncurses-devel libtermcap-devel zlib-devel slang-devel texinfo gettext-devel libselinux-devel e2fsprogs-devel audit-libs-devel

// and yet again, followed by (because of a build error saying it couldn't find aclocal, which also installed m4 as a dependency):

yum install automake autoconf

// I then re-ran rpmbuild -bb --target=i586 util-linux.spec
// with the following results:

Obsoletes: fdisk tunelp mount losetup schedutils
Checking for unpackaged file(s): /usr/lib/rpm/check-files /var/tmp/util-linux-root
error: Installed (but unpackaged) file(s) found:
/sbin/cfdisk
/usr/share/man/man8/cfdisk.8.gz


RPM build errors:
Installed (but unpackaged) file(s) found:
/sbin/cfdisk
/usr/share/man/man8/cfdisk.8.gz

// This means that the cfdisk file was built, but isn't listed as an included file in the rpm package (per the spec file) ... so I need to edit the util-linux.spec file to be like the following:

// old:
/sbin/fdisk
%{_mandir}/man8/fdisk.8*

// new:
/sbin/fdisk
%{_mandir}/man8/fdisk.8*
/sbin/cfdisk
%{_mandir}/man8/cfdisk.8*

// Finally... a successful build of util-linux with cfdisk being included in the package instead of behing removed.

// and finally, the commands to install this util-linux over top your old util linux:

rpm -Uvh --force /usr/src/redhat/RPMS/i586/util-linux-2.13-0.20.4.i586.rpm

// --force was required since the package was already listed as being installed (and technically it was the same version)

// one thing to note is that if redhat ever updates the util-linux package, it may over-write your util-linux package during the update... I'm not sure if it will remove the cfdisk binary or not (it probably will), so you may want to add util-linux to a list of packages that are not to be updated automatically... or, if you're energetic, you could create a small patch between the original spec file and the modified one and keep it around for when you want to rebuild util-linux with newer source packages. The second idea may be better in the long run, as there may be security updates that should be installed for this package at some point.. so of course to err on the side of safety, you should allow redhat to replace the util-linux package with the default ones (if there are updates) and if you ever notice cfdisk is not available on the box, it means you need to go download the latest source package for util-linux from the repositories, edit the specfile, and build away, and finally re-install the updated package.

No comments: