Here you can post notes / scripts / ideas for Linux From Scratch. We began LFS at VCLUG at the meeting on Saturday, June 12, 2010. Three of us started on the 12th. Two more started the next meeting. You are encouraged to begin LFS at any time. We will be there to help with anything we can. It is a great way to get more of an in depth look into the Linux system.


Script to download packages

Script to download packages and check hashes. Written by Paul Bernard with Stuart Sheldon’s help.

I know that some of the packages will fail hash checks or have bad links. I have not had the time to check into this. This script assumes that you have created a file lfs.list and you will need to run in the directory that you wish the files be downloaded to.

#Create a file by pasting all the packages directly from the book.
#I pasted from the middle of page 17 to the middle of page 23 in the LFS book
#Change lfs.list to whatever you named the file.

#This line will strip all the info in the lfs.list file and leave only the
#Download url. It will be formatted to use with the wget command and will #be saved in the file lfswget.lst
egrep ‘^Download:’ ${startfile} | sed -e ‘s/^Download:\ *//g’ > lfswget.lst

#This line will create a file that will have only the MD5 checksum and the
#file names. It will be formatted propely for the md5sum command.
for a in $(for i in \
$(sed -e ‘s/^.*:\///’ lfswget.lst); \
do basename ${i}; done); do
MD5SUM=$(sed -n ‘/’${a}’/,/^MD5/ s/MD5\ sum:\ *//p’ ${startfile})
echo -e “${MD5SUM} ${a}”
done > allfiles.md5

#This will download all packages into the current working directory
wget –input-file lfswget.lst

#This will check the downloaded files with the hashes for the files.
md5sum -c allfiles.md5 2>&1 | less

Here’s another script too

Here’s another script to download the packages and patches and to check the md5sums. This was written by Jim Lang.


# This script has two switches defined.
# -c Check links. This runs wget in ?spider? mode to check that the links to the
# packages and patches are all available.
# -q Quit after creating the list files.

# Define variables with the directory path to data used by various commands, the name
# of the file that contains the data from the book, the name of the file containing the
# list of urls that wget needs to use, and the name of the file containing the list of
# md5sums and file names needed by md5sum. These files ought NOT to be in $LFS/sources.

# Parse the pdf file’s data.
# Initialize wgetlist and md5sumlist with a blank line.
echo > “$wgetlist”
echo > “$md5sumck”

# Pipe the data from the pdf file into the while loop one line at a time.
time cat ${pdfdata} | \
while read aline; do

# If the line begins with “Download: ” then the remainder of the line is a URL.
if [ “${aline:0:9}” == “Download:” ]; then
filename=$(basename ${url});
elif [ “${aline:0:8}” == “MD5 sum:” ]; then
echo $url >> “$wgetlist”;
echo “$cksum $LFS/sources/${filename}” >> “$md5sumck”;

if [ “.$1” == ‘.-q’ ]; then

# If this script was called with -c then run wget to only verify that the links are valid
# and exit from this script. Check the list and edit the pasted file to correct any mistakes
# before rerunning this script. If all the package and patch links are valid then rerun the
# script without the ?-c? switch.
if [ “.$1” == “.-c” ]; then
wget –no-verbose –spider –input-file=${wgetlist};

# Otherwise, after a couple of sanity checks, change the working directory for
# downloading the packages and patches to $LFS/sources.
if [ -z ${LFS} ]; then
echo ?Variable LFS has not been set.?;
exit 1

if [ -d ${LFS}/sources ]; then
cd ${LFS}/sources;
echo ?Directory ${LFS}/sources does not exist.?;
exit 1

# Finally, run wget to download the packages and patches and run md5sum to validate the data.
wget –no-verbose –input-file=${wgetlist};
md5sum -c ${md5sumck} | grep FAILED