Files
LFSPkgBuilds/LFSScripts/HowTo-SystemD
2020-08-13 14:24:56 +01:00

355 lines
11 KiB
Plaintext

1)
#It will be assumed that your LFS partition is mounted on /mnt/LFS, using /dev/sda1 and /dev/sda2 as swap, alter as needed.
#Use sudo where necessary to create links etc.
#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 /mnt/lfs/LFSPkgBuildScripts
#Set some env vars to make it easier to copy and paste these instructions.
#Folders should be pre created, change paths to suit,
LFS=/mnt/LFS
LFSVERSION=9.0
SOURCEARCHIVES=/LFSSourceArchives/$LFSVERSION
BUILTPACKAGES=/LFSBuiltPackages/$LFSVERSION
EXTFOLDER=
KERNELVERSION=5.2.8
USESYSTEMD=1
export LFS
export LFSVERSION
export SOURCEARCHIVES
export BUILTPACKAGES
export EXTFOLDER
export KERNELVERSION
export USESYSTEMD
###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 $LFS/LFSPkgBuilds
[sudo] ln -sv LFSPkgBuilds/LFSPkgBuildScripts $LFS/LFSPkgBuildScripts
[sudo] ln -sv LFSPkgBuilds/LFSScripts $LFS/LFSScripts
3)
#cd into the lfsscripts folder
cd 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-SystemD
4.5)
#Mount bind external folder if set and if not already mounted.
. ./SystemData
mkdir -vp ${LFS}/${SOURCEARCHIVES}||true
mkdir -vp ${LFS}/${BUILTPACKAGES}||true
if [ "X$EXTFOLDER" != "X" ];then
sudo mount --bind $EXTFOLDER/${BUILTPACKAGES} $LFS/${BUILTPACKAGES}
sudo mount --bind $EXTFOLDER/${SOURCEARCHIVES} $LFS/${SOURCEARCHIVES}
fi
5)
#Run BuildFileSystem script:
[sudo] ./BuildFileSystem-SystemD
5.2)
#You may/will have to re-own/set perms the various folders etc, so:
[sudo] chown -R $USER:$USER $LFS/LFSPkgBuilds $LFS/LFSSourceArchives/$LFSVERSION $LFS/LFSBuiltPackages/$LFSVERSION
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.
screen
#Chroot into temporary system:
[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/root/.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 )
#Rc files are sourced from /etc/lfspkg.rc
#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)
#Re-enter the chroot ( this time and subsequent times don't use the 'system' argument to Chroot ):
[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 install
13)
#No point in compiling your own kernel on pi so prebuilt one is used, so skip this bit on pi.
#Configure and build the kernel:
cd /LFSPkgBuildScripts/kernel
#Optional copy the config for the running kernel, don't do this if running from bootcd
#gunzip < /proc/config.gz > config-${KERNELVERSION}
./kernel.LFSBuild install
#Again on pi skip this bit as firmware is installed by the pi-system-meta package.
#You may prefer to manually copy all firmware modules from the host sytem from /lib/firmware to your new LFS system.
#Or use the firmware build script to install all the latest firmware from https://git.kernel.org/ eg Whilst still in the kernel build folder:
./firmware.LFSBuild install
#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
13.5)
#No grub on pi
#Optional install of grub, see here:
#http://www.linuxfromscratch.org/lfs/view/stable/chapter08/grub.html
#The LFSSetup script will install a basic grub.cfg file in ${LFS}/${BUILDSCRIPTS}/system/grub/ based on the details given to the script.
#Check that the grub.cfg file is OK, make any changes and just copy it to /boot/grub, or manually do this:
#assuming root device is /dev/sda and LFS system is on /dev/sda1:
grub-install /dev/sda
cat > /boot/grub/grub.cfg << "EOF"
# Begin /boot/grub/grub.cfg
set default=0
set timeout=30
insmod ext2
set root=(hd0,1)
menuentry "GNU/Linux, Linux $LFSVERSION" {
linux /boot/vmlinuz-$KERNELVERSION root=/dev/sda1 ro
}
EOF
14)
#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:
cd /LFSPkgBuildScripts/xorg/xorg-meta/
./xorg-meta.LFSBuild install
15)
#Install documentation stuff
#Also installs python via dependency
#Loads of apps need these for building documentation so might as well install now.
cd /LFSPkgBuildScripts/devel/gtk-doc
./gtk-doc.LFSBuild install
cd /LFSPkgBuildScripts/devel/doxygen
./doxygen.LFSBuild install
16)
#Install cups and gtk.
#Gtk2 has a 'soft' dependency on cups so best to buils cups first.
cd /LFSPkgBuildScripts/print/cups
./cups.LFSBuild install
cd /LFSPkgBuildScripts/gtk/gtk
./gtk.LFSBuild install
#xsane frontends and xsane require gimp installed first to build the plugin
cd /LFSPkgBuildScripts/desktop/gimp
./gimp.LFSBuild install
#rest of printing stuff
cd /LFSPkgBuildScripts/print/printing-meta
./printing-meta.LFSBuild install
16.5)
#multi media
cd /LFSPkgBuildScripts/mm/mm-meta
./mm-meta.LFSBuild install
17)
#Development stuff
cd /LFSPkgBuildScripts/devel/development-meta
./development-meta.LFSBuild install
18)
#The big one! build a complete desktop
#this meta packagage includes other meta packages and takes a LOOOooooonnnnggggg time to build!
#this is for an xfce4 desktop.
cd /LFSPkgBuildScripts/desktop/desktop-meta
./desktop-meta.LFSBuild install
#Or for an LFSDesktop
cd /LFSPkgBuildScripts/lfsdesktop/LFSDesktop-meta
./LFSDesktop-meta.LFSBuild install
19)
#Extra odd stuff
#Chromium
cd /LFSPkgBuildScripts/desktop/chromium
./chromium.LFSBuild install
#falkon
cd /LFSPkgBuildScripts/qt/falkon/
./falkon.LFSBuild install
#Cairo-dock-plugins pulls in cairo-dock as a dependency
cd /LFSPkgBuildScripts/desktop/cairo-dock-plugins
./cairo-dock-plugins.LFSBuild install
#Qemu builds both static and dynamically linked versions
cd /LFSPkgBuildScripts/hware/qemu
./qemu.LFSBuild install
#Seamonkey for web dev
cd /LFSPkgBuildScripts/net/seamonkey
./seamonkey.LFSBuild install
#Icedtea-web BROKEN
#cd /LFSPkgBuildScripts/net/icedtea-web
#./icedtea-web.LFSBuild install
#For pulse audio
#cd /LFSPkgBuildScripts/net/icedtea-sound
#./icedtea-sound.LFSBuild install
#Samba
cd /LFSPkgBuildScripts/net/samba
./samba.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
#TODO
cd /LFSPkgBuildScripts/qt/qt-creator
./qt-creator.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
#Odd stuff
cd /LFSPkgBuildScripts/xorg/xbindkeys
./xbindkeys.LFSBuild install
cd /LFSPkgBuildScripts/net/libcddb
./libcddb.LFSBuild install
cd /LFSPkgBuildScripts/desktop/epdfview
./epdfview.LFSBuild install
#Conky is getting increasingly tied to gnome and difficult ( impossible! )to build.
#cd /LFSPkgBuildScripts/desktop/conky
#./conky.LFSBuild install
#Try an alternative!
cd /LFSPkgBuildScripts/desktop/gkrellm
./gkrellm.LFSBuild install
#Add users
cd /LFSPkgBuildScripts/HelperScripts/
./UsersAndGroups YOURUSERNAME