This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
doc:howto:tce [2021/01/25 00:18] stefanbaur [Configuring the Build] This is part one of the patch to create Images for the Raspberry Pi |
doc:howto:tce [2021/01/25 00:19] stefanbaur [Starting the Build] This is part two of the patch to create Images for the Raspberry Pi |
||
---|---|---|---|
Line 250: | Line 250: | ||
# Create Timestamp | # Create Timestamp | ||
LBX2GO_TIMESTAMP=$(date +" | LBX2GO_TIMESTAMP=$(date +" | ||
+ | |||
+ | exec > >(tee "/ | ||
# Set Directory name | # Set Directory name | ||
- | LBX2GO_TCEDIR=" | + | LBX2GO_TCEDIR=" |
if [ -z " | if [ -z " | ||
+ | ( echo " | ||
[ -z " | [ -z " | ||
[ -z " | [ -z " | ||
Line 266: | Line 269: | ||
echo -e "One or more of the following variables is unset:" | echo -e "One or more of the following variables is unset:" | ||
echo -e " | echo -e " | ||
+ | echo " | ||
echo -e " | echo -e " | ||
echo -e " | echo -e " | ||
Line 282: | Line 286: | ||
cd $LBX2GO_TCEDIR | cd $LBX2GO_TCEDIR | ||
+ | X2GO_LBCONFIG_STRING=$(cat << | ||
lb config $LBX2GO_ARCH $LBX2GO_SPACE $LBX2GO_DEFAULTS \ | lb config $LBX2GO_ARCH $LBX2GO_SPACE $LBX2GO_DEFAULTS \ | ||
| | ||
| | ||
| | ||
+ | X2GOLBCONFIGSTRING | ||
+ | ) | ||
+ | # Our previous way of doing this had issues with newlines and multiple blanks. So we're now doing a bit | ||
+ | # of sanitizing, then we eval the variable. | ||
+ | X2GO_LBCONFIG_STRING=$(echo " | ||
+ | eval " | ||
+ | |||
# This will copy any patches we have prepared | # This will copy any patches we have prepared | ||
if [ -d " | if [ -d " | ||
cp -a ../patch/* config/ | cp -a ../patch/* config/ | ||
fi | fi | ||
+ | |||
# This will copy any patches we have prepared for minidesktop | # This will copy any patches we have prepared for minidesktop | ||
if [ -d " | if [ -d " | ||
cp -a ../ | cp -a ../ | ||
fi | fi | ||
+ | |||
+ | # This checks if a bootloader directory is present (e.g. because of a custom splash.svg) | ||
+ | # and adds all other files that might be missing (live-build won't add them automatically | ||
+ | # if the directory already exists) | ||
+ | if [ -d config/ | ||
+ | rsync -aPH --ignore-existing --exclude=" | ||
+ | fi | ||
+ | # When enabled, this silences the audible beep at syslinux/ | ||
+ | # Note that this is an accessibility feature for blind users, so use with care. | ||
+ | sed -e " | ||
+ | |||
# This enables an i386-only package in the sources.list file when an i386 build is requested | # This enables an i386-only package in the sources.list file when an i386 build is requested | ||
- | if echo "$LBX2GO_ARCH" | + | if echo $LBX2GO_ARCH | grep -q -i " |
sed -i -e 's/# for i386 only #//' config/ | sed -i -e 's/# for i386 only #//' config/ | ||
fi | fi | ||
+ | |||
+ | # This is part of our experimental ARM support | ||
+ | # It adds required arm64-only packages when an arm64 build is requested | ||
+ | if echo $LBX2GO_ARCH | grep -q " | ||
+ | |||
+ | # firmware for wifi | ||
+ | echo " | ||
+ | |||
+ | if [ " | ||
+ | # modules required for Raspberry Pi 3 LAN | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | echo " | ||
+ | |||
+ | # firmware for basic raspi functions - required for boot on Pi3 | ||
+ | echo " | ||
+ | # standard linux kernel - for Pi3 | ||
+ | echo " | ||
+ | |||
+ | elif [ " | ||
+ | # firmware for basic raspi functions - required for boot on Pi4 | ||
+ | echo " | ||
+ | echo " | ||
+ | |||
+ | # newer linux kernel - required for pi4/pi400 | ||
+ | echo " | ||
+ | |||
+ | else | ||
+ | echo " | ||
+ | fi | ||
+ | |||
+ | fi | ||
+ | |||
+ | |||
# This is for minidesktop builds only | # This is for minidesktop builds only | ||
if [ -f config/ | if [ -f config/ | ||
Line 328: | Line 390: | ||
# at files not being downloaded, disable these three entries. | # at files not being downloaded, disable these three entries. | ||
export https_proxy=$LB_APT_HTTP_PROXY | export https_proxy=$LB_APT_HTTP_PROXY | ||
- | export http_proxy=$LB_APT_HTTP_PROXY | + | |
export ftp_proxy=$LB_APT_FTP_PROXY | export ftp_proxy=$LB_APT_FTP_PROXY | ||
fi | fi | ||
- | # This is a crude hack to detect crossbuilds | + | # This is part of our experimental ARM support |
- | # It makes some necessary changes, and also tries to speed up squashfs creation. | + | # It is used when building |
- | | + | # It makes some necessary changes, and also tries to speed up squashfs creation |
- | | + | |
+ | | ||
- | # This command removes all references to fuseext and x2gothinclient from the | + | # This command removes all references to fuseext, freerdp-nightly, |
- | # package list files. | + | # package list files. |
- | echo " | + | echo " |
- | sed -e ' | + | sed -e ' |
- | # This command removes the X2Go repository from the directory where additional | + | |
- | # archives are stored. | + | # archives are stored. |
# packages, but Debian Buster does - so that's what we're falling back to. | # packages, but Debian Buster does - so that's what we're falling back to. | ||
echo " | echo " | ||
rm ./ | rm ./ | ||
- | # The following is a hack to reduce squashfs creation time. We're replacing mksquashfs | + | |
- | # in the changeroot | + | # We're replacing mksquashfs in the changeroot with a wrapper script that drops the |
- | # mksquashfs call into a file. | + | # original |
- | # We need to do this as a background task, waiting for the mksquashfs executable to | + | |
- | # appear in the changeroot; as the changeroot will only be created later on, once | + | |
- | # lb build is called. | + | # appear in the changeroot; as the changeroot will only be created later on, once |
- | + | # lb build is called. | |
- | # The other background task waits until the command file has been created, then | + | |
- | # it applies some necessary patches to it, and starts the mksquashfs command natively | + | |
- | # on the build host, rather than in the changeroot environment. | + | |
- | # This is because in the changeroot, we'd be running the ARM mksquashfs in a qemu | + | |
- | # software emulation of the ARM architecture, | + | |
- | # native, raw CPU power and cores available to us. | + | |
- | | + | |
- | # our own PID along to the background tasks, and tell them to terminate if our PID | + | # it applies some necessary patches |
- | # disappears while they're still in their waiting/ | + | # on the build host, rather than in the changeroot environment. |
+ | # This is because in the changeroot, we'd be running the ARM mksquashfs | ||
+ | # software emulation of the ARM architecture, | ||
+ | # native, raw CPU power and cores available to us. | ||
- | MASTERPID=$$ | + | # To make sure we don't have any lingering processes in the background, we're passing |
+ | # our own PID along to the background tasks, and tell them to terminate if our PID | ||
+ | # disappears while they' | ||
- | # Replace mksquashfs in chroot with script | + | |
- | # (script will undo this upon completion) | + | |
- | ( | + | |
- | # wait until the chroot has been populated or until our parent process dies | + | |
- | while ! [ -x ./ | + | |
- | ps $MASTERPID | + | |
- | sleep 1 | + | |
- | done | + | |
- | # make sure we don't overwrite the real executable if it has already been | + | |
- | # moved out of the way | + | |
- | if ! [ -x ./ | + | |
- | cp ./ | + | |
- | fi | + | |
- | echo '# | + | |
- | # log the name we've been called with and all parameters into this file | + | |
- | echo 'echo "$0 $@" >/ | + | |
- | # once the native mksquashfs is complete, we will remove this file | + | |
- | echo 'while [ -f / | + | |
- | echo ' | + | |
- | echo ' | + | |
- | # so let's wait until it has been removed before deleting ourselves ... | + | |
- | echo 'rm / | + | |
- | # ... and moving the real executable back into its place | + | |
- | echo 'mv / | + | |
- | chmod 755 ./ | + | |
- | ) & | + | |
- | | + | |
- | ( | + | # |
- | # wait until the trigger file has been created | + | ( |
- | while ! [ -f ./chroot/tmp/filesystem.squashfs.temp | + | |
- | ps $MASTERPID >/ | + | while ! [ -x ./chroot/usr/bin/ |
- | sleep 1 | + | ps $MASTERPID >/ |
- | done | + | sleep 1 |
- | # using any of the available filters (x86, arm, armthumb) for the | + | done |
- | # -Xbcj command results in an unusable squashfs on arm, so we drop the | + | # make sure we don't overwrite |
- | # parameter completely | + | # moved out of the way |
- | # also, all absolute paths (detected by beginning with " | + | if ! [ -x ./ |
- | # prefixed | + | cp ./ |
- | # to look for the corresponding paths/ | + | fi |
- | | + | echo '#!/bin/ |
- | ./chroot/tmp/filesystem.squashfs.temp | + | |
- | # now let's make this executable | + | echo ' |
- | chmod 755 ./chroot/tmp/filesystem.squashfs.temp | + | |
+ | echo 'while [ -f / | ||
+ | | ||
+ | echo ' | ||
+ | # so let's wait until it has been removed before deleting ourselves ... | ||
+ | echo 'rm / | ||
+ | # | ||
+ | echo 'mv / | ||
+ | | ||
+ | ) & | ||
- | | + | # start the native mksquashfs after patching the parameters |
- | # in the squashfs - no idea why we don't need them while inside the chroot ... | + | ( |
- | echo ' | + | # wait until the trigger file has been created or until our parent process dies |
- | echo ' | + | while ! [ -f ./ |
- | echo ' | + | ps $MASTERPID >/ |
- | # now let's execute the script and, if it terminates without an error, | + | sleep 1 |
- | # we'll move the newly created squashfs into the chroot where the chrooted | + | done |
- | # mksquashfs command would have created it; if that worked as well, we' | + | # using any of the available filters (x86, arm, armthumb) for the |
- | # remove the script file so our dummy mksquashfs inside the chroot knows | + | # -Xbcj command results in an unusable squashfs on arm, so we drop the |
- | # it's time to terminate itself. | + | # parameter completely if it's there. |
- | ./ | + | # also, all absolute paths (detected by beginning with " /") need to be |
- | mv ./ | + | # prefixed with " |
- | rm ./ | + | # to look for the corresponding paths/ |
- | ) & | + | sed -e 's/ -Xbcj x86/ /g' -e 's# /# ./ |
+ | ./ | ||
+ | #needs switch from e.g. / | ||
+ | sed -e " | ||
+ | ./ | ||
+ | # now let's make this executable | ||
+ | chmod 755 ./ | ||
+ | |||
+ | | ||
+ | # in the squashfs - no idea why we don't need them while inside the chroot ... | ||
+ | echo ' | ||
+ | echo ' | ||
+ | echo ' | ||
+ | # now let's execute the script and, if it terminates without an error, | ||
+ | # we'll move the newly created squashfs into the chroot where the chrooted | ||
+ | # mksquashfs command would have created it; if that worked as well, we' | ||
+ | # remove the script file so our dummy mksquashfs inside the chroot knows | ||
+ | # it's time to terminate itself. | ||
+ | ./ | ||
+ | mv ./ | ||
+ | rm ./ | ||
+ | ) & | ||
+ | fi | ||
fi | fi | ||
Line 437: | Line 505: | ||
if [ " | if [ " | ||
- | ln ./ | + | ln ./ |
- | | + | |
fi | fi | ||
+ | |||
+ | # This is part of our experimental ARM support | ||
+ | if [ " | ||
+ | # after the build, let's determine the name of our image file ... | ||
+ | IMAGEFILE=" | ||
+ | |||
+ | # ... and change the partition type to reflect the file system actually in use for partition 1 | ||
+ | # (" | ||
+ | sfdisk --part-type $IMAGEFILE 1 b | ||
+ | |||
+ | # next, we need to patch two things inside the image, so we need to set up a loop device for it. | ||
+ | FREELOOP=$(losetup -f) # note that this could become a TOCTOU issue if more than 1 process tries to use loop devices | ||
+ | |||
+ | # as the image is a full disk image containing a partition, we need to jump to the position where the first partition starts | ||
+ | losetup -o 1048576 $FREELOOP $IMAGEFILE | ||
+ | |||
+ | # now let's mount it | ||
+ | mkdir -p ./tempmount | ||
+ | mount $FREELOOP ./tempmount | ||
+ | |||
+ | # purge this dir, so we have enough space; we'll return to fill it later | ||
+ | rm ./ | ||
+ | |||
+ | # first, we copy the contents of the boot/ | ||
+ | # see if inplace helps against out of space errors | ||
+ | rsync -aP --inplace ./ | ||
+ | |||
+ | mkdir -p ./ | ||
+ | rsync -aP ./ | ||
+ | |||
+ | # next, we replace the " | ||
+ | sed -e ' | ||
+ | |||
+ | # here comes the cleanup part | ||
+ | sync | ||
+ | umount $FREELOOP | ||
+ | losetup -d $FREELOOP | ||
+ | rmdir ./tempmount | ||
+ | fi | ||
+ | |||
if [ " | if [ " | ||
if [ " | if [ " | ||
Line 451: | Line 559: | ||
if [ " | if [ " | ||
genisoimage -o ./ | genisoimage -o ./ | ||
- | if [ -e ./ | + | if [ -e ./ |
- | ln ./ | + | ln ./ |
- | | + | |
- | elif [ -e ./ | + | elif [ -e ./ |
- | ln ./ | + | ln ./ |
- | | + | |
fi | fi | ||
mv ./ | mv ./ | ||
Line 487: | Line 595: | ||
cd .. | cd .. | ||
fi | fi | ||
+ | |||
</ | </ |