Last active
September 29, 2022 09:09
-
-
Save escalonn/8fd9edc2994afca78d96bef7d2d542c1 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
set -e -o pipefail -x | |
export DEBIAN_FRONTEND=noninteractive | |
echo 'deb http://deb.debian.org/debian/ bullseye contrib non-free' | sudo tee /etc/apt/sources.list.d/other.list | |
sudo apt update | |
sudo apt full-upgrade | |
sudo apt autoremove | |
sudo apt install \ | |
bash \ | |
bash-completion \ | |
bash-doc \ | |
binutils \ | |
binutils-dev \ | |
binutils-doc \ | |
bison \ | |
libbison-dev \ | |
bison-doc \ | |
coreutils \ | |
diffutils \ | |
diffutils-doc \ | |
findutils \ | |
gawk \ | |
gawk-doc \ | |
gcc \ | |
gcc-doc \ | |
libc6 \ | |
libc6-dev \ | |
glibc-doc \ | |
glibc-doc-reference \ | |
manpages-dev \ | |
g++ \ | |
libstdc++6 \ | |
libstdc++-10-dev \ | |
libstdc++-10-doc \ | |
grep \ | |
gzip \ | |
linux-headers-$(uname -r) \ | |
m4 \ | |
m4-doc \ | |
make \ | |
make-doc \ | |
parted \ | |
patch \ | |
perl \ | |
libperl-dev \ | |
perl-doc \ | |
python3 \ | |
python3-doc \ | |
sed \ | |
tar \ | |
libtar-dev \ | |
tar-doc \ | |
texinfo \ | |
wget \ | |
xz-utils | |
sudo apt clean | |
echo "dash dash/sh boolean false" | sudo debconf-set-selections | |
sudo dpkg-reconfigure dash | |
sudo parted --align optimal /dev/nvme0n1 \ | |
rm 2 \ | |
rm 3 \ | |
mkpart "'LFS partition'" ext4 273678336B 61702MiB \ | |
mkpart "'swap partition'" linux-swap 61702MiB 86278MiB | |
sudo mkfs -v -t ext4 /dev/nvme0n1p2 | |
sudo mkswap /dev/nvme0n1p3 | |
export LFS=/mnt/lfs | |
sudo mkdir -pv $LFS | |
sudo mount -v -t ext4 /dev/nvme0n1p2 $LFS | |
/sbin/swapon -v /dev/nvme0n1p3 | |
sudo mkdir -v $LFS/sources | |
sudo chmod -v a+wt $LFS/sources | |
wget https://www.linuxfromscratch.org/lfs/view/stable/wget-list-sysv | |
wget --input-file=wget-list-sysv --continue --directory-prefix=$LFS/sources | |
rm -f $LFS/sources/{expat-2.4.8.tar.xz,Python-3.10.6.tar.xz,python-3.10.6-docs-html.tar.bz2,linux-5.19.2.tar.xz,vim-9.0.0228.tar.gz} | |
wget --directory-prefix=$LFS/sources https://github.com/libexpat/libexpat/releases/download/R_2_4_9/expat-2.4.9.tar.xz https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.19.11.tar.xz https://www.python.org/ftp/python/3.10.7/Python-3.10.7.tar.xz https://www.python.org/ftp/python/doc/3.10.7/python-3.10.7-docs-html.tar.bz2 | |
wget --output-document=$LFS/sources/vim-9.0.0612.tar.gz https://github.com/vim/vim/archive/refs/tags/v9.0.0612.tar.gz | |
wget --directory-prefix=$LFS/sources https://www.linuxfromscratch.org/lfs/view/stable/md5sums | |
pushd $LFS/sources | |
md5sum -c md5sums | |
popd | |
rm $LFS/sources/md5sums | |
sudo mkdir -pv $LFS/{etc,var} $LFS/usr/{bin,lib,sbin} | |
for i in bin lib sbin; do | |
sudo ln -sv usr/$i $LFS/$i | |
done | |
case $(uname -m) in | |
x86_64) sudo mkdir -pv $LFS/lib64 ;; | |
esac | |
sudo mkdir -pv $LFS/tools | |
sudo groupadd lfs | |
sudo useradd -s /bin/bash -g lfs -m -k /dev/null lfs | |
sudo passwd lfs | |
sudo chown -v lfs $LFS/{usr{,/*},lib,var,etc,bin,sbin,tools} | |
case $(uname -m) in | |
x86_64) sudo chown -v lfs $LFS/lib64 ;; | |
esac | |
su - lfs | |
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=/usr/bin | |
if [ ! -L /bin ]; then PATH=/bin:$PATH; fi | |
PATH=$LFS/tools/bin:$PATH | |
CONFIG_SITE=$LFS/usr/share/config.site | |
MAKEFLAGS='-j8' | |
export LFS LC_ALL LFS_TGT PATH CONFIG_SITE MAKEFLAGS | |
EOF | |
[ ! -e /etc/bash.bashrc ] || sudo mv -v /etc/bash.bashrc /etc/bash.bashrc.NOUSE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment