-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit db26533
Showing
27 changed files
with
829 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
#!/bin/bash | ||
|
||
# This should be run on the host system to ensure that necessary | ||
# programs are installed. | ||
|
||
function install_prereqs () { | ||
# Bash: assign /bin/sh to /bin/bash | ||
ln -sfv /bin/bash /bin/sh | ||
|
||
apt-get install -y bison | ||
|
||
# Gawk should be installed and set as the default awk. | ||
apt-get install -y gawk | ||
update-alternatives --set awk /usr/bin/gawk | ||
|
||
# Patch | ||
apt-get install -y patch | ||
|
||
# Texinfo | ||
apt-get install texinfo | ||
} | ||
|
||
function modify_system_bashrc () { | ||
# This is outside the scope of the LFS docs. It's a trivial fix | ||
# related to the PS1 environment variable. | ||
# | ||
# /etc/bash.bashrc modifies PS1. This will disable it. | ||
|
||
sed -i /etc/bash.bashrc -e 's/^PS1=/#PS1=/' | ||
|
||
# Reason: on a login shell in the Ubuntu Live CD, files get read | ||
# in this order: | ||
# | ||
# - /etc/profile | ||
# - /etc/bash.bashrc | ||
# - ~/.bash_profile | ||
# - /etc/bash.bashrc | ||
# - ~/.bashrc | ||
# | ||
# That is, not only are /etc/profile and ~/.bash_profile read, but | ||
# additionally /etc/bash.bashrc and ~/.bashrc are also read. | ||
} | ||
|
||
function create_version_check_script () { | ||
# Source of the following script: | ||
# http://www.linuxfromscratch.org/lfs/view/stable/prologue/hostreqs.html | ||
cat > version-check.sh << "EOF" | ||
#!/bin/bash | ||
export LC_ALL=C | ||
# Simple script to list version numbers of critical development tools | ||
bash --version | head -n1 | cut -d" " -f2-4 | ||
echo "/bin/sh -> `readlink -f /bin/sh`" | ||
echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3- | ||
bison --version | head -n1 | ||
if [ -e /usr/bin/yacc ]; | ||
then echo "/usr/bin/yacc -> `readlink -f /usr/bin/yacc`"; | ||
else echo "yacc not found"; fi | ||
bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6- | ||
echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2 | ||
diff --version | head -n1 | ||
find --version | head -n1 | ||
gawk --version | head -n1 | ||
if [ -e /usr/bin/awk ]; | ||
then echo "/usr/bin/awk -> `readlink -f /usr/bin/awk`"; | ||
else echo "awk not found"; fi | ||
gcc --version | head -n1 | ||
/lib/libc.so.6 | head -n1 | cut -d"," -f1 | ||
grep --version | head -n1 | ||
gzip --version | head -n1 | ||
cat /proc/version | ||
m4 --version | head -n1 | ||
make --version | head -n1 | ||
patch --version | head -n1 | ||
echo Perl `perl -V:version` | ||
sed --version | head -n1 | ||
tar --version | head -n1 | ||
echo "Texinfo: `makeinfo --version | head -n1`" | ||
echo 'main(){}' > dummy.c && gcc -o dummy dummy.c | ||
if [ -x dummy ]; then echo "Compilation OK"; | ||
else echo "Compilation failed"; fi | ||
rm -f dummy.c dummy | ||
EOF | ||
} | ||
|
||
###################################################################### | ||
|
||
set -o nounset | ||
set -o errexit | ||
|
||
source shared.sh | ||
match_root || die "This script must be run as root." | ||
|
||
cd ~/ | ||
|
||
# For everyone: | ||
install_prereqs | ||
modify_system_bashrc | ||
create_version_check_script | ||
bash version-check.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../shared.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
# LFS Reference: | ||
# http://www.linuxfromscratch.org/lfs/view/stable/chapter02/creatingpartition.html | ||
|
||
# This script should set up the disk as follows: | ||
# pri /boot 100 MB | ||
# ext swap 2 GB | ||
# ext / 10 GB | ||
# ext /home Remainder | ||
|
||
function partition_disk () { | ||
# Partition the disk | ||
# Explanation: | ||
# - c\n: Turn off DOS compat | ||
# - u\n: Switch to sector display | ||
# - o\n: Create new DOS partition table | ||
# - n\np\n1\n\n+100M\n: Create pri part. 1 from start of disk, 100MB | ||
# - n\ne\n2\n\n\n: Create extended partition for remainder of disk. | ||
# - n\nl\n\n+2G\n: Create logical partition (5), from start, 2GB. | ||
# - n\nl\n\n+10G\n: Create logical partition (6), from start, 10 GB. | ||
# - n\nl\n\n\n: Create logical partition (7), from start, use remainder. | ||
# - t\n1\n83\n: Set partition 1 as type "Linux". | ||
# - t\n5\n82\n: Set partition 5 as type "Linux swap". | ||
# - t\n6\n83\n: Set partition 6 as type "Linux". | ||
# - t\n7\n83\n: Set partition 7 as type "Linux". | ||
# - w\n: Write to disk. | ||
|
||
echo -ne "c\nu\no\nn\np\n1\n\n+100M\nn\ne\n2\n\n\nn\nl\n\n+2G\nn\nl\n\n+10G\nn\nl\n\n\nt\n1\n83\nt\n5\n82\nt\n6\n83\nt\n7\n83\nw\n" \ | ||
| fdisk /dev/sda | ||
} | ||
|
||
###################################################################### | ||
|
||
set -o nounset | ||
set -o errexit | ||
|
||
source shared.sh | ||
match_root || die "This script must be run as root." | ||
|
||
partition_disk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
# LFS Reference: | ||
# http://www.linuxfromscratch.org/lfs/view/stable/chapter02/creatingfilesystem.html | ||
|
||
# This depends directly on the disk structure created in | ||
# 22_partition_setup.sh. | ||
|
||
function format_disk () { | ||
mke2fs -jv /dev/sda1 | ||
mkswap /dev/sda5 | ||
mke2fs -jv /dev/sda6 | ||
mke2fs -jv /dev/sda7 | ||
} | ||
|
||
###################################################################### | ||
|
||
set -o nounset | ||
set -o errexit | ||
|
||
source shared.sh | ||
match_root || die "This script must be run as root." | ||
|
||
format_disk | ||
# Note: we don't do the feature check on the partitions, but if you're | ||
# using the right Ubuntu host version, it should be okay. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
# LFS Reference: | ||
# http://www.linuxfromscratch.org/lfs/view/stable/chapter02/mounting.html | ||
|
||
# This depends directly on the disk structure created in the previous | ||
# two scripts. | ||
|
||
source shared.sh | ||
|
||
function mount_partitions () { | ||
mkdir -pv $LFS | ||
mount -v -t ext3 /dev/sda6 $LFS | ||
mkdir -pv $LFS/boot | ||
mount -v -t ext3 /dev/sda1 $LFS/boot | ||
mkdir -pv $LFS/home | ||
mount -v -t ext3 /dev/sda7 $LFS/home | ||
/sbin/swapon -v /dev/sda5 | ||
} | ||
|
||
###################################################################### | ||
|
||
set -o nounset | ||
set -o errexit | ||
|
||
match_root || die "This script must be run as root." | ||
|
||
mount_partitions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
# LFS Reference: | ||
# http://www.linuxfromscratch.org/lfs/view/stable/chapter02/mounting.html | ||
|
||
# This depends directly on the disk structure created in the previous | ||
# two scripts. | ||
|
||
source shared.sh | ||
|
||
function prep_sources_dir () { | ||
mkdir -v $LFS/sources | ||
chmod -v a+wt $LFS/sources | ||
} | ||
|
||
function download_sources () { | ||
wget "http://www.linuxfromscratch.org/lfs/view/stable/wget-list" | ||
wget -i wget-list -P $LFS/sources | ||
} | ||
|
||
###################################################################### | ||
|
||
set -o nounset | ||
set -o errexit | ||
|
||
match_root || die "This script must be run as root." | ||
|
||
prep_sources_dir | ||
download_sources |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
# LFS Reference: | ||
# http://www.linuxfromscratch.org/lfs/view/stable/chapter04/creatingtoolsdir.html | ||
|
||
set -o nounset | ||
set -o errexit | ||
|
||
source shared.sh | ||
match_root || die "This script must be run as root." | ||
|
||
mkdir -v $LFS/tools | ||
ln -sv $LFS/tools / |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# LFS Reference: | ||
# http://www.linuxfromscratch.org/lfs/view/stable/chapter04/addinguser.html | ||
|
||
set -o nounset | ||
set -o errexit | ||
|
||
source shared.sh | ||
match_root || die "This script must be run as root." | ||
|
||
groupadd lfs | ||
useradd -s /bin/bash -g lfs -m -k /dev/null lfs | ||
|
||
echo 'Setting password of "lfs" user.' | ||
passwd lfs | ||
|
||
chown -v lfs $LFS/tools | ||
chown -v lfs $LFS/sources | ||
|
||
echo 'ATTENTION: The next script must be run via the "lfs" user via a' \ | ||
'login shell:' | ||
echo | ||
echo -e "\tsu - lfs" | ||
echo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../shared.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/bash | ||
|
||
# LFS Reference: | ||
# http://www.linuxfromscratch.org/lfs/view/stable/chapter04/settingenvironment.html | ||
|
||
set -o nounset | ||
set -o errexit | ||
|
||
source shared.sh | ||
|
||
match_user "lfs" || die 'This script must be run as the "lfs" user.' | ||
|
||
cat > ~/.bash_profile << "EOF" | ||
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash | ||
EOF | ||
|
||
cat > ~/.bashrc << "EOF" | ||
set +h | ||
umask 022 | ||
LFS=/mnt/lfs | ||
LC_ALL=POSIX | ||
LFS_TGT=$(uname -m)-lfs-linux-gnu | ||
PATH=/tools/bin:/bin:/usr/bin | ||
export LFS LC_ALL LFS_TGT PATH | ||
EOF | ||
|
||
echo "ATTENTION: Please run: source ~/.bash_profile" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
There's a note about setting "MAKEFLAGS='-j 2" or using "make -j2". | ||
While I like this on my nice quad-core system, it does seem to cause | ||
intermittent compilation errors. If you want the least headaches, | ||
although it takes time, I suggest *not* using this option. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../shared.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/bin/bash | ||
|
||
# LFS Reference: | ||
# http://www.linuxfromscratch.org/lfs/view/stable/chapter05/binutils-pass1.html | ||
|
||
set -o nounset | ||
set -o errexit | ||
|
||
source shared.sh | ||
match_user "lfs" || die 'This script must be run as the "lfs" user.' | ||
|
||
cd $LFS/sources | ||
tar -xf binutils-2.21.tar.bz2 | ||
cd binutils-2.21 | ||
|
||
mkdir -v ../binutils-build | ||
cd ../binutils-build | ||
|
||
time { | ||
../binutils-2.21/configure \ | ||
--target=$LFS_TGT --prefix=/tools \ | ||
--disable-nls --disable-werror | ||
make | ||
make install | ||
} | ||
|
||
# Cleanup | ||
cd $LFS/sources | ||
rm -rf binutils-2.21 binutils-build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
|
||
# LFS Reference: | ||
# http://www.linuxfromscratch.org/lfs/view/stable/chapter05/gcc-pass1.html | ||
|
||
set -o nounset | ||
set -o errexit | ||
|
||
source shared.sh | ||
match_user "lfs" || die 'This script must be run as the "lfs" user.' | ||
|
||
cd $LFS/sources | ||
tar -xf gcc-4.5.2.tar.bz2 | ||
cd gcc-4.5.2 | ||
|
||
tar -jxf ../mpfr-3.0.0.tar.bz2 | ||
mv -v mpfr-3.0.0 mpfr | ||
tar -jxf ../gmp-5.0.1.tar.bz2 | ||
mv -v gmp-5.0.1 gmp | ||
tar -zxf ../mpc-0.8.2.tar.gz | ||
mv -v mpc-0.8.2 mpc | ||
|
||
mkdir -v ../gcc-build | ||
cd ../gcc-build | ||
|
||
../gcc-4.5.2/configure \ | ||
--target=$LFS_TGT --prefix=/tools \ | ||
--disable-nls --disable-shared --disable-multilib \ | ||
--disable-decimal-float --disable-threads \ | ||
--disable-libmudflap --disable-libssp \ | ||
--disable-libgomp --enable-languages=c \ | ||
--with-gmp-include=$(pwd)/gmp --with-gmp-lib=$(pwd)/gmp/.libs \ | ||
--without-ppl --without-cloog | ||
make | ||
make install | ||
|
||
ln -vs libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | \ | ||
sed 's/libgcc/&_eh/'` | ||
|
||
# Cleanup | ||
cd $LFS/sources | ||
rm -rf gcc-4.5.2 gcc-build |
Oops, something went wrong.