Files
LFSPkgBuilds/LFSScripts/PiBuild/HowTo
2021-04-21 12:22:55 +01:00

290 lines
9.6 KiB
Plaintext

Instructions for Raspberry Pi 4 !ONLY!
1)
#Set some env vars to make copy/paste easier, ( change as needed for your setup ).
#Folders should be pre created, change paths to suit,
#Use sudo where necessary to create links etc.
#It will be assumed that your LFS partition is mounted on /mnt/LFS, using /dev/mmcblk0p11 <--- You MUST set this correctly!
LFS=/mnt/LFS
LFSVERSION=9.0
SOURCEARCHIVES=/LFSSourceArchives/$LFSVERSION
PKGARCHIVES=/LFSBuiltPackages/$LFSVERSION
EXTFOLDER=
KERNELVERSION=4.19
PIVERS=4
PIBUILD=1
PIBOOTDEV=/dev/mmcblk0p10
PIROOTDEV=/dev/mmcblk0p11
#While building tools
COMPILEAT=$LFS/$SOURCEARCHIVES
export LFS
export LFSVERSION
export SOURCEARCHIVES
export PKGARCHIVES
export EXTFOLDER
export KERNELVERSION
export PIVERS
export PIBUILD
export PIBOOTDEV
export PIROOTDEV
export COMPILEAT
sudo mount /dev/mmcblk0p11 $LFS
sudo mkdir -vp $SOURCEARCHIVES $PKGARCHIVES
#If compiling on raspberian you need to install some extra files like so:
apt-get update
apt-get install bison gawk m4 texinfo
#Also make sure /bin/sh points to /bin/bash
#Get the build scripts and helper scripts from:
#https://github.com/KeithDHedger/LFSPkgBuilds
#either via git clone or downloading the zip file and unpacking it.
#you should place the LFSPkgBuildScripts and LFSScripts folder in the root of what will be your new LFS eg ${LFS}/LFSPkgBuildScripts
2)
###RECOMMENDED####
#or cd into the mounted partition wher you intend to build LFS:
#LFS should point to your mounted LFS partition ( eg LFS=/mnt/LFS ).
cd $LFS
sudo git clone https://github.com/KeithDHedger/LFSPkgBuilds.git
Own the files:
sudo chown -R $USER:$USER LFSPkgBuilds
sudo ln -sv LFSPkgBuilds/LFSPkgBuildScripts LFSPkgBuildScripts
sudo ln -sv LFSPkgBuilds/LFSScripts LFSScripts
#If you want a swap file set up for later do:
#set count to the size of the swapfile needed.
sudo dd if=/dev/zero of=swapfile bs=1M count=512
sudo chmod 600 swapfile
sudo mkswap swapfile
sudo swapon -v swapfile
#If you are mounting a network folder over SOURCEARCHIVES & PKGARCHIVES (reccomened to save room ) you may want to set where the actual compilation takes place.
#You will need to compile in a place that can set linux permissions so an smb mount would be no good for compiling as some files need to have specific permissions.
#This is usually at $LFS/$SOURCEARCHIVES, compiling over a network is slow so you can use a local compile instead, eg:
COMPILEAT=$LFS/tmp
export COMPILEAT
3)
#cd into the lfsscripts folder
cd $LFS/LFSScripts
#Set up config files !!IMPORTANT!!
#You can just press 'Return' to accept the default.
#Run:
sudo -E ./LFSSetUp
#To check config:
./ShowSystemData
4)
#Run BuildTools script:
./BuildTools-Pi
4.5)
#Mount bind external folder if set and if not already mounted.
. ./SystemData
mkdir -vp ${LFS}/${SOURCEARCHIVES}||true
mkdir -vp ${LFS}/${PKGARCHIVES}||true
if [ "X$EXTFOLDER" != "X" ];then
sudo mount --bind $EXTFOLDER/${PKGARCHIVES} $LFS/${PKGARCHIVES}
sudo mount --bind $EXTFOLDER/${SOURCEARCHIVES} $LFS/${SOURCEARCHIVES}
fi
5)
#Run BuildFileSystem script:
sudo ./BuildFileSystem
5.2)
#You may/will have to re-own/set perms the various folders etc, so:
sudo chown -R $USER:$USER $LFS/LFSPkgBuilds
#If these are not network mounts then
sudo chown -R $USER:$USER $LFS/LFSSourceArchives/$LFSVERSION $LFS/LFSBuiltPackages/$LFSVERSION
sudo chmod -R 755 $LFS/LFSSourceArchives/$LFSVERSION $LFS/LFSBuiltPackages/$LFSVERSION
5.5)
#Create a link from downloaded linux tarball to /LFSSourceArchives/$LFSVERSION/KERNEL to prevent re-downloading source tarball.
mkdir $LFS/LFSSourceArchives/$LFSVERSION/KERNEL
cd $LFS/LFSSourceArchives/$LFSVERSION/KERNEL
ln -sv ../SYSTEM/linux-$KERNELVERSION.tar.xz .
5.6)
#get the package manager archive via the host system:
cd $LFS/LFSPkgBuildScripts/admin/LFSPkg
wget -c --no-check-certificate "https://github.com/KeithDHedger/LFSPkg/archive/master.zip" -O LFSPkg.zip
unzip LFSPkg.zip
6)
#Change back to $LFS/LFSScripts folder.
cd $LFS/LFSScripts
#If you are building over ssh you may want to start a screen session that you can come back to later, if you haven't already.
screen
#Chroot into temporary system:
#make sure the /tools link on the host is valid
#I necessary do:
#sudo ln -sv $LFS/tools/ /tools
sudo ./Chroot system
7)
#You should now be in the chroot
#First install lfspkg:
cd /LFSPkgBuildScripts/admin/LFSPkg
BOOTSTRAP=1 ./LFSPkg.LFSBuild install
#As part of the LFSSetUp script $LFS/etc/lfspkg.rc has been created to contain basic info needed by lfspkg, review and change if needed.
#Set $LFS/etc/lfspkg.rc variables, make sure the SOURCEARCHIVES points to the same place as $SOURCEARCHIVES from #SystemData.local as that's where the main LFS system source files are, you can do this either from in the chroot environment or from the host with root permissions.
#At this point wget/openssl is not installed so you will get a load of complaints from lfspkg, ignore them as lfspkg will be reinstalled later with the main system.
#You should run lfspkg --setup to create the lfspkg.rc file ( in /etc )
#lfspkg --setup can be run again later if you need/want to change source/build folders etc.
#For building the main system you should probably set the configure options config files in /etc and log options.
lfspkg --setup
8)
#Build main system:
cd /LFSPkgBuildScripts/system/system-meta
#LFSSetUp will have created a symlink to your desired init type so use:
./system-meta.LFSBuild install
#Or if you have changed your mind you can install a different init system like so:
#Use system-sysvinit-meta for standard sysvinit like so:
./system-sysvinit-meta.LFSBuild install
#Or use system-bbinit-meta.LFSBuildfor a busy box init system ( non standard ) like so:
./system-bbinit-meta.LFSBuild install
#Or for ##experimental## custom init system use:
./system-LFSInit-meta.LFSBuild install
#Or for rpi sysvinit system use:
./system-pi-sysvinit-meta.LFSBuild install
Wait for script to complete:
...
Have coffee
Walk the dog
...
9)
#logout from temporary system:
exit
10)
#Remove tools folder link from host and if you want to save tools archive for futre use move/copy the ${LFS}/tools-${LFSVERSION}.tar.gz somewhere safe:
sudo rm /tools
#Remove the tools folder from your LFS install disk:
sudo rm -rf $LFS/tools
11)
#Change back to $LFS/LFSScripts folder and re-enter the chroot ( this time and subsequent times don't use the 'system' argument to Chroot ):
cd $LFS/LFSScripts
sudo ./Chroot
12)
#You MUST rebuild lfspkg after completeing the the basic system and removing the tools folder.
#Use same process as 2)/7) EXCEPT do NOT use BOOTSTRAP=1
#If you have set any vairiable in /etc/lfspkg.rc then reply 'R' ( without the quotes ) when asked about replacing files in /etc.
#If you forgot to do the above bit just re-edit /etc/lfspkg.rc:
cd /LFSPkgBuildScripts/admin/LFSPkg
./LFSPkg.LFSBuild
#You may/probably want to run sudo lfspkg --setup to set up the full /etc/lfspkg.rc file
13)
#No point in compiling your own kernel on pi so prebuilt one is used.
#But you may want to set up wifi now so:
cd /LFSPkgBuildScripts/net/wpa-supplicant/
./wpa-supplicant.LFSBuild install
#configure
wpa_passphrase SSID SECRET_PASSWORD > /etc/sysconfig/wpa_supplicant-wifi0.conf
#Set the country code:
sed -i '1s/^/country=GB\n/' /etc/sysconfig/wpa_supplicant-wifi0.conf
cd /LFSPkgBuildScripts/HelperScripts/
#dialog program not yet installed so use:
./InstallService-NoDialog wpa
#Don't forget to set up /etc/sysconfig/ifconfig.wifi0 if nessasary ( a default is created based on /LFSSourceArchives/9.0/SYSTEM/SystemData.local ).
#Disable eth0
mv /etc/sysconfig/ifconfig.eth0 /etc/sysconfig/XXifconfig.eth0XX
#Openssh and the sshd init script is installed by the system-meta package.
#########################
# If you have trouble ssh'ing into the 'real' LFS system you may need to manually set the date if the ntpd server takes too long, eg:
ntpdate -s time.nist.gov
#########################
#Install any extra hardware/firmware packages you need ( you may have to boot into the 'real' system for this ).
#eg usb wireless package:
cd /LFSPkgBuildScripts/hware/RTL88x2BU-Linux-Driver
./RTL88x2BU-Linux-Driver.LFSBuild install
14)
#The following are optional but useful
#Before building the X server now is a good time to quickly boot into your new system and make sure all is OK, you can then reboot back to the host and continue building in the chroot or build in the 'real' system, the choice is yours but this HowTo assumes all building is done in the chroot.
#Build xorg ( experimental at the moment ):
cd /LFSPkgBuildScripts/xorg/xorg-meta/
./xorg-meta.LFSBuild install
#Samba
cd /LFSPkgBuildScripts/net/samba
./samba.LFSBuild install
#nfs
cd /LFSPkgBuildScripts/net/nfs-utils
./nfs-utils.LFSBuild install
#Fuse and stuff
cd /LFSPkgBuildScripts/net/sshfs
./sshfs.LFSBuild install
cd /LFSPkgBuildScripts/net/davfs2
./davfs2.LFSBuild install
cd /LFSPkgBuildScripts/net/curlftpfs
./curlftpfs.LFSBuild install
#System admin/security stuff
cd /LFSPkgBuildScripts/admin/logrotate
./logrotate.LFSBuild install
cd /LFSPkgBuildScripts/admin/fcron
./fcron.LFSBuild install
cd /LFSPkgBuildScripts/net/iptables
./iptables.LFSBuild install
cd /LFSPkgBuildScripts/net/fail2ban
./fail2ban.LFSBuild install
#If you are building in chroot you will pobably have to rerun the postinstall script for this package AFTER booting to the 'real' system.
cd /LFSPkgBuildScripts/admin/mariadb
./mariadb.LFSBuild install
#Kodi
#Install needed deps
cd /LFSPkgBuildScripts/mm/kodi
./pi-kodi-mindeps
#Add users
cd /LFSPkgBuildScripts/HelperScripts/
./UsersAndGroups YOURUSERNAME
#Add services
cd /LFSPkgBuildScripts/HelperScripts/
#Select from list, install/uninstall
./InstallService-NoDialog
#Auto install
./InstallService-NoDialog "ntpd sshd gpm"