|
1 | NO CONTENT: modified file |
@@ -1,31 +1,32 | |||
|
1 | 1 | logger -t "rc.firstboot" "Regenerating initramfs to remove encrypted root partition auto-expand" |
|
2 | 2 | |
|
3 | 3 | KERNEL_VERSION=$(uname -r) |
|
4 | 4 | KERNEL_ARCH=$(uname -m) |
|
5 | 5 | INITRAMFS="/boot/firmware/initramfs-${KERNEL_VERSION}" |
|
6 | 6 | INITRAMFS_UBOOT="${INITRAMFS}.uboot" |
|
7 | 7 | |
|
8 | 8 | # Extract kernel arch |
|
9 | 9 | case "${KERNEL_ARCH}" in |
|
10 | 10 | arm*) KERNEL_ARCH=arm ;; |
|
11 | aarch64) KERNEL_ARCH=arm64 ;; | |
|
11 | 12 | esac |
|
12 | 13 | |
|
13 | 14 | # Regenerate initramfs |
|
14 | 15 | if [ -r "${INITRAMFS}" ] ; then |
|
15 | 16 | rm -f /etc/initramfs-tools/scripts/init-premount/expand_encrypted_rootfs |
|
16 | 17 | rm -f /etc/initramfs-tools/scripts/local-premount/expand-premount |
|
17 | 18 | rm -f /etc/initramfs-tools/hooks/expand-tools |
|
18 | 19 | rm -f "${INITRAMFS}" |
|
19 | 20 | mkinitramfs -o "${INITRAMFS}" "${KERNEL_VERSION}" |
|
20 | 21 | fi |
|
21 | 22 | |
|
22 | 23 | # Convert generated initramfs for U-Boot using mkimage |
|
23 | 24 | if [ -r "${INITRAMFS_UBOOT}" ] ; then |
|
24 | 25 | rm -f /etc/initramfs-tools/scripts/init-premount/expand_encrypted_rootfs |
|
25 | 26 | rm -f /etc/initramfs-tools/scripts/local-premount/expand-premount |
|
26 | 27 | rm -f /etc/initramfs-tools/hooks/expand-tools |
|
27 | 28 | rm -f "${INITRAMFS_UBOOT}" |
|
28 | 29 | mkinitramfs -o "${INITRAMFS}" "${KERNEL_VERSION}" |
|
29 | 30 | mkimage -A "${KERNEL_ARCH}" -T ramdisk -C none -n "initramfs-${KERNEL_VERSION}" -d "${INITRAMFS}" "${INITRAMFS_UBOOT}" |
|
30 | 31 | rm -f "${INITRAMFS}" |
|
31 | 32 | fi |
@@ -1,86 +1,86 | |||
|
1 | 1 | # This file contains utility functions used by rpi23-gen-image.sh |
|
2 | 2 | |
|
3 | 3 | cleanup (){ |
|
4 | 4 | set +x |
|
5 | 5 | set +e |
|
6 | 6 | |
|
7 | 7 | # Identify and kill all processes still using files |
|
8 | 8 | echo "killing processes using mount point ..." |
|
9 | 9 | fuser -k "${R}" |
|
10 | 10 | sleep 3 |
|
11 | 11 | fuser -9 -k -v "${R}" |
|
12 | 12 | |
|
13 | 13 | # Clean up temporary .password file |
|
14 | 14 | if [ -r ".password" ] ; then |
|
15 | 15 | shred -zu .password |
|
16 | 16 | fi |
|
17 | 17 | |
|
18 | 18 | # Clean up all temporary mount points |
|
19 | 19 | echo "removing temporary mount points ..." |
|
20 | 20 | umount -l "${R}/proc" 2> /dev/null |
|
21 | 21 | umount -l "${R}/sys" 2> /dev/null |
|
22 | 22 | umount -l "${R}/dev/pts" 2> /dev/null |
|
23 | 23 | umount "$BUILDDIR/mount/boot/firmware" 2> /dev/null |
|
24 | 24 | umount "$BUILDDIR/mount" 2> /dev/null |
|
25 | 25 | cryptsetup close "${CRYPTFS_MAPPING}" 2> /dev/null |
|
26 | 26 | losetup -d "$ROOT_LOOP" 2> /dev/null |
|
27 | 27 | losetup -d "$FRMW_LOOP" 2> /dev/null |
|
28 | 28 | trap - 0 1 2 3 6 |
|
29 | 29 | } |
|
30 | 30 | |
|
31 | 31 | chroot_exec() { |
|
32 | 32 | # Exec command in chroot |
|
33 | 33 | LANG=C LC_ALL=C DEBIAN_FRONTEND=noninteractive chroot "${R}" "$@" |
|
34 | 34 | } |
|
35 | 35 | |
|
36 | 36 | as_nobody() { |
|
37 | 37 | # Exec command as user nobody |
|
38 | 38 | sudo -E -u nobody LANG=C LC_ALL=C "$@" |
|
39 | 39 | } |
|
40 | 40 | |
|
41 | 41 | install_readonly() { |
|
42 | 42 | # Install file with user read-only permissions |
|
43 | 43 | install -o root -g root -m 644 "$@" |
|
44 | 44 | } |
|
45 | 45 | |
|
46 | 46 | install_exec() { |
|
47 | 47 | # Install file with root exec permissions |
|
48 | 48 | install -o root -g root -m 744 "$@" |
|
49 | 49 | } |
|
50 | 50 | |
|
51 | 51 | use_template () { |
|
52 | 52 | # Test if configuration template file exists |
|
53 | 53 | if [ ! -r "./templates/${CONFIG_TEMPLATE}" ] ; then |
|
54 | 54 | echo "error: configuration template ${CONFIG_TEMPLATE} not found" |
|
55 | 55 | exit 1 |
|
56 | 56 | fi |
|
57 | 57 | |
|
58 | 58 | # Load template configuration parameters |
|
59 | 59 | . "./templates/${CONFIG_TEMPLATE}" |
|
60 | 60 | } |
|
61 | 61 | |
|
62 | 62 | chroot_install_cc() { |
|
63 | 63 | # Install c/c++ build environment inside the chroot |
|
64 | 64 | if [ -z "${COMPILER_PACKAGES}" ] ; then |
|
65 | 65 | COMPILER_PACKAGES=$(chroot_exec apt-get -s install g++ make bc | grep "^Inst " | awk -v ORS=" " '{ print $2 }') |
|
66 | # Install COMPILER_PACKAGES in chroot | |
|
67 |
chroot_exec apt-get -q -y --allow-unauthenticated --no-install-recommends install |
|
|
66 | # Install COMPILER_PACKAGES in chroot - NEVER do "${COMPILER_PACKAGES}" -> breaks uboot | |
|
67 | chroot_exec apt-get -q -y --allow-unauthenticated --no-install-recommends install ${COMPILER_PACKAGES} | |
|
68 | 68 | fi |
|
69 | 69 | } |
|
70 | 70 | |
|
71 | 71 | chroot_remove_cc() { |
|
72 | 72 | # Remove c/c++ build environment from the chroot |
|
73 | 73 | if [ -n "${COMPILER_PACKAGES}" ] ; then |
|
74 |
chroot_exec apt-get -qq -y --auto-remove purge |
|
|
74 | chroot_exec apt-get -qq -y --auto-remove purge ${COMPILER_PACKAGES} | |
|
75 | 75 | COMPILER_PACKAGES="" |
|
76 | 76 | fi |
|
77 | 77 | } |
|
78 | 78 | |
|
79 | 79 | # https://serverfault.com/a/682849 - converts e.g. /24 to 255.255.255.0 |
|
80 | 80 | cdr2mask () |
|
81 | 81 | { |
|
82 | 82 | # Number of args to shift, 255..255, first non-255 byte, zeroes |
|
83 | 83 | set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0 |
|
84 | 84 | [ $1 -gt 1 ] && shift $1 || shift |
|
85 | 85 | echo ${1-0}.${2-0}.${3-0}.${4-0} |
|
86 | 86 | } No newline at end of file |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant