@@ -1,41 +1,41 | |||||
1 | # |
|
1 | # | |
2 | # Debootstrap basic system |
|
2 | # Debootstrap basic system | |
3 | # |
|
3 | # | |
4 |
|
4 | |||
5 | # Load utility functions |
|
5 | # Load utility functions | |
6 | . ./functions.sh |
|
6 | . ./functions.sh | |
7 |
|
7 | |||
8 | VARIANT="" |
|
8 | VARIANT="" | |
9 | COMPONENTS="main" |
|
9 | COMPONENTS="main" | |
10 |
|
10 | |||
11 | # Use non-free Debian packages if needed |
|
11 | # Use non-free Debian packages if needed | |
12 | if [ "$ENABLE_NONFREE" = true ] ; then |
|
12 | if [ "$ENABLE_NONFREE" = true ] ; then | |
13 | COMPONENTS="main,non-free,contrib" |
|
13 | COMPONENTS="main,non-free,contrib" | |
14 | fi |
|
14 | fi | |
15 |
|
15 | |||
16 | # Use minbase bootstrap variant which only includes essential packages |
|
16 | # Use minbase bootstrap variant which only includes essential packages | |
17 | if [ "$ENABLE_MINBASE" = true ] ; then |
|
17 | if [ "$ENABLE_MINBASE" = true ] ; then | |
18 | VARIANT="--variant=minbase" |
|
18 | VARIANT="--variant=minbase" | |
19 | fi |
|
19 | fi | |
20 |
|
20 | |||
21 | # Base debootstrap (unpack only) |
|
21 | # Base debootstrap (unpack only) | |
22 | http_proxy=${APT_PROXY} debootstrap ${APT_EXCLUDES} --arch="${RELEASE_ARCH}" --foreign ${VARIANT} --components="${COMPONENTS}" --include="${APT_INCLUDES}" "${RELEASE}" "${R}" "http://${APT_SERVER}" |
|
22 | http_proxy=${APT_PROXY} debootstrap "${APT_EXCLUDES}" --arch="${RELEASE_ARCH}" --foreign ${VARIANT} --components="${COMPONENTS}" --include="${APT_INCLUDES}" "${RELEASE}" "${R}" "http://${APT_SERVER}" | |
23 |
|
23 | |||
24 | # Copy qemu emulator binary to chroot |
|
24 | # Copy qemu emulator binary to chroot | |
25 | install -m 755 -o root -g root "${QEMU_BINARY}" "${R}${QEMU_BINARY}" |
|
25 | install -m 755 -o root -g root "${QEMU_BINARY}" "${R}${QEMU_BINARY}" | |
26 |
|
26 | |||
27 | # Copy debian-archive-keyring.pgp |
|
27 | # Copy debian-archive-keyring.pgp | |
28 | mkdir -p "${R}/usr/share/keyrings" |
|
28 | mkdir -p "${R}/usr/share/keyrings" | |
29 | install_readonly /usr/share/keyrings/debian-archive-keyring.gpg "${R}/usr/share/keyrings/debian-archive-keyring.gpg" |
|
29 | install_readonly /usr/share/keyrings/debian-archive-keyring.gpg "${R}/usr/share/keyrings/debian-archive-keyring.gpg" | |
30 |
|
30 | |||
31 | # Complete the bootstrapping process |
|
31 | # Complete the bootstrapping process | |
32 | chroot_exec /debootstrap/debootstrap --second-stage |
|
32 | chroot_exec /debootstrap/debootstrap --second-stage | |
33 |
|
33 | |||
34 | # Mount required filesystems |
|
34 | # Mount required filesystems | |
35 | mount -t proc none "${R}/proc" |
|
35 | mount -t proc none "${R}/proc" | |
36 | mount -t sysfs none "${R}/sys" |
|
36 | mount -t sysfs none "${R}/sys" | |
37 |
|
37 | |||
38 | # Mount pseudo terminal slave if supported by Debian release |
|
38 | # Mount pseudo terminal slave if supported by Debian release | |
39 | if [ -d "${R}/dev/pts" ] ; then |
|
39 | if [ -d "${R}/dev/pts" ] ; then | |
40 | mount --bind /dev/pts "${R}/dev/pts" |
|
40 | mount --bind /dev/pts "${R}/dev/pts" | |
41 | fi |
|
41 | fi |
@@ -1,410 +1,410 | |||||
1 | # |
|
1 | # | |
2 | # Build and Setup RPi2/3 Kernel |
|
2 | # Build and Setup RPi2/3 Kernel | |
3 | # |
|
3 | # | |
4 |
|
4 | |||
5 | # Load utility functions |
|
5 | # Load utility functions | |
6 | . ./functions.sh |
|
6 | . ./functions.sh | |
7 |
|
7 | |||
8 | # Fetch and build latest raspberry kernel |
|
8 | # Fetch and build latest raspberry kernel | |
9 | if [ "$BUILD_KERNEL" = true ] ; then |
|
9 | if [ "$BUILD_KERNEL" = true ] ; then | |
10 | # Setup source directory |
|
10 | # Setup source directory | |
11 | mkdir -p "${KERNEL_DIR}" |
|
11 | mkdir -p "${KERNEL_DIR}" | |
12 |
|
12 | |||
13 | # Copy existing kernel sources into chroot directory |
|
13 | # Copy existing kernel sources into chroot directory | |
14 | if [ -n "$KERNELSRC_DIR" ] && [ -d "$KERNELSRC_DIR" ] ; then |
|
14 | if [ -n "$KERNELSRC_DIR" ] && [ -d "$KERNELSRC_DIR" ] ; then | |
15 | # Copy kernel sources and include hidden files |
|
15 | # Copy kernel sources and include hidden files | |
16 | cp -r "${KERNELSRC_DIR}/". "${KERNEL_DIR}" |
|
16 | cp -r "${KERNELSRC_DIR}/". "${KERNEL_DIR}" | |
17 |
|
17 | |||
18 | # Clean the kernel sources |
|
18 | # Clean the kernel sources | |
19 | if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then |
|
19 | if [ "$KERNELSRC_CLEAN" = true ] && [ "$KERNELSRC_PREBUILT" = false ] ; then | |
20 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper |
|
20 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" mrproper | |
21 | fi |
|
21 | fi | |
22 | else # KERNELSRC_DIR="" |
|
22 | else # KERNELSRC_DIR="" | |
23 | # Create temporary directory for kernel sources |
|
23 | # Create temporary directory for kernel sources | |
24 | temp_dir=$(as_nobody mktemp -d) |
|
24 | temp_dir=$(as_nobody mktemp -d) | |
25 |
|
25 | |||
26 | # Fetch current RPi2/3 kernel sources |
|
26 | # Fetch current RPi2/3 kernel sources | |
27 | if [ -z "${KERNEL_BRANCH}" ] ; then |
|
27 | if [ -z "${KERNEL_BRANCH}" ] ; then | |
28 | as_nobody -H git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}" linux |
|
28 | as_nobody -H git -C "${temp_dir}" clone --depth=1 "${KERNEL_URL}" linux | |
29 | else |
|
29 | else | |
30 | as_nobody -H git -C "${temp_dir}" clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_URL}" linux |
|
30 | as_nobody -H git -C "${temp_dir}" clone --depth=1 --branch "${KERNEL_BRANCH}" "${KERNEL_URL}" linux | |
31 | fi |
|
31 | fi | |
32 |
|
32 | |||
33 | # Copy downloaded kernel sources |
|
33 | # Copy downloaded kernel sources | |
34 | cp -r "${temp_dir}/linux/"* "${KERNEL_DIR}" |
|
34 | cp -r "${temp_dir}/linux/"* "${KERNEL_DIR}" | |
35 |
|
35 | |||
36 | # Remove temporary directory for kernel sources |
|
36 | # Remove temporary directory for kernel sources | |
37 | rm -fr "${temp_dir}" |
|
37 | rm -fr "${temp_dir}" | |
38 |
|
38 | |||
39 | # Set permissions of the kernel sources |
|
39 | # Set permissions of the kernel sources | |
40 | chown -R root:root "${R}/usr/src" |
|
40 | chown -R root:root "${R}/usr/src" | |
41 | fi |
|
41 | fi | |
42 |
|
42 | |||
43 | # Calculate optimal number of kernel building threads |
|
43 | # Calculate optimal number of kernel building threads | |
44 | if [ "$KERNEL_THREADS" = "1" ] && [ -r /proc/cpuinfo ] ; then |
|
44 | if [ "$KERNEL_THREADS" = "1" ] && [ -r /proc/cpuinfo ] ; then | |
45 | KERNEL_THREADS=$(grep -c processor /proc/cpuinfo) |
|
45 | KERNEL_THREADS=$(grep -c processor /proc/cpuinfo) | |
46 | fi |
|
46 | fi | |
47 |
|
47 | |||
48 | # Configure and build kernel |
|
48 | # Configure and build kernel | |
49 | if [ "$KERNELSRC_PREBUILT" = false ] ; then |
|
49 | if [ "$KERNELSRC_PREBUILT" = false ] ; then | |
50 | # Remove device, network and filesystem drivers from kernel configuration |
|
50 | # Remove device, network and filesystem drivers from kernel configuration | |
51 | if [ "$KERNEL_REDUCE" = true ] ; then |
|
51 | if [ "$KERNEL_REDUCE" = true ] ; then | |
52 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}" |
|
52 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" "${KERNEL_DEFCONFIG}" | |
53 | sed -i\ |
|
53 | sed -i\ | |
54 | -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\ |
|
54 | -e "s/\(^CONFIG_SND.*\=\).*/\1n/"\ | |
55 | -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\ |
|
55 | -e "s/\(^CONFIG_SOUND.*\=\).*/\1n/"\ | |
56 | -e "s/\(^CONFIG_AC97.*\=\).*/\1n/"\ |
|
56 | -e "s/\(^CONFIG_AC97.*\=\).*/\1n/"\ | |
57 | -e "s/\(^CONFIG_VIDEO_.*\=\).*/\1n/"\ |
|
57 | -e "s/\(^CONFIG_VIDEO_.*\=\).*/\1n/"\ | |
58 | -e "s/\(^CONFIG_MEDIA_TUNER.*\=\).*/\1n/"\ |
|
58 | -e "s/\(^CONFIG_MEDIA_TUNER.*\=\).*/\1n/"\ | |
59 | -e "s/\(^CONFIG_DVB.*\=\)[ym]/\1n/"\ |
|
59 | -e "s/\(^CONFIG_DVB.*\=\)[ym]/\1n/"\ | |
60 | -e "s/\(^CONFIG_REISERFS.*\=\).*/\1n/"\ |
|
60 | -e "s/\(^CONFIG_REISERFS.*\=\).*/\1n/"\ | |
61 | -e "s/\(^CONFIG_JFS.*\=\).*/\1n/"\ |
|
61 | -e "s/\(^CONFIG_JFS.*\=\).*/\1n/"\ | |
62 | -e "s/\(^CONFIG_XFS.*\=\).*/\1n/"\ |
|
62 | -e "s/\(^CONFIG_XFS.*\=\).*/\1n/"\ | |
63 | -e "s/\(^CONFIG_GFS2.*\=\).*/\1n/"\ |
|
63 | -e "s/\(^CONFIG_GFS2.*\=\).*/\1n/"\ | |
64 | -e "s/\(^CONFIG_OCFS2.*\=\).*/\1n/"\ |
|
64 | -e "s/\(^CONFIG_OCFS2.*\=\).*/\1n/"\ | |
65 | -e "s/\(^CONFIG_BTRFS.*\=\).*/\1n/"\ |
|
65 | -e "s/\(^CONFIG_BTRFS.*\=\).*/\1n/"\ | |
66 | -e "s/\(^CONFIG_HFS.*\=\).*/\1n/"\ |
|
66 | -e "s/\(^CONFIG_HFS.*\=\).*/\1n/"\ | |
67 | -e "s/\(^CONFIG_JFFS2.*\=\)[ym]/\1n/"\ |
|
67 | -e "s/\(^CONFIG_JFFS2.*\=\)[ym]/\1n/"\ | |
68 | -e "s/\(^CONFIG_UBIFS.*\=\).*/\1n/"\ |
|
68 | -e "s/\(^CONFIG_UBIFS.*\=\).*/\1n/"\ | |
69 | -e "s/\(^CONFIG_SQUASHFS.*\=\)[ym]/\1n/"\ |
|
69 | -e "s/\(^CONFIG_SQUASHFS.*\=\)[ym]/\1n/"\ | |
70 | -e "s/\(^CONFIG_W1.*\=\)[ym]/\1n/"\ |
|
70 | -e "s/\(^CONFIG_W1.*\=\)[ym]/\1n/"\ | |
71 | -e "s/\(^CONFIG_HAMRADIO.*\=\).*/\1n/"\ |
|
71 | -e "s/\(^CONFIG_HAMRADIO.*\=\).*/\1n/"\ | |
72 | -e "s/\(^CONFIG_CAN.*\=\).*/\1n/"\ |
|
72 | -e "s/\(^CONFIG_CAN.*\=\).*/\1n/"\ | |
73 | -e "s/\(^CONFIG_IRDA.*\=\).*/\1n/"\ |
|
73 | -e "s/\(^CONFIG_IRDA.*\=\).*/\1n/"\ | |
74 | -e "s/\(^CONFIG_BT_.*\=\).*/\1n/"\ |
|
74 | -e "s/\(^CONFIG_BT_.*\=\).*/\1n/"\ | |
75 | -e "s/\(^CONFIG_WIMAX.*\=\)[ym]/\1n/"\ |
|
75 | -e "s/\(^CONFIG_WIMAX.*\=\)[ym]/\1n/"\ | |
76 | -e "s/\(^CONFIG_6LOWPAN.*\=\).*/\1n/"\ |
|
76 | -e "s/\(^CONFIG_6LOWPAN.*\=\).*/\1n/"\ | |
77 | -e "s/\(^CONFIG_IEEE802154.*\=\).*/\1n/"\ |
|
77 | -e "s/\(^CONFIG_IEEE802154.*\=\).*/\1n/"\ | |
78 | -e "s/\(^CONFIG_NFC.*\=\).*/\1n/"\ |
|
78 | -e "s/\(^CONFIG_NFC.*\=\).*/\1n/"\ | |
79 | -e "s/\(^CONFIG_FB_TFT=.*\=\).*/\1n/"\ |
|
79 | -e "s/\(^CONFIG_FB_TFT=.*\=\).*/\1n/"\ | |
80 | -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\ |
|
80 | -e "s/\(^CONFIG_TOUCHSCREEN.*\=\).*/\1n/"\ | |
81 | -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\ |
|
81 | -e "s/\(^CONFIG_USB_GSPCA_.*\=\).*/\1n/"\ | |
82 | -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\ |
|
82 | -e "s/\(^CONFIG_DRM.*\=\).*/\1n/"\ | |
83 | "${KERNEL_DIR}/.config" |
|
83 | "${KERNEL_DIR}/.config" | |
84 | fi |
|
84 | fi | |
85 |
|
85 | |||
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 | |||
90 | #Switch to KERNELSRC_DIR |
|
90 | #Switch to KERNELSRC_DIR | |
91 | pushd "${KERNEL_DIR}" |
|
91 | pushd "${KERNEL_DIR}" | |
92 |
|
92 | |||
93 | # GPL v2.0 |
|
93 | # GPL v2.0 | |
94 | #https://github.com/sakaki-/bcmrpi3-kernel-bis/blob/master/conform_config.sh |
|
94 | #https://github.com/sakaki-/bcmrpi3-kernel-bis/blob/master/conform_config.sh | |
95 | if [ "$KERNEL_ZSWAP" = true ] && ( [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ) ; then |
|
95 | if [ "$KERNEL_ZSWAP" = true ] && ( [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ) ; then | |
96 | # enable ZSWAP support for better performance during large builds etc. |
|
96 | # enable ZSWAP support for better performance during large builds etc. | |
97 | # requires activation via kernel parameter or sysfs |
|
97 | # requires activation via kernel parameter or sysfs | |
98 | # see e.g. https://askubuntu.com/a/472227 for a summary of ZSWAP (vs ZRAM etc.) |
|
98 | # see e.g. https://askubuntu.com/a/472227 for a summary of ZSWAP (vs ZRAM etc.) | |
99 | # and e.g. https://wiki.archlinux.org/index.php/zswap for parameters etc. |
|
99 | # and e.g. https://wiki.archlinux.org/index.php/zswap for parameters etc. | |
100 | set_kernel_config ZPOOL y |
|
100 | set_kernel_config ZPOOL y | |
101 | set_kernel_config ZSWAP y |
|
101 | set_kernel_config ZSWAP y | |
102 | set_kernel_config ZBUD y |
|
102 | set_kernel_config ZBUD y | |
103 | set_kernel_config Z3FOLD y |
|
103 | set_kernel_config Z3FOLD y | |
104 | set_kernel_config ZSMALLOC y |
|
104 | set_kernel_config ZSMALLOC y | |
105 | set_kernel_config PGTABLE_MAPPING y |
|
105 | set_kernel_config PGTABLE_MAPPING y | |
106 | fi |
|
106 | fi | |
107 |
|
107 | |||
108 | if [ "$KERNEL_VIRT" = true ] && ( [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ) ; then |
|
108 | if [ "$KERNEL_VIRT" = true ] && ( [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ) ; then | |
109 | # enable basic KVM support; see e.g. |
|
109 | # enable basic KVM support; see e.g. | |
110 | # https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=210546&start=25#p1300453 |
|
110 | # https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=210546&start=25#p1300453 | |
111 | set_kernel_config VIRTUALIZATION y |
|
111 | set_kernel_config VIRTUALIZATION y | |
112 | set_kernel_config KVM y |
|
112 | set_kernel_config KVM y | |
113 | set_kernel_config VHOST_NET m |
|
113 | set_kernel_config VHOST_NET m | |
114 | set_kernel_config VHOST_CROSS_ENDIAN_LEGACY y |
|
114 | set_kernel_config VHOST_CROSS_ENDIAN_LEGACY y | |
115 | fi |
|
115 | fi | |
116 | #See https://github.com/raspberrypi/linux/issues/2177#issuecomment-354647406 |
|
116 | #See https://github.com/raspberrypi/linux/issues/2177#issuecomment-354647406 | |
117 | # Netfilter kernel support |
|
117 | # Netfilter kernel support | |
118 | if [ "$KERNEL_NF" = true ] && ( [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ) ; then |
|
118 | if [ "$KERNEL_NF" = true ] && ( [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ) ; then | |
119 | set_kernel_config CONFIG_NETFILTER_XTABLES m |
|
119 | set_kernel_config CONFIG_NETFILTER_XTABLES m | |
120 | set_kernel_config CONFIG_NF_DUP_NETDEV m |
|
120 | set_kernel_config CONFIG_NF_DUP_NETDEV m | |
121 | set_kernel_config CONFIG_NF_NAT_SIP m |
|
121 | set_kernel_config CONFIG_NF_NAT_SIP m | |
122 | set_kernel_config CONFIG_NF_TABLES_ARP m |
|
122 | set_kernel_config CONFIG_NF_TABLES_ARP m | |
123 | set_kernel_config CONFIG_NF_TABLES_BRIDGE m |
|
123 | set_kernel_config CONFIG_NF_TABLES_BRIDGE m | |
124 | set_kernel_config NF_TABLES m |
|
124 | set_kernel_config NF_TABLES m | |
125 | set_kernel_config CONFIG_BRIDGE_EBT_BROUTE m |
|
125 | set_kernel_config CONFIG_BRIDGE_EBT_BROUTE m | |
126 | set_kernel_config CONFIG_BRIDGE_EBT_T_FILTER m |
|
126 | set_kernel_config CONFIG_BRIDGE_EBT_T_FILTER m | |
127 | set_kernel_config CONFIG_BRIDGE_NF_EBTABLES m |
|
127 | set_kernel_config CONFIG_BRIDGE_NF_EBTABLES m | |
128 | set_kernel_config CONFIG_IP6_NF_IPTABLES m |
|
128 | set_kernel_config CONFIG_IP6_NF_IPTABLES m | |
129 | set_kernel_config CONFIG_IP6_NF_MATCH_AH m |
|
129 | set_kernel_config CONFIG_IP6_NF_MATCH_AH m | |
130 | set_kernel_config CONFIG_IP6_NF_MATCH_EUI64 m |
|
130 | set_kernel_config CONFIG_IP6_NF_MATCH_EUI64 m | |
131 | set_kernel_config CONFIG_IP6_NF_NAT m |
|
131 | set_kernel_config CONFIG_IP6_NF_NAT m | |
132 | set_kernel_config CONFIG_IP6_NF_TARGET_MASQUERADE m |
|
132 | set_kernel_config CONFIG_IP6_NF_TARGET_MASQUERADE m | |
133 | set_kernel_config CONFIG_IP6_NF_TARGET_NPT m |
|
133 | set_kernel_config CONFIG_IP6_NF_TARGET_NPT m | |
134 | set_kernel_config CONFIG_IP_SET_BITMAP_IPMAC m |
|
134 | set_kernel_config CONFIG_IP_SET_BITMAP_IPMAC m | |
135 | set_kernel_config CONFIG_IP_SET_BITMAP_PORT m |
|
135 | set_kernel_config CONFIG_IP_SET_BITMAP_PORT m | |
136 | set_kernel_config CONFIG_IP_SET_HASH_IP m |
|
136 | set_kernel_config CONFIG_IP_SET_HASH_IP m | |
137 | set_kernel_config CONFIG_IP_SET_HASH_IPMARK m |
|
137 | set_kernel_config CONFIG_IP_SET_HASH_IPMARK m | |
138 | set_kernel_config CONFIG_IP_SET_HASH_IPPORT m |
|
138 | set_kernel_config CONFIG_IP_SET_HASH_IPPORT m | |
139 | set_kernel_config CONFIG_IP_SET_HASH_IPPORTIP m |
|
139 | set_kernel_config CONFIG_IP_SET_HASH_IPPORTIP m | |
140 | set_kernel_config CONFIG_IP_SET_HASH_IPPORTNET m |
|
140 | set_kernel_config CONFIG_IP_SET_HASH_IPPORTNET m | |
141 | set_kernel_config CONFIG_IP_SET_HASH_MAC m |
|
141 | set_kernel_config CONFIG_IP_SET_HASH_MAC m | |
142 | set_kernel_config CONFIG_IP_SET_HASH_NET m |
|
142 | set_kernel_config CONFIG_IP_SET_HASH_NET m | |
143 | set_kernel_config CONFIG_IP_SET_HASH_NETIFACE m |
|
143 | set_kernel_config CONFIG_IP_SET_HASH_NETIFACE m | |
144 | set_kernel_config CONFIG_IP_SET_HASH_NETNET m |
|
144 | set_kernel_config CONFIG_IP_SET_HASH_NETNET m | |
145 | set_kernel_config CONFIG_IP_SET_HASH_NETPORT m |
|
145 | set_kernel_config CONFIG_IP_SET_HASH_NETPORT m | |
146 | set_kernel_config CONFIG_IP_SET_HASH_NETPORTNET m |
|
146 | set_kernel_config CONFIG_IP_SET_HASH_NETPORTNET m | |
147 | set_kernel_config CONFIG_IP_SET_LIST_SET m |
|
147 | set_kernel_config CONFIG_IP_SET_LIST_SET m | |
148 | set_kernel_config CONFIG_NFT_BRIDGE_META m |
|
148 | set_kernel_config CONFIG_NFT_BRIDGE_META m | |
149 | set_kernel_config CONFIG_NFT_BRIDGE_REJECT m |
|
149 | set_kernel_config CONFIG_NFT_BRIDGE_REJECT m | |
150 | set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV4 m |
|
150 | set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV4 m | |
151 | set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV6 m |
|
151 | set_kernel_config CONFIG_NFT_CHAIN_NAT_IPV6 m | |
152 | set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV4 m |
|
152 | set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV4 m | |
153 | set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV6 m |
|
153 | set_kernel_config CONFIG_NFT_CHAIN_ROUTE_IPV6 m | |
154 | set_kernel_config CONFIG_NFT_COMPAT m |
|
154 | set_kernel_config CONFIG_NFT_COMPAT m | |
155 | set_kernel_config CONFIG_NFT_COUNTER m |
|
155 | set_kernel_config CONFIG_NFT_COUNTER m | |
156 | set_kernel_config CONFIG_NFT_CT m |
|
156 | set_kernel_config CONFIG_NFT_CT m | |
157 | set_kernel_config CONFIG_NFT_DUP_IPV4 m |
|
157 | set_kernel_config CONFIG_NFT_DUP_IPV4 m | |
158 | set_kernel_config CONFIG_NFT_DUP_IPV6 m |
|
158 | set_kernel_config CONFIG_NFT_DUP_IPV6 m | |
159 | set_kernel_config CONFIG_NFT_DUP_NETDEV m |
|
159 | set_kernel_config CONFIG_NFT_DUP_NETDEV m | |
160 | set_kernel_config CONFIG_NFT_EXTHDR m |
|
160 | set_kernel_config CONFIG_NFT_EXTHDR m | |
161 | set_kernel_config CONFIG_NFT_FWD_NETDEV m |
|
161 | set_kernel_config CONFIG_NFT_FWD_NETDEV m | |
162 | set_kernel_config CONFIG_NFT_HASH m |
|
162 | set_kernel_config CONFIG_NFT_HASH m | |
163 | set_kernel_config CONFIG_NFT_LIMIT m |
|
163 | set_kernel_config CONFIG_NFT_LIMIT m | |
164 | set_kernel_config CONFIG_NFT_LOG m |
|
164 | set_kernel_config CONFIG_NFT_LOG m | |
165 | set_kernel_config CONFIG_NFT_MASQ m |
|
165 | set_kernel_config CONFIG_NFT_MASQ m | |
166 | set_kernel_config CONFIG_NFT_MASQ_IPV4 m |
|
166 | set_kernel_config CONFIG_NFT_MASQ_IPV4 m | |
167 | set_kernel_config CONFIG_NFT_MASQ_IPV6 m |
|
167 | set_kernel_config CONFIG_NFT_MASQ_IPV6 m | |
168 | set_kernel_config CONFIG_NFT_META m |
|
168 | set_kernel_config CONFIG_NFT_META m | |
169 | set_kernel_config CONFIG_NFT_NAT m |
|
169 | set_kernel_config CONFIG_NFT_NAT m | |
170 | set_kernel_config CONFIG_NFT_NUMGEN m |
|
170 | set_kernel_config CONFIG_NFT_NUMGEN m | |
171 | set_kernel_config CONFIG_NFT_QUEUE m |
|
171 | set_kernel_config CONFIG_NFT_QUEUE m | |
172 | set_kernel_config CONFIG_NFT_QUOTA m |
|
172 | set_kernel_config CONFIG_NFT_QUOTA m | |
173 | set_kernel_config CONFIG_NFT_REDIR m |
|
173 | set_kernel_config CONFIG_NFT_REDIR m | |
174 | set_kernel_config CONFIG_NFT_REDIR_IPV4 m |
|
174 | set_kernel_config CONFIG_NFT_REDIR_IPV4 m | |
175 | set_kernel_config CONFIG_NFT_REDIR_IPV6 m |
|
175 | set_kernel_config CONFIG_NFT_REDIR_IPV6 m | |
176 | set_kernel_config CONFIG_NFT_REJECT m |
|
176 | set_kernel_config CONFIG_NFT_REJECT m | |
177 | set_kernel_config CONFIG_NFT_REJECT_INET m |
|
177 | set_kernel_config CONFIG_NFT_REJECT_INET m | |
178 | set_kernel_config CONFIG_NFT_REJECT_IPV4 m |
|
178 | set_kernel_config CONFIG_NFT_REJECT_IPV4 m | |
179 | set_kernel_config CONFIG_NFT_REJECT_IPV6 m |
|
179 | set_kernel_config CONFIG_NFT_REJECT_IPV6 m | |
180 | set_kernel_config CONFIG_NFT_SET_HASH m |
|
180 | set_kernel_config CONFIG_NFT_SET_HASH m | |
181 | set_kernel_config CONFIG_NFT_SET_RBTREE m |
|
181 | set_kernel_config CONFIG_NFT_SET_RBTREE m | |
182 | set_kernel_config CONFIG_NF_CONNTRACK_IPV4 m |
|
182 | set_kernel_config CONFIG_NF_CONNTRACK_IPV4 m | |
183 | set_kernel_config CONFIG_NF_CONNTRACK_IPV6 m |
|
183 | set_kernel_config CONFIG_NF_CONNTRACK_IPV6 m | |
184 | set_kernel_config CONFIG_NF_DEFRAG_IPV4 m |
|
184 | set_kernel_config CONFIG_NF_DEFRAG_IPV4 m | |
185 | set_kernel_config CONFIG_NF_DEFRAG_IPV6 m |
|
185 | set_kernel_config CONFIG_NF_DEFRAG_IPV6 m | |
186 | set_kernel_config CONFIG_NF_DUP_IPV4 m |
|
186 | set_kernel_config CONFIG_NF_DUP_IPV4 m | |
187 | set_kernel_config CONFIG_NF_DUP_IPV6 m |
|
187 | set_kernel_config CONFIG_NF_DUP_IPV6 m | |
188 | set_kernel_config CONFIG_NF_LOG_BRIDGE m |
|
188 | set_kernel_config CONFIG_NF_LOG_BRIDGE m | |
189 | set_kernel_config CONFIG_NF_LOG_IPV4 m |
|
189 | set_kernel_config CONFIG_NF_LOG_IPV4 m | |
190 | set_kernel_config CONFIG_NF_LOG_IPV6 m |
|
190 | set_kernel_config CONFIG_NF_LOG_IPV6 m | |
191 | set_kernel_config CONFIG_NF_NAT_IPV4 m |
|
191 | set_kernel_config CONFIG_NF_NAT_IPV4 m | |
192 | set_kernel_config CONFIG_NF_NAT_IPV6 m |
|
192 | set_kernel_config CONFIG_NF_NAT_IPV6 m | |
193 | set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV4 m |
|
193 | set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV4 m | |
194 | set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV6 m |
|
194 | set_kernel_config CONFIG_NF_NAT_MASQUERADE_IPV6 m | |
195 | set_kernel_config CONFIG_NF_NAT_PPTP m |
|
195 | set_kernel_config CONFIG_NF_NAT_PPTP m | |
196 | set_kernel_config CONFIG_NF_NAT_PROTO_GRE m |
|
196 | set_kernel_config CONFIG_NF_NAT_PROTO_GRE m | |
197 | set_kernel_config CONFIG_NF_NAT_REDIRECT m |
|
197 | set_kernel_config CONFIG_NF_NAT_REDIRECT m | |
198 | set_kernel_config CONFIG_NF_NAT_SNMP_BASIC m |
|
198 | set_kernel_config CONFIG_NF_NAT_SNMP_BASIC m | |
199 | set_kernel_config CONFIG_NF_NAT_TFTP m |
|
199 | set_kernel_config CONFIG_NF_NAT_TFTP m | |
200 | set_kernel_config CONFIG_NF_REJECT_IPV4 m |
|
200 | set_kernel_config CONFIG_NF_REJECT_IPV4 m | |
201 | set_kernel_config CONFIG_NF_REJECT_IPV6 m |
|
201 | set_kernel_config CONFIG_NF_REJECT_IPV6 m | |
202 | set_kernel_config CONFIG_NF_TABLES_INET m |
|
202 | set_kernel_config CONFIG_NF_TABLES_INET m | |
203 | set_kernel_config CONFIG_NF_TABLES_IPV4 m |
|
203 | set_kernel_config CONFIG_NF_TABLES_IPV4 m | |
204 | set_kernel_config CONFIG_NF_TABLES_IPV6 m |
|
204 | set_kernel_config CONFIG_NF_TABLES_IPV6 m | |
205 | set_kernel_config CONFIG_NF_TABLES_NETDEV m |
|
205 | set_kernel_config CONFIG_NF_TABLES_NETDEV m | |
206 | set_kernel_config NETFILTER_XTABLES m |
|
206 | set_kernel_config NETFILTER_XTABLES m | |
207 | fi |
|
207 | fi | |
208 |
|
208 | |||
209 | #https://groups.google.com/forum/#!topic/linux.gentoo.user/_2aSc_ztGpA |
|
209 | #https://groups.google.com/forum/#!topic/linux.gentoo.user/_2aSc_ztGpA | |
210 | #https://github.com/torvalds/linux/blob/master/init/Kconfig#L848 |
|
210 | #https://github.com/torvalds/linux/blob/master/init/Kconfig#L848 | |
211 | # Enables BPF syscall for systemd-journald |
|
211 | # Enables BPF syscall for systemd-journald | |
212 | if [ "$KERNEL_BPF" = true ] && ( [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ) ; then |
|
212 | if [ "$KERNEL_BPF" = true ] && ( [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ) ; then | |
213 | set_kernel_config CONFIG_BPF_SYSCALL y |
|
213 | set_kernel_config CONFIG_BPF_SYSCALL y | |
214 | set_kernel_config CONFIG_CGROUP_BPF y |
|
214 | set_kernel_config CONFIG_CGROUP_BPF y | |
215 | fi |
|
215 | fi | |
216 |
|
216 | |||
217 | #Revert to previous directory |
|
217 | #Revert to previous directory | |
218 | popd |
|
218 | popd | |
219 |
|
219 | |||
220 | # Set kernel configuration parameters to enable qemu emulation |
|
220 | # Set kernel configuration parameters to enable qemu emulation | |
221 | if [ "$ENABLE_QEMU" = true ] ; then |
|
221 | if [ "$ENABLE_QEMU" = true ] ; then | |
222 | echo "CONFIG_FHANDLE=y" >> "${KERNEL_DIR}"/.config |
|
222 | echo "CONFIG_FHANDLE=y" >> "${KERNEL_DIR}"/.config | |
223 | echo "CONFIG_LBDAF=y" >> "${KERNEL_DIR}"/.config |
|
223 | echo "CONFIG_LBDAF=y" >> "${KERNEL_DIR}"/.config | |
224 |
|
224 | |||
225 | if [ "$ENABLE_CRYPTFS" = true ] ; then |
|
225 | if [ "$ENABLE_CRYPTFS" = true ] ; then | |
226 | { |
|
226 | { | |
227 | echo "CONFIG_EMBEDDED=y" |
|
227 | echo "CONFIG_EMBEDDED=y" | |
228 | echo "CONFIG_EXPERT=y" |
|
228 | echo "CONFIG_EXPERT=y" | |
229 | echo "CONFIG_DAX=y" |
|
229 | echo "CONFIG_DAX=y" | |
230 | echo "CONFIG_MD=y" |
|
230 | echo "CONFIG_MD=y" | |
231 | echo "CONFIG_BLK_DEV_MD=y" |
|
231 | echo "CONFIG_BLK_DEV_MD=y" | |
232 | echo "CONFIG_MD_AUTODETECT=y" |
|
232 | echo "CONFIG_MD_AUTODETECT=y" | |
233 | echo "CONFIG_BLK_DEV_DM=y" |
|
233 | echo "CONFIG_BLK_DEV_DM=y" | |
234 | echo "CONFIG_BLK_DEV_DM_BUILTIN=y" |
|
234 | echo "CONFIG_BLK_DEV_DM_BUILTIN=y" | |
235 | echo "CONFIG_DM_CRYPT=y" |
|
235 | echo "CONFIG_DM_CRYPT=y" | |
236 | echo "CONFIG_CRYPTO_BLKCIPHER=y" |
|
236 | echo "CONFIG_CRYPTO_BLKCIPHER=y" | |
237 | echo "CONFIG_CRYPTO_CBC=y" |
|
237 | echo "CONFIG_CRYPTO_CBC=y" | |
238 | echo "CONFIG_CRYPTO_XTS=y" |
|
238 | echo "CONFIG_CRYPTO_XTS=y" | |
239 | echo "CONFIG_CRYPTO_SHA512=y" |
|
239 | echo "CONFIG_CRYPTO_SHA512=y" | |
240 | echo "CONFIG_CRYPTO_MANAGER=y" |
|
240 | echo "CONFIG_CRYPTO_MANAGER=y" | |
241 | } >> ${KERNEL_DIR}/.config |
|
241 | } >> ${KERNEL_DIR}/.config | |
242 | fi |
|
242 | fi | |
243 | fi |
|
243 | fi | |
244 |
|
244 | |||
245 | # Copy custom kernel configuration file |
|
245 | # Copy custom kernel configuration file | |
246 | if [ -n "$KERNELSRC_USRCONFIG" ] ; then |
|
246 | if [ -n "$KERNELSRC_USRCONFIG" ] ; then | |
247 | cp "$KERNELSRC_USRCONFIG" "${KERNEL_DIR}"/.config |
|
247 | cp "$KERNELSRC_USRCONFIG" "${KERNEL_DIR}"/.config | |
248 | fi |
|
248 | fi | |
249 |
|
249 | |||
250 | # Set kernel configuration parameters to their default values |
|
250 | # Set kernel configuration parameters to their default values | |
251 | if [ "$KERNEL_OLDDEFCONFIG" = true ] ; then |
|
251 | if [ "$KERNEL_OLDDEFCONFIG" = true ] ; then | |
252 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" olddefconfig |
|
252 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" olddefconfig | |
253 | fi |
|
253 | fi | |
254 |
|
254 | |||
255 | # Start menu-driven kernel configuration (interactive) |
|
255 | # Start menu-driven kernel configuration (interactive) | |
256 | if [ "$KERNEL_MENUCONFIG" = true ] ; then |
|
256 | if [ "$KERNEL_MENUCONFIG" = true ] ; then | |
257 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig |
|
257 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig | |
258 | fi |
|
258 | fi | |
259 | fi |
|
259 | fi | |
260 |
|
260 | |||
261 | # Use ccache to cross compile the kernel |
|
261 | # Use ccache to cross compile the kernel | |
262 | if [ "$KERNEL_CCACHE" = true ] ; then |
|
262 | if [ "$KERNEL_CCACHE" = true ] ; then | |
263 | cc="ccache ${CROSS_COMPILE}gcc" |
|
263 | cc="ccache ${CROSS_COMPILE}gcc" | |
264 | else |
|
264 | else | |
265 | cc="${CROSS_COMPILE}gcc" |
|
265 | cc="${CROSS_COMPILE}gcc" | |
266 | fi |
|
266 | fi | |
267 |
|
267 | |||
268 | # Cross compile kernel and dtbs |
|
268 | # Cross compile kernel and dtbs | |
269 | make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs |
|
269 | make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs | |
270 |
|
270 | |||
271 | # Cross compile kernel modules |
|
271 | # Cross compile kernel modules | |
272 | if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then |
|
272 | if [ "$(grep "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 |
|
273 | make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules | |
274 | fi |
|
274 | fi | |
275 | fi |
|
275 | fi | |
276 |
|
276 | |||
277 | # Check if kernel compilation was successful |
|
277 | # Check if kernel compilation was successful | |
278 | if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" ] ; then |
|
278 | if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" ] ; then | |
279 | echo "error: kernel compilation failed! (kernel image not found)" |
|
279 | echo "error: kernel compilation failed! (kernel image not found)" | |
280 | cleanup |
|
280 | cleanup | |
281 | exit 1 |
|
281 | exit 1 | |
282 | fi |
|
282 | fi | |
283 |
|
283 | |||
284 | # Install kernel modules |
|
284 | # Install kernel modules | |
285 | if [ "$ENABLE_REDUCE" = true ] ; then |
|
285 | if [ "$ENABLE_REDUCE" = true ] ; then | |
286 | if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then |
|
286 | if [ "$(grep "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 |
|
287 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install | |
288 | fi |
|
288 | fi | |
289 | else |
|
289 | else | |
290 | if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then |
|
290 | if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then | |
291 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install |
|
291 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install | |
292 | fi |
|
292 | fi | |
293 |
|
293 | |||
294 | # Install kernel firmware |
|
294 | # Install kernel firmware | |
295 | if [ "$(grep "^firmware_install:" "${KERNEL_DIR}/Makefile")" ] ; then |
|
295 | if [ "$(grep "^firmware_install:" "${KERNEL_DIR}/Makefile")" ] ; then | |
296 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install |
|
296 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install | |
297 | fi |
|
297 | fi | |
298 | fi |
|
298 | fi | |
299 |
|
299 | |||
300 | # Install kernel headers |
|
300 | # Install kernel headers | |
301 | if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then |
|
301 | if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then | |
302 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install |
|
302 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install | |
303 | fi |
|
303 | fi | |
304 | # make tar.gz kernel package - missing os bzw. modules |
|
304 | # make tar.gz kernel package - missing os bzw. modules | |
305 | #** ** ** WARNING ** ** ** |
|
305 | #** ** ** WARNING ** ** ** | |
306 | #Your architecture did not define any architecture-dependent files |
|
306 | #Your architecture did not define any architecture-dependent files | |
307 | #to be placed into the tarball. Please add those to ./scripts/package/buildtar . |
|
307 | #to be placed into the tarball. Please add those to ./scripts/package/buildtar . | |
308 | # make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" targz-pkg |
|
308 | # make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" targz-pkg | |
309 |
|
309 | |||
310 | # Prepare boot (firmware) directory |
|
310 | # Prepare boot (firmware) directory | |
311 | mkdir "${BOOT_DIR}" |
|
311 | mkdir "${BOOT_DIR}" | |
312 |
|
312 | |||
313 | # Get kernel release version |
|
313 | # Get kernel release version | |
314 | KERNEL_VERSION=$(cat "${KERNEL_DIR}/include/config/kernel.release") |
|
314 | KERNEL_VERSION=$(cat "${KERNEL_DIR}/include/config/kernel.release") | |
315 |
|
315 | |||
316 | # Copy kernel configuration file to the boot directory |
|
316 | # Copy kernel configuration file to the boot directory | |
317 | install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}" |
|
317 | install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}" | |
318 |
|
318 | |||
319 | # Prepare device tree directory |
|
319 | # Prepare device tree directory | |
320 | mkdir "${BOOT_DIR}/overlays" |
|
320 | mkdir "${BOOT_DIR}/overlays" | |
321 |
|
321 | |||
322 | # Ensure the proper .dtb is located |
|
322 | # Ensure the proper .dtb is located | |
323 | if [ "$KERNEL_ARCH" = "arm" ] ; then |
|
323 | if [ "$KERNEL_ARCH" = "arm" ] ; then | |
324 | for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb ; do |
|
324 | for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb ; do | |
325 | if [ -f "${dtb}" ] ; then |
|
325 | if [ -f "${dtb}" ] ; then | |
326 | install_readonly "${dtb}" "${BOOT_DIR}/" |
|
326 | install_readonly "${dtb}" "${BOOT_DIR}/" | |
327 | fi |
|
327 | fi | |
328 | done |
|
328 | done | |
329 | else |
|
329 | else | |
330 | for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/broadcom/"*.dtb ; do |
|
330 | for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/broadcom/"*.dtb ; do | |
331 | if [ -f "${dtb}" ] ; then |
|
331 | if [ -f "${dtb}" ] ; then | |
332 | install_readonly "${dtb}" "${BOOT_DIR}/" |
|
332 | install_readonly "${dtb}" "${BOOT_DIR}/" | |
333 | fi |
|
333 | fi | |
334 | done |
|
334 | done | |
335 | fi |
|
335 | fi | |
336 |
|
336 | |||
337 | # Copy compiled dtb device tree files |
|
337 | # Copy compiled dtb device tree files | |
338 | if [ -d "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays" ] ; then |
|
338 | if [ -d "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays" ] ; then | |
339 | for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb ; do |
|
339 | for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb ; do | |
340 | if [ -f "${dtb}" ] ; then |
|
340 | if [ -f "${dtb}" ] ; then | |
341 | install_readonly "${dtb}" "${BOOT_DIR}/overlays/" |
|
341 | install_readonly "${dtb}" "${BOOT_DIR}/overlays/" | |
342 | fi |
|
342 | fi | |
343 | done |
|
343 | done | |
344 |
|
344 | |||
345 | if [ -f "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" ] ; then |
|
345 | if [ -f "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" ] ; then | |
346 | install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README" |
|
346 | install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README" | |
347 | fi |
|
347 | fi | |
348 | fi |
|
348 | fi | |
349 |
|
349 | |||
350 | if [ "$ENABLE_UBOOT" = false ] ; then |
|
350 | if [ "$ENABLE_UBOOT" = false ] ; then | |
351 | # Convert and copy kernel image to the boot directory |
|
351 | # Convert and copy kernel image to the boot directory | |
352 | "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}" |
|
352 | "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}" | |
353 | else |
|
353 | else | |
354 | # Copy kernel image to the boot directory |
|
354 | # Copy kernel image to the boot directory | |
355 | install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}" |
|
355 | install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}" | |
356 | fi |
|
356 | fi | |
357 |
|
357 | |||
358 | # Remove kernel sources |
|
358 | # Remove kernel sources | |
359 | if [ "$KERNEL_REMOVESRC" = true ] ; then |
|
359 | if [ "$KERNEL_REMOVESRC" = true ] ; then | |
360 | rm -fr "${KERNEL_DIR}" |
|
360 | rm -fr "${KERNEL_DIR}" | |
361 | else |
|
361 | else | |
362 | # Prepare compiled kernel modules |
|
362 | # Prepare compiled kernel modules | |
363 | if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then |
|
363 | if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then | |
364 | if [ "$(grep "^modules_prepare:" "${KERNEL_DIR}/Makefile")" ] ; then |
|
364 | if [ "$(grep "^modules_prepare:" "${KERNEL_DIR}/Makefile")" ] ; then | |
365 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare |
|
365 | make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare | |
366 | fi |
|
366 | fi | |
367 |
|
367 | |||
368 | # Create symlinks for kernel modules |
|
368 | # Create symlinks for kernel modules | |
369 | chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/build" |
|
369 | chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/build" | |
370 | chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/source" |
|
370 | chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/source" | |
371 | fi |
|
371 | fi | |
372 | fi |
|
372 | fi | |
373 |
|
373 | |||
374 | else # BUILD_KERNEL=false |
|
374 | else # BUILD_KERNEL=false | |
375 | # echo " Install precompiled kernel..." |
|
375 | # echo " Install precompiled kernel..." | |
376 | # echo "error: not implemented" |
|
376 | # echo "error: not implemented" | |
377 | if [ "$KERNEL_ARCH" = arm64 ] && ( [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ) ; then |
|
377 | if [ "$KERNEL_ARCH" = arm64 ] && ( [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ) ; then | |
378 | # Create temporary directory for dl |
|
378 | # Create temporary directory for dl | |
379 | temp_dir=$(as_nobody mktemp -d) |
|
379 | temp_dir=$(as_nobody mktemp -d) | |
380 |
|
380 | |||
381 | # Fetch kernel dl |
|
381 | # Fetch kernel dl | |
382 |
as_nobody wget -c "$RPI3_64_KERNEL_URL" |
|
382 | as_nobody wget -O "${temp_dir}"/kernel.tar.xz -c "$RPI3_64_KERNEL_URL" | |
383 | #extract download |
|
383 | #extract download | |
384 | tar -xJf kernel.tar.xz -C "${R}" |
|
384 | tar -xJf kernel.tar.xz -C "${R}" | |
385 |
|
385 | |||
386 | # Remove temporary directory for kernel sources |
|
386 | # Remove temporary directory for kernel sources | |
387 | rm -fr "${temp_dir}" |
|
387 | rm -fr "${temp_dir}" | |
388 |
|
388 | |||
389 | # Set permissions of the kernel sources |
|
389 | # Set permissions of the kernel sources | |
390 | chown -R root:root "${R}/boot/firmware" |
|
390 | chown -R root:root "${R}/boot/firmware" | |
391 | chown -R root:root "${R}/lib" |
|
391 | chown -R root:root "${R}/lib" | |
392 | fi |
|
392 | fi | |
393 |
|
393 | |||
394 | # Check if kernel installation was successful |
|
394 | # Check if kernel installation was successful | |
395 | KERNEL="$(ls -1 "${R}"/boot/kernel* | sort | tail -n 1)" |
|
395 | KERNEL="$(ls -1 "${R}"/boot/kernel* | sort | tail -n 1)" | |
396 | if [ -z "$KERNEL" ] ; then |
|
396 | if [ -z "$KERNEL" ] ; then | |
397 | echo "error: kernel installation failed! (/boot/kernel* not found)" |
|
397 | echo "error: kernel installation failed! (/boot/kernel* not found)" | |
398 | cleanup |
|
398 | cleanup | |
399 | exit 1 |
|
399 | exit 1 | |
400 | fi |
|
400 | fi | |
401 |
|
401 | |||
402 | if [ "$SET_ARCH" = 64 ] ; then |
|
402 | if [ "$SET_ARCH" = 64 ] ; then | |
403 | echo "Using precompiled arm64 kernel" |
|
403 | echo "Using precompiled arm64 kernel" | |
404 | else |
|
404 | else | |
405 | echo "error: no precompiled arm64 (bcmrpi3) kernel found" |
|
405 | echo "error: no precompiled arm64 (bcmrpi3) kernel found" | |
406 | exit 1 |
|
406 | exit 1 | |
407 | # inset precompiled 64 bit kernel code here |
|
407 | # inset precompiled 64 bit kernel code here | |
408 | fi |
|
408 | fi | |
409 | #fi build_kernel=true |
|
409 | #fi build_kernel=true | |
410 | fi |
|
410 | fi |
@@ -1,179 +1,204 | |||||
1 | # |
|
1 | # | |
2 | # Setup RPi2/3 config and cmdline |
|
2 | # Setup RPi2/3 config and cmdline | |
3 | # |
|
3 | # | |
4 |
|
4 | |||
5 | # Load utility functions |
|
5 | # Load utility functions | |
6 | . ./functions.sh |
|
6 | . ./functions.sh | |
7 |
|
7 | |||
8 | if [ "$BUILD_KERNEL" = true ] ; then |
|
8 | if [ "$BUILD_KERNEL" = true ] ; then | |
9 | if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then |
|
9 | if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then | |
10 | # Install boot binaries from local directory |
|
10 | # Install boot binaries from local directory | |
11 | cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin |
|
11 | cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin | |
12 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat |
|
12 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat | |
13 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat |
|
13 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat | |
14 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat |
|
14 | cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat | |
15 | cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf |
|
15 | cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf | |
16 | cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf |
|
16 | cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf | |
17 | cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf |
|
17 | cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf | |
18 | else |
|
18 | else | |
19 | # Create temporary directory for boot binaries |
|
19 | # Create temporary directory for boot binaries | |
20 | temp_dir=$(as_nobody mktemp -d) |
|
20 | temp_dir=$(as_nobody mktemp -d) | |
21 |
|
21 | |||
22 | # Install latest boot binaries from raspberry/firmware github |
|
22 | # Install latest boot binaries from raspberry/firmware github | |
23 | as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin" |
|
23 | as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin" | |
24 | as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat" |
|
24 | as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat" | |
25 | as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat" |
|
25 | as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat" | |
26 | as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat" |
|
26 | as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat" | |
27 | as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf" |
|
27 | as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf" | |
28 | as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf" |
|
28 | as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf" | |
29 | as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf" |
|
29 | as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf" | |
30 |
|
30 | |||
31 | # Move downloaded boot binaries |
|
31 | # Move downloaded boot binaries | |
32 | mv "${temp_dir}/"* "${BOOT_DIR}/" |
|
32 | mv "${temp_dir}/"* "${BOOT_DIR}/" | |
33 |
|
33 | |||
34 | # Remove temporary directory for boot binaries |
|
34 | # Remove temporary directory for boot binaries | |
35 | rm -fr "${temp_dir}" |
|
35 | rm -fr "${temp_dir}" | |
36 |
|
36 | |||
37 | # Set permissions of the boot binaries |
|
37 | # Set permissions of the boot binaries | |
38 | chown -R root:root "${BOOT_DIR}" |
|
38 | chown -R root:root "${BOOT_DIR}" | |
39 | chmod -R 600 "${BOOT_DIR}" |
|
39 | chmod -R 600 "${BOOT_DIR}" | |
40 | fi |
|
40 | fi | |
41 | fi |
|
41 | fi | |
42 |
|
42 | |||
43 | # Setup firmware boot cmdline |
|
43 | # Setup firmware boot cmdline | |
44 | if [ "$ENABLE_UBOOTUSB" = true ] ; then |
|
44 | if [ "$ENABLE_UBOOTUSB" = true ] ; then | |
45 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" |
|
45 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" | |
46 | else |
|
46 | else | |
47 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
47 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
48 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" |
|
48 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" | |
49 | else |
|
49 | else | |
50 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" |
|
50 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1" | |
51 | fi |
|
51 | fi | |
52 | fi |
|
52 | fi | |
53 |
|
53 | |||
54 |
|
54 | |||
55 |
|
55 | |||
56 | # Add encrypted root partition to cmdline.txt |
|
56 | # Add encrypted root partition to cmdline.txt | |
57 | if [ "$ENABLE_CRYPTFS" = true ] ; then |
|
57 | if [ "$ENABLE_CRYPTFS" = true ] ; then | |
58 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
58 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
59 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/") |
|
59 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/") | |
60 | else |
|
60 | else | |
61 | if [ "$ENABLE_UBOOTUSB" = true ] ; then |
|
61 | if [ "$ENABLE_UBOOTUSB" = true ] ; then | |
62 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/") |
|
62 | CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/") | |
63 | else |
|
63 | else | |
64 | CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/") |
|
64 | CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/") | |
65 | fi |
|
65 | fi | |
66 | fi |
|
66 | fi | |
67 | fi |
|
67 | fi | |
68 |
|
68 | |||
69 | # Add serial console support |
|
69 | # Add serial console support | |
70 | if [ "$ENABLE_CONSOLE" = true ] ; then |
|
70 | if [ "$ENABLE_CONSOLE" = true ] ; then | |
71 | CMDLINE="${CMDLINE} console=ttyAMA0,115200 kgdboc=ttyAMA0,115200" |
|
71 | CMDLINE="${CMDLINE} console=ttyAMA0,115200 kgdboc=ttyAMA0,115200" | |
72 | fi |
|
72 | fi | |
73 |
|
73 | |||
74 | # Remove IPv6 networking support |
|
74 | # Remove IPv6 networking support | |
75 | if [ "$ENABLE_IPV6" = false ] ; then |
|
75 | if [ "$ENABLE_IPV6" = false ] ; then | |
76 | CMDLINE="${CMDLINE} ipv6.disable=1" |
|
76 | CMDLINE="${CMDLINE} ipv6.disable=1" | |
77 | fi |
|
77 | fi | |
78 |
|
78 | |||
79 | # Automatically assign predictable network interface names |
|
79 | # Automatically assign predictable network interface names | |
80 | if [ "$ENABLE_IFNAMES" = false ] ; then |
|
80 | if [ "$ENABLE_IFNAMES" = false ] ; then | |
81 | CMDLINE="${CMDLINE} net.ifnames=0" |
|
81 | CMDLINE="${CMDLINE} net.ifnames=0" | |
82 | else |
|
82 | else | |
83 | CMDLINE="${CMDLINE} net.ifnames=1" |
|
83 | CMDLINE="${CMDLINE} net.ifnames=1" | |
84 | fi |
|
84 | fi | |
85 |
|
85 | |||
86 | # Set init to systemd if required by Debian release |
|
86 | # Set init to systemd if required by Debian release | |
87 | if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then |
|
87 | if [ "$RELEASE" = "stretch" ] || [ "$RELEASE" = "buster" ] ; then | |
88 | CMDLINE="${CMDLINE} init=/bin/systemd" |
|
88 | CMDLINE="${CMDLINE} init=/bin/systemd" | |
89 | fi |
|
89 | fi | |
90 |
|
90 | |||
91 | # Install firmware boot cmdline |
|
91 | # Install firmware boot cmdline | |
92 | echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt" |
|
92 | echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt" | |
93 |
|
93 | |||
94 | # Install firmware config |
|
94 | # Install firmware config | |
95 | install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt" |
|
95 | install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt" | |
96 |
|
96 | |||
97 | # Setup minimal GPU memory allocation size: 16MB (no X) |
|
97 | # Setup minimal GPU memory allocation size: 16MB (no X) | |
98 | if [ "$ENABLE_MINGPU" = true ] ; then |
|
98 | if [ "$ENABLE_MINGPU" = true ] ; then | |
99 | echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt" |
|
99 | echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt" | |
100 | fi |
|
100 | fi | |
101 |
|
101 | |||
102 | # Setup boot with initramfs |
|
102 | # Setup boot with initramfs | |
103 | if [ "$ENABLE_INITRAMFS" = true ] ; then |
|
103 | if [ "$ENABLE_INITRAMFS" = true ] ; then | |
104 | echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt" |
|
104 | echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt" | |
105 | fi |
|
105 | fi | |
106 |
|
106 | |||
107 | # Disable RPi3 Bluetooth and restore ttyAMA0 serial device |
|
107 | # Disable RPi3 Bluetooth and restore ttyAMA0 serial device | |
108 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 3P ]; then |
|
108 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] || [ "$RPI_MODEL" = 3P ]; then | |
109 | if [ "$ENABLE_CONSOLE" = true ] && [ "$ENABLE_UBOOT" = false ] ; then |
|
109 | if [ "$ENABLE_CONSOLE" = true ] && [ "$ENABLE_UBOOT" = false ] ; then | |
110 | echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt" |
|
110 | echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt" | |
111 | echo "enable_uart=1" >> "${BOOT_DIR}/config.txt" |
|
111 | echo "enable_uart=1" >> "${BOOT_DIR}/config.txt" | |
112 |
|
|
112 | else | |
113 |
|
|
113 | # Create temporary directory for Bluetooth sources | |
114 |
|
|
114 | temp_dir=$(as_nobody mktemp -d) | |
|
115 | ||||
|
116 | # Fetch Bluetooth sources | |||
|
117 | as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}" | |||
|
118 | ||||
|
119 | # Copy downloaded sources | |||
|
120 | mv "${temp_dir}/pi-bluetooth" "${R}/tmp/" | |||
|
121 | ||||
|
122 | # Set permissions | |||
|
123 | chown -R root:root "${R}/tmp/pi-bluetooth" | |||
|
124 | ||||
|
125 | # Install files to chroot | |||
|
126 | # Install tools | |||
|
127 | install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart" | |||
|
128 | install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper" | |||
|
129 | ||||
|
130 | # Install bluetooth udev rule | |||
|
131 | install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules" | |||
|
132 | #aur | |||
|
133 | #install_readonly "${R}/tmp/pi-bluetooth/50-bluetooth-hci-auto-poweron.rules" "${ETC_DIR}/udev/rules.d/50-bluetooth-hci-auto-poweron.rules" | |||
|
134 | ||||
|
135 | # Install Firmware Flash file and apropiate licence | |||
|
136 | mkdir "${ETC_DIR}/firmware/" | |||
115 |
|
|
137 | ||
116 | # Fetch U-Boot sources |
|
138 | #aur https://aur.archlinux.org/packages/pi-bluetooth/ | |
117 | #as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}" |
|
139 | #install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${ETC_DIR}/firmware/LICENCE.broadcom_bcm43xx" | |
|
140 | #install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${ETC_DIR}/firmware/BCM43430A1.hcd" | |||
118 |
|
141 | |||
119 | # Copy downloaded U-Boot sources |
|
142 | wget -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth | |
120 | #mv "${temp_dir}/pi-bluetooth" "${R}/tmp/" |
|
143 | wget -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://aur.archlinux.org/cgit/aur.git/plain/BCM43430A1.hcd?h=pi-bluetooth | |
121 |
|
144 | |||
122 | # Set permissions of the U-Boot sources |
|
145 | # Install systemd service for bluetooth | |
123 | #chown -R root:root "${R}/tmp/pi-bluetooth" |
|
146 | #install_readonly "${R}/tmp/pi-bluetooth/brcm43438.service" "${ETC_DIR}/systemd/system/brcm43438.service" | |
124 |
|
147 | |||
125 |
# Remove temporary directory |
|
148 | # Remove temporary directory | |
126 | #rm -fr "${temp_dir}" |
|
149 | #rm -fr "${temp_dir}" | |
127 |
|
150 | |||
|
151 | # Get /dev/serial back for compability | |||
|
152 | # Raspberry-sys-mod package | |||
|
153 | wget -O "${ETC_DIR}/udev/rules.d/99-com.rules" https://raw.githubusercontent.com/RPi-Distro/raspberrypi-sys-mods/master/etc.armhf/udev/rules.d/99-com.rules | |||
128 |
|
154 | |||
129 | #"${R}/tmp/userland" |
|
|||
130 |
|
|
155 | fi | |
131 | fi |
|
156 | fi | |
132 |
|
157 | |||
133 | # Create firmware configuration and cmdline symlinks |
|
158 | # Create firmware configuration and cmdline symlinks | |
134 | ln -sf firmware/config.txt "${R}/boot/config.txt" |
|
159 | ln -sf firmware/config.txt "${R}/boot/config.txt" | |
135 | ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt" |
|
160 | ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt" | |
136 |
|
161 | |||
137 | # Install and setup kernel modules to load at boot |
|
162 | # Install and setup kernel modules to load at boot | |
138 | mkdir -p "${LIB_DIR}/modules-load.d/" |
|
163 | mkdir -p "${LIB_DIR}/modules-load.d/" | |
139 | install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
164 | install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf" | |
140 |
|
165 | |||
141 | # Load hardware random module at boot |
|
166 | # Load hardware random module at boot | |
142 | if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then |
|
167 | if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then | |
143 | sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
168 | sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
144 | fi |
|
169 | fi | |
145 |
|
170 | |||
146 | # Load sound module at boot |
|
171 | # Load sound module at boot | |
147 | if [ "$ENABLE_SOUND" = true ] ; then |
|
172 | if [ "$ENABLE_SOUND" = true ] ; then | |
148 | sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
173 | sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
149 | else |
|
174 | else | |
150 | echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt" |
|
175 | echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt" | |
151 | fi |
|
176 | fi | |
152 |
|
177 | |||
153 | # Enable I2C interface |
|
178 | # Enable I2C interface | |
154 | if [ "$ENABLE_I2C" = true ] ; then |
|
179 | if [ "$ENABLE_I2C" = true ] ; then | |
155 | echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt" |
|
180 | echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt" | |
156 | sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
181 | sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
157 | sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
182 | sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
158 | fi |
|
183 | fi | |
159 |
|
184 | |||
160 | # Enable SPI interface |
|
185 | # Enable SPI interface | |
161 | if [ "$ENABLE_SPI" = true ] ; then |
|
186 | if [ "$ENABLE_SPI" = true ] ; then | |
162 | echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt" |
|
187 | echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt" | |
163 | echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
188 | echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf" | |
164 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then |
|
189 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then | |
165 | sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" |
|
190 | sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf" | |
166 | fi |
|
191 | fi | |
167 | fi |
|
192 | fi | |
168 |
|
193 | |||
169 | # Disable RPi2/3 under-voltage warnings |
|
194 | # Disable RPi2/3 under-voltage warnings | |
170 | if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then |
|
195 | if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then | |
171 | echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt" |
|
196 | echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt" | |
172 | fi |
|
197 | fi | |
173 |
|
198 | |||
174 | # Install kernel modules blacklist |
|
199 | # Install kernel modules blacklist | |
175 | mkdir -p "${ETC_DIR}/modprobe.d/" |
|
200 | mkdir -p "${ETC_DIR}/modprobe.d/" | |
176 | install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf" |
|
201 | install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf" | |
177 |
|
202 | |||
178 | # Install sysctl.d configuration files |
|
203 | # Install sysctl.d configuration files | |
179 | install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf" |
|
204 | install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf" |
@@ -1,830 +1,831 | |||||
1 | #!/bin/bash |
|
1 | #!/bin/bash | |
2 | ######################################################################## |
|
2 | ######################################################################## | |
3 | # rpi23-gen-image.sh 2015-2017 |
|
3 | # rpi23-gen-image.sh 2015-2017 | |
4 | # |
|
4 | # | |
5 | # Advanced Debian "stretch" and "buster" bootstrap script for RPi2/3 |
|
5 | # Advanced Debian "stretch" and "buster" bootstrap script for RPi2/3 | |
6 | # |
|
6 | # | |
7 | # This program is free software; you can redistribute it and/or |
|
7 | # This program is free software; you can redistribute it and/or | |
8 | # modify it under the terms of the GNU General Public License |
|
8 | # modify it under the terms of the GNU General Public License | |
9 | # as published by the Free Software Foundation; either version 2 |
|
9 | # as published by the Free Software Foundation; either version 2 | |
10 | # of the License, or (at your option) any later version. |
|
10 | # of the License, or (at your option) any later version. | |
11 | # |
|
11 | # | |
12 | # Copyright (C) 2015 Jan Wagner <mail@jwagner.eu> |
|
12 | # Copyright (C) 2015 Jan Wagner <mail@jwagner.eu> | |
13 | # |
|
13 | # | |
14 | # Big thanks for patches and enhancements by 20+ github contributors! |
|
14 | # Big thanks for patches and enhancements by 20+ github contributors! | |
15 | ######################################################################## |
|
15 | ######################################################################## | |
16 |
|
16 | |||
17 | # Are we running as root? |
|
17 | # Are we running as root? | |
18 | if [ "$(id -u)" -ne "0" ] ; then |
|
18 | if [ "$(id -u)" -ne "0" ] ; then | |
19 | echo "error: this script must be executed with root privileges!" |
|
19 | echo "error: this script must be executed with root privileges!" | |
20 | exit 1 |
|
20 | exit 1 | |
21 | fi |
|
21 | fi | |
22 |
|
22 | |||
23 | # Check if ./functions.sh script exists |
|
23 | # Check if ./functions.sh script exists | |
24 | if [ ! -r "./functions.sh" ] ; then |
|
24 | if [ ! -r "./functions.sh" ] ; then | |
25 | echo "error: './functions.sh' required script not found!" |
|
25 | echo "error: './functions.sh' required script not found!" | |
26 | exit 1 |
|
26 | exit 1 | |
27 | fi |
|
27 | fi | |
28 |
|
28 | |||
29 | # Load utility functions |
|
29 | # Load utility functions | |
30 | . ./functions.sh |
|
30 | . ./functions.sh | |
31 |
|
31 | |||
32 | # Load parameters from configuration template file |
|
32 | # Load parameters from configuration template file | |
33 | if [ -n "$CONFIG_TEMPLATE" ] ; then |
|
33 | if [ -n "$CONFIG_TEMPLATE" ] ; then | |
34 | use_template |
|
34 | use_template | |
35 | fi |
|
35 | fi | |
36 |
|
36 | |||
37 | # Introduce settings |
|
37 | # Introduce settings | |
38 | set -e |
|
38 | set -e | |
39 | echo -n -e "\n#\n# RPi2/3 Bootstrap Settings\n#\n" |
|
39 | echo -n -e "\n#\n# RPi2/3 Bootstrap Settings\n#\n" | |
40 | set -x |
|
40 | set -x | |
41 |
|
41 | |||
42 | # Raspberry Pi model configuration |
|
42 | # Raspberry Pi model configuration | |
43 | export RPI_MODEL=${RPI_MODEL:=2} |
|
43 | export RPI_MODEL=${RPI_MODEL:=2} | |
44 |
|
44 | |||
45 | # Debian release |
|
45 | # Debian release | |
46 | export RELEASE=${RELEASE:=buster} |
|
46 | export RELEASE=${RELEASE:=buster} | |
47 |
|
47 | |||
48 | #Kernel Branch |
|
48 | #Kernel Branch | |
49 | export KERNEL_BRANCH=${KERNEL_BRANCH:=""} |
|
49 | export KERNEL_BRANCH=${KERNEL_BRANCH:=""} | |
50 |
|
50 | |||
51 | # URLs |
|
51 | # URLs | |
52 | KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux} |
|
52 | KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux} | |
53 | FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot} |
|
53 | FIRMWARE_URL=${FIRMWARE_URL:=https://github.com/raspberrypi/firmware/raw/master/boot} | |
54 | WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm} |
|
54 | WLAN_FIRMWARE_URL=${WLAN_FIRMWARE_URL:=https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm} | |
55 | COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian} |
|
55 | COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian} | |
56 | FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git} |
|
56 | FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git} | |
57 | UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git} |
|
57 | UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git} | |
58 | VIDEOCORE_URL=${VIDEOCORE_URL:=https://github.com/raspberrypi/userland} |
|
58 | VIDEOCORE_URL=${VIDEOCORE_URL:=https://github.com/raspberrypi/userland} | |
59 | #BIS= Kernel has KVM and zswap enabled |
|
59 | #BIS= Kernel has KVM and zswap enabled | |
60 | RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.14.80.20181113/bcmrpi3-kernel-bis-4.14.80.20181113.tar.xz} |
|
60 | RPI3_64_BIS_KERNEL_URL=${RPI3_64_BIS_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel-bis/releases/download/4.14.80.20181113/bcmrpi3-kernel-bis-4.14.80.20181113.tar.xz} | |
61 | #default bcmrpi3_defconfig target kernel |
|
61 | #default bcmrpi3_defconfig target kernel | |
62 | RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.14.80.20181113/bcmrpi3-kernel-4.14.80.20181113.tar.xz} |
|
62 | RPI3_64_DEF_KERNEL_URL=${RPI3_64_DEF_KERNEL_URL:=https://github.com/sakaki-/bcmrpi3-kernel/releases/download/4.14.80.20181113/bcmrpi3-kernel-4.14.80.20181113.tar.xz} | |
63 | #enhanced kernel |
|
63 | #enhanced kernel | |
64 | RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_BIS_KERNEL_URL} |
|
64 | RPI3_64_KERNEL_URL=${RPI3_64_KERNEL_URL:=$RPI3_64_BIS_KERNEL_URL} | |
65 | #https://aur.archlinux.org/packages/pi-bluetooth/ |
|
65 | #https://aur.archlinux.org/packages/pi-bluetooth/ | |
66 | BLUETOOTH_URL=${BLUETOOTH_URL:=https://aur.archlinux.org/pi-bluetooth.git} |
|
66 | #BLUETOOTH_URL=${BLUETOOTH_URL:=https://aur.archlinux.org/pi-bluetooth.git} | |
|
67 | BLUETOOTH_URL=${BLUETOOTH_URL:=https://github.com/RPi-Distro/pi-bluetooth.git} | |||
67 |
|
68 | |||
68 | # Build directories |
|
69 | # Build directories | |
69 | BASEDIR=${BASEDIR:=$(pwd)/images/${RELEASE}} |
|
70 | BASEDIR=${BASEDIR:=$(pwd)/images/${RELEASE}} | |
70 | BUILDDIR="${BASEDIR}/build" |
|
71 | BUILDDIR="${BASEDIR}/build" | |
71 |
|
72 | |||
72 | # Prepare date string for default image file name |
|
73 | # Prepare date string for default image file name | |
73 | DATE="$(date +%Y-%m-%d)" |
|
74 | DATE="$(date +%Y-%m-%d)" | |
74 | if [ -z "$KERNEL_BRANCH" ] ; then |
|
75 | if [ -z "$KERNEL_BRANCH" ] ; then | |
75 | IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} |
|
76 | IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} | |
76 | else |
|
77 | else | |
77 | IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} |
|
78 | IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} | |
78 | fi |
|
79 | fi | |
79 |
|
80 | |||
80 | # Chroot directories |
|
81 | # Chroot directories | |
81 | R="${BUILDDIR}/chroot" |
|
82 | R="${BUILDDIR}/chroot" | |
82 | ETC_DIR="${R}/etc" |
|
83 | ETC_DIR="${R}/etc" | |
83 | LIB_DIR="${R}/lib" |
|
84 | LIB_DIR="${R}/lib" | |
84 | BOOT_DIR="${R}/boot/firmware" |
|
85 | BOOT_DIR="${R}/boot/firmware" | |
85 | KERNEL_DIR="${R}/usr/src/linux" |
|
86 | KERNEL_DIR="${R}/usr/src/linux" | |
86 | WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm" |
|
87 | WLAN_FIRMWARE_DIR="${LIB_DIR}/firmware/brcm" | |
87 |
|
88 | |||
88 | # Firmware directory: Blank if download from github |
|
89 | # Firmware directory: Blank if download from github | |
89 | RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""} |
|
90 | RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""} | |
90 | # General settings |
|
91 | # General settings | |
91 | SET_ARCH=${SET_ARCH:=32} |
|
92 | SET_ARCH=${SET_ARCH:=32} | |
92 | HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}} |
|
93 | HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}} | |
93 | PASSWORD=${PASSWORD:=raspberry} |
|
94 | PASSWORD=${PASSWORD:=raspberry} | |
94 | USER_PASSWORD=${USER_PASSWORD:=raspberry} |
|
95 | USER_PASSWORD=${USER_PASSWORD:=raspberry} | |
95 | DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"} |
|
96 | DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"} | |
96 | TIMEZONE=${TIMEZONE:="Europe/Berlin"} |
|
97 | TIMEZONE=${TIMEZONE:="Europe/Berlin"} | |
97 | EXPANDROOT=${EXPANDROOT:=true} |
|
98 | EXPANDROOT=${EXPANDROOT:=true} | |
98 |
|
99 | |||
99 | # Keyboard settings |
|
100 | # Keyboard settings | |
100 | XKB_MODEL=${XKB_MODEL:=""} |
|
101 | XKB_MODEL=${XKB_MODEL:=""} | |
101 | XKB_LAYOUT=${XKB_LAYOUT:=""} |
|
102 | XKB_LAYOUT=${XKB_LAYOUT:=""} | |
102 | XKB_VARIANT=${XKB_VARIANT:=""} |
|
103 | XKB_VARIANT=${XKB_VARIANT:=""} | |
103 | XKB_OPTIONS=${XKB_OPTIONS:=""} |
|
104 | XKB_OPTIONS=${XKB_OPTIONS:=""} | |
104 |
|
105 | |||
105 | # Network settings (DHCP) |
|
106 | # Network settings (DHCP) | |
106 | ENABLE_DHCP=${ENABLE_DHCP:=true} |
|
107 | ENABLE_DHCP=${ENABLE_DHCP:=true} | |
107 |
|
108 | |||
108 | # Network settings (static) |
|
109 | # Network settings (static) | |
109 | NET_ADDRESS=${NET_ADDRESS:=""} |
|
110 | NET_ADDRESS=${NET_ADDRESS:=""} | |
110 | NET_GATEWAY=${NET_GATEWAY:=""} |
|
111 | NET_GATEWAY=${NET_GATEWAY:=""} | |
111 | NET_DNS_1=${NET_DNS_1:=""} |
|
112 | NET_DNS_1=${NET_DNS_1:=""} | |
112 | NET_DNS_2=${NET_DNS_2:=""} |
|
113 | NET_DNS_2=${NET_DNS_2:=""} | |
113 | NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""} |
|
114 | NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""} | |
114 | NET_NTP_1=${NET_NTP_1:=""} |
|
115 | NET_NTP_1=${NET_NTP_1:=""} | |
115 | NET_NTP_2=${NET_NTP_2:=""} |
|
116 | NET_NTP_2=${NET_NTP_2:=""} | |
116 |
|
117 | |||
117 | # APT settings |
|
118 | # APT settings | |
118 | APT_PROXY=${APT_PROXY:=""} |
|
119 | APT_PROXY=${APT_PROXY:=""} | |
119 | APT_SERVER=${APT_SERVER:="ftp.debian.org"} |
|
120 | APT_SERVER=${APT_SERVER:="ftp.debian.org"} | |
120 |
|
121 | |||
121 | # Feature settings |
|
122 | # Feature settings | |
122 | ENABLE_CONSOLE=${ENABLE_CONSOLE:=true} |
|
123 | ENABLE_CONSOLE=${ENABLE_CONSOLE:=true} | |
123 | ENABLE_I2C=${ENABLE_I2C:=false} |
|
124 | ENABLE_I2C=${ENABLE_I2C:=false} | |
124 | ENABLE_SPI=${ENABLE_SPI:=false} |
|
125 | ENABLE_SPI=${ENABLE_SPI:=false} | |
125 | ENABLE_IPV6=${ENABLE_IPV6:=true} |
|
126 | ENABLE_IPV6=${ENABLE_IPV6:=true} | |
126 | ENABLE_SSHD=${ENABLE_SSHD:=true} |
|
127 | ENABLE_SSHD=${ENABLE_SSHD:=true} | |
127 | ENABLE_NONFREE=${ENABLE_NONFREE:=false} |
|
128 | ENABLE_NONFREE=${ENABLE_NONFREE:=false} | |
128 | ENABLE_WIRELESS=${ENABLE_WIRELESS:=false} |
|
129 | ENABLE_WIRELESS=${ENABLE_WIRELESS:=false} | |
129 | ENABLE_SOUND=${ENABLE_SOUND:=true} |
|
130 | ENABLE_SOUND=${ENABLE_SOUND:=true} | |
130 | ENABLE_DBUS=${ENABLE_DBUS:=true} |
|
131 | ENABLE_DBUS=${ENABLE_DBUS:=true} | |
131 | ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true} |
|
132 | ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true} | |
132 | ENABLE_MINGPU=${ENABLE_MINGPU:=false} |
|
133 | ENABLE_MINGPU=${ENABLE_MINGPU:=false} | |
133 | ENABLE_XORG=${ENABLE_XORG:=false} |
|
134 | ENABLE_XORG=${ENABLE_XORG:=false} | |
134 | ENABLE_WM=${ENABLE_WM:=""} |
|
135 | ENABLE_WM=${ENABLE_WM:=""} | |
135 | ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true} |
|
136 | ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true} | |
136 | ENABLE_USER=${ENABLE_USER:=true} |
|
137 | ENABLE_USER=${ENABLE_USER:=true} | |
137 | USER_NAME=${USER_NAME:="pi"} |
|
138 | USER_NAME=${USER_NAME:="pi"} | |
138 | ENABLE_ROOT=${ENABLE_ROOT:=false} |
|
139 | ENABLE_ROOT=${ENABLE_ROOT:=false} | |
139 | ENABLE_QEMU=${ENABLE_QEMU:=false} |
|
140 | ENABLE_QEMU=${ENABLE_QEMU:=false} | |
140 | ENABLE_SYSVINIT=${ENABLE_SYSVINIT:=false} |
|
141 | ENABLE_SYSVINIT=${ENABLE_SYSVINIT:=false} | |
141 |
|
142 | |||
142 | # SSH settings |
|
143 | # SSH settings | |
143 | SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false} |
|
144 | SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false} | |
144 | SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false} |
|
145 | SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false} | |
145 | SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false} |
|
146 | SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false} | |
146 | SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""} |
|
147 | SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""} | |
147 | SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""} |
|
148 | SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""} | |
148 |
|
149 | |||
149 | # Advanced settings |
|
150 | # Advanced settings | |
150 | ENABLE_MINBASE=${ENABLE_MINBASE:=false} |
|
151 | ENABLE_MINBASE=${ENABLE_MINBASE:=false} | |
151 | ENABLE_REDUCE=${ENABLE_REDUCE:=false} |
|
152 | ENABLE_REDUCE=${ENABLE_REDUCE:=false} | |
152 | ENABLE_UBOOT=${ENABLE_UBOOT:=false} |
|
153 | ENABLE_UBOOT=${ENABLE_UBOOT:=false} | |
153 | UBOOTSRC_DIR=${UBOOTSRC_DIR:=""} |
|
154 | UBOOTSRC_DIR=${UBOOTSRC_DIR:=""} | |
154 | ENABLE_UBOOTUSB=${ENABLE_UBOOTUSB=false} |
|
155 | ENABLE_UBOOTUSB=${ENABLE_UBOOTUSB=false} | |
155 | ENABLE_FBTURBO=${ENABLE_FBTURBO:=false} |
|
156 | ENABLE_FBTURBO=${ENABLE_FBTURBO:=false} | |
156 | ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=true} |
|
157 | ENABLE_VIDEOCORE=${ENABLE_VIDEOCORE:=true} | |
157 | VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""} |
|
158 | VIDEOCORESRC_DIR=${VIDEOCORESRC_DIR:=""} | |
158 | FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""} |
|
159 | FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""} | |
159 | ENABLE_HARDNET=${ENABLE_HARDNET:=false} |
|
160 | ENABLE_HARDNET=${ENABLE_HARDNET:=false} | |
160 | ENABLE_IPTABLES=${ENABLE_IPTABLES:=false} |
|
161 | ENABLE_IPTABLES=${ENABLE_IPTABLES:=false} | |
161 | ENABLE_SPLITFS=${ENABLE_SPLITFS:=false} |
|
162 | ENABLE_SPLITFS=${ENABLE_SPLITFS:=false} | |
162 | ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false} |
|
163 | ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false} | |
163 | ENABLE_IFNAMES=${ENABLE_IFNAMES:=true} |
|
164 | ENABLE_IFNAMES=${ENABLE_IFNAMES:=true} | |
164 | DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=} |
|
165 | DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=} | |
165 |
|
166 | |||
166 | # Kernel compilation settings |
|
167 | # Kernel compilation settings | |
167 | BUILD_KERNEL=${BUILD_KERNEL:=true} |
|
168 | BUILD_KERNEL=${BUILD_KERNEL:=true} | |
168 | KERNEL_REDUCE=${KERNEL_REDUCE:=false} |
|
169 | KERNEL_REDUCE=${KERNEL_REDUCE:=false} | |
169 | KERNEL_THREADS=${KERNEL_THREADS:=1} |
|
170 | KERNEL_THREADS=${KERNEL_THREADS:=1} | |
170 | KERNEL_HEADERS=${KERNEL_HEADERS:=true} |
|
171 | KERNEL_HEADERS=${KERNEL_HEADERS:=true} | |
171 | KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false} |
|
172 | KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false} | |
172 | KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true} |
|
173 | KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true} | |
173 | KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false} |
|
174 | KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false} | |
174 | KERNEL_CCACHE=${KERNEL_CCACHE:=false} |
|
175 | KERNEL_CCACHE=${KERNEL_CCACHE:=false} | |
175 | KERNEL_ZSWAP=${KERNEL_ZSWAP:=false} |
|
176 | KERNEL_ZSWAP=${KERNEL_ZSWAP:=false} | |
176 | KERNEL_VIRT=${KERNEL_VIRT:=false} |
|
177 | KERNEL_VIRT=${KERNEL_VIRT:=false} | |
177 | KERNEL_BPF=${KERNEL_BPF:=true} |
|
178 | KERNEL_BPF=${KERNEL_BPF:=true} | |
178 |
|
179 | |||
179 | # Kernel compilation from source directory settings |
|
180 | # Kernel compilation from source directory settings | |
180 | KERNELSRC_DIR=${KERNELSRC_DIR:=""} |
|
181 | KERNELSRC_DIR=${KERNELSRC_DIR:=""} | |
181 | KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false} |
|
182 | KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false} | |
182 | KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true} |
|
183 | KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true} | |
183 | KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false} |
|
184 | KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false} | |
184 |
|
185 | |||
185 | # Reduce disk usage settings |
|
186 | # Reduce disk usage settings | |
186 | REDUCE_APT=${REDUCE_APT:=true} |
|
187 | REDUCE_APT=${REDUCE_APT:=true} | |
187 | REDUCE_DOC=${REDUCE_DOC:=true} |
|
188 | REDUCE_DOC=${REDUCE_DOC:=true} | |
188 | REDUCE_MAN=${REDUCE_MAN:=true} |
|
189 | REDUCE_MAN=${REDUCE_MAN:=true} | |
189 | REDUCE_VIM=${REDUCE_VIM:=false} |
|
190 | REDUCE_VIM=${REDUCE_VIM:=false} | |
190 | REDUCE_BASH=${REDUCE_BASH:=false} |
|
191 | REDUCE_BASH=${REDUCE_BASH:=false} | |
191 | REDUCE_HWDB=${REDUCE_HWDB:=true} |
|
192 | REDUCE_HWDB=${REDUCE_HWDB:=true} | |
192 | REDUCE_SSHD=${REDUCE_SSHD:=true} |
|
193 | REDUCE_SSHD=${REDUCE_SSHD:=true} | |
193 | REDUCE_LOCALE=${REDUCE_LOCALE:=true} |
|
194 | REDUCE_LOCALE=${REDUCE_LOCALE:=true} | |
194 |
|
195 | |||
195 | # Encrypted filesystem settings |
|
196 | # Encrypted filesystem settings | |
196 | ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false} |
|
197 | ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false} | |
197 | CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""} |
|
198 | CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""} | |
198 | CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"} |
|
199 | CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"} | |
199 | CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"} |
|
200 | CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"} | |
200 | CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512} |
|
201 | CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512} | |
201 |
|
202 | |||
202 | # Chroot scripts directory |
|
203 | # Chroot scripts directory | |
203 | CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""} |
|
204 | CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""} | |
204 |
|
205 | |||
205 | # Packages required in the chroot build environment |
|
206 | # Packages required in the chroot build environment | |
206 | APT_INCLUDES=${APT_INCLUDES:=""} |
|
207 | APT_INCLUDES=${APT_INCLUDES:=""} | |
207 | APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup" |
|
208 | APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils,locales,keyboard-configuration,console-setup" | |
208 |
|
209 | |||
209 | #Packages to exclude from chroot build environment |
|
210 | #Packages to exclude from chroot build environment | |
210 | APT_EXCLUDES=${APT_EXCLUDES:=""} |
|
211 | APT_EXCLUDES=${APT_EXCLUDES:=""} | |
211 |
|
212 | |||
212 | # Packages required for bootstrapping |
|
213 | # Packages required for bootstrapping | |
213 | REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo netselect-apt" |
|
214 | REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo netselect-apt" | |
214 | MISSING_PACKAGES="" |
|
215 | MISSING_PACKAGES="" | |
215 |
|
216 | |||
216 | # Packages installed for c/c++ build environment in chroot (keep empty) |
|
217 | # Packages installed for c/c++ build environment in chroot (keep empty) | |
217 | COMPILER_PACKAGES="" |
|
218 | COMPILER_PACKAGES="" | |
218 |
|
219 | |||
219 | #If init and systemd-sysv are wanted e.g. halt/reboot/shutdown scripts |
|
220 | #If init and systemd-sysv are wanted e.g. halt/reboot/shutdown scripts | |
220 | if [ "$ENABLE_SYSVINIT" = false ] ; then |
|
221 | if [ "$ENABLE_SYSVINIT" = false ] ; then | |
221 | APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv" |
|
222 | APT_EXCLUDES="--exclude=${APT_EXCLUDES},init,systemd-sysv" | |
222 | fi |
|
223 | fi | |
223 |
|
224 | |||
224 | #Check if apt-cacher-ng has its default port open on and set APT_PROXY |
|
225 | #Check if apt-cacher-ng has its default port open on and set APT_PROXY | |
225 | if [ -n "$(lsof -i :3142)" ] ; then |
|
226 | if [ -n "$(lsof -i :3142)" ] ; then | |
226 | HTTP_PROXY=http://127.0.0.1:3142/ |
|
227 | HTTP_PROXY=http://127.0.0.1:3142/ | |
227 | fi |
|
228 | fi | |
228 |
|
229 | |||
229 | #ipinfo=$(curl ipinfo.io | grep country ) |
|
230 | #ipinfo=$(curl ipinfo.io | grep country ) | |
230 | #grep -o '\"[^"]*\"' $ipinfo | tr -d '"' |
|
231 | #grep -o '\"[^"]*\"' $ipinfo | tr -d '"' | |
231 | #grep -Po '"country":.*?[^\\]",' $(curl ipinfo.io | grep country ) |
|
232 | #grep -Po '"country":.*?[^\\]",' $(curl ipinfo.io | grep country ) | |
232 | #sed -i "s,http:,https:,g" "${ETC_DIR}/apt/sources.list" |
|
233 | #sed -i "s,http:,https:,g" "${ETC_DIR}/apt/sources.list" | |
233 | #autconfigure best apt server to not spam ftp.debian.org |
|
234 | #autconfigure best apt server to not spam ftp.debian.org | |
234 | #rm files/apt/sources.list |
|
235 | #rm files/apt/sources.list | |
235 | #netselect-apt does not know buster yet |
|
236 | #netselect-apt does not know buster yet | |
236 | if [ "$RELEASE" = "buster" ] ; then |
|
237 | if [ "$RELEASE" = "buster" ] ; then | |
237 | RLS=testing |
|
238 | RLS=testing | |
238 | else |
|
239 | else | |
239 | RLS="$RELEASE" |
|
240 | RLS="$RELEASE" | |
240 | fi |
|
241 | fi | |
241 |
|
242 | |||
242 | if [ -f "$(pwd)/files/apt/sources.list" ] ; then |
|
243 | if [ -f "$(pwd)/files/apt/sources.list" ] ; then | |
243 | rm "$(pwd)/files/apt/sources.list" |
|
244 | rm "$(pwd)/files/apt/sources.list" | |
244 | fi |
|
245 | fi | |
245 |
|
246 | |||
246 | if [ "$ENABLE_NONFREE" = true ] ; then |
|
247 | if [ "$ENABLE_NONFREE" = true ] ; then | |
247 | netselect-apt --arch "$RELEASE_ARCH" --tests 10 --sources --nonfree --outfile "$(pwd)/files/apt/sources.list" -d "$RLS" |
|
248 | netselect-apt --arch "$RELEASE_ARCH" --tests 10 --sources --nonfree --outfile "$(pwd)/files/apt/sources.list" -d "$RLS" | |
248 | else |
|
249 | else | |
249 | netselect-apt --arch "$RELEASE_ARCH" --tests 10 --sources --outfile "$(pwd)/files/apt/sources.list" -d "$RLS" |
|
250 | netselect-apt --arch "$RELEASE_ARCH" --tests 10 --sources --outfile "$(pwd)/files/apt/sources.list" -d "$RLS" | |
250 | fi |
|
251 | fi | |
251 |
|
252 | |||
252 | #sed and cut the result string so we can use it as APT_SERVER |
|
253 | #sed and cut the result string so we can use it as APT_SERVER | |
253 | APT_SERVER=$(grep -m 1 http files/apt/sources.list | sed "s|http://| |g" | cut -d ' ' -f 3) |
|
254 | APT_SERVER=$(grep -m 1 http files/apt/sources.list | sed "s|http://| |g" | cut -d ' ' -f 3) | |
254 | APT_SERVER=${APT_SERVER::-1} |
|
255 | APT_SERVER=${APT_SERVER::-1} | |
255 |
|
256 | |||
256 | #make script easier and more stable to use with convenient setup switch. Just setup SET_ARCH and RPI_MODEL and your good to go! |
|
257 | #make script easier and more stable to use with convenient setup switch. Just setup SET_ARCH and RPI_MODEL and your good to go! | |
257 | if [ -n "$SET_ARCH" ] ; then |
|
258 | if [ -n "$SET_ARCH" ] ; then | |
258 | echo "Setting Architecture specific settings" |
|
259 | echo "Setting Architecture specific settings" | |
259 | ################################## |
|
260 | ################################## | |
260 | # 64 bit config |
|
261 | # 64 bit config | |
261 | ################################## |
|
262 | ################################## | |
262 | if [ "$SET_ARCH" = 64 ] ; then |
|
263 | if [ "$SET_ARCH" = 64 ] ; then | |
263 | echo "64 bit mode selected - Setting up enviroment" |
|
264 | echo "64 bit mode selected - Setting up enviroment" | |
264 | # 64 bit depended settings |
|
265 | # 64 bit depended settings | |
265 | QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static} |
|
266 | QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static} | |
266 | KERNEL_ARCH=${KERNEL_ARCH:=arm64} |
|
267 | KERNEL_ARCH=${KERNEL_ARCH:=arm64} | |
267 | KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"} |
|
268 | KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"} | |
268 |
|
269 | |||
269 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then |
|
270 | if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then | |
270 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64" |
|
271 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64" | |
271 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig} |
|
272 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig} | |
272 | RELEASE_ARCH=${RELEASE_ARCH:=arm64} |
|
273 | RELEASE_ARCH=${RELEASE_ARCH:=arm64} | |
273 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img} |
|
274 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img} | |
274 | CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-} |
|
275 | CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-} | |
275 | else |
|
276 | else | |
276 | echo "error: Only Raspberry PI 3 and 3B+ support 64bit" |
|
277 | echo "error: Only Raspberry PI 3 and 3B+ support 64bit" | |
277 | exit 1 |
|
278 | exit 1 | |
278 | fi |
|
279 | fi | |
279 | fi |
|
280 | fi | |
280 |
|
281 | |||
281 | ################################## |
|
282 | ################################## | |
282 | # 32 bit config |
|
283 | # 32 bit config | |
283 | ################################## |
|
284 | ################################## | |
284 | if [ "$SET_ARCH" = 32 ] ; then |
|
285 | if [ "$SET_ARCH" = 32 ] ; then | |
285 | echo "32 bit mode selected - Setting up enviroment" |
|
286 | echo "32 bit mode selected - Setting up enviroment" | |
286 | #General 32bit configuration |
|
287 | #General 32bit configuration | |
287 | QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static} |
|
288 | QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static} | |
288 | KERNEL_ARCH=${KERNEL_ARCH:=arm} |
|
289 | KERNEL_ARCH=${KERNEL_ARCH:=arm} | |
289 | KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"} |
|
290 | KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"} | |
290 |
|
291 | |||
291 | #Raspberry setting grouped by board compability |
|
292 | #Raspberry setting grouped by board compability | |
292 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then |
|
293 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then | |
293 | echo "Setting settings for bcm2835 Raspberry PI boards" |
|
294 | echo "Setting settings for bcm2835 Raspberry PI boards" | |
294 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel" |
|
295 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel" | |
295 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig} |
|
296 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig} | |
296 | RELEASE_ARCH=${RELEASE_ARCH:=armel} |
|
297 | RELEASE_ARCH=${RELEASE_ARCH:=armel} | |
297 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img} |
|
298 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img} | |
298 | CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-} |
|
299 | CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-} | |
299 | fi |
|
300 | fi | |
300 | if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then |
|
301 | if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then | |
301 | echo "Setting settings for bcm2837 Raspberry PI boards" |
|
302 | echo "Setting settings for bcm2837 Raspberry PI boards" | |
302 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf" |
|
303 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf" | |
303 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig} |
|
304 | KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig} | |
304 | RELEASE_ARCH=${RELEASE_ARCH:=armhf} |
|
305 | RELEASE_ARCH=${RELEASE_ARCH:=armhf} | |
305 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img} |
|
306 | KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img} | |
306 | CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-} |
|
307 | CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-} | |
307 | fi |
|
308 | fi | |
308 | fi |
|
309 | fi | |
309 | #SET_ARCH not set |
|
310 | #SET_ARCH not set | |
310 | else |
|
311 | else | |
311 | echo "error: Please set '32' or '64' as value for SET_ARCH" |
|
312 | echo "error: Please set '32' or '64' as value for SET_ARCH" | |
312 | exit 1 |
|
313 | exit 1 | |
313 | fi |
|
314 | fi | |
314 |
|
315 | |||
315 | #Device specific configuration |
|
316 | #Device specific configuration | |
316 | echo "Select DTB-File" |
|
317 | echo "Select DTB-File" | |
317 | case "$RPI_MODEL" in |
|
318 | case "$RPI_MODEL" in | |
318 | 0) |
|
319 | 0) | |
319 | DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb} |
|
320 | DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb} | |
320 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} |
|
321 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} | |
321 | ;; |
|
322 | ;; | |
322 | 1) |
|
323 | 1) | |
323 | DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb} |
|
324 | DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb} | |
324 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} |
|
325 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} | |
325 | ;; |
|
326 | ;; | |
326 | 1P) |
|
327 | 1P) | |
327 | DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb} |
|
328 | DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb} | |
328 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} |
|
329 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig} | |
329 | ;; |
|
330 | ;; | |
330 | 2) |
|
331 | 2) | |
331 | DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb} |
|
332 | DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb} | |
332 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig} |
|
333 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig} | |
333 | ;; |
|
334 | ;; | |
334 | 3) |
|
335 | 3) | |
335 | DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb} |
|
336 | DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb} | |
336 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig} |
|
337 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig} | |
337 | ;; |
|
338 | ;; | |
338 | 3P) |
|
339 | 3P) | |
339 | DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb} |
|
340 | DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb} | |
340 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig} |
|
341 | UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig} | |
341 | ;; |
|
342 | ;; | |
342 | *) |
|
343 | *) | |
343 | echo "error: Raspberry Pi model $RPI_MODEL is not supported!" |
|
344 | echo "error: Raspberry Pi model $RPI_MODEL is not supported!" | |
344 | exit 1 |
|
345 | exit 1 | |
345 | ;; |
|
346 | ;; | |
346 | esac |
|
347 | esac | |
347 | echo "$DTB_FILE selected" |
|
348 | echo "$DTB_FILE selected" | |
348 |
|
349 | |||
349 | #DEBUG off |
|
350 | #DEBUG off | |
350 | set +x |
|
351 | set +x | |
351 |
|
352 | |||
352 | # Check if the internal wireless interface is supported by the RPi model |
|
353 | # Check if the internal wireless interface is supported by the RPi model | |
353 | if [ "$ENABLE_WIRELESS" = true ] ; then |
|
354 | if [ "$ENABLE_WIRELESS" = true ] ; then | |
354 | if [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ] ; then |
|
355 | if [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ] ; then | |
355 | echo "error: The selected Raspberry Pi model has no internal wireless interface" |
|
356 | echo "error: The selected Raspberry Pi model has no internal wireless interface" | |
356 | exit 1 |
|
357 | exit 1 | |
357 | else |
|
358 | else | |
358 | echo "Raspberry Pi $RPI_MODEL has WIFI support" |
|
359 | echo "Raspberry Pi $RPI_MODEL has WIFI support" | |
359 | fi |
|
360 | fi | |
360 | fi |
|
361 | fi | |
361 |
|
362 | |||
362 | # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported |
|
363 | # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported | |
363 | if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then |
|
364 | if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then | |
364 | if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then |
|
365 | if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then | |
365 | echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported" |
|
366 | echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported" | |
366 | exit 1 |
|
367 | exit 1 | |
367 | fi |
|
368 | fi | |
368 | fi |
|
369 | fi | |
369 |
|
370 | |||
370 | if [ "$ENABLE_VIDEOCORE" = true ] ; then |
|
371 | if [ "$ENABLE_VIDEOCORE" = true ] ; then | |
371 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake" |
|
372 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cmake" | |
372 | fi |
|
373 | fi | |
373 |
|
374 | |||
374 | # Add libncurses5 to enable kernel menuconfig |
|
375 | # Add libncurses5 to enable kernel menuconfig | |
375 | if [ "$KERNEL_MENUCONFIG" = true ] ; then |
|
376 | if [ "$KERNEL_MENUCONFIG" = true ] ; then | |
376 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses-dev" |
|
377 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses-dev" | |
377 | fi |
|
378 | fi | |
378 |
|
379 | |||
379 | # Add ccache compiler cache for (faster) kernel cross (re)compilation |
|
380 | # Add ccache compiler cache for (faster) kernel cross (re)compilation | |
380 | if [ "$KERNEL_CCACHE" = true ] ; then |
|
381 | if [ "$KERNEL_CCACHE" = true ] ; then | |
381 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache" |
|
382 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache" | |
382 | fi |
|
383 | fi | |
383 |
|
384 | |||
384 | # Add cryptsetup package to enable filesystem encryption |
|
385 | # Add cryptsetup package to enable filesystem encryption | |
385 | if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then |
|
386 | if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then | |
386 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup" |
|
387 | REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup" | |
387 | APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup" |
|
388 | APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup" | |
388 |
|
389 | |||
389 | if [ -z "$CRYPTFS_PASSWORD" ] ; then |
|
390 | if [ -z "$CRYPTFS_PASSWORD" ] ; then | |
390 | echo "error: no password defined (CRYPTFS_PASSWORD)!" |
|
391 | echo "error: no password defined (CRYPTFS_PASSWORD)!" | |
391 | exit 1 |
|
392 | exit 1 | |
392 | fi |
|
393 | fi | |
393 | ENABLE_INITRAMFS=true |
|
394 | ENABLE_INITRAMFS=true | |
394 | fi |
|
395 | fi | |
395 |
|
396 | |||
396 | # Add initramfs generation tools |
|
397 | # Add initramfs generation tools | |
397 | if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then |
|
398 | if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then | |
398 | APT_INCLUDES="${APT_INCLUDES},initramfs-tools" |
|
399 | APT_INCLUDES="${APT_INCLUDES},initramfs-tools" | |
399 | fi |
|
400 | fi | |
400 |
|
401 | |||
401 | # Add device-tree-compiler required for building the U-Boot bootloader |
|
402 | # Add device-tree-compiler required for building the U-Boot bootloader | |
402 | if [ "$ENABLE_UBOOT" = true ] ; then |
|
403 | if [ "$ENABLE_UBOOT" = true ] ; then | |
403 | APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc" |
|
404 | APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex,bc" | |
404 | else |
|
405 | else | |
405 | if [ "$ENABLE_UBOOTUSB" = true ] ; then |
|
406 | if [ "$ENABLE_UBOOTUSB" = true ] ; then | |
406 | echo "error: Enabling UBOOTUSB requires u-boot to be enabled" |
|
407 | echo "error: Enabling UBOOTUSB requires u-boot to be enabled" | |
407 | exit 1 |
|
408 | exit 1 | |
408 | fi |
|
409 | fi | |
409 | fi |
|
410 | fi | |
410 |
|
411 | |||
411 | # Check if root SSH (v2) public key file exists |
|
412 | # Check if root SSH (v2) public key file exists | |
412 | if [ -n "$SSH_ROOT_PUB_KEY" ] ; then |
|
413 | if [ -n "$SSH_ROOT_PUB_KEY" ] ; then | |
413 | if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then |
|
414 | if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then | |
414 | echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!" |
|
415 | echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!" | |
415 | exit 1 |
|
416 | exit 1 | |
416 | fi |
|
417 | fi | |
417 | fi |
|
418 | fi | |
418 |
|
419 | |||
419 | # Check if $USER_NAME SSH (v2) public key file exists |
|
420 | # Check if $USER_NAME SSH (v2) public key file exists | |
420 | if [ -n "$SSH_USER_PUB_KEY" ] ; then |
|
421 | if [ -n "$SSH_USER_PUB_KEY" ] ; then | |
421 | if [ ! -f "$SSH_USER_PUB_KEY" ] ; then |
|
422 | if [ ! -f "$SSH_USER_PUB_KEY" ] ; then | |
422 | echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!" |
|
423 | echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!" | |
423 | exit 1 |
|
424 | exit 1 | |
424 | fi |
|
425 | fi | |
425 | fi |
|
426 | fi | |
426 |
|
427 | |||
427 | # Check if all required packages are installed on the build system |
|
428 | # Check if all required packages are installed on the build system | |
428 | for package in $REQUIRED_PACKAGES ; do |
|
429 | for package in $REQUIRED_PACKAGES ; do | |
429 | if [ "$(dpkg-query -W -f='${Status}' $package)" != "install ok installed" ] ; then |
|
430 | if [ "$(dpkg-query -W -f='${Status}' $package)" != "install ok installed" ] ; then | |
430 | MISSING_PACKAGES="${MISSING_PACKAGES} $package" |
|
431 | MISSING_PACKAGES="${MISSING_PACKAGES} $package" | |
431 | fi |
|
432 | fi | |
432 | done |
|
433 | done | |
433 |
|
434 | |||
434 | # If there are missing packages ask confirmation for install, or exit |
|
435 | # If there are missing packages ask confirmation for install, or exit | |
435 | if [ -n "$MISSING_PACKAGES" ] ; then |
|
436 | if [ -n "$MISSING_PACKAGES" ] ; then | |
436 | echo "the following packages needed by this script are not installed:" |
|
437 | echo "the following packages needed by this script are not installed:" | |
437 | echo "$MISSING_PACKAGES" |
|
438 | echo "$MISSING_PACKAGES" | |
438 |
|
439 | |||
439 | printf "\ndo you want to install the missing packages right now? [y/n] " |
|
440 | printf "\ndo you want to install the missing packages right now? [y/n] " | |
440 | read -r confirm |
|
441 | read -r confirm | |
441 | [ "$confirm" != "y" ] && exit 1 |
|
442 | [ "$confirm" != "y" ] && exit 1 | |
442 |
|
443 | |||
443 | # Make sure all missing required packages are installed |
|
444 | # Make sure all missing required packages are installed | |
444 | apt-get -qq -y install "${MISSING_PACKAGES}" |
|
445 | apt-get -qq -y install "${MISSING_PACKAGES}" | |
445 | fi |
|
446 | fi | |
446 |
|
447 | |||
447 | # Check if ./bootstrap.d directory exists |
|
448 | # Check if ./bootstrap.d directory exists | |
448 | if [ ! -d "./bootstrap.d/" ] ; then |
|
449 | if [ ! -d "./bootstrap.d/" ] ; then | |
449 | echo "error: './bootstrap.d' required directory not found!" |
|
450 | echo "error: './bootstrap.d' required directory not found!" | |
450 | exit 1 |
|
451 | exit 1 | |
451 | fi |
|
452 | fi | |
452 |
|
453 | |||
453 | # Check if ./files directory exists |
|
454 | # Check if ./files directory exists | |
454 | if [ ! -d "./files/" ] ; then |
|
455 | if [ ! -d "./files/" ] ; then | |
455 | echo "error: './files' required directory not found!" |
|
456 | echo "error: './files' required directory not found!" | |
456 | exit 1 |
|
457 | exit 1 | |
457 | fi |
|
458 | fi | |
458 |
|
459 | |||
459 | # Check if specified KERNELSRC_DIR directory exists |
|
460 | # Check if specified KERNELSRC_DIR directory exists | |
460 | if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then |
|
461 | if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then | |
461 | echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!" |
|
462 | echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!" | |
462 | exit 1 |
|
463 | exit 1 | |
463 | fi |
|
464 | fi | |
464 |
|
465 | |||
465 | # Check if specified UBOOTSRC_DIR directory exists |
|
466 | # Check if specified UBOOTSRC_DIR directory exists | |
466 | if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then |
|
467 | if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then | |
467 | echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!" |
|
468 | echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!" | |
468 | exit 1 |
|
469 | exit 1 | |
469 | fi |
|
470 | fi | |
470 |
|
471 | |||
471 | # Check if specified VIDEOCORESRC_DIR directory exists |
|
472 | # Check if specified VIDEOCORESRC_DIR directory exists | |
472 | if [ -n "$VIDEOCORESRC_DIR" ] && [ ! -d "$VIDEOCORESRC_DIR" ] ; then |
|
473 | if [ -n "$VIDEOCORESRC_DIR" ] && [ ! -d "$VIDEOCORESRC_DIR" ] ; then | |
473 | echo "error: '${VIDEOCORESRC_DIR}' specified directory not found (VIDEOCORESRC_DIR)!" |
|
474 | echo "error: '${VIDEOCORESRC_DIR}' specified directory not found (VIDEOCORESRC_DIR)!" | |
474 | exit 1 |
|
475 | exit 1 | |
475 | fi |
|
476 | fi | |
476 |
|
477 | |||
477 | # Check if specified FBTURBOSRC_DIR directory exists |
|
478 | # Check if specified FBTURBOSRC_DIR directory exists | |
478 | if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then |
|
479 | if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then | |
479 | echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!" |
|
480 | echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!" | |
480 | exit 1 |
|
481 | exit 1 | |
481 | fi |
|
482 | fi | |
482 |
|
483 | |||
483 | # Check if specified CHROOT_SCRIPTS directory exists |
|
484 | # Check if specified CHROOT_SCRIPTS directory exists | |
484 | if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then |
|
485 | if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then | |
485 | echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!" |
|
486 | echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!" | |
486 | exit 1 |
|
487 | exit 1 | |
487 | fi |
|
488 | fi | |
488 |
|
489 | |||
489 | # Check if specified device mapping already exists (will be used by cryptsetup) |
|
490 | # Check if specified device mapping already exists (will be used by cryptsetup) | |
490 | if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then |
|
491 | if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then | |
491 | echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding" |
|
492 | echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding" | |
492 | exit 1 |
|
493 | exit 1 | |
493 | fi |
|
494 | fi | |
494 |
|
495 | |||
495 | # Don't clobber an old build |
|
496 | # Don't clobber an old build | |
496 | if [ -e "$BUILDDIR" ] ; then |
|
497 | if [ -e "$BUILDDIR" ] ; then | |
497 | echo "error: directory ${BUILDDIR} already exists, not proceeding" |
|
498 | echo "error: directory ${BUILDDIR} already exists, not proceeding" | |
498 | exit 1 |
|
499 | exit 1 | |
499 | fi |
|
500 | fi | |
500 |
|
501 | |||
501 | # Setup chroot directory |
|
502 | # Setup chroot directory | |
502 | mkdir -p "${R}" |
|
503 | mkdir -p "${R}" | |
503 |
|
504 | |||
504 | # Check if build directory has enough of free disk space >512MB |
|
505 | # Check if build directory has enough of free disk space >512MB | |
505 | if [ "$(df --output=avail "${BUILDDIR}" | sed "1d")" -le "524288" ] ; then |
|
506 | if [ "$(df --output=avail "${BUILDDIR}" | sed "1d")" -le "524288" ] ; then | |
506 | echo "error: ${BUILDDIR} not enough space left to generate the output image!" |
|
507 | echo "error: ${BUILDDIR} not enough space left to generate the output image!" | |
507 | exit 1 |
|
508 | exit 1 | |
508 | fi |
|
509 | fi | |
509 |
|
510 | |||
510 | set -x |
|
511 | set -x | |
511 |
|
512 | |||
512 | # Call "cleanup" function on various signals and errors |
|
513 | # Call "cleanup" function on various signals and errors | |
513 | trap cleanup 0 1 2 3 6 |
|
514 | trap cleanup 0 1 2 3 6 | |
514 |
|
515 | |||
515 | # Add required packages for the minbase installation |
|
516 | # Add required packages for the minbase installation | |
516 | if [ "$ENABLE_MINBASE" = true ] ; then |
|
517 | if [ "$ENABLE_MINBASE" = true ] ; then | |
517 | APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown" |
|
518 | APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown" | |
518 | fi |
|
519 | fi | |
519 |
|
520 | |||
520 | # Add parted package, required to get partprobe utility |
|
521 | # Add parted package, required to get partprobe utility | |
521 | if [ "$EXPANDROOT" = true ] ; then |
|
522 | if [ "$EXPANDROOT" = true ] ; then | |
522 | APT_INCLUDES="${APT_INCLUDES},parted" |
|
523 | APT_INCLUDES="${APT_INCLUDES},parted" | |
523 | fi |
|
524 | fi | |
524 |
|
525 | |||
525 | # Add dbus package, recommended if using systemd |
|
526 | # Add dbus package, recommended if using systemd | |
526 | if [ "$ENABLE_DBUS" = true ] ; then |
|
527 | if [ "$ENABLE_DBUS" = true ] ; then | |
527 | APT_INCLUDES="${APT_INCLUDES},dbus" |
|
528 | APT_INCLUDES="${APT_INCLUDES},dbus" | |
528 | fi |
|
529 | fi | |
529 |
|
530 | |||
530 | # Add iptables IPv4/IPv6 package |
|
531 | # Add iptables IPv4/IPv6 package | |
531 | if [ "$ENABLE_IPTABLES" = true ] ; then |
|
532 | if [ "$ENABLE_IPTABLES" = true ] ; then | |
532 | APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent" |
|
533 | APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent" | |
533 | fi |
|
534 | fi | |
534 |
|
535 | |||
535 | # Add openssh server package |
|
536 | # Add openssh server package | |
536 | if [ "$ENABLE_SSHD" = true ] ; then |
|
537 | if [ "$ENABLE_SSHD" = true ] ; then | |
537 | APT_INCLUDES="${APT_INCLUDES},openssh-server" |
|
538 | APT_INCLUDES="${APT_INCLUDES},openssh-server" | |
538 | fi |
|
539 | fi | |
539 |
|
540 | |||
540 | # Add alsa-utils package |
|
541 | # Add alsa-utils package | |
541 | if [ "$ENABLE_SOUND" = true ] ; then |
|
542 | if [ "$ENABLE_SOUND" = true ] ; then | |
542 | APT_INCLUDES="${APT_INCLUDES},alsa-utils" |
|
543 | APT_INCLUDES="${APT_INCLUDES},alsa-utils" | |
543 | fi |
|
544 | fi | |
544 |
|
545 | |||
545 | # Add rng-tools package |
|
546 | # Add rng-tools package | |
546 | if [ "$ENABLE_HWRANDOM" = true ] ; then |
|
547 | if [ "$ENABLE_HWRANDOM" = true ] ; then | |
547 | APT_INCLUDES="${APT_INCLUDES},rng-tools" |
|
548 | APT_INCLUDES="${APT_INCLUDES},rng-tools" | |
548 | fi |
|
549 | fi | |
549 |
|
550 | |||
550 | # Add fbturbo video driver |
|
551 | # Add fbturbo video driver | |
551 | if [ "$ENABLE_FBTURBO" = true ] ; then |
|
552 | if [ "$ENABLE_FBTURBO" = true ] ; then | |
552 | # Enable xorg package dependencies |
|
553 | # Enable xorg package dependencies | |
553 | ENABLE_XORG=true |
|
554 | ENABLE_XORG=true | |
554 | fi |
|
555 | fi | |
555 |
|
556 | |||
556 | # Add user defined window manager package |
|
557 | # Add user defined window manager package | |
557 | if [ -n "$ENABLE_WM" ] ; then |
|
558 | if [ -n "$ENABLE_WM" ] ; then | |
558 | APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}" |
|
559 | APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}" | |
559 |
|
560 | |||
560 | # Enable xorg package dependencies |
|
561 | # Enable xorg package dependencies | |
561 | ENABLE_XORG=true |
|
562 | ENABLE_XORG=true | |
562 | fi |
|
563 | fi | |
563 |
|
564 | |||
564 | # Add xorg package |
|
565 | # Add xorg package | |
565 | if [ "$ENABLE_XORG" = true ] ; then |
|
566 | if [ "$ENABLE_XORG" = true ] ; then | |
566 | APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11" |
|
567 | APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11" | |
567 | fi |
|
568 | fi | |
568 |
|
569 | |||
569 | # Replace selected packages with smaller clones |
|
570 | # Replace selected packages with smaller clones | |
570 | if [ "$ENABLE_REDUCE" = true ] ; then |
|
571 | if [ "$ENABLE_REDUCE" = true ] ; then | |
571 | # Add levee package instead of vim-tiny |
|
572 | # Add levee package instead of vim-tiny | |
572 | if [ "$REDUCE_VIM" = true ] ; then |
|
573 | if [ "$REDUCE_VIM" = true ] ; then | |
573 | APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")" |
|
574 | APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")" | |
574 | fi |
|
575 | fi | |
575 |
|
576 | |||
576 | # Add dropbear package instead of openssh-server |
|
577 | # Add dropbear package instead of openssh-server | |
577 | if [ "$REDUCE_SSHD" = true ] ; then |
|
578 | if [ "$REDUCE_SSHD" = true ] ; then | |
578 | APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")" |
|
579 | APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")" | |
579 | fi |
|
580 | fi | |
580 | fi |
|
581 | fi | |
581 |
|
582 | |||
582 | # Configure kernel sources if no KERNELSRC_DIR |
|
583 | # Configure kernel sources if no KERNELSRC_DIR | |
583 | if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then |
|
584 | if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then | |
584 | KERNELSRC_CONFIG=true |
|
585 | KERNELSRC_CONFIG=true | |
585 | fi |
|
586 | fi | |
586 |
|
587 | |||
587 | # Configure reduced kernel |
|
588 | # Configure reduced kernel | |
588 | if [ "$KERNEL_REDUCE" = true ] ; then |
|
589 | if [ "$KERNEL_REDUCE" = true ] ; then | |
589 | KERNELSRC_CONFIG=false |
|
590 | KERNELSRC_CONFIG=false | |
590 | fi |
|
591 | fi | |
591 |
|
592 | |||
592 | # Configure qemu compatible kernel |
|
593 | # Configure qemu compatible kernel | |
593 | if [ "$ENABLE_QEMU" = true ] ; then |
|
594 | if [ "$ENABLE_QEMU" = true ] ; then | |
594 | DTB_FILE=vexpress-v2p-ca15_a7.dtb |
|
595 | DTB_FILE=vexpress-v2p-ca15_a7.dtb | |
595 | UBOOT_CONFIG=vexpress_ca15_tc2_defconfig |
|
596 | UBOOT_CONFIG=vexpress_ca15_tc2_defconfig | |
596 | KERNEL_DEFCONFIG="vexpress_defconfig" |
|
597 | KERNEL_DEFCONFIG="vexpress_defconfig" | |
597 | if [ "$KERNEL_MENUCONFIG" = false ] ; then |
|
598 | if [ "$KERNEL_MENUCONFIG" = false ] ; then | |
598 | KERNEL_OLDDEFCONFIG=true |
|
599 | KERNEL_OLDDEFCONFIG=true | |
599 | fi |
|
600 | fi | |
600 | fi |
|
601 | fi | |
601 |
|
602 | |||
602 | # Execute bootstrap scripts |
|
603 | # Execute bootstrap scripts | |
603 | for SCRIPT in bootstrap.d/*.sh; do |
|
604 | for SCRIPT in bootstrap.d/*.sh; do | |
604 | head -n 3 "$SCRIPT" |
|
605 | head -n 3 "$SCRIPT" | |
605 | . "$SCRIPT" |
|
606 | . "$SCRIPT" | |
606 | done |
|
607 | done | |
607 |
|
608 | |||
608 | ## Execute custom bootstrap scripts |
|
609 | ## Execute custom bootstrap scripts | |
609 | if [ -d "custom.d" ] ; then |
|
610 | if [ -d "custom.d" ] ; then | |
610 | for SCRIPT in custom.d/*.sh; do |
|
611 | for SCRIPT in custom.d/*.sh; do | |
611 | . "$SCRIPT" |
|
612 | . "$SCRIPT" | |
612 | done |
|
613 | done | |
613 | fi |
|
614 | fi | |
614 |
|
615 | |||
615 | # Execute custom scripts inside the chroot |
|
616 | # Execute custom scripts inside the chroot | |
616 | if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then |
|
617 | if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then | |
617 | cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts" |
|
618 | cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts" | |
618 | chroot_exec /bin/bash -x <<'EOF' |
|
619 | chroot_exec /bin/bash -x <<'EOF' | |
619 | for SCRIPT in /chroot_scripts/* ; do |
|
620 | for SCRIPT in /chroot_scripts/* ; do | |
620 | if [ -f $SCRIPT -a -x $SCRIPT ] ; then |
|
621 | if [ -f $SCRIPT -a -x $SCRIPT ] ; then | |
621 | $SCRIPT |
|
622 | $SCRIPT | |
622 | fi |
|
623 | fi | |
623 | done |
|
624 | done | |
624 | EOF |
|
625 | EOF | |
625 | rm -rf "${R}/chroot_scripts" |
|
626 | rm -rf "${R}/chroot_scripts" | |
626 | fi |
|
627 | fi | |
627 |
|
628 | |||
628 | # Remove c/c++ build environment from the chroot |
|
629 | # Remove c/c++ build environment from the chroot | |
629 | chroot_remove_cc |
|
630 | chroot_remove_cc | |
630 |
|
631 | |||
631 | # Generate required machine-id |
|
632 | # Generate required machine-id | |
632 | MACHINE_ID=$(dbus-uuidgen) |
|
633 | MACHINE_ID=$(dbus-uuidgen) | |
633 | echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id" |
|
634 | echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id" | |
634 | echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id" |
|
635 | echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id" | |
635 |
|
636 | |||
636 | # APT Cleanup |
|
637 | # APT Cleanup | |
637 | chroot_exec apt-get -y clean |
|
638 | chroot_exec apt-get -y clean | |
638 | chroot_exec apt-get -y autoclean |
|
639 | chroot_exec apt-get -y autoclean | |
639 | chroot_exec apt-get -y autoremove |
|
640 | chroot_exec apt-get -y autoremove | |
640 |
|
641 | |||
641 | # Unmount mounted filesystems |
|
642 | # Unmount mounted filesystems | |
642 | umount -l "${R}/proc" |
|
643 | umount -l "${R}/proc" | |
643 | umount -l "${R}/sys" |
|
644 | umount -l "${R}/sys" | |
644 |
|
645 | |||
645 | # Clean up directories |
|
646 | # Clean up directories | |
646 | rm -rf "${R}/run/*" |
|
647 | rm -rf "${R}/run/*" | |
647 | rm -rf "${R}/tmp/*" |
|
648 | rm -rf "${R}/tmp/*" | |
648 |
|
649 | |||
649 | # Clean up files |
|
650 | # Clean up files | |
650 | rm -f "${ETC_DIR}/ssh/ssh_host_*" |
|
651 | rm -f "${ETC_DIR}/ssh/ssh_host_*" | |
651 | rm -f "${ETC_DIR}/dropbear/dropbear_*" |
|
652 | rm -f "${ETC_DIR}/dropbear/dropbear_*" | |
652 | rm -f "${ETC_DIR}/apt/sources.list.save" |
|
653 | rm -f "${ETC_DIR}/apt/sources.list.save" | |
653 | rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original" |
|
654 | rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original" | |
654 | rm -f "${ETC_DIR}/*-" |
|
655 | rm -f "${ETC_DIR}/*-" | |
655 | rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy" |
|
656 | rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy" | |
656 | rm -f "${ETC_DIR}/resolv.conf" |
|
657 | rm -f "${ETC_DIR}/resolv.conf" | |
657 | rm -f "${R}/root/.bash_history" |
|
658 | rm -f "${R}/root/.bash_history" | |
658 | rm -f "${R}/var/lib/urandom/random-seed" |
|
659 | rm -f "${R}/var/lib/urandom/random-seed" | |
659 | rm -f "${R}/initrd.img" |
|
660 | rm -f "${R}/initrd.img" | |
660 | rm -f "${R}/vmlinuz" |
|
661 | rm -f "${R}/vmlinuz" | |
661 | rm -f "${R}${QEMU_BINARY}" |
|
662 | rm -f "${R}${QEMU_BINARY}" | |
662 |
|
663 | |||
663 | if [ "$ENABLE_QEMU" = true ] ; then |
|
664 | if [ "$ENABLE_QEMU" = true ] ; then | |
664 | # Setup QEMU directory |
|
665 | # Setup QEMU directory | |
665 | mkdir "${BASEDIR}/qemu" |
|
666 | mkdir "${BASEDIR}/qemu" | |
666 |
|
667 | |||
667 | # Copy kernel image to QEMU directory |
|
668 | # Copy kernel image to QEMU directory | |
668 | install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}" |
|
669 | install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}" | |
669 |
|
670 | |||
670 | # Copy kernel config to QEMU directory |
|
671 | # Copy kernel config to QEMU directory | |
671 | install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}" |
|
672 | install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}" | |
672 |
|
673 | |||
673 | # Copy kernel dtbs to QEMU directory |
|
674 | # Copy kernel dtbs to QEMU directory | |
674 | for dtb in "${BOOT_DIR}/"*.dtb ; do |
|
675 | for dtb in "${BOOT_DIR}/"*.dtb ; do | |
675 | if [ -f "${dtb}" ] ; then |
|
676 | if [ -f "${dtb}" ] ; then | |
676 | install_readonly "${dtb}" "${BASEDIR}/qemu/" |
|
677 | install_readonly "${dtb}" "${BASEDIR}/qemu/" | |
677 | fi |
|
678 | fi | |
678 | done |
|
679 | done | |
679 |
|
680 | |||
680 | # Copy kernel overlays to QEMU directory |
|
681 | # Copy kernel overlays to QEMU directory | |
681 | if [ -d "${BOOT_DIR}/overlays" ] ; then |
|
682 | if [ -d "${BOOT_DIR}/overlays" ] ; then | |
682 | # Setup overlays dtbs directory |
|
683 | # Setup overlays dtbs directory | |
683 | mkdir "${BASEDIR}/qemu/overlays" |
|
684 | mkdir "${BASEDIR}/qemu/overlays" | |
684 |
|
685 | |||
685 | for dtb in "${BOOT_DIR}/overlays/"*.dtb ; do |
|
686 | for dtb in "${BOOT_DIR}/overlays/"*.dtb ; do | |
686 | if [ -f "${dtb}" ] ; then |
|
687 | if [ -f "${dtb}" ] ; then | |
687 | install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/" |
|
688 | install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/" | |
688 | fi |
|
689 | fi | |
689 | done |
|
690 | done | |
690 | fi |
|
691 | fi | |
691 |
|
692 | |||
692 | # Copy u-boot files to QEMU directory |
|
693 | # Copy u-boot files to QEMU directory | |
693 | if [ "$ENABLE_UBOOT" = true ] ; then |
|
694 | if [ "$ENABLE_UBOOT" = true ] ; then | |
694 | if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then |
|
695 | if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then | |
695 | install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin" |
|
696 | install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin" | |
696 | fi |
|
697 | fi | |
697 | if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then |
|
698 | if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then | |
698 | install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage" |
|
699 | install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage" | |
699 | fi |
|
700 | fi | |
700 | if [ -f "${BOOT_DIR}/boot.scr" ] ; then |
|
701 | if [ -f "${BOOT_DIR}/boot.scr" ] ; then | |
701 | install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr" |
|
702 | install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr" | |
702 | fi |
|
703 | fi | |
703 | fi |
|
704 | fi | |
704 |
|
705 | |||
705 | # Copy initramfs to QEMU directory |
|
706 | # Copy initramfs to QEMU directory | |
706 | if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then |
|
707 | if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then | |
707 | install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}" |
|
708 | install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}" | |
708 | fi |
|
709 | fi | |
709 | fi |
|
710 | fi | |
710 |
|
711 | |||
711 | # Calculate size of the chroot directory in KB |
|
712 | # Calculate size of the chroot directory in KB | |
712 | CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')") |
|
713 | CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')") | |
713 |
|
714 | |||
714 | # Calculate the amount of needed 512 Byte sectors |
|
715 | # Calculate the amount of needed 512 Byte sectors | |
715 | TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512) |
|
716 | TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512) | |
716 | FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512) |
|
717 | FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512) | |
717 | ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}") |
|
718 | ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}") | |
718 |
|
719 | |||
719 | # The root partition is EXT4 |
|
720 | # The root partition is EXT4 | |
720 | # This means more space than the actual used space of the chroot is used. |
|
721 | # This means more space than the actual used space of the chroot is used. | |
721 | # As overhead for journaling and reserved blocks 35% are added. |
|
722 | # As overhead for journaling and reserved blocks 35% are added. | |
722 | ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512) |
|
723 | ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512) | |
723 |
|
724 | |||
724 | # Calculate required image size in 512 Byte sectors |
|
725 | # Calculate required image size in 512 Byte sectors | |
725 | IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}") |
|
726 | IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}") | |
726 |
|
727 | |||
727 | # Prepare image file |
|
728 | # Prepare image file | |
728 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
729 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
729 | dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}" |
|
730 | dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}" | |
730 | dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}" |
|
731 | dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}" | |
731 | dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}" |
|
732 | dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}" | |
732 | dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}" |
|
733 | dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}" | |
733 |
|
734 | |||
734 | # Write firmware/boot partition tables |
|
735 | # Write firmware/boot partition tables | |
735 | sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM |
|
736 | sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM | |
736 | ${TABLE_SECTORS},${FRMW_SECTORS},c,* |
|
737 | ${TABLE_SECTORS},${FRMW_SECTORS},c,* | |
737 | EOM |
|
738 | EOM | |
738 |
|
739 | |||
739 | # Write root partition table |
|
740 | # Write root partition table | |
740 | sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM |
|
741 | sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM | |
741 | ${TABLE_SECTORS},${ROOT_SECTORS},83 |
|
742 | ${TABLE_SECTORS},${ROOT_SECTORS},83 | |
742 | EOM |
|
743 | EOM | |
743 |
|
744 | |||
744 | # Setup temporary loop devices |
|
745 | # Setup temporary loop devices | |
745 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME"-frmw.img)" |
|
746 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME"-frmw.img)" | |
746 | ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME"-root.img)" |
|
747 | ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME"-root.img)" | |
747 | else # ENABLE_SPLITFS=false |
|
748 | else # ENABLE_SPLITFS=false | |
748 | dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}" |
|
749 | dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}" | |
749 | dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}" |
|
750 | dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}" | |
750 |
|
751 | |||
751 | # Write partition table |
|
752 | # Write partition table | |
752 | sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM |
|
753 | sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM | |
753 | ${TABLE_SECTORS},${FRMW_SECTORS},c,* |
|
754 | ${TABLE_SECTORS},${FRMW_SECTORS},c,* | |
754 | ${ROOT_OFFSET},${ROOT_SECTORS},83 |
|
755 | ${ROOT_OFFSET},${ROOT_SECTORS},83 | |
755 | EOM |
|
756 | EOM | |
756 |
|
757 | |||
757 | # Setup temporary loop devices |
|
758 | # Setup temporary loop devices | |
758 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME".img)" |
|
759 | FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME".img)" | |
759 | ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME".img)" |
|
760 | ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME".img)" | |
760 | fi |
|
761 | fi | |
761 |
|
762 | |||
762 | if [ "$ENABLE_CRYPTFS" = true ] ; then |
|
763 | if [ "$ENABLE_CRYPTFS" = true ] ; then | |
763 | # Create dummy ext4 fs |
|
764 | # Create dummy ext4 fs | |
764 | mkfs.ext4 "$ROOT_LOOP" |
|
765 | mkfs.ext4 "$ROOT_LOOP" | |
765 |
|
766 | |||
766 | # Setup password keyfile |
|
767 | # Setup password keyfile | |
767 | touch .password |
|
768 | touch .password | |
768 | chmod 600 .password |
|
769 | chmod 600 .password | |
769 | echo -n ${CRYPTFS_PASSWORD} > .password |
|
770 | echo -n ${CRYPTFS_PASSWORD} > .password | |
770 |
|
771 | |||
771 | # Initialize encrypted partition |
|
772 | # Initialize encrypted partition | |
772 | echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password |
|
773 | echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password | |
773 |
|
774 | |||
774 | # Open encrypted partition and setup mapping |
|
775 | # Open encrypted partition and setup mapping | |
775 | cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}" |
|
776 | cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}" | |
776 |
|
777 | |||
777 | # Secure delete password keyfile |
|
778 | # Secure delete password keyfile | |
778 | shred -zu .password |
|
779 | shred -zu .password | |
779 |
|
780 | |||
780 | # Update temporary loop device |
|
781 | # Update temporary loop device | |
781 | ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}" |
|
782 | ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}" | |
782 |
|
783 | |||
783 | # Wipe encrypted partition (encryption cipher is used for randomness) |
|
784 | # Wipe encrypted partition (encryption cipher is used for randomness) | |
784 | dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")" |
|
785 | dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")" | |
785 | fi |
|
786 | fi | |
786 |
|
787 | |||
787 | # Build filesystems |
|
788 | # Build filesystems | |
788 | mkfs.vfat "$FRMW_LOOP" |
|
789 | mkfs.vfat "$FRMW_LOOP" | |
789 | mkfs.ext4 "$ROOT_LOOP" |
|
790 | mkfs.ext4 "$ROOT_LOOP" | |
790 |
|
791 | |||
791 | # Mount the temporary loop devices |
|
792 | # Mount the temporary loop devices | |
792 | mkdir -p "$BUILDDIR/mount" |
|
793 | mkdir -p "$BUILDDIR/mount" | |
793 | mount "$ROOT_LOOP" "$BUILDDIR/mount" |
|
794 | mount "$ROOT_LOOP" "$BUILDDIR/mount" | |
794 |
|
795 | |||
795 | mkdir -p "$BUILDDIR/mount/boot/firmware" |
|
796 | mkdir -p "$BUILDDIR/mount/boot/firmware" | |
796 | mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware" |
|
797 | mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware" | |
797 |
|
798 | |||
798 | # Copy all files from the chroot to the loop device mount point directory |
|
799 | # Copy all files from the chroot to the loop device mount point directory | |
799 | rsync -a "${R}/" "$BUILDDIR/mount/" |
|
800 | rsync -a "${R}/" "$BUILDDIR/mount/" | |
800 |
|
801 | |||
801 | # Unmount all temporary loop devices and mount points |
|
802 | # Unmount all temporary loop devices and mount points | |
802 | cleanup |
|
803 | cleanup | |
803 |
|
804 | |||
804 | # Create block map file(s) of image(s) |
|
805 | # Create block map file(s) of image(s) | |
805 | if [ "$ENABLE_SPLITFS" = true ] ; then |
|
806 | if [ "$ENABLE_SPLITFS" = true ] ; then | |
806 | # Create block map files for "bmaptool" |
|
807 | # Create block map files for "bmaptool" | |
807 | bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img" |
|
808 | bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img" | |
808 | bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img" |
|
809 | bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img" | |
809 |
|
810 | |||
810 | # Image was successfully created |
|
811 | # Image was successfully created | |
811 | echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" |
|
812 | echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" | |
812 | echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" |
|
813 | echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" | |
813 | else |
|
814 | else | |
814 | # Create block map file for "bmaptool" |
|
815 | # Create block map file for "bmaptool" | |
815 | bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img" |
|
816 | bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img" | |
816 |
|
817 | |||
817 | # Image was successfully created |
|
818 | # Image was successfully created | |
818 | echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" |
|
819 | echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created" | |
819 |
|
820 | |||
820 | # Create qemu qcow2 image |
|
821 | # Create qemu qcow2 image | |
821 | if [ "$ENABLE_QEMU" = true ] ; then |
|
822 | if [ "$ENABLE_QEMU" = true ] ; then | |
822 | QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} |
|
823 | QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}} | |
823 | QEMU_SIZE=16G |
|
824 | QEMU_SIZE=16G | |
824 |
|
825 | |||
825 | qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2 |
|
826 | qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2 | |
826 | qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE |
|
827 | qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE | |
827 |
|
828 | |||
828 | echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created" |
|
829 | echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created" | |
829 | fi |
|
830 | fi | |
830 | fi |
|
831 | fi |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant