Files
LFSPkgBuilds/LFSScripts/SystemDBuild/HowTo
2021-04-25 18:09:48 +01:00

372 lines
11 KiB
Plaintext

#SystemD Version
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=10.1
SOURCEARCHIVES=/LFSSourceArchives/$LFSVERSION
BUILTPACKAGES=/LFSBuiltPackages/$LFSVERSION
EXTFOLDER=
KERNELVERSION=5.11.10
USESYSTEMD=1
export LFS
export LFSVERSION
export SOURCEARCHIVES
export BUILTPACKAGES
export EXTFOLDER
export KERNELVERSION
export USESYSTEMD
#Own the files ( If needed ):
[sudo -E] chown -R $USER:$USER $LFS/LFSPkgBuilds
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)
#make sure normal user owns $LFS ( if you are using a dedicated user change $USER if needed ).
[sudo -E] chown $USER $LFS
#Run BuildTools script:
./BuildTools1
5)
#Run BuildFileSystem script:
[sudo -E ] ./BuildFileSystem
6)
#Enter chroot
[sudo] ./Chroot
cd /LFSScripts
7)
#finish building tempory tools.
./BuildTools2
exit
#Make sure you are no longer in the chroot. !IMPORTANT!
8)
cd $LFS
[sudo] find usr/{lib,libexec} -name \*.la -delete
[sudo] rm -rf usr/share/{info,man,doc}/*
[sudo] strip --strip-debug usr/lib/*
[sudo] strip --strip-unneeded usr/{,s}bin/*
[sudo] strip --strip-unneeded tools/bin/*
#tar MUST be run as root to preserve permissions.
#change ${HOME}/tools-${LFSVERSION}.tar.xz to suit.
#make sure all virtual file systems etc are unmounted, including /LFSSourceArchives etc if you have mounted an extern drive there.
[sudo -E] tar -apcv -f ${HOME}/tools-${LFSVERSION}-SystemD.tar.xz .
9)
#make sure you are back in the lfsscripts folder.
cd $LFS/LFSScripts
#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
10)
#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
11)
#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 -snfv ../SYSTEM/linux-$KERNELVERSION.tar.xz .
12)
#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
13)
#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
14)
#You should now be in the chroot
#First install lfspkg:
cd /LFSPkgBuildScripts/admin/LFSPkg
BOOTSTRAP=1 ./LFSPkg.LFSBuild install
#If you are asked whether to replace files etc You should reply 'R' to keep the settings created by the LFSSetup script.
#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 about no wget etc, 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
#You shoud probably set log file to 1, and check etc to 0 when installing the base system.
#You can rerun lfspkg --setup at any time to tweak the settings.
#after installing the base system you will probably want to at least set check etc to 1.
15)
#Remake a ( possibly ) broken symlink
cd /LFSPkgBuildScripts/system
ln -snvf ../../../LFSScripts/PkgVersions PkgVersions
#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
Wait for script to complete:
...
Have coffee
Walk the dog
...
16)
#logout from temporary system:
exit
18)
#Re-enter the chroot:
cd $LFS/LFSScripts
[sudo] ./Chroot
19)
#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
#rerun setup if needed, ( probably best to set "Check /etc For Possible Config File Clashes" to 1 now.
lfspkg --setup
20)
#Configure and build the kernel:
cd /LFSPkgBuildScripts/kernel
#Optional copy the config for the running kernel, don't do this if running from bootcd, you may have to set KERNELVERSION if you are doing this from chroot.
#gunzip < /proc/config.gz > config-${KERNELVERSION}
./kernel.LFSBuild install
#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
21)
#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
22)
#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
#Install Xfce4
cd /LFSPkgBuildScripts/xfce/xfce4-meta
./xfce4-meta.LFSBuild install
##all below here is for LFS9.0 needs updating to 10.1
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