-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVagrantfile
More file actions
89 lines (75 loc) · 2.42 KB
/
Copy pathVagrantfile
File metadata and controls
89 lines (75 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Vagrant.configure("2") do |config|
config.vm.box = "debian/bookworm64"
config.vm.synced_folder ".", "/lfs_host", type: "9p", disabled: true
config.vm.provider :libvirt do |lv|
lv.memory = 8192 # RAM in MB
lv.cpus = 8 # Match your physical CPU cores
# 50GB virtual disk specifically for building LFS
# we can use later the same device name to parition our storage
lv.storage :file, size: '50G', device: 'vdb'
end
config.vm.provision "shell", inline: <<-SHELL
set -e
echo "=== 1: Updating Repositories and Installing LFS Toolchain ==="
export DEBIAN_FRONTEND=noninteractive
apt-get update
# Install every package required to pass the LFS host system check
apt-get install -y \
build-essential \
gcc \
g++ \
bison \
gawk \
m4 \
texinfo \
patch \
python3 \
diffutils \
findutils \
grep \
gzip \
sed \
tar \
xz-utils \
perl \
make \
git \
exuberant-ctags \
bc \
libssl-dev \
libncurses-dev \
flex \
libelf-dev
echo "=== 2: Configuring LFS Prerequisites ==="
# LFS strictly requires /bin/sh to point to bash (Debian defaults to dash)
ln -sf /bin/bash /bin/sh
# Create a yacc wrapper pointing to bison (required for LFS script)
if [ ! -e /usr/bin/yacc ]; then
ln -sf /usr/bin/bison /usr/bin/yacc
fi
# https://www.linuxfromscratch.org/lfs/view/stable-systemd/chapter02/creatingfilesystem.html
echo "=== 3: Preparing /mnt/lfs Disk Partition ==="
if ! blkid /dev/vdb; then
mkfs.ext4 /dev/vdb
fi
mkdir -p /mnt/lfs
mount /dev/vdb /mnt/lfs
chown -R vagrant:vagrant /mnt/lfs
echo "=== 4: Running LFS Version Check Script ==="
if [ -f /lfs_host/scripts/version-check.sh ]; then
chmod +x /lfs_host/scripts/version-check.sh
/lfs_host/scripts/version-check.sh
else
echo "WARNING: /lfs_host/scripts/version-check.sh not found!"
fi
echo "=== 5: Setting up the \$LFS=/mnt/lfs ==="
echo 'export LFS=/mnt/lfs' >> /home/vagrant/.bashrc
echo 'umask 022' >> /home/vagrant/.bashrc
# Ensure the mount directory exists and matches $LFS
if [ "$LFS" = "/mnt/lfs" ] && mountpoint -q "$LFS"; then
echo "OK: $LFS is set and properly mounted!"
else
echo "FATAL: LFS variable is wrong or disk is not mounted!"
fi
SHELL
end