Skip to content

Commit

Permalink
Adjust build for lk5.13, add more options to rootfs creation, add e2f…
Browse files Browse the repository at this point in the history
…sck to initramfs
  • Loading branch information
Heisath committed Jul 28, 2021
1 parent 71efbd9 commit 321b77d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 15 deletions.
33 changes: 26 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ read_arguments() {
BUILD_INITRAMFS='on'
shift;
;;
--cmdline)
ALLOW_CMDLINE_CHANGES='on'
shift;
;;


--ghrunner)
Expand Down Expand Up @@ -488,7 +492,13 @@ EOF

if [[ ${ALLOW_ROOTFS_CHANGES} == 'on' ]]; then
echo "### You can now adjust the rootfs in output/rootfs/"
read -r -p "### Press any key to continue and pack it up..." -n1
read -r -p "### Press any key to continue..." -n1
fi

if [[ ${ALLOW_CMDLINE_CHANGES} == 'on' ]]; then
echo "### Will now enter a root bash in the new rootfs"
echo "### Once you are done making changes, 'exit' to continue..."
chroot "${rootfs_dir}" /bin/bash
fi

echo "### Unmounting"
Expand Down Expand Up @@ -579,6 +589,7 @@ if [[ -z $BUILD_KERNEL ]] && [[ -z $BUILD_ROOTFS ]]; then

BUILD_ROOTFS='on'
ALLOW_ROOTFS_CHANGES='off'
ALLOW_CMDLINE_CHANGES='off'
ASK_EXTRA_PKGS='off'
ZRAM_ENABLED='on'

Expand All @@ -588,16 +599,18 @@ if [[ -z $BUILD_KERNEL ]] && [[ -z $BUILD_ROOTFS ]]; then
"2" "Clean Kernel sources" "$CLEAN_KERNEL_SRC" \
"3" "Allow Kernel config changes" "$ALLOW_KERNEL_CONFIG_CHANGES" \
"4" "Debian Rootfs" "$BUILD_ROOTFS" \
"5" "Allow Rootfs changes" "$ALLOW_ROOTFS_CHANGES" \
"6" "Ask for extra apt pkgs" "$ASK_EXTRA_PKGS" \
"7" "Enable ZRAM on rootfs" "$ZRAM_ENABLED"
"5" "Pause to allow rootfs changes via filesystem" "$ALLOW_ROOTFS_CHANGES" \
"6" "Enter bash in rootfs for manual changes" "$ALLOW_CMDLINE_CHANGES" \
"7" "Ask for extra apt pkgs" "$ASK_EXTRA_PKGS" \
"8" "Enable ZRAM on rootfs" "$ZRAM_ENABLED"

# Accept user choices
BUILD_KERNEL='off'
CLEAN_KERNEL_SRC='off'
ALLOW_KERNEL_CONFIG_CHANGES='off'
BUILD_ROOTFS='off'
ALLOW_ROOTFS_CHANGES='off'
ALLOW_CMDLINE_CHANGES='off'
ASK_EXTRA_PKGS='off'
ZRAM_ENABLED='off'

Expand All @@ -606,8 +619,10 @@ if [[ -z $BUILD_KERNEL ]] && [[ -z $BUILD_ROOTFS ]]; then
[[ $selection == *3* ]] && ALLOW_KERNEL_CONFIG_CHANGES='on'
[[ $selection == *4* ]] && BUILD_ROOTFS='on'
[[ $selection == *5* ]] && ALLOW_ROOTFS_CHANGES='on'
[[ $selection == *6* ]] && ASK_EXTRA_PKGS='on'
[[ $selection == *7* ]] && ZRAM_ENABLED='on'
[[ $selection == *6* ]] && ALLOW_CMDLINE_CHANGES='on'
[[ $selection == *7* ]] && ASK_EXTRA_PKGS='on'
[[ $selection == *8* ]] && ZRAM_ENABLED='on'

else # at least kernel or rootfs has been selected via command line, check other options and set defaults
[[ -z $CLEAN_KERNEL_SRC ]] && CLEAN_KERNEL_SRC='on'
[[ -z $ALLOW_KERNEL_CONFIG_CHANGES ]] && ALLOW_KERNEL_CONFIG_CHANGES='off'
Expand All @@ -617,14 +632,17 @@ else # at least kernel or rootfs has been selected via command line, check other
[[ -z $ZRAM_ENABLED ]] && ZRAM_ENABLED='on'
fi


# inquire about further kernel configuration
if [[ $BUILD_KERNEL == "on" ]] && [ -z "$kernel_branch" ]; then
display_select "Kernel Building" "Please select the Linux Kernel branch to build." \
"4.18" "Linux kernel 4.18" \
"5.6" "Linux kernel 5.6" \
"5.8" "Linux kernel 5.8" \
"5.10" "Linux kernel 5.10" \
"5.11" "Linux kernel 5.11" \
"5.12" "Linux kernel 5.12"
"5.12" "Linux kernel 5.12" \
"5.13" "Linux kernel 5.13"

############################################################
# Required gcc:
Expand Down Expand Up @@ -654,6 +672,7 @@ if [[ $BUILD_ROOTFS == "on" ]] && [[ -z $BUILD_INITRAMFS ]]; then
[[ $selection == "y" ]] && BUILD_INITRAMFS='on'
fi

# get details for building the rootfs
if [[ $BUILD_ROOTFS == "on" ]]; then
if [ -z "$release" ]; then
display_select "Rootfs creation" "Please select the Debian release to build." \
Expand Down
30 changes: 22 additions & 8 deletions build_initramfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ CURRENT_DIR=$PWD
INITRAMFS=${CURRENT_DIR}/initramfs
INITRAMFS_ROOT=${INITRAMFS}/root

if [ "$1" = '--update' ]
then
if [ "$1" = '--update' ]
then
UPDATE_BOOT='yes'
else
UPDATE_BOOT='no'
Expand All @@ -34,6 +34,9 @@ cp -a /dev/{null,console,tty} ${INITRAMFS_ROOT}/dev
cp -a /bin/busybox ${INITRAMFS_ROOT}/bin/busybox
cp $(ldd "/bin/busybox" | egrep -o '/.* ') ${INITRAMFS_ROOT}/lib/

cp -a /sbin/e2fsck ${INITRAMFS_ROOT}/sbin/e2fsck
cp $(ldd "/sbin/e2fsck" | egrep -o '/.* ') ${INITRAMFS_ROOT}/lib/

cat << EOF > ${INITRAMFS_ROOT}/init
#!/bin/busybox sh
/bin/busybox --install
Expand Down Expand Up @@ -138,13 +141,24 @@ mkimage -A arm -O linux -T ramdisk -a 0x00e00000 -e 0x0 -n "Custom initramfs" -d

if [ "$UPDATE_BOOT" = 'yes' ]
then
echo '### Updating /boot'
if [ -e '/boot/uRamdisk' ]
then
mv /boot/uRamdisk /boot/uRamdisk.old
fi
if [ -e '/boot/boot/' ]; then
echo '### Updating /boot/boot'

if [ -e '/boot/boot/uRamdisk' ]; then
mv /boot/boot/uRamdisk /boot/boot/uRamdisk.old
fi

mv ${INITRAMFS}/uRamdisk /boot/uRamdisk
mv ${INITRAMFS}/uRamdisk /boot/boot/uRamdisk
elif [ -e '/boot/' ]; then
echo '### Updating /boot'

if [ -e '/boot/uRamdisk' ]; then
mv /boot/uRamdisk /boot/uRamdisk.old
fi

mv ${INITRAMFS}/uRamdisk /boot/uRamdisk
fi

rm -rf ${INITRAMFS}
else
echo '### Cleanup'
Expand Down
Binary file modified prebuilt/uRamdisk
Binary file not shown.

0 comments on commit 321b77d

Please sign in to comment.