##// END OF EJS Templates
fixes and shellcheck
Unknown -
r382:68c10636851d
parent child
Show More
@@ -86,13 +86,12 if [ "$BUILD_KERNEL" = true ] ; then
86 if [ "$KERNELSRC_CONFIG" = true ] ; then
86 if [ "$KERNELSRC_CONFIG" = true ] ; then
87 # Load default raspberry kernel configuration
87 # Load default raspberry kernel configuration
88 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
88 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}"
89
89 #Switch to KERNELSRC_DIR
90 #Switch to KERNELSRC_DIR
90 pushd "${KERNEL_DIR}"
91 pushd "${KERNEL_DIR}"
92
91
93 # GPL v2.0
92 # GPL v2.0
94 #https://github.com/sakaki-/bcmrpi3-kernel-bis/blob/master/conform_config.sh
93 #https://github.com/sakaki-/bcmrpi3-kernel-bis/blob/master/conform_config.sh
95 if [ "$KERNEL_ZSWAP" = true ] && ( [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ) ; then
94 if [ "$KERNEL_ZSWAP" = true ] && { [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then
96 # enable ZSWAP support for better performance during large builds etc.
95 # enable ZSWAP support for better performance during large builds etc.
97 # requires activation via kernel parameter or sysfs
96 # requires activation via kernel parameter or sysfs
98 # see e.g. https://askubuntu.com/a/472227 for a summary of ZSWAP (vs ZRAM etc.)
97 # see e.g. https://askubuntu.com/a/472227 for a summary of ZSWAP (vs ZRAM etc.)
@@ -105,7 +104,7 if [ "$BUILD_KERNEL" = true ] ; then
105 set_kernel_config PGTABLE_MAPPING y
104 set_kernel_config PGTABLE_MAPPING y
106 fi
105 fi
107
106
108 if [ "$KERNEL_VIRT" = true ] && ( [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ) ; then
107 if [ "$KERNEL_VIRT" = true ] && { [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then
109 # enable basic KVM support; see e.g.
108 # enable basic KVM support; see e.g.
110 # https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=210546&start=25#p1300453
109 # https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=210546&start=25#p1300453
111 set_kernel_config VIRTUALIZATION y
110 set_kernel_config VIRTUALIZATION y
@@ -115,7 +114,7 if [ "$BUILD_KERNEL" = true ] ; then
115 fi
114 fi
116 #See https://github.com/raspberrypi/linux/issues/2177#issuecomment-354647406
115 #See https://github.com/raspberrypi/linux/issues/2177#issuecomment-354647406
117 # Netfilter kernel support
116 # Netfilter kernel support
118 if [ "$KERNEL_NF" = true ] && ( [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ) ; then
117 if [ "$KERNEL_NF" = true ] && { [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then
119 set_kernel_config CONFIG_NETFILTER_XTABLES m
118 set_kernel_config CONFIG_NETFILTER_XTABLES m
120 set_kernel_config CONFIG_NF_DUP_NETDEV m
119 set_kernel_config CONFIG_NF_DUP_NETDEV m
121 set_kernel_config CONFIG_NF_NAT_SIP m
120 set_kernel_config CONFIG_NF_NAT_SIP m
@@ -209,7 +208,7 if [ "$BUILD_KERNEL" = true ] ; then
209 #https://groups.google.com/forum/#!topic/linux.gentoo.user/_2aSc_ztGpA
208 #https://groups.google.com/forum/#!topic/linux.gentoo.user/_2aSc_ztGpA
210 #https://github.com/torvalds/linux/blob/master/init/Kconfig#L848
209 #https://github.com/torvalds/linux/blob/master/init/Kconfig#L848
211 # Enables BPF syscall for systemd-journald
210 # Enables BPF syscall for systemd-journald
212 if [ "$KERNEL_BPF" = true ] && ( [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ) ; then
211 if [ "$KERNEL_BPF" = true ] && { [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then
213 set_kernel_config CONFIG_BPF_SYSCALL y
212 set_kernel_config CONFIG_BPF_SYSCALL y
214 set_kernel_config CONFIG_CGROUP_BPF y
213 set_kernel_config CONFIG_CGROUP_BPF y
215 fi
214 fi
@@ -238,7 +237,7 if [ "$BUILD_KERNEL" = true ] ; then
238 echo "CONFIG_CRYPTO_XTS=y"
237 echo "CONFIG_CRYPTO_XTS=y"
239 echo "CONFIG_CRYPTO_SHA512=y"
238 echo "CONFIG_CRYPTO_SHA512=y"
240 echo "CONFIG_CRYPTO_MANAGER=y"
239 echo "CONFIG_CRYPTO_MANAGER=y"
241 } >> ${KERNEL_DIR}/.config
240 } >> "${KERNEL_DIR}/.config"
242 fi
241 fi
243 fi
242 fi
244
243
@@ -269,7 +268,7 if [ "$BUILD_KERNEL" = true ] ; then
269 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs
268 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs
270
269
271 # Cross compile kernel modules
270 # Cross compile kernel modules
272 if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then
271 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
273 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules
272 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules
274 fi
273 fi
275 fi
274 fi
@@ -283,16 +282,16 if [ "$BUILD_KERNEL" = true ] ; then
283
282
284 # Install kernel modules
283 # Install kernel modules
285 if [ "$ENABLE_REDUCE" = true ] ; then
284 if [ "$ENABLE_REDUCE" = true ] ; then
286 if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then
285 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
287 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
286 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
288 fi
287 fi
289 else
288 else
290 if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then
289 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
291 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
290 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
292 fi
291 fi
293
292
294 # Install kernel firmware
293 # Install kernel firmware
295 if [ "$(grep "^firmware_install:" "${KERNEL_DIR}/Makefile")" ] ; then
294 if grep -q "^firmware_install:" "${KERNEL_DIR}/Makefile" ; then
296 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
295 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
297 fi
296 fi
298 fi
297 fi
@@ -360,8 +359,8 if [ "$BUILD_KERNEL" = true ] ; then
360 rm -fr "${KERNEL_DIR}"
359 rm -fr "${KERNEL_DIR}"
361 else
360 else
362 # Prepare compiled kernel modules
361 # Prepare compiled kernel modules
363 if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then
362 if grep -q "CONFIG_MODULES=y" "${KERNEL_DIR}/.config" ; then
364 if [ "$(grep "^modules_prepare:" "${KERNEL_DIR}/Makefile")" ] ; then
363 if grep -q "^modules_prepare:" "${KERNEL_DIR}/Makefile" ; then
365 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
364 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
366 fi
365 fi
367
366
@@ -372,29 +371,26 if [ "$BUILD_KERNEL" = true ] ; then
372 fi
371 fi
373
372
374 else # BUILD_KERNEL=false
373 else # BUILD_KERNEL=false
375 # echo " Install precompiled kernel..."
374 # echo Install precompiled kernel...
376 # echo "error: not implemented"
375 # echo error: not implemented
377 if [ "$KERNEL_ARCH" = arm64 ] && ( [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ) ; then
376 if [ "$KERNEL_ARCH" = arm64 ] && { [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; } ; then
378 # Create temporary directory for dl
377 # Create temporary directory for dl
379 temp_dir=$(as_nobody mktemp -d)
378 temp_dir=$(as_nobody mktemp -d)
380
379
381 # Fetch kernel dl
380 # Fetch kernel dl
382 as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI3_64_KERNEL_URL"
381 as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI3_64_KERNEL_URL"
383 #extract download
382 #extract download
384 tar -xJf "${temp_dir}"/kernel.tar.xz -C "${R}"
383 tar -xJf "${temp_dir}"/kernel.tar.xz -C "${R}"
385
386 # Remove temporary directory for kernel sources
384 # Remove temporary directory for kernel sources
387 rm -fr "${temp_dir}"
385 rm -fr "${temp_dir}"
388
389 # Set permissions of the kernel sources
386 # Set permissions of the kernel sources
390 mkdir "${R}/boot/firmware"
387 mkdir "${R}/boot/firmware"
391 cp -r "${R}/boot/ "${R}/boot/firmware"
388 cp -r "${R}/boot/" "${R}/boot/firmware"
392 chown -R root:root "${R}/boot/firmware"
389 chown -R root:root "${R}/boot/firmware"
393 chown -R root:root "${R}/lib"
390 chown -R root:root "${R}/lib"
394
391 #Create cmdline.txt
395 #Create cmdline.txt
392 touch "${BOOT_DIR}/cmdline.txt"
396 touch "${BOOT_DIR}/cmdline.txt"
393 fi
397 fi
398
394
399 # Check if kernel installation was successful
395 # Check if kernel installation was successful
400 KERNEL="$(ls -1 "${R}"/boot/kernel* | sort | tail -n 1)"
396 KERNEL="$(ls -1 "${R}"/boot/kernel* | sort | tail -n 1)"
@@ -403,5 +399,4 fi
403 cleanup
399 cleanup
404 exit 1
400 exit 1
405 fi
401 fi
406
402 fi
407 fi No newline at end of file
@@ -11,8 +11,8 ENCRYPTED_USER_PASSWORD=$(mkpasswd -m sha-512 "${USER_PASSWORD}")
11
11
12 # Setup default user
12 # Setup default user
13 if [ "$ENABLE_USER" = true ] ; then
13 if [ "$ENABLE_USER" = true ] ; then
14 chroot_exec adduser --gecos $USER_NAME --add_extra_groups --disabled-password $USER_NAME
14 chroot_exec adduser --gecos "$USER_NAME" --add_extra_groups --disabled-password "$USER_NAME"
15 chroot_exec usermod -a -G sudo -p "${ENCRYPTED_USER_PASSWORD}" $USER_NAME
15 chroot_exec usermod -a -G sudo -p "${ENCRYPTED_USER_PASSWORD}" "$USER_NAME"
16 fi
16 fi
17
17
18 # Setup root password or not
18 # Setup root password or not
@@ -41,7 +41,7 if [ "$ENABLE_UBOOT" = true ] ; then
41
41
42 # Install and setup U-Boot command file
42 # Install and setup U-Boot command file
43 install_readonly files/boot/uboot.mkimage "${BOOT_DIR}/uboot.mkimage"
43 install_readonly files/boot/uboot.mkimage "${BOOT_DIR}/uboot.mkimage"
44 printf "# Set the kernel boot command line\nsetenv bootargs \"earlyprintk ${CMDLINE}\"\n\n$(cat ${BOOT_DIR}/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage"
44 printf "# Set the kernel boot command line\nsetenv bootargs \"earlyprintk ${CMDLINE}\"\n\n$(cat "${BOOT_DIR}"/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage"
45
45
46 if [ "$ENABLE_INITRAMFS" = true ] ; then
46 if [ "$ENABLE_INITRAMFS" = true ] ; then
47 # Convert generated initramfs for U-Boot using mkimage
47 # Convert generated initramfs for U-Boot using mkimage
@@ -51,7 +51,7 if [ "$ENABLE_UBOOT" = true ] ; then
51 rm -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}"
51 rm -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}"
52
52
53 # Configure U-Boot to load generated initramfs
53 # Configure U-Boot to load generated initramfs
54 printf "# Set initramfs file\nsetenv initramfs initramfs-${KERNEL_VERSION}.uboot\n\n$(cat ${BOOT_DIR}/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage"
54 printf "# Set initramfs file\nsetenv initramfs initramfs-${KERNEL_VERSION}.uboot\n\n$(cat "${BOOT_DIR}"/uboot.mkimage)" > "${BOOT_DIR}/uboot.mkimage"
55 printf "\nbootz \${kernel_addr_r} \${ramdisk_addr_r} \${fdt_addr_r}" >> "${BOOT_DIR}/uboot.mkimage"
55 printf "\nbootz \${kernel_addr_r} \${ramdisk_addr_r} \${fdt_addr_r}" >> "${BOOT_DIR}/uboot.mkimage"
56 else # ENABLE_INITRAMFS=false
56 else # ENABLE_INITRAMFS=false
57 # Remove initramfs from U-Boot mkfile
57 # Remove initramfs from U-Boot mkfile
@@ -68,10 +68,12 if [ "$ENABLE_UBOOT" = true ] ; then
68
68
69 if [ "$SET_ARCH" = 64 ] ; then
69 if [ "$SET_ARCH" = 64 ] ; then
70 echo "Setting up config.txt to boot 64bit uboot"
70 echo "Setting up config.txt to boot 64bit uboot"
71
71 {
72 printf "\n# 64bit-mode" >> "${BOOT_DIR}/config.txt"
72 printf "\n# 64bit-mode"
73 printf "\n# arm_control=0x200 is deprecated https://www.raspberrypi.org/documentation/configuration/config-txt/misc.md" >> "${BOOT_DIR}/config.txt"
73 printf "\n# arm_control=0x200 is deprecated https://www.raspberrypi.org/documentation/configuration/config-txt/misc.md"
74 printf "\narm_64bit=1" >> "${BOOT_DIR}/config.txt"
74 printf "\narm_64bit=1"
75 } >> "${BOOT_DIR}/config.txt"
76
75 #in 64bit uboot booti is used instead of bootz [like in KERNEL_BIN_IMAGE=zImage (armv7)|| Image(armv8)]
77 #in 64bit uboot booti is used instead of bootz [like in KERNEL_BIN_IMAGE=zImage (armv7)|| Image(armv8)]
76 sed -i "s|bootz|booti|g" "${BOOT_DIR}/uboot.mkimage"
78 sed -i "s|bootz|booti|g" "${BOOT_DIR}/uboot.mkimage"
77 fi
79 fi
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant