Kano's Instructions Modified / Annotated for CentOS 6.4Before Kano's stuff we do some preparation for a new user as well as prepare per
http://wiki.centos.org/TipsAndTricks/YumAndRPMWe start as the root user, create a new user "abcd" and then continue work as this new user. That way, everything is fresh.
[root] yum install rpm-build # Install the package builder
[root] useradd abcd # Add a new user named abcd
[root] su abcd # Become user abcd
[abcd] cd /home/abcd
[abcd] mkdir /home/abcd/rpmbuild/{BUILD,RPMS,SPECS,SOURCES,SRPMS} # Build the directory structure for rpmbuild
[abcd] # The next two lines create a special rpmbuild file that tells the packager where we want to build and who we are
[abcd] echo "%_topdir /home/abcd/rpmbuild" > /home/abcd/.rpmmacros
[abcd] echo "%packager Test User <
testuser@example.com>" >> /home/abcd/.rpmmacros
1) Find the correct SRC RPM
Update fc16 to the latest everything and get openssl-1.0.0j-1.fc16.src.rpm from any mirror
[abcd] cd /home/abcd ; curl -O
http://vault.centos.org/6.4/os/Source/SPackages/openssl-1.0.0-27.el6.src.rpm2) rpm -Uvh openssl-1.0.0j-1.fc16.src.rpm[abcd] rpm --install openssl-1.0.0-27.el6.src.rpm
Note: I'm getting a warning which I'm going to ignore (for now) : group mockbuild does not exist - using root
3) cd ~/rpmbuild/SPECS[abcd] cd ~/abcd/rpmbuild/SPECS
4) vim openssl.spec
look for "./Configure" at the start of a line
(in 1.0.0j-1.fc16 it is line 219)
about 3 lines down from that you will see:
enable-cms enable-md2 no-idea no-mdc2 no-rc5 no-ec no-ecdh no-ecdsa \
change it to look like:
enable-cms enable-md2 no-idea no-mdc2 no-rc5 enable-ec enable-ecdh enable-ecdsa \I'm going to use the
sed editor because you can find it on almost any linux box and you can do these changes as little one-line scripts.
[abcd] sed -i -e "s/no-ec/enable-ec/; s/no-ecdh/enable-ecdh/; s/no-ecdsa/enable-ecdsa/" /home/abcd/rpmbuild/SPECS/openssl.spec
search for
Source1: hobble-openssl
(line 29) and change it (comment it out) to:
#Source1: hobble-openssl
search for
%{SOURCE1} > /dev/null
(line 133) and change it (comment it out) to:
#%{SOURCE1} > /dev/null[abcd] sed -i -e "s/^Source1: hobble-openssl/#&/; s/^%.SOURCE1. /#&/" ~/rpmbuild/SPECS/openssl.spec
go back to the top and increase "Release:"
line 24 increment the "Release:" number
e.g. change
Release: 1%{?dist}
to
Release: 2%{?dist}For now, I'm going to keep the version unchanged unless it seems important to do so. (can always force the package update)
5) install rpm-build
yum install rpm-buildWe completed this step right in the beginning when we were still the root user, so can ignore now
6) cd ~/rpmbuild/SOURCES/
in ~/rpmbuild/SOURCES/ there is a file called "openssl-1.0.0j-usa.tar.xz"
rename it to "openssl-1.0.0j-usa.tar.xz.orig" (or whatever else you like)[abcd] cd ~/rpmbuild/SOURCES/ ; mv openssl-1.0.0-usa.tar.bz2 old-usa-bz2-file-not-needed
get a full replacement for the tar file, at http://www.openssl.org/source/
http://www.openssl.org/source/openssl-1.0.0j.tar.gz
and put it in the directory: ~/rpmbuild/SOURCES/
then rename it to "openssl-1.0.0j-usa.tar.xz"[abcd] cd ~/rpmbuild/SOURCES/ ; curl -O
http://www.openssl.org/source/openssl-1.0.0j.tar.gz # Download sources from openssl.org
[abcd] gunzip -d openssl-1.0.0j.tar.gz ; bzip2 -z openssl-1.0.0j.tar # We have to convert to .bz2 because that is required in spec file openssl.spec
[abcd] mv openssl-1.0.0j.tar.bz2 openssl-1.0.0-usa.tar.bz2 # We have to rename it to this because that is what the spec file openssl.spec is looking for
7) cd ~/rpmbuild/SPECS
rpmbuild -bb openssl.specI'm going with -ba instead of -bb because -ba seems to build everything. Hope that doesn't bite us later.
[abcd] cd ~/rpmbuild/SPECS
[abcd] rpmbuild -ba openssl.spec
DOH - The instructions break here. The problem is as follows:
In the original openssl-1.0.0-usa.tar.bz2, all the source get extracted to rpmbuild/SOURCE/openssl-1.0.0
In the downloaded openssl-1.0.0j (which we rename), source go to rpmbuild/SOURCE/openssl-1.0.0j <<< note the extra "j" at the end.
I somehow have to modify the "root" directory in the tar file to be openssl-1.0.0 instead of openssl-1.0.0j.Here's the clue from the rpmbuild output. The last thing that works is the extraction of the archive.
It then tries a
cd openssl-1.0.0 which fails. However the directory rpmbuild/BUILD/openssl-1.0.0j (note the j at the end) exists and is populated with the source files.
+ /usr/bin/bzip2 -dc /home/abcd/rpmbuild/SOURCES/openssl-1.0.0-usa.tar.bz2 | /bin/tar -xf -
+ cd openssl-1.0.0
error: line 38: cd: openssl-1.0.0: No such file or directory
Below is a fairly ugly hack as a workaround attempt.
Basically, I take the wrongly installed openssl-1.0.0j, rename it to1.0.0 and then reconvert to bz2.
cd /home/abcd/rpmbuild/BUILD
mv openssl-1.0.0j openssl-1.0.0 # Get rid of the "j" at the end
tar -cvf openssl-1.0.0j.tar openssl-1.0.0 # Archive to tar
bzip2 -z openssl-1.0.0j.tar # Convert to bz2
mv openssl-1.0.0j.tar.bz2 ~/rpmbild/SOURCES/ openssl-1.0.0-usa.tar.bz2 # Rename and move to SOURCES
With this hack, during rpmbuild, the archive extracts correctly to BUILD/openssl-1.0.0.
The build now fails because the patches in the SOURCES directory do not fully correlate to the source in he "fake" openssl-1.0.0-usa.bz2 we created.
This seems to be the flaw in kano's instructions, and we'll have to figure that out.
For those interested, here is some output from the build process so far
http://pastebin.com/z5nx844J
You now have the RPM files you need in ~/rpmbuild/RPMS/I wish...
[abcd] ls ~/rpmbuild/RPMS/
[abcd] echo woo hoo !!!