Tag Archives: Man Pages

LFS 6.8 (Part 10): The Second Part of the Rest of the Temporary Toolchain

The LFS temporary toolchain is going to take a while to cover completely, so I’m breaking it up into several parts for readability.

I’m about halfway through building the LFS temporary toolchain, and encountering mostly smooth sailing.

Grep

According to Wikipedia, “The name [Grep] comes from the ed command g/re/p (global / regular expression / print).” What Grep does is search files for the patterns you specify.

Grep installed to /tools (in the temporary toolchain, /mnt/lfs/tools).

Grep was supposed to build in 5 minutes, but with the test suites took a total of 19 minutes.

Gzip

Gzip is an older and only fairly efficient compression tool, but it works well enough that it is still a near-universal compression format.

Gzip installed to /tools (in the temporary toolchain, /mnt/lfs/tools).

I calculated Gzip to build in less than 5 minutes, but took 8 minutes. Those test suites! Well, at least I’m getting practice in what to look for.

M4

M4 is (as the LFS book puts it) a macro processor typically used to pre-process source code for a compiler. What does it do that’s so different from any other scripting/macro language? I don’t know, but it probably is very well suited to pre-processing source code for compilers, since that’s what its used for 😛 .

M4 installed to /tools (in the temporary toolchain, /mnt/lfs/tools).

M4 should have taken 10 minutes to build, but test suites inflated that number to 29 minutes.

Make

Ah, Make is our friend! Make automates the compiling of programs by reading that Makefile you keep seeing in the source directory and compiling the program accordingly. I can’t imagine what it would be like doing all of the steps by hand. The LFS book would be huge!

Anyway, Make is installed to /tools (in the temporary toolchain, /mnt/lfs/tools).

For all its versatility, Make was only supposed to need 5 minutes to build, but with its test suite, 7 minutes.

Patch

Patch modifies source code by applying the changes specified in a patch file. This makes it easy to apply small fixes with accuracy without having to wait for the developers to update the whole program.

Patch is installed to /tools (in the temporary toolchain, /mnt/lfs/tools).

Patch was projected for a less-than 5 minute build, and finished in a satisfying 4 minutes. Including the test suite!

The test suite threw up two errors, though. One error seemed to be dependent on the ed text editor, and the LFS live CD apparently didn’t have it; however, it shouldn’t have run anyway, so no biggie. The other error I couldn’t even track down, and seems to be a failure of cat or something. Since I couldn’t find a way to fix it (or even figure out what it was), I decided to forge ahead regardless.

Perl

Perl is a general-purpose scripting language, often represented with a camel mascot. There is much that can be said about Perl, but you have Google for that 🙂 .

First I had to apply a patch “to adapt some hard-wired paths to the C library” and run Perl’s configure script to build a minimal Perl for testing purposes (which is all it will be used for in the temporary toolchain). When I installed Perl, I only needed the utilities and one library, so it built in a lot less time than it will later. Perl installed to /tools (in the temporary toolchain, /mnt/lfs/tools).

I did skip the test suite, since the LFS book informed me that all of the rest of Perl would be built as well for the test; because Perl was only partially built, “installing” the temporary toolchain Perl was really just copying directories. Again, because this is a minimal version of Perl for the toolchain, it should only take 39 minutes to build, but it took 2 hours 9 minutes. I have no idea why so slow; I guess Pressie is getting tired.

Sed

Sed is a commonly used *nix tool for editing text, and is especially handy for shell scripts.

Installing Sed was straightforward, and Sed was installed to /tools (in the temporary toolchain, /mnt/lfs/tools).

5 minutes is all Sed should have taken to install, but the optional test suite inflated that to a full 7 minutes.

Tar

Tar stands for “tape archiver”, so you can guess how far back its roots go. Tar made backup to tapes easy by concatenating files into a single .tar file. This made backups to tape much easier, as the tape didn’t have to rewind and fast forward back and forth between a single file and the master file table.

Anyway, Tar was installed to /tools (in the temporary toolchain, /mnt/lfs/tools).

Tar should have taken 15 minutes to build, but with the optional test suite, Tar took a full 57 minutes to build (all okay, though).

Texinfo

Texinfo is a suite of utilities for manipulating info pages (a longer, more detailed version of the man pages).

Texinfo was installed to /tools (in the temporary toolchain, /mnt/lfs/tools).

Simple to build, Texinfo was scheduled for a 10 minute build, but took 12 minutes with the optional test suite.

Xz

Xz is an up-and-coming compression format that hopes to mostly replace less efficient formats like Gzip and Bzip2. It is great for source code, as Xz compresses text even better than either Gzip or Bzip2.

Xz installed to /tools (in the temporary toolchain, /mnt/lfs/tools).

15 minutes expected, 17 minutes taken (test suite included).

Now What?

All the packages for the temporary toolchain are now installed to /tools (in the temporary toolchain, /mnt/lfs/tools), and I am ready for the final steps in preparing the temporary toolchain for action!

More Playing Around With def

I read a little further in Hetland about def, and found that you can self-document your functions. Though it’s not too much help in my programs so far (I don’t yet know how to make a --help option available), but the Python interpreter turn them automagically into *nix-style man pages when you call them with __doc__ !

Anyway, Hello World! seems to be turning into my guinea pig of choice when it comes to learning new coding tricks, so I fiddled around some to create hello.v1-2-1.py:

Hello World! v1.2.1

Hello World! v1.2.1

#!/usr/bin/env python

# hello.py v1.2.1
# Hello World!
#
# Changelog:
# v1.2.1 (10/12/2010) + More playing around with def
#                     + Tells user how long their name is
# v1.2.0 (10/11/2010) + Now with def magic
# v1.1.2 (09/19/2010) + Now ensures user enters a name
# v1.1.1 (09/11/2010) + Added GPLv3 license text & changelog to comments
#                     + Added user-visible program & (c) info
#                     + Re-commented program, because we were all newbs once
# v1.1 (08/08/2010) + Added "Press <enter>" prompt for terminal execution
#                   - Deleted unnecessary comments
# v1.0 (07/20/2010) - Initial release (My first program!)
#
# Copyright 2010 Benjamin Braithwaite
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# (c) info

print "Hello World! v1.2.1"
print "Copyright 2010 by Benjamin Braithwaite"
print

# get user's name

name = ""
while not name.strip():
    name = raw_input("What is your name? ")

# put user's name into template

ltrs = ""
def hello(name,ltrs):
    "Template for returning user's name in a personalized greeting."
    ltrs = len(name)
    return "Hello, %s! You have %s letters in your name." % (name,ltrs)

# print user's name in a personalized greeting

print
print hello(name,ltrs)
print

# successful exit dialog

raw_input("Press <enter> to exit.")

You can download hello.v1-2-1.py from my Dropbox.

As you can see, I added a letter counter for fun. You know, to spice things up a bit! Unfortunately, it also counts spaces, so it’s not always accurate. I’m realizing that edge cases really are most of the work of coding!

Again, I’m sorry for the shortness of the commentary in my recent posts — I’ve started biking to and from work, so my time is a little more limited as far as writing is concerned. Until tomorrow, happy hacking!