This course will become read-only in the near future. Tell us at community.p2pu.org if that is a problem.

Set up your build environment [May 11, 2012, 1:13 a.m.]



Prerequisites


First and foremost, building Linux is going to take you using the shell a lot. If you aren't comfortable using a bash shell and the "make" utility to build software, you'll want to check out these links first (this list is in the book in the "Prerequisites" section of the Foreword)

http://www.tldp.org/HOWTO/Software-Building-HOWTO.html

http://www.linuxhq.com/guides/LUG/guide.html

http://hints.cross-lfs.org/index.php/Essential_Prereading

Cross linux from scratch can be built from just about any operating system with a working C compiler. I'll be building mine on a Windows machine using the free MinGW compiler, using MSYS for my shell and environment. I made a quick video helping you if you're starting out this way:

http://youtu.be/U2Agy6ulJtc


It's probably easiest if you're having trouble, though, to do this from a BSD, Mac, or a Linux computer. Linux has several LiveCD, LiveUSB, and virtualized distributions that are worth checking out. I think Linux from Scratch even has their own LiveCD made just for us. Any of these will have working c compilers and environments that will suit our needs. You can run this script (from the "Prerequisites" section of the Foreword) to see if your OS has everything we need to build CLFS:

http://greenback.gremlin.net/version-check.sh

You'll also need to download all the sources to local media. I reccomend a DVD so that everything's nice and indestructable. The book has a list of all the sources we'll need in sections 3.2 through 3.5. Probably the easiest way to get all of them is to download this file

http://greenback.gremlin.net/downloads.txt

and then use it with the wget utility like this:

wget -i downloads.txt

If you don't have wget, you can find the page in the CBLFS book for installing it here:

http://cblfs.cross-lfs.org/index.php/Wget

Finally, whatever you're installing LFS to, it would help a lot if it were bootable. I picked an 8 GB USB stick. It doesn't have to be formatted, and in fact it would help a lot if you didn't care what was on it. The instructions here will involve formatting at least one partition, and Windows up to Vista (and possibly Windows 7 and 8, I haven't tried) can't recognize any partitions past the first, so formatting may destroy the entire disk. For an 8 GB disk that can be booted from and recognized on a windows computer, I used Slackware's USB bootloader. I won't be covering that here to avoid confusing people not on windows computers, but you can go here for more info:

http://slackware.cs.utah.edu/pub/slackware/slackware-13.37/usb-and-pxe-installers/

I will not be teaching you how to create LiveCDs, although there are tutorials that exist online, including here:

http://www.linux-live.org/

You can of course ignore all tasks past program installation. This will give you a "chroot" distribution, or a distribution you can use as an embedded distro from another linux distro with a compatible kernel via the "chroot" command. The chroot method runs the least risk of destroying data and can be safely done without disrupting the computer you're building on at all (although some things may not work correctly if you build from a cygwin or msys environment).

That's it; everything else we'll be building for ourselves.

Goal


In this stage, we lay out our foundation. Our goals are all of the following:

  • A "bootstrapping" filesystem that closely mirrors the one found in the book, makes it easy to keep track of what we're doing, and allows us to build programs as an ordinary user while making sure the only user that can install software is an administrator. This usually has the creative name "build environment".
  • A way to "rewind" in case we mess anything up. This is usually done with something called "version control".
  • A way to modularize components so that they can be used on multiple systems. This is called "packaging".

We'll be using git for version control, and RPM for packaging.

Build Environment


 

Git


 

RPM