Improve autobuild blfs

This commit is contained in:
Krizsán Péter 2024-11-29 16:00:54 +01:00
parent 89a5b1b1ee
commit 4d36db7882

View File

@ -144,9 +144,17 @@ _finalize_lfs_build()
# Move blfs folder to pkr home folder # Move blfs folder to pkr home folder
sudo mv -v "$dir_lfs/blfs_root" "$dir_lfs/home/pkr/" && sudo mv -v "$dir_lfs/blfs_root" "$dir_lfs/home/pkr/" &&
sudo chroot "$dir_lfs" sed -i -E "/(=configuration|python3)/s/^/#/g;/=configuration/i\ source /home/pkr/custom_blfs_packages/libs/func_general.sh && _create_blfs_config /" /home/pkr/blfs_root/Makefile &&
sudo chroot "$dir_lfs" chown -hR pkr:pkr "/home/pkr/blfs_root" && sudo chroot "$dir_lfs" chown -hR pkr:pkr "/home/pkr/blfs_root" &&
sudo chroot "$dir_lfs" chown -hR pkr:pkr "/var/lib/jhalfs" && sudo chroot "$dir_lfs" chown -hR pkr:pkr "/var/lib/jhalfs" &&
sudo sed -i "s|/blfs_root/packdesc.dtd|/home/pkr/blfs_root/packdesc.dtd|g" "$dir_lfs/var/lib/jhalfs/BLFS/instpkg.xml" sudo sed -i "s|/blfs_root/packdesc.dtd|/home/pkr/blfs_root/packdesc.dtd|g" "$dir_lfs/var/lib/jhalfs/BLFS/instpkg.xml"
# Copy custom blfs folder to pkr home folder if exist
if [ ! -d "$HOME/custom_blfs_packages" ] ; then
return 0
fi
sudo cp -rv "$HOME/custom_blfs_packages" "$dir_lfs/home/pkr/" &&
sudo chroot "$dir_lfs" chown -hR pkr:pkr "/home/pkr/custom_blfs_packages"
} }
@ -162,7 +170,7 @@ _setup_autologin()
local dir_autologin="$dir_lfs/etc/systemd/system/getty@tty1.service.d" local dir_autologin="$dir_lfs/etc/systemd/system/getty@tty1.service.d"
sudo mkdir -pv "$dir_autologin" && sudo mkdir -pv "$dir_autologin" &&
printf "[Service]\nType=simple\nExecStart=\nExecStart=-/sbin/agetty --autologin pkr %%I 38400 linux\n" | sudo tee "$dir_autologin/override.conf" > /dev/null printf "[Service]\nType=simple\nExecStart=\nExecStart=-/sbin/agetty --autologin pkr --noclear - \$TERM\n" | sudo tee "$dir_autologin/override.conf" > /dev/null
} }
@ -238,23 +246,32 @@ _create_blfs_builder_script()
echo "Invalid folder: $dir_lfs" echo "Invalid folder: $dir_lfs"
return 1 return 1
fi fi
cat > "$dir_lfs/home/pkr/.profile" << EOF printf '#!/bin/bash
#!/bin/bash
cd "/home/pkr/blfs_root/blfs-xml" _build_blfs()
git reset --hard {(
git clean -xfd if ! [ "$USER" == "pkr" ] ; then return 0; fi
cd "/home/pkr/blfs_root/lfs-xml" local dir_home="/home/pkr"
git reset --hard local dir_blfs_root="$dir_home/blfs_root"
git clean -xfd local dir_lfs_xml="$dir_blfs_root/lfs-xml"
cd "/home/pkr/blfs_root" local dir_blfs_xml="$dir_blfs_root/blfs-xml"
make update local dir_blfs_work="$dir_blfs_root/work"
. gen_pkg_book.sh <<< yes cd "$dir_lfs_xml"
cd work git reset --hard
../gen-makefile.sh git clean -xfd
make cd "$dir_blfs_xml"
sudo rm -rfv /etc/systemd/system/getty@tty1.service.d git reset --hard
rm -fv /home/pkr/.profile git clean -xfd
sudo systemctl poweroff cd "$dir_blfs_root"
EOF make clean
make update
make <<< yes
cd "$dir_blfs_work"
../gen-makefile.sh
make
sudo rm -rfv /etc/systemd/system/getty@tty1.service.d
)}
_build_blfs\n' | sudo tee "$dir_lfs/etc/profile.d/x_build_blfs.sh" > /dev/null
} }