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

Build Environment Set-Up [May 18, 2012, 12:51 p.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 in three parts weighing in at about half an hour helping you if you're starting out this way (you might want to full screen):

http://youtu.be/U2Agy6ulJtc

http://youtu.be/it4kGicvADI

I didn't get around to it in the next video, but you can chain configure and make together with a double-ampersand like

./configure --all-your-config-options && make

http://youtu.be/-Tl2WsGfw1M

And you'll want to grab your dependencies from the following URLs:

http://www.mingw.org/wiki/Getting_Started

http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express

http://sourceforge.net/projects/gnuwin32/files/

ftp://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.9.tar.gz

http://www.fs-driver.org/

That last one I didn't mention in the videos, but it will let you create native linux ext2 filesystems. You can use fat32 as well, but you'll have to put up with slower disk access, and on top of the slowdown you already get with a USB stick I highly recommend this approach instead.

 

I've also copied in some scripts from the CLFS book, and written a couple myself, here

http://greenback.gremlin.net/chown

http://greenback.gremlin.net/RENAME.profile

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

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

 


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 the version-check.sh script (above) to see if your OS has everything we need to build CLFS.

 

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 grab the downloads.txt file (above) and then use it with the wget utility like this:

wget -i downloads.txt

If you don't have wget, you can find generic instructions that will work in any build environment for building and installing it from source in wget's page in the CBLFS book, 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.

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. It's up to you if you want a bootable OS.

 

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