You probably know everything on your computer is just zeroes and ones, grouped together in eights and sixteens, and so forth. You might know a bunch of folks type out lines of instructions ("code") for computers which have to be converted into those ones and zeroes, in a process called compiling. You may have heard compiling stuff on Windows requires you to buy expensive software suites to do that sort of stuff. Maybe you know Open Source means the entire process from start to finish is wide open and free, and if you take a notion, you can compile your own software because it's all part of the package. This is why I recommended you install the Developer Workstation package profile. You can take all those instructions people write and make it into zeroes and ones yourself.
On RHEL, you have the option of going out and finding that code from the sources and learning how to use the common build scripts. I do it all the time. But it's a whole lot simpler chasing down all the extra piles of code you need if it comes pre-packaged. For RHEL, that means the RPM system. It's not just a way to add packages someone else built for you, but you can build the packages, because the source is also neatly packaged. We call them source RPMs or SRPMs. Whenever you see a package which ends in the combination ".src.rpm" you have an SRPM.
Depending on what we are trying to build, we can get our SRPMs from several different places. For RHEL, the primary source is the official RHEL 6 workstation repository. Occasionally I also have to check the server repository. These two are updated regularly when something is fixed, so check to get the version with the highest number, which may mean the last in a long string of digits, dots, dashes and underscores. A much wider variety of packages come from the Fedora repositories. If you understand Fedora is the playground development system for the serious RHEL working systems, then it's no surprise Fedora has more different kinds of stuff. You just have to be aware of which of the many versions of Fedora is closest to your version of RHEL. In this case, RHEL 6 is built largely from FC13, but parts of it appear to come from FC12. At any rate, if you don't find what you need on the RHEL repositories, your second look should be "FC13 Updates" and "FC13 Everything" in that order. You can find a list of mirrors here simply select the one closest to you. For each one, it's usually a matter of this layout on the servers:
In the case of CentOS and Scientific Linux, they will have their own mirrors and structure when 6.0 is finally released by each of them. They are built from RHEL 6 SRPMs, and the same FC13 SRPMs should work for things not included in the primary SRPM sets.
Today we are going to grab the package called "freetype," which is a standard item from RHEL, so go to the Workstation SRPMs and download that package. We can't install this from the browser, so prepare to do some commandline work. Just as a reminder, in Linux, all commands are case-sensitive. Most commands are in lower case, but there are switches (usually with a dash in front of them) which are both upper and lower case, so you need to pay attention to them.
Open your Terminal and
su to root. Type
so you are working from root's Home. You can issue the command to
install this SRPM from here, as long as you declare on the commandline
the exact location of that RPM file (called the "full
rpm -ivh /home/username/Downloads/freetype-[hit TAB]
In this case, we use the "i" switch for a straight install,
and the "vh" allows you to watch it work. You can ignore the
warnings about who owns the files. When it's done, if you type
ls you should see a folder named
This is where all SRPMs will be installed so we can work on them. There
are several sub-folders underneath. We are primarily interested in the
SPEC folder, so type:
ls here you'll find a single file,
freetype.spec. This is the building configuration file. The
Freetype library is the run-time reference for the way fonts are
rendered on your screen. We are going to change it by adding two
features not enabled by default, called "bytecode hinting" and
"subpixel rendering." If you take a quick look at this SPEC
you'll see some interesting instructions at the top. That "less" command is equivalent to the Windows file viewer command "more" -- less is more. The second line of the file tells you how to add those features. You see we can add a couple of "switches" on the commandline of the build process to make it happen. But it's not a simple swipe of the mouse because there is some extra verbiage and punctuation. So you can hit "q" to close this viewer and I'll give it to you below.
The basic command is
rpmbuild, with a switch (-bb)
telling it to build the software and create the RPM packages. We'll
stick in the additional switches from inside the SPEC file and finish
with telling RPMbuild what it's working on:
rpmbuild -bb --with bytecode_interpreter --with subpixel_rendering freetype.spec
Hit ENTER and it should take off and build it, displaying the details on the screen in your Terminal. When it's finished, the prompt will come back and we have to go find those packages and install them. If you take a moment to look in your Terminal window, you'll see up just a few lines where it says "Wrote /root/rpmbuild/RPM/i686/freetype...." Each of those packages comes from the same SRPM. That's the common pattern, and it also tells you where to find the packages. The source is not just the library, but some other stuff, which includes the development libraries. We need the base package and the "devel" package. Now, let's go there:
That double dot is simply shorthand for "the directory above this one." We go up one layer, then down two into the place where RPMbuild drops the finished packages, in this case the i686 folder(x86_64 for 64-bit). We need to install them both at the same time. And because we already have a couple of RPMs by the same names installed right now, but crippled versions we want to replace, we'll need to tell RPM to ignore that. Keep in mind, as you type this rather long command, you only have to type enough to distinguish between files and hit the TAB key for each file. What you see below were the ones I built for this tutorial:
rpm -Uvh --force freetype-2.3.11-6.el6.2.i686.rpm freetype-devel-2.3.11-6.el6.2.i686.rpm
That's the "rpm" command, with the "U" upgrade switch, and as before, the "vh" switches so you can see what's happening. Then we add the "force" switch because it won't do it otherwise. Don't abuse that option! You seldom have any need for it, but it's there and it can really mess things up and make your system quit running if you don't know what you are doing. The command is completed by listing all the packages, each separated by a space. Hit ENTER.
In order to see the effects of this altered font rendering package, we have to restart the display server. That means log out, then log back in, because logging out typically restarts the display server. It should make at least some noticeable difference in how fonts are rendered, mostly by tightening up and sharpening the characters so they aren't so fat, fuzzy and dark.
Welcome to RPM Land. More extensive instructions can be found starting here.
Ed Hurst is Associate Editor of Open for Business.
|Home About Connect: Twitter Facebook RSS|