##// END OF EJS Templates
Merge remote-tracking branch 'origin/ref+fix' into ref+fix
Unknown -
r311:34ec6150691e Fusion
parent child
Show More
@@ -1,68 +1,48
1 #
1 #
2 # Setup APT repositories
2 # Setup APT repositories
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 # Install and setup APT proxy configuration
8 # Install and setup APT proxy configuration
9 if [ -z "$APT_PROXY" ] ; then
9 if [ -z "$APT_PROXY" ] ; then
10 install_readonly files/apt/10proxy "${ETC_DIR}/apt/apt.conf.d/10proxy"
10 install_readonly files/apt/10proxy "${ETC_DIR}/apt/apt.conf.d/10proxy"
11 sed -i "s/\"\"/\"${APT_PROXY}\"/" "${ETC_DIR}/apt/apt.conf.d/10proxy"
11 sed -i "s/\"\"/\"${APT_PROXY}\"/" "${ETC_DIR}/apt/apt.conf.d/10proxy"
12 fi
12 fi
13
13
14 if [ "$BUILD_KERNEL" = false ] ; then
14 if [ "$BUILD_KERNEL" = false ] ; then
15 if [ "$RPI_MODEL" = 2 ] ; then
15 echo "Downloading precompiled kernel"
16 # Install APT pinning configuration for flash-kernel package
16 echo "error: not configured"
17 install_readonly files/apt/flash-kernel "${ETC_DIR}/apt/preferences.d/flash-kernel"
17 exit 1;
18
19 # Install APT sources.list
20 install_readonly files/apt/sources.list "${ETC_DIR}/apt/sources.list"
21 echo "deb ${COLLABORA_URL} ${RELEASE} rpi2" >> "${ETC_DIR}/apt/sources.list"
22
23 # Upgrade collabora package index and install collabora keyring
24 chroot_exec apt-get -qq -y update
25 chroot_exec apt-get -qq -y --allow-unauthenticated install collabora-obs-archive-keyring
26 # if RPI_MODEL = [0] || [1] || [1P]
27 else
28 echo "error: ATM there is just a precompiled kernel for model 2";
29 # insert apt configuration for precompiled kernel repository for RPI 0,1,1P
30 fi
31
32 else # BUILD_KERNEL=true
18 else # BUILD_KERNEL=true
33 #autconfigure best apt server to not spam ftp.debian.org
19 #autconfigure best apt server to not spam ftp.debian.org
34 rm files/apt/sources.list
20 #rm files/apt/sources.list
35 #netselect-apt does not know buster yet
21 #netselect-apt does not know buster yet
36 if [ "$RELEASE" = "buster" ] ; then
22 if [ "$RELEASE" = "buster" ] ; then
37 RLS = "testing"
23 RELEASE=${RELEASE:=testing}
38 fi
24 fi
39
25 netselect_string=${netselect_string:=""}
40 if [ "$ENABLE_NONFREE" ] ; then
26 if [ "$ENABLE_NONFREE" = true ] ; then
41 netselect-apt --arch "$RELEASE_ARCH" --sources --nonfree --outfile "${ETC_DIR}/apt/sources.list" -d "$RELEASE"
27 netselect-apt --arch "$RELEASE_ARCH" --sources "$netselect_string" --outfile "${ETC_DIR}/apt/sources.list" -d "$RLS"
42 else
43 netselect-apt --arch "$RELEASE_ARCH" --sources --nonfree --outfile "${ETC_DIR}/apt/sources.list" -d "$RELEASE"
44 fi
28 fi
45 fi
29 netselect-apt --arch "$RELEASE_ARCH" --sources "$netselect_string" --outfile "${ETC_DIR}/apt/sources.list" -d "$RLS"
46
47 # Allow the installation of non-free Debian packages
48 if [ "$ENABLE_NONFREE" = true ] ; then
49 sed -i "s/ contrib/ contrib non-free/" "${ETC_DIR}/apt/sources.list"
50 fi
30 fi
51
31
52 # Upgrade package index and update all installed packages and changed dependencies
32 # Upgrade package index and update all installed packages and changed dependencies
53 chroot_exec apt-get -qq -y update
33 chroot_exec apt-get -qq -y update
54 chroot_exec apt-get -qq -y -u dist-upgrade
34 chroot_exec apt-get -qq -y -u dist-upgrade
55
35
56 if [ "$APT_INCLUDES_LATE" ] ; then
36 if [ "$APT_INCLUDES_LATE" ] ; then
57 chroot_exec apt-get -qq -y install $(echo $APT_INCLUDES_LATE |tr , ' ')
37 chroot_exec apt-get -qq -y install "$(echo "$APT_INCLUDES_LATE" |tr , ' ')"
58 fi
38 fi
59
39
60 if [ -d packages ] ; then
40 if [ -d packages ] ; then
61 for package in packages/*.deb ; do
41 for package in packages/*.deb ; do
62 cp $package ${R}/tmp
42 cp "$package" "${R}"/tmp
63 chroot_exec dpkg --unpack /tmp/$(basename $package)
43 chroot_exec dpkg --unpack /tmp/"$(basename "$package")"
64 done
44 done
65 fi
45 fi
66 chroot_exec apt-get -qq -y -f install
46 chroot_exec apt-get -qq -y -f install
67
47
68 chroot_exec apt-get -qq -y check
48 chroot_exec apt-get -qq -y check
@@ -1,58 +1,59
1 #
1 #
2 # Setup Locales and keyboard settings
2 # Setup Locales and keyboard settings
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 # Install and setup timezone
8 # Install and setup timezone
9 echo ${TIMEZONE} > "${ETC_DIR}/timezone"
9 echo "${TIMEZONE}" > "${ETC_DIR}/timezone"
10 chroot_exec dpkg-reconfigure -f noninteractive tzdata
10 chroot_exec dpkg-reconfigure -f noninteractive tzdata
11
11
12 # Install and setup default locale and keyboard configuration
12 # Install and setup default locale and keyboard configuration
13 if [ $(echo "$APT_INCLUDES" | grep ",locales") ] ; then
13
14 if [ "$(echo "$APT_INCLUDES" | grep ",locales")" ] ; then
14 # Set locale choice in debconf db, even though dpkg-reconfigure ignores and overwrites them due to some bug
15 # Set locale choice in debconf db, even though dpkg-reconfigure ignores and overwrites them due to some bug
15 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=684134 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=685957
16 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=684134 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=685957
16 # ... so we have to set locales manually
17 # ... so we have to set locales manually
17 if [ "$DEFLOCAL" = "en_US.UTF-8" ] ; then
18 if [ "$DEFLOCAL" = "en_US.UTF-8" ] ; then
18 chroot_exec echo "locales locales/locales_to_be_generated multiselect ${DEFLOCAL} UTF-8" | debconf-set-selections
19 chroot_exec echo "locales locales/locales_to_be_generated multiselect ${DEFLOCAL} UTF-8" | debconf-set-selections
19 else
20 else
20 # en_US.UTF-8 should be available anyway : https://www.debian.org/doc/manuals/debian-reference/ch08.en.html#_the_reconfiguration_of_the_locale
21 # en_US.UTF-8 should be available anyway : https://www.debian.org/doc/manuals/debian-reference/ch08.en.html#_the_reconfiguration_of_the_locale
21 chroot_exec echo "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8, ${DEFLOCAL} UTF-8" | debconf-set-selections
22 chroot_exec echo "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8, ${DEFLOCAL} UTF-8" | debconf-set-selections
22 sed -i "/en_US.UTF-8/s/^#//" "${ETC_DIR}/locale.gen"
23 sed -i "/en_US.UTF-8/s/^#//" "${ETC_DIR}/locale.gen"
23 fi
24 fi
24
25
25 sed -i "/${DEFLOCAL}/s/^#//" "${ETC_DIR}/locale.gen"
26 sed -i "/${DEFLOCAL}/s/^#//" "${ETC_DIR}/locale.gen"
26 chroot_exec echo "locales locales/default_environment_locale select ${DEFLOCAL}" | debconf-set-selections
27 chroot_exec echo "locales locales/default_environment_locale select ${DEFLOCAL}" | debconf-set-selections
27 chroot_exec locale-gen
28 chroot_exec locale-gen
28 chroot_exec update-locale LANG="${DEFLOCAL}"
29 chroot_exec update-locale LANG="${DEFLOCAL}"
29
30
30 # Install and setup default keyboard configuration
31 # Install and setup default keyboard configuration
31 if [ "$XKB_MODEL" != "pc105" ] ; then
32 if [ "$XKB_MODEL" != "pc105" ] ; then
32 sed -i "s/^XKBMODEL.*/XKBMODEL=\"${XKB_MODEL}\"/" "${ETC_DIR}/default/keyboard"
33 sed -i "s/^XKBMODEL.*/XKBMODEL=\"${XKB_MODEL}\"/" "${ETC_DIR}/default/keyboard"
33 fi
34 fi
34 if [ "$XKB_LAYOUT" != "us" ] ; then
35 if [ "$XKB_LAYOUT" != "us" ] ; then
35 sed -i "s/^XKBLAYOUT.*/XKBLAYOUT=\"${XKB_LAYOUT}\"/" "${ETC_DIR}/default/keyboard"
36 sed -i "s/^XKBLAYOUT.*/XKBLAYOUT=\"${XKB_LAYOUT}\"/" "${ETC_DIR}/default/keyboard"
36 fi
37 fi
37 if [ "$XKB_VARIANT" != "" ] ; then
38 if [ "$XKB_VARIANT" != "" ] ; then
38 sed -i "s/^XKBVARIANT.*/XKBVARIANT=\"${XKB_VARIANT}\"/" "${ETC_DIR}/default/keyboard"
39 sed -i "s/^XKBVARIANT.*/XKBVARIANT=\"${XKB_VARIANT}\"/" "${ETC_DIR}/default/keyboard"
39 fi
40 fi
40 if [ "$XKB_OPTIONS" != "" ] ; then
41 if [ "$XKB_OPTIONS" != "" ] ; then
41 sed -i "s/^XKBOPTIONS.*/XKBOPTIONS=\"${XKB_OPTIONS}\"/" "${ETC_DIR}/default/keyboard"
42 sed -i "s/^XKBOPTIONS.*/XKBOPTIONS=\"${XKB_OPTIONS}\"/" "${ETC_DIR}/default/keyboard"
42 fi
43 fi
43 chroot_exec dpkg-reconfigure -f noninteractive keyboard-configuration
44 chroot_exec dpkg-reconfigure -f noninteractive keyboard-configuration
44
45
45 # Install and setup font console
46 # Install and setup font console
46 case "${DEFLOCAL}" in
47 case "${DEFLOCAL}" in
47 *UTF-8)
48 *UTF-8)
48 sed -i 's/^CHARMAP.*/CHARMAP="UTF-8"/' "${ETC_DIR}/default/console-setup"
49 sed -i 's/^CHARMAP.*/CHARMAP="UTF-8"/' "${ETC_DIR}/default/console-setup"
49 ;;
50 ;;
50 *)
51 *)
51 sed -i 's/^CHARMAP.*/CHARMAP="guess"/' "${ETC_DIR}/default/console-setup"
52 sed -i 's/^CHARMAP.*/CHARMAP="guess"/' "${ETC_DIR}/default/console-setup"
52 ;;
53 ;;
53 esac
54 esac
54 chroot_exec dpkg-reconfigure -f noninteractive console-setup
55 chroot_exec dpkg-reconfigure -f noninteractive console-setup
55 else # (no locales were installed)
56 else # (no locales were installed)
56 # Install POSIX default locale
57 # Install POSIX default locale
57 install_readonly files/locales/locale "${ETC_DIR}/default/locale"
58 install_readonly files/locales/locale "${ETC_DIR}/default/locale"
58 fi
59 fi
@@ -1,270 +1,257
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 "${R}/usr/src/linux"
11 mkdir -p "${R}/usr/src/linux"
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}/". "${R}/usr/src/linux"
16 cp -r "${KERNELSRC_DIR}/". "${R}/usr/src/linux"
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/"* "${R}/usr/src/linux/"
34 cp -r "${temp_dir}/linux/"* "${R}/usr/src/linux/"
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 # Set kernel configuration parameters to enable qemu emulation
90 # Set kernel configuration parameters to enable qemu emulation
91 if [ "$ENABLE_QEMU" = true ] ; then
91 if [ "$ENABLE_QEMU" = true ] ; then
92 echo "CONFIG_FHANDLE=y" >> ${KERNEL_DIR}/.config
92 echo "CONFIG_FHANDLE=y" >> "${KERNEL_DIR}"/.config
93 echo "CONFIG_LBDAF=y" >> ${KERNEL_DIR}/.config
93 echo "CONFIG_LBDAF=y" >> "${KERNEL_DIR}"/.config
94
94
95 if [ "$ENABLE_CRYPTFS" = true ] ; then
95 if [ "$ENABLE_CRYPTFS" = true ] ; then
96 echo "CONFIG_EMBEDDED=y" >> ${KERNEL_DIR}/.config
96 echo "CONFIG_EMBEDDED=y" >> "${KERNEL_DIR}"/.config
97 echo "CONFIG_EXPERT=y" >> ${KERNEL_DIR}/.config
97 echo "CONFIG_EXPERT=y" >> "${KERNEL_DIR}"/.config
98 echo "CONFIG_DAX=y" >> ${KERNEL_DIR}/.config
98 echo "CONFIG_DAX=y" >> "${KERNEL_DIR}"/.config
99 echo "CONFIG_MD=y" >> ${KERNEL_DIR}/.config
99 echo "CONFIG_MD=y" >> "${KERNEL_DIR}"/.config
100 echo "CONFIG_BLK_DEV_MD=y" >> ${KERNEL_DIR}/.config
100 echo "CONFIG_BLK_DEV_MD=y" >> "${KERNEL_DIR}"/.config
101 echo "CONFIG_MD_AUTODETECT=y" >> ${KERNEL_DIR}/.config
101 echo "CONFIG_MD_AUTODETECT=y" >> "${KERNEL_DIR}"/.config
102 echo "CONFIG_BLK_DEV_DM=y" >> ${KERNEL_DIR}/.config
102 echo "CONFIG_BLK_DEV_DM=y" >> "${KERNEL_DIR}"/.config
103 echo "CONFIG_BLK_DEV_DM_BUILTIN=y" >> ${KERNEL_DIR}/.config
103 echo "CONFIG_BLK_DEV_DM_BUILTIN=y" >> "${KERNEL_DIR}"/.config
104 echo "CONFIG_DM_CRYPT=y" >> ${KERNEL_DIR}/.config
104 echo "CONFIG_DM_CRYPT=y" >> "${KERNEL_DIR}"/.config
105 echo "CONFIG_CRYPTO_BLKCIPHER=y" >> ${KERNEL_DIR}/.config
105 echo "CONFIG_CRYPTO_BLKCIPHER=y" >> "${KERNEL_DIR}"/.config
106 echo "CONFIG_CRYPTO_CBC=y" >> ${KERNEL_DIR}/.config
106 echo "CONFIG_CRYPTO_CBC=y" >> "${KERNEL_DIR}"/.config
107 echo "CONFIG_CRYPTO_XTS=y" >> ${KERNEL_DIR}/.config
107 echo "CONFIG_CRYPTO_XTS=y" >> "${KERNEL_DIR}"/.config
108 echo "CONFIG_CRYPTO_SHA512=y" >> ${KERNEL_DIR}/.config
108 echo "CONFIG_CRYPTO_SHA512=y" >> "${KERNEL_DIR}"/.config
109 echo "CONFIG_CRYPTO_MANAGER=y" >> ${KERNEL_DIR}/.config
109 echo "CONFIG_CRYPTO_MANAGER=y" >> "${KERNEL_DIR}"/.config
110 fi
110 fi
111 fi
111 fi
112
112
113 # Copy custom kernel configuration file
113 # Copy custom kernel configuration file
114 if [ ! -z "$KERNELSRC_USRCONFIG" ] ; then
114 if [ -n "$KERNELSRC_USRCONFIG" ] ; then
115 cp $KERNELSRC_USRCONFIG ${KERNEL_DIR}/.config
115 cp "$KERNELSRC_USRCONFIG" "${KERNEL_DIR}"/.config
116 fi
116 fi
117
117
118 # Set kernel configuration parameters to their default values
118 # Set kernel configuration parameters to their default values
119 if [ "$KERNEL_OLDDEFCONFIG" = true ] ; then
119 if [ "$KERNEL_OLDDEFCONFIG" = true ] ; then
120 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" olddefconfig
120 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" olddefconfig
121 fi
121 fi
122
122
123 # Start menu-driven kernel configuration (interactive)
123 # Start menu-driven kernel configuration (interactive)
124 if [ "$KERNEL_MENUCONFIG" = true ] ; then
124 if [ "$KERNEL_MENUCONFIG" = true ] ; then
125 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig
125 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" menuconfig
126 fi
126 fi
127 fi
127 fi
128
128
129 # Use ccache to cross compile the kernel
129 # Use ccache to cross compile the kernel
130 if [ "$KERNEL_CCACHE" = true ] ; then
130 if [ "$KERNEL_CCACHE" = true ] ; then
131 cc="ccache ${CROSS_COMPILE}gcc"
131 cc="ccache ${CROSS_COMPILE}gcc"
132 else
132 else
133 cc="${CROSS_COMPILE}gcc"
133 cc="${CROSS_COMPILE}gcc"
134 fi
134 fi
135
135
136 # Cross compile kernel and dtbs
136 # Cross compile kernel and dtbs
137 make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs
137 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" "${KERNEL_BIN_IMAGE}" dtbs
138
138
139 # Cross compile kernel modules
139 # Cross compile kernel modules
140 if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
140 if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then
141 make -C "${KERNEL_DIR}" -j${KERNEL_THREADS} ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules
141 make -C "${KERNEL_DIR}" -j"${KERNEL_THREADS}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" CC="${cc}" modules
142 fi
142 fi
143 fi
143 fi
144
144
145 # Check if kernel compilation was successful
145 # Check if kernel compilation was successful
146 if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" ] ; then
146 if [ ! -r "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" ] ; then
147 echo "error: kernel compilation failed! (kernel image not found)"
147 echo "error: kernel compilation failed! (kernel image not found)"
148 cleanup
148 cleanup
149 exit 1
149 exit 1
150 fi
150 fi
151
151
152 # Install kernel modules
152 # Install kernel modules
153 if [ "$ENABLE_REDUCE" = true ] ; then
153 if [ "$ENABLE_REDUCE" = true ] ; then
154 if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
154 if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then
155 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
155 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_STRIP=1 INSTALL_MOD_PATH=../../.. modules_install
156 fi
156 fi
157 else
157 else
158 if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
158 if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then
159 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
159 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_MOD_PATH=../../.. modules_install
160 fi
160 fi
161
161
162 # Install kernel firmware
162 # Install kernel firmware
163 if [ $(grep "^firmware_install:" "${KERNEL_DIR}/Makefile") ] ; then
163 if [ "$(grep "^firmware_install:" "${KERNEL_DIR}/Makefile")" ] ; then
164 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
164 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_FW_PATH=../../../lib firmware_install
165 fi
165 fi
166 fi
166 fi
167
167
168 # Install kernel headers
168 # Install kernel headers
169 if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then
169 if [ "$KERNEL_HEADERS" = true ] && [ "$KERNEL_REDUCE" = false ] ; then
170 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install
170 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" INSTALL_HDR_PATH=../.. headers_install
171 fi
171 fi
172
172
173 # Prepare boot (firmware) directory
173 # Prepare boot (firmware) directory
174 mkdir "${BOOT_DIR}"
174 mkdir "${BOOT_DIR}"
175
175
176 # Get kernel release version
176 # Get kernel release version
177 KERNEL_VERSION=`cat "${KERNEL_DIR}/include/config/kernel.release"`
177 KERNEL_VERSION=$(cat "${KERNEL_DIR}/include/config/kernel.release")
178
178
179 # Copy kernel configuration file to the boot directory
179 # Copy kernel configuration file to the boot directory
180 install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}"
180 install_readonly "${KERNEL_DIR}/.config" "${R}/boot/config-${KERNEL_VERSION}"
181
181
182 # Prepare device tree directory
182 # Prepare device tree directory
183 mkdir "${BOOT_DIR}/overlays"
183 mkdir "${BOOT_DIR}/overlays"
184
184
185 # Ensure the proper .dtb is located
185 # Ensure the proper .dtb is located
186 if [ "$KERNEL_ARCH" = "arm" ] ; then
186 if [ "$KERNEL_ARCH" = "arm" ] ; then
187 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb ; do
187 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/"*.dtb ; do
188 if [ -f "${dtb}" ] ; then
188 if [ -f "${dtb}" ] ; then
189 install_readonly "${dtb}" "${BOOT_DIR}/"
189 install_readonly "${dtb}" "${BOOT_DIR}/"
190 fi
190 fi
191 done
191 done
192 else
192 else
193 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/broadcom/"*.dtb ; do
193 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/broadcom/"*.dtb ; do
194 if [ -f "${dtb}" ] ; then
194 if [ -f "${dtb}" ] ; then
195 install_readonly "${dtb}" "${BOOT_DIR}/"
195 install_readonly "${dtb}" "${BOOT_DIR}/"
196 fi
196 fi
197 done
197 done
198 fi
198 fi
199
199
200 # Copy compiled dtb device tree files
200 # Copy compiled dtb device tree files
201 if [ -d "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays" ] ; then
201 if [ -d "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays" ] ; then
202 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb ; do
202 for dtb in "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/"*.dtb ; do
203 if [ -f "${dtb}" ] ; then
203 if [ -f "${dtb}" ] ; then
204 install_readonly "${dtb}" "${BOOT_DIR}/overlays/"
204 install_readonly "${dtb}" "${BOOT_DIR}/overlays/"
205 fi
205 fi
206 done
206 done
207
207
208 if [ -f "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" ] ; then
208 if [ -f "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" ] ; then
209 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README"
209 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/dts/overlays/README" "${BOOT_DIR}/overlays/README"
210 fi
210 fi
211 fi
211 fi
212
212
213 if [ "$ENABLE_UBOOT" = false ] ; then
213 if [ "$ENABLE_UBOOT" = false ] ; then
214 # Convert and copy kernel image to the boot directory
214 # Convert and copy kernel image to the boot directory
215 "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}"
215 "${KERNEL_DIR}/scripts/mkknlimg" "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}"
216 else
216 else
217 # Copy kernel image to the boot directory
217 # Copy kernel image to the boot directory
218 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}"
218 install_readonly "${KERNEL_DIR}/arch/${KERNEL_ARCH}/boot/${KERNEL_BIN_IMAGE}" "${BOOT_DIR}/${KERNEL_IMAGE}"
219 fi
219 fi
220
220
221 # Remove kernel sources
221 # Remove kernel sources
222 if [ "$KERNEL_REMOVESRC" = true ] ; then
222 if [ "$KERNEL_REMOVESRC" = true ] ; then
223 rm -fr "${KERNEL_DIR}"
223 rm -fr "${KERNEL_DIR}"
224 else
224 else
225 # Prepare compiled kernel modules
225 # Prepare compiled kernel modules
226 if [ $(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config") ] ; then
226 if [ "$(grep "CONFIG_MODULES=y" "${KERNEL_DIR}/.config")" ] ; then
227 if [ $(grep "^modules_prepare:" "${KERNEL_DIR}/Makefile") ] ; then
227 if [ "$(grep "^modules_prepare:" "${KERNEL_DIR}/Makefile")" ] ; then
228 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
228 make -C "${KERNEL_DIR}" ARCH="${KERNEL_ARCH}" CROSS_COMPILE="${CROSS_COMPILE}" modules_prepare
229 fi
229 fi
230
230
231 # Create symlinks for kernel modules
231 # Create symlinks for kernel modules
232 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/build"
232 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/build"
233 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/source"
233 chroot_exec ln -sf /usr/src/linux "/lib/modules/${KERNEL_VERSION}/source"
234 fi
234 fi
235 fi
235 fi
236 elif [ "$BUILD_KERNEL" = false ] ; then
236 elif [ "$BUILD_KERNEL" = false ] ; then
237 # Collabora states this kernel is just for RPI 2 so better implement a check.
237 echo " Install precompiled kernel..."
238 #From https://repositories.collabora.co.uk/debian/dists/jessie/rpi2/binary-armhf/Packages
238 echo "error: not implemented"
239 #"The Linux kernel "${COLLABORA_KERNEL}" and modules for use on ARMv7 kernel for Raspberry pi 2 model B+"
239 # Check if kernel installation was successful
240 # nested if to be easily extended for more precompiled kernels
240 VMLINUZ="$(ls -1 "${R}"/boot/vmlinuz-* | sort | tail -n 1)"
241 if [ "$SET_ARCH" = 32 ] ; then
241 if [ -z "$VMLINUZ" ] ; then
242 if [ "$RPI_MODEL" = 2 ] ; then
242 echo "error: kernel installation failed! (/boot/vmlinuz-* not found)"
243 # Kernel installation
243 cleanup
244 chroot_exec apt-get -qq -y --no-install-recommends install linux-image-"${COLLABORA_KERNEL}" raspberrypi-bootloader-nokernel
244 exit 1
245
245 fi
246 # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot
246 # Copy vmlinuz kernel to the boot directory
247 chroot_exec apt-get -qq -y install flash-kernel
247 install_readonly "${VMLINUZ}" "${BOOT_DIR}/${KERNEL_IMAGE}"
248
248
249 # Check if kernel installation was successful
249 if [ "$SET_ARCH" = 64 ] ; then
250 VMLINUZ="$(ls -1 ${R}/boot/vmlinuz-* | sort | tail -n 1)"
250 echo "Using precompiled arm64 kernel"
251 if [ -z "$VMLINUZ" ] ; then
252 echo "error: kernel installation failed! (/boot/vmlinuz-* not found)"
253 cleanup
254 exit 1
255 fi
256 # Copy vmlinuz kernel to the boot directory
257 install_readonly "${VMLINUZ}" "${BOOT_DIR}/${KERNEL_IMAGE}"
258 fi
259 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then
260 echo "error: no precompiled kernel found"
261 exit 1
262 # insert precompiled Kernel code here
263 fi
264 #if [ "$SET_ARCH" = 64 ]
265 else
251 else
266 echo "error: no precompiled 64bit kernel found"
252 echo "error: no precompiled arm64 (bcmrpi3) kernel found"
267 exit 1
253 exit 1
268 # inset precompiled 64 bit kernel code here
254 # inset precompiled 64 bit kernel code here
269 fi
255 fi
256 #fi build_kernel=true
270 fi
257 fi
@@ -1,49 +1,52
1 #
1 #
2 # Setup Firewall
2 # Setup Firewall
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 if [ "$ENABLE_IPTABLES" = true ] ; then
8 if [ "$ENABLE_IPTABLES" = true ] ; then
9 # Create iptables configuration directory
9 # Create iptables configuration directory
10 mkdir -p "${ETC_DIR}/iptables"
10 mkdir -p "${ETC_DIR}/iptables"
11
11
12 #In Jessie iptables is old enough
13 if ! [ "$RELEASE" = jessie ] ; then
12 # make sure iptables-legacy,iptables-legacy-restore and iptables-legacy-save are the used alternatives
14 # make sure iptables-legacy,iptables-legacy-restore and iptables-legacy-save are the used alternatives
13 chroot_exec update-alternatives --verbose --set iptables /usr/sbin/iptables-legacy
15 chroot_exec update-alternatives --verbose --set iptables /usr/sbin/iptables-legacy
14 chroot_exec update-alternatives --verbose --set iptables-save /usr/sbin/iptables-legacy-save
16 #chroot_exec update-alternatives --verbose --set iptables-save /usr/sbin/iptables-legacy-save
15 chroot_exec update-alternatives --verbose --set iptables-restore /usr/sbin/iptables-legacy-restore
17 #chroot_exec update-alternatives --verbose --set iptables-restore /usr/sbin/iptables-legacy-restore
16
18 fi
19
17 # Install iptables systemd service
20 # Install iptables systemd service
18 install_readonly files/iptables/iptables.service "${ETC_DIR}/systemd/system/iptables.service"
21 install_readonly files/iptables/iptables.service "${ETC_DIR}/systemd/system/iptables.service"
19
22
20 # Install flush-table script called by iptables service
23 # Install flush-table script called by iptables service
21 install_exec files/iptables/flush-iptables.sh "${ETC_DIR}/iptables/flush-iptables.sh"
24 install_exec files/iptables/flush-iptables.sh "${ETC_DIR}/iptables/flush-iptables.sh"
22
25
23 # Install iptables rule file
26 # Install iptables rule file
24 install_readonly files/iptables/iptables.rules "${ETC_DIR}/iptables/iptables.rules"
27 install_readonly files/iptables/iptables.rules "${ETC_DIR}/iptables/iptables.rules"
25
28
26 # Reload systemd configuration and enable iptables service
29 # Reload systemd configuration and enable iptables service
27 chroot_exec systemctl daemon-reload
30 chroot_exec systemctl daemon-reload
28 chroot_exec systemctl enable iptables.service
31 chroot_exec systemctl enable iptables.service
29
32
30 if [ "$ENABLE_IPV6" = true ] ; then
33 if [ "$ENABLE_IPV6" = true ] ; then
31 # Install ip6tables systemd service
34 # Install ip6tables systemd service
32 install_readonly files/iptables/ip6tables.service "${ETC_DIR}/systemd/system/ip6tables.service"
35 install_readonly files/iptables/ip6tables.service "${ETC_DIR}/systemd/system/ip6tables.service"
33
36
34 # Install ip6tables file
37 # Install ip6tables file
35 install_exec files/iptables/flush-ip6tables.sh "${ETC_DIR}/iptables/flush-ip6tables.sh"
38 install_exec files/iptables/flush-ip6tables.sh "${ETC_DIR}/iptables/flush-ip6tables.sh"
36
39
37 install_readonly files/iptables/ip6tables.rules "${ETC_DIR}/iptables/ip6tables.rules"
40 install_readonly files/iptables/ip6tables.rules "${ETC_DIR}/iptables/ip6tables.rules"
38
41
39 # Reload systemd configuration and enable iptables service
42 # Reload systemd configuration and enable iptables service
40 chroot_exec systemctl daemon-reload
43 chroot_exec systemctl daemon-reload
41 chroot_exec systemctl enable ip6tables.service
44 chroot_exec systemctl enable ip6tables.service
42 fi
45 fi
43
46
44 if [ "$ENABLE_SSHD" = false ] ; then
47 if [ "$ENABLE_SSHD" = false ] ; then
45 # Remove SSHD related iptables rules
48 # Remove SSHD related iptables rules
46 sed -i "/^#/! {/SSH/ s/^/# /}" "${ETC_DIR}/iptables/iptables.rules" 2> /dev/null
49 sed -i "/^#/! {/SSH/ s/^/# /}" "${ETC_DIR}/iptables/iptables.rules" 2> /dev/null
47 sed -i "/^#/! {/SSH/ s/^/# /}" "${ETC_DIR}/iptables/ip6tables.rules" 2> /dev/null
50 sed -i "/^#/! {/SSH/ s/^/# /}" "${ETC_DIR}/iptables/ip6tables.rules" 2> /dev/null
48 fi
51 fi
49 fi
52 fi
@@ -1,8 +1,9
1 deb http://ftp.debian.org/debian jessie main contrib
1 deb http://ftp.debian.org/debian jessie main contrib
2 #deb-src http://ftp.debian.org/debian jessie main contrib
2 #deb-src http://ftp.debian.org/debian jessie main contrib
3
3
4 deb http://ftp.debian.org/debian/ jessie-updates main contrib
4 deb http://ftp.debian.org/debian/ jessie-updates main contrib
5 #deb-src http://ftp.debian.org/debian/ jessie-updates main contrib
5 #deb-src http://ftp.debian.org/debian/ jessie-updates main contrib
6
6
7 deb http://security.debian.org/ jessie/updates main contrib
7 #deb http://security.debian.org/ jessie/updates main contrib
8 #deb-src http://security.debian.org/ jessie/updates main contrib
8 #deb-src http://security.debian.org/ jessie/updates main contrib
9
@@ -1,772 +1,790
1 #!/bin/sh
1 #!/bin/bash
2
3 ########################################################################
2 ########################################################################
4 # rpi23-gen-image.sh 2015-2017
3 # rpi23-gen-image.sh 2015-2017
5 #
4 #
6 # Advanced Debian "jessie", "stretch" and "buster" bootstrap script for RPi2/3
5 # Advanced Debian "stretch" and "buster" bootstrap script for RPi2/3
7 #
6 #
8 # This program is free software; you can redistribute it and/or
7 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
8 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation; either version 2
9 # as published by the Free Software Foundation; either version 2
11 # of the License, or (at your option) any later version.
10 # of the License, or (at your option) any later version.
12 #
11 #
13 # Copyright (C) 2015 Jan Wagner <mail@jwagner.eu>
12 # Copyright (C) 2015 Jan Wagner <mail@jwagner.eu>
14 #
13 #
15 # Big thanks for patches and enhancements by 20+ github contributors!
14 # Big thanks for patches and enhancements by 20+ github contributors!
16 ########################################################################
15 ########################################################################
17
16
18 # Are we running as root?
17 # Are we running as root?
19 if [ "$(id -u)" -ne "0" ] ; then
18 if [ "$(id -u)" -ne "0" ] ; then
20 echo "error: this script must be executed with root privileges!"
19 echo "error: this script must be executed with root privileges!"
21 exit 1
20 exit 1
22 fi
21 fi
23
22
24 # Check if ./functions.sh script exists
23 # Check if ./functions.sh script exists
25 if [ ! -r "./functions.sh" ] ; then
24 if [ ! -r "./functions.sh" ] ; then
26 echo "error: './functions.sh' required script not found!"
25 echo "error: './functions.sh' required script not found!"
27 exit 1
26 exit 1
28 fi
27 fi
29
28
30 # Load utility functions
29 # Load utility functions
31 . ./functions.sh
30 . ./functions.sh
32
31
33 # Load parameters from configuration template file
32 # Load parameters from configuration template file
34 if [ ! -z "$CONFIG_TEMPLATE" ] ; then
33 if [ -n "$CONFIG_TEMPLATE" ] ; then
35 use_template
34 use_template
36 fi
35 fi
37
36
38 # Introduce settings
37 # Introduce settings
39 set -e
38 set -e
40 echo -n -e "\n#\n# RPi2/3 Bootstrap Settings\n#\n"
39 echo -n -e "\n#\n# RPi2/3 Bootstrap Settings\n#\n"
41 set -x
40 set -x
42
41
43 # Raspberry Pi model configuration
42 # Raspberry Pi model configuration
44 RPI_MODEL=${RPI_MODEL:=2}
43 RPI_MODEL=${RPI_MODEL:=2}
45
44
46 # Debian release
45 # Debian release
47 RELEASE=${RELEASE:=jessie}
46 RELEASE=${RELEASE:=buster}
48
47
49 #Kernel Branch
48 #Kernel Branch
50 KERNEL_BRANCH=${KERNEL_BRANCH:=""}
49 KERNEL_BRANCH=${KERNEL_BRANCH:=""}
51
50
52 # URLs
51 # URLs
53 KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux}
52 KERNEL_URL=${KERNEL_URL:=https://github.com/raspberrypi/linux}
54 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}
55 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}
56 COLLABORA_URL=${COLLABORA_URL:=https://repositories.collabora.co.uk/debian}
57 FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git}
55 FBTURBO_URL=${FBTURBO_URL:=https://github.com/ssvb/xf86-video-fbturbo.git}
58 UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git}
56 UBOOT_URL=${UBOOT_URL:=https://git.denx.de/u-boot.git}
59
57
58 # Firmware directory: Blank if download from github
59 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
60
60 # Build directories
61 # Build directories
61 BASEDIR=${BASEDIR:=$(pwd)/images/${RELEASE}}
62 BASEDIR=${BASEDIR:=$(pwd)/images/${RELEASE}}
62 BUILDDIR="${BASEDIR}/build"
63 BUILDDIR="${BASEDIR}/build"
63
64
64 # Prepare date string for default image file name
65 # Prepare date string for default image file name
65 DATE="$(date +%Y-%m-%d)"
66 DATE="$(date +%Y-%m-%d)"
66 if [ -z "$KERNEL_BRANCH" ] ; then
67 if [ -z "$KERNEL_BRANCH" ] ; then
67 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
68 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
68 else
69 else
69 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
70 IMAGE_NAME=${IMAGE_NAME:=${BASEDIR}/${DATE}-${KERNEL_ARCH}-${KERNEL_BRANCH}-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
70 fi
71 fi
71
72
72 # Chroot directories
73 # Chroot directories
73 R="${BUILDDIR}/chroot"
74 R="${BUILDDIR}/chroot"
74 ETC_DIR="${R}/etc"
75 ETC_DIR="${R}/etc"
75 LIB_DIR="${R}/lib"
76 LIB_DIR="${R}/lib"
76 BOOT_DIR="${R}/boot/firmware"
77 BOOT_DIR="${R}/boot/firmware"
77 KERNEL_DIR="${R}/usr/src/linux"
78 KERNEL_DIR="${R}/usr/src/linux"
78 WLAN_FIRMWARE_DIR="${R}/lib/firmware/brcm"
79 WLAN_FIRMWARE_DIR="${R}/lib/firmware/brcm"
79
80
80 # Firmware directory: Blank if download from github
81 RPI_FIRMWARE_DIR=${RPI_FIRMWARE_DIR:=""}
82
83 # General settings
81 # General settings
84 SET_ARCH=${SET_ARCH}
82 SET_ARCH=${SET_ARCH:=32}
85 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
83 HOSTNAME=${HOSTNAME:=rpi${RPI_MODEL}-${RELEASE}}
86 PASSWORD=${PASSWORD:=raspberry}
84 PASSWORD=${PASSWORD:=raspberry}
87 USER_PASSWORD=${USER_PASSWORD:=raspberry}
85 USER_PASSWORD=${USER_PASSWORD:=raspberry}
88 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
86 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
89 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
87 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
90 EXPANDROOT=${EXPANDROOT:=true}
88 EXPANDROOT=${EXPANDROOT:=true}
91
89
92 # Keyboard settings
90 # Keyboard settings
93 XKB_MODEL=${XKB_MODEL:=""}
91 XKB_MODEL=${XKB_MODEL:=""}
94 XKB_LAYOUT=${XKB_LAYOUT:=""}
92 XKB_LAYOUT=${XKB_LAYOUT:=""}
95 XKB_VARIANT=${XKB_VARIANT:=""}
93 XKB_VARIANT=${XKB_VARIANT:=""}
96 XKB_OPTIONS=${XKB_OPTIONS:=""}
94 XKB_OPTIONS=${XKB_OPTIONS:=""}
97
95
98 # Network settings (DHCP)
96 # Network settings (DHCP)
99 ENABLE_DHCP=${ENABLE_DHCP:=true}
97 ENABLE_DHCP=${ENABLE_DHCP:=true}
100
98
101 # Network settings (static)
99 # Network settings (static)
102 NET_ADDRESS=${NET_ADDRESS:=""}
100 NET_ADDRESS=${NET_ADDRESS:=""}
103 NET_GATEWAY=${NET_GATEWAY:=""}
101 NET_GATEWAY=${NET_GATEWAY:=""}
104 NET_DNS_1=${NET_DNS_1:=""}
102 NET_DNS_1=${NET_DNS_1:=""}
105 NET_DNS_2=${NET_DNS_2:=""}
103 NET_DNS_2=${NET_DNS_2:=""}
106 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
104 NET_DNS_DOMAINS=${NET_DNS_DOMAINS:=""}
107 NET_NTP_1=${NET_NTP_1:=""}
105 NET_NTP_1=${NET_NTP_1:=""}
108 NET_NTP_2=${NET_NTP_2:=""}
106 NET_NTP_2=${NET_NTP_2:=""}
109
107
110 # APT settings
108 # APT settings
111 APT_PROXY=${APT_PROXY:=""}
109 APT_PROXY=${APT_PROXY:=""}
112 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
110 APT_SERVER=${APT_SERVER:="ftp.debian.org"}
113
111
114 # Feature settings
112 # Feature settings
115 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
113 ENABLE_CONSOLE=${ENABLE_CONSOLE:=true}
116 ENABLE_I2C=${ENABLE_I2C:=false}
114 ENABLE_I2C=${ENABLE_I2C:=false}
117 ENABLE_SPI=${ENABLE_SPI:=false}
115 ENABLE_SPI=${ENABLE_SPI:=false}
118 ENABLE_IPV6=${ENABLE_IPV6:=true}
116 ENABLE_IPV6=${ENABLE_IPV6:=true}
119 ENABLE_SSHD=${ENABLE_SSHD:=true}
117 ENABLE_SSHD=${ENABLE_SSHD:=true}
120 ENABLE_NONFREE=${ENABLE_NONFREE:=false}
118 ENABLE_NONFREE=${ENABLE_NONFREE:=false}
121 ENABLE_WIRELESS=${ENABLE_WIRELESS:=false}
119 ENABLE_WIRELESS=${ENABLE_WIRELESS:=false}
122 ENABLE_SOUND=${ENABLE_SOUND:=true}
120 ENABLE_SOUND=${ENABLE_SOUND:=true}
123 ENABLE_DBUS=${ENABLE_DBUS:=true}
121 ENABLE_DBUS=${ENABLE_DBUS:=true}
124 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
122 ENABLE_HWRANDOM=${ENABLE_HWRANDOM:=true}
125 ENABLE_MINGPU=${ENABLE_MINGPU:=false}
123 ENABLE_MINGPU=${ENABLE_MINGPU:=false}
126 ENABLE_XORG=${ENABLE_XORG:=false}
124 ENABLE_XORG=${ENABLE_XORG:=false}
127 ENABLE_WM=${ENABLE_WM:=""}
125 ENABLE_WM=${ENABLE_WM:=""}
128 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
126 ENABLE_RSYSLOG=${ENABLE_RSYSLOG:=true}
129 ENABLE_USER=${ENABLE_USER:=true}
127 ENABLE_USER=${ENABLE_USER:=true}
130 USER_NAME=${USER_NAME:="pi"}
128 USER_NAME=${USER_NAME:="pi"}
131 ENABLE_ROOT=${ENABLE_ROOT:=false}
129 ENABLE_ROOT=${ENABLE_ROOT:=false}
132 ENABLE_QEMU=${ENABLE_QEMU:=false}
130 ENABLE_QEMU=${ENABLE_QEMU:=false}
133
131
134 # SSH settings
132 # SSH settings
135 SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false}
133 SSH_ENABLE_ROOT=${SSH_ENABLE_ROOT:=false}
136 SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false}
134 SSH_DISABLE_PASSWORD_AUTH=${SSH_DISABLE_PASSWORD_AUTH:=false}
137 SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false}
135 SSH_LIMIT_USERS=${SSH_LIMIT_USERS:=false}
138 SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""}
136 SSH_ROOT_PUB_KEY=${SSH_ROOT_PUB_KEY:=""}
139 SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""}
137 SSH_USER_PUB_KEY=${SSH_USER_PUB_KEY:=""}
140
138
141 # Advanced settings
139 # Advanced settings
142 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
140 ENABLE_MINBASE=${ENABLE_MINBASE:=false}
143 ENABLE_REDUCE=${ENABLE_REDUCE:=false}
141 ENABLE_REDUCE=${ENABLE_REDUCE:=false}
144 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
142 ENABLE_UBOOT=${ENABLE_UBOOT:=false}
145 UBOOTSRC_DIR=${UBOOTSRC_DIR:=""}
143 UBOOTSRC_DIR=${UBOOTSRC_DIR:=""}
146 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
144 ENABLE_FBTURBO=${ENABLE_FBTURBO:=false}
147 FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""}
145 FBTURBOSRC_DIR=${FBTURBOSRC_DIR:=""}
148 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
146 ENABLE_HARDNET=${ENABLE_HARDNET:=false}
149 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
147 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
150 ENABLE_SPLITFS=${ENABLE_SPLITFS:=false}
148 ENABLE_SPLITFS=${ENABLE_SPLITFS:=false}
151 ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false}
149 ENABLE_INITRAMFS=${ENABLE_INITRAMFS:=false}
152 ENABLE_IFNAMES=${ENABLE_IFNAMES:=true}
150 ENABLE_IFNAMES=${ENABLE_IFNAMES:=true}
153 DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=}
151 DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS:=}
154
152
155 # Kernel compilation settings
153 # Kernel compilation settings
156 BUILD_KERNEL=${BUILD_KERNEL:=true}
154 BUILD_KERNEL=${BUILD_KERNEL:=true}
157 KERNEL_REDUCE=${KERNEL_REDUCE:=false}
155 KERNEL_REDUCE=${KERNEL_REDUCE:=false}
158 KERNEL_THREADS=${KERNEL_THREADS:=1}
156 KERNEL_THREADS=${KERNEL_THREADS:=1}
159 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
157 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
160 KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
158 KERNEL_MENUCONFIG=${KERNEL_MENUCONFIG:=false}
161 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
159 KERNEL_REMOVESRC=${KERNEL_REMOVESRC:=true}
162 KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false}
160 KERNEL_OLDDEFCONFIG=${KERNEL_OLDDEFCONFIG:=false}
163 KERNEL_CCACHE=${KERNEL_CCACHE:=false}
161 KERNEL_CCACHE=${KERNEL_CCACHE:=false}
164
162
165 # Kernel compilation from source directory settings
163 # Kernel compilation from source directory settings
166 KERNELSRC_DIR=${KERNELSRC_DIR:=""}
164 KERNELSRC_DIR=${KERNELSRC_DIR:=""}
167 KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
165 KERNELSRC_CLEAN=${KERNELSRC_CLEAN:=false}
168 KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true}
166 KERNELSRC_CONFIG=${KERNELSRC_CONFIG:=true}
169 KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false}
167 KERNELSRC_PREBUILT=${KERNELSRC_PREBUILT:=false}
170
168
171 # Reduce disk usage settings
169 # Reduce disk usage settings
172 REDUCE_APT=${REDUCE_APT:=true}
170 REDUCE_APT=${REDUCE_APT:=true}
173 REDUCE_DOC=${REDUCE_DOC:=true}
171 REDUCE_DOC=${REDUCE_DOC:=true}
174 REDUCE_MAN=${REDUCE_MAN:=true}
172 REDUCE_MAN=${REDUCE_MAN:=true}
175 REDUCE_VIM=${REDUCE_VIM:=false}
173 REDUCE_VIM=${REDUCE_VIM:=false}
176 REDUCE_BASH=${REDUCE_BASH:=false}
174 REDUCE_BASH=${REDUCE_BASH:=false}
177 REDUCE_HWDB=${REDUCE_HWDB:=true}
175 REDUCE_HWDB=${REDUCE_HWDB:=true}
178 REDUCE_SSHD=${REDUCE_SSHD:=true}
176 REDUCE_SSHD=${REDUCE_SSHD:=true}
179 REDUCE_LOCALE=${REDUCE_LOCALE:=true}
177 REDUCE_LOCALE=${REDUCE_LOCALE:=true}
180
178
181 # Encrypted filesystem settings
179 # Encrypted filesystem settings
182 ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false}
180 ENABLE_CRYPTFS=${ENABLE_CRYPTFS:=false}
183 CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""}
181 CRYPTFS_PASSWORD=${CRYPTFS_PASSWORD:=""}
184 CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"}
182 CRYPTFS_MAPPING=${CRYPTFS_MAPPING:="secure"}
185 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"}
183 CRYPTFS_CIPHER=${CRYPTFS_CIPHER:="aes-xts-plain64:sha512"}
186 CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512}
184 CRYPTFS_XTSKEYSIZE=${CRYPTFS_XTSKEYSIZE:=512}
187
185
188 # Chroot scripts directory
186 # Chroot scripts directory
189 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
187 CHROOT_SCRIPTS=${CHROOT_SCRIPTS:=""}
190
188
191 # Packages required in the chroot build environment
189 # Packages required in the chroot build environment
192 APT_INCLUDES=${APT_INCLUDES:=""}
190 APT_INCLUDES=${APT_INCLUDES:=""}
193 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils"
191 APT_INCLUDES="${APT_INCLUDES},apt-transport-https,apt-utils,ca-certificates,debian-archive-keyring,dialog,sudo,systemd,sysvinit-utils"
194
192
195 # Packages required for bootstrapping
193 # Packages required for bootstrapping
196 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo"
194 REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static binfmt-support dosfstools rsync bmap-tools whois git bc psmisc dbus sudo"
197 MISSING_PACKAGES=""
195 MISSING_PACKAGES=""
198
196
199 #autoselect best apt mirror
197 #autoselect best apt mirror
200 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} netselect-apt"
198 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} netselect-apt"
201
199
202 # Packages installed for c/c++ build environment in chroot (keep empty)
200 # Packages installed for c/c++ build environment in chroot (keep empty)
203 COMPILER_PACKAGES=""
201 COMPILER_PACKAGES=""
204
202
205 set +x
203 set +x
206
204
207 #make script easier and more stable to use with convenient setup switch. Just setup SET_ARCH and RPI_MODEL and your good to go!
205 #make script easier and more stable to use with convenient setup switch. Just setup SET_ARCH and RPI_MODEL and your good to go!
208 if [ -n "$SET_ARCH" ] ; then
206 if [ -n "$SET_ARCH" ] ; then
209 echo "Setting Architecture specific settings"
207 echo "Setting Architecture specific settings"
210 ##################################
208 ##################################
211 # 64 bit config
209 # 64 bit config
212 ##################################
210 ##################################
213 if [ "$SET_ARCH" = 64 ] ; then
211 if [ "$SET_ARCH" = 64 ] ; then
214 echo "64 bit mode selected - Setting up enviroment"
212 echo "64 bit mode selected - Setting up enviroment"
215 # 64 bit depended settings
213 # 64 bit depended settings
216 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static}
214 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-aarch64-static}
217 KERNEL_ARCH=${KERNEL_ARCH:=arm64}
215 KERNEL_ARCH=${KERNEL_ARCH:=arm64}
218 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"}
216 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="Image"}
219 RELEASE_ARCH=${RELEASE_ARCH:=arm64}
217 RELEASE_ARCH=${RELEASE_ARCH:=arm64}
220 CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-}
218 CROSS_COMPILE=${CROSS_COMPILE:=aarch64-linux-gnu-}
221 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64"
219 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-arm64"
222
220
223 if ([ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]) ; then
221 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
224 # RPI 3 serie specific settings
222 # RPI 3 serie specific settings
225 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
223 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
226 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
224 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_defconfig}
227
225
228 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig}
226 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi3_defconfig}
229 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img}
227 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel8.img}
230 else
228 else
231 echo "error: At the moment Raspberry PI 3 and 3B+ are the only Models which support 64bit"
229 echo "error: At the moment Raspberry PI 3 and 3B+ are the only Models which support 64bit"
232 exit 1
230 exit 1
233 fi
231 fi
234 fi
232 fi
235
233
236 ##################################
234 ##################################
237 # 32 bit config
235 # 32 bit config
238 ##################################
236 ##################################
239 if [ "$SET_ARCH" = 32 ] ; then
237 if [ "$SET_ARCH" = 32 ] ; then
240 echo "32 bit mode selected - Setting up enviroment"
238 echo "32 bit mode selected - Setting up enviroment"
241 #General 32bit configuration
239 #General 32bit configuration
242 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
240 QEMU_BINARY=${QEMU_BINARY:=/usr/bin/qemu-arm-static}
243 KERNEL_ARCH=${KERNEL_ARCH:=arm}
241 KERNEL_ARCH=${KERNEL_ARCH:=arm}
244 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"}
242 KERNEL_BIN_IMAGE=${KERNEL_BIN_IMAGE:="zImage"}
245
243
246 #Raspberry setting grouped by board compability
244 #Raspberry setting grouped by board compability
247 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then
245 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] ; then
248 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel"
246 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armel"
249 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig}
247 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcmrpi_defconfig}
250 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
248 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_defconfig}
251 RELEASE_ARCH=${RELEASE_ARCH:=armel}
249 RELEASE_ARCH=${RELEASE_ARCH:=armel}
252 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img}
250 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel.img}
253 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-}
251 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabi-}
254 fi
252 fi
255 if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
253 if [ "$RPI_MODEL" = 2 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
256 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
254 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} crossbuild-essential-armhf"
257 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
255 KERNEL_DEFCONFIG=${KERNEL_DEFCONFIG:=bcm2709_defconfig}
258 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
256 RELEASE_ARCH=${RELEASE_ARCH:=armhf}
259 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
257 KERNEL_IMAGE=${KERNEL_IMAGE:=kernel7.img}
260 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
258 CROSS_COMPILE=${CROSS_COMPILE:=arm-linux-gnueabihf-}
261 fi
259 fi
262
260 #Device specific configuration
263 #Device specific configuration
261 case "$RPI_MODEL" in
264 case "$RPI_MODEL" in
265 0)
262 0)
266 DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb} ;;
263 DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb}
264 ;;
267 1)
265 1)
268 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb} ;;
266 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb}
267 ;;
269 1P)
268 1P)
270 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb} ;;
269 DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb}
270 ;;
271 2)
271 2)
272 DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
272 DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
273 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
273 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
274 #Precompiled Kernel rpi2
274 ;;
275 COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2}
275 3)
276 ;;
276 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
277 3)
277 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_32b_defconfig}
278 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
278 ;;
279 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_32b_defconfig}
280 ;;
281 3P)
279 3P)
282 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
280 DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
283 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_32b_defconfig}
281 UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_32b_defconfig}
284 ;;
282 ;;
285 *)
283 *)
286 echo "error: Raspberry Pi model ${RPI_MODEL} is not supported!"
284 echo "error: Raspberry Pi model ${RPI_MODEL} is not supported!"
287 exit 1
285 exit 1
288 ;;
286 ;;
289 esac
287 esac
288
289 #Device specific configuration
290 # if [ "$RPI_MODEL" = 0 ] ; then
291 # DTB_FILE=${DTB_FILE:=bcm2708-rpi-0-w.dtb}
292 # fi
293 # if [ "$RPI_MODEL" = 1 ] ; then
294 # DTB_FILE=${DTB_FILE:=bcm2708-rpi-b.dtb}
295 # fi
296 # if [ "$RPI_MODEL" = 1P ] ; then
297 # DTB_FILE=${DTB_FILE:=bcm2708-rpi-b-plus.dtb}
298 # fi
299 # if [ "$RPI_MODEL" = 2 ] ; then
300 # DTB_FILE=${DTB_FILE:=bcm2709-rpi-2-b.dtb}
301 # UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_2_defconfig}
302 # #Precompiled Kernel rpi2
303 # #COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2}
304 # fi
305 # if [ "$RPI_MODEL" = 3 ] ; then
306 # DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
307 # UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_32b_defconfig}
308 # fi
309 # if [ "$RPI_MODEL" = 3P ] ; then
310 # DTB_FILE=${DTB_FILE:=bcm2710-rpi-3-b.dtb}
311 # UBOOT_CONFIG=${UBOOT_CONFIG:=rpi_3_32b_defconfig}
312 # fi
313 # if [ -z "$RPI_MODEL" ] ; then
314 # echo "error: Raspberry Pi model $RPI_MODEL is not set!"
315 # exit 1
316 # fi
317
290 #end 32 bit
318 #end 32 bit
291 fi
319 fi
292 #SET_ARCH not set
320 #SET_ARCH not set
293 else
321 else
294 echo "error: Please set '32' or '64' as value for SET_ARCH"
322 echo "error: Please set '32' or '64' as value for SET_ARCH"
295 exit 1
323 exit 1
296 fi
324 fi
297
325
298 # Check if the internal wireless interface is supported by the RPi model
326 # Check if the internal wireless interface is supported by the RPi model
299 if [ "$ENABLE_WIRELESS" = true ] && ([ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ]) ; then
327 if [ "$ENABLE_WIRELESS" = true ] && { [ "$RPI_MODEL" = 1 ] || [ "$RPI_MODEL" = 1P ] || [ "$RPI_MODEL" = 2 ] ; } ; then
300 echo "error: The selected Raspberry Pi model has no internal wireless interface"
328 echo "error: The selected Raspberry Pi model has no internal wireless interface"
301 exit 1
329 exit 1
302 else
330 else
303 echo "Raspberry Pi model"
331 echo "Raspberry Pi model"
304 fi
332 fi
305
333
306 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
334 # Check if DISABLE_UNDERVOLT_WARNINGS parameter value is supported
307 if [ ! -z "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
335 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
308 if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then
336 if [ "$DISABLE_UNDERVOLT_WARNINGS" != 1 ] && [ "$DISABLE_UNDERVOLT_WARNINGS" != 2 ] ; then
309 echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported"
337 echo "error: DISABLE_UNDERVOLT_WARNINGS=${DISABLE_UNDERVOLT_WARNINGS} is not supported"
310 exit 1
338 exit 1
311 fi
339 fi
312 fi
340 fi
313
341
314 # Add libncurses5 to enable kernel menuconfig
342 # Add libncurses5 to enable kernel menuconfig
315 if [ "$KERNEL_MENUCONFIG" = true ] ; then
343 if [ "$KERNEL_MENUCONFIG" = true ] ; then
316 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses5-dev"
344 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} libncurses5-dev"
317 fi
345 fi
318
346
319 # Add ccache compiler cache for (faster) kernel cross (re)compilation
347 # Add ccache compiler cache for (faster) kernel cross (re)compilation
320 if [ "$KERNEL_CCACHE" = true ] ; then
348 if [ "$KERNEL_CCACHE" = true ] ; then
321 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache"
349 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} ccache"
322 fi
350 fi
323
351
324 # Add cryptsetup package to enable filesystem encryption
352 # Add cryptsetup package to enable filesystem encryption
325 if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
353 if [ "$ENABLE_CRYPTFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
326 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup"
354 REQUIRED_PACKAGES="${REQUIRED_PACKAGES} cryptsetup"
327 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup"
355 APT_INCLUDES="${APT_INCLUDES},cryptsetup,busybox,console-setup"
328
356
329 if [ -z "$CRYPTFS_PASSWORD" ] ; then
357 if [ -z "$CRYPTFS_PASSWORD" ] ; then
330 echo "error: no password defined (CRYPTFS_PASSWORD)!"
358 echo "error: no password defined (CRYPTFS_PASSWORD)!"
331 exit 1
359 exit 1
332 fi
360 fi
333 ENABLE_INITRAMFS=true
361 ENABLE_INITRAMFS=true
334 fi
362 fi
335
363
336 # Add initramfs generation tools
364 # Add initramfs generation tools
337 if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
365 if [ "$ENABLE_INITRAMFS" = true ] && [ "$BUILD_KERNEL" = true ] ; then
338 APT_INCLUDES="${APT_INCLUDES},initramfs-tools"
366 APT_INCLUDES="${APT_INCLUDES},initramfs-tools"
339 fi
367 fi
340
368
341 # Add device-tree-compiler required for building the U-Boot bootloader
369 # Add device-tree-compiler required for building the U-Boot bootloader
342 if [ "$ENABLE_UBOOT" = true ] ; then
370 if [ "$ENABLE_UBOOT" = true ] ; then
343 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex"
371 APT_INCLUDES="${APT_INCLUDES},device-tree-compiler,bison,flex"
344 fi
372 fi
345
373
346 # Check if root SSH (v2) public key file exists
374 # Check if root SSH (v2) public key file exists
347 if [ ! -z "$SSH_ROOT_PUB_KEY" ] ; then
375 if [ -n "$SSH_ROOT_PUB_KEY" ] ; then
348 if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then
376 if [ ! -f "$SSH_ROOT_PUB_KEY" ] ; then
349 echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!"
377 echo "error: '$SSH_ROOT_PUB_KEY' specified SSH public key file not found (SSH_ROOT_PUB_KEY)!"
350 exit 1
378 exit 1
351 fi
379 fi
352 fi
380 fi
353
381
354 # Check if $USER_NAME SSH (v2) public key file exists
382 # Check if $USER_NAME SSH (v2) public key file exists
355 if [ ! -z "$SSH_USER_PUB_KEY" ] ; then
383 if [ -n "$SSH_USER_PUB_KEY" ] ; then
356 if [ ! -f "$SSH_USER_PUB_KEY" ] ; then
384 if [ ! -f "$SSH_USER_PUB_KEY" ] ; then
357 echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!"
385 echo "error: '$SSH_USER_PUB_KEY' specified SSH public key file not found (SSH_USER_PUB_KEY)!"
358 exit 1
386 exit 1
359 fi
387 fi
360 fi
388 fi
361
389
362 # Check if all required packages are installed on the build system
390 # Check if all required packages are installed on the build system
363 for package in $REQUIRED_PACKAGES ; do
391 for package in $REQUIRED_PACKAGES ; do
364 if [ "`dpkg-query -W -f='${Status}' $package`" != "install ok installed" ] ; then
392 if [ "$(dpkg-query -W -f='${Status}' "$package")" != "install ok installed" ] ; then
365 MISSING_PACKAGES="${MISSING_PACKAGES} $package"
393 MISSING_PACKAGES="${MISSING_PACKAGES} $package"
366 fi
394 fi
367 done
395 done
368
396
369 # If there are missing packages ask confirmation for install, or exit
397 # If there are missing packages ask confirmation for install, or exit
370 if [ -n "$MISSING_PACKAGES" ] ; then
398 if [ -n "$MISSING_PACKAGES" ] ; then
371 echo "the following packages needed by this script are not installed:"
399 echo "the following packages needed by this script are not installed:"
372 echo "$MISSING_PACKAGES"
400 echo "$MISSING_PACKAGES"
373
401
374 echo -n "\ndo you want to install the missing packages right now? [y/n] "
402 printf "\ndo you want to install the missing packages right now? [y/n] "
375 read confirm
403 read -r confirm
376 [ "$confirm" != "y" ] && exit 1
404 [ "$confirm" != "y" ] && exit 1
377
405
378 # Make sure all missing required packages are installed
406 # Make sure all missing required packages are installed
379 apt-get -qq -y install ${MISSING_PACKAGES}
407 apt-get -qq -y install "${MISSING_PACKAGES}"
380 fi
408 fi
381
409
382 # Check if ./bootstrap.d directory exists
410 # Check if ./bootstrap.d directory exists
383 if [ ! -d "./bootstrap.d/" ] ; then
411 if [ ! -d "./bootstrap.d/" ] ; then
384 echo "error: './bootstrap.d' required directory not found!"
412 echo "error: './bootstrap.d' required directory not found!"
385 exit 1
413 exit 1
386 fi
414 fi
387
415
388 # Check if ./files directory exists
416 # Check if ./files directory exists
389 if [ ! -d "./files/" ] ; then
417 if [ ! -d "./files/" ] ; then
390 echo "error: './files' required directory not found!"
418 echo "error: './files' required directory not found!"
391 exit 1
419 exit 1
392 fi
420 fi
393
421
394 # Check if specified KERNELSRC_DIR directory exists
422 # Check if specified KERNELSRC_DIR directory exists
395 if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then
423 if [ -n "$KERNELSRC_DIR" ] && [ ! -d "$KERNELSRC_DIR" ] ; then
396 echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!"
424 echo "error: '${KERNELSRC_DIR}' specified directory not found (KERNELSRC_DIR)!"
397 exit 1
425 exit 1
398 fi
426 fi
399
427
400 # Check if specified UBOOTSRC_DIR directory exists
428 # Check if specified UBOOTSRC_DIR directory exists
401 if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then
429 if [ -n "$UBOOTSRC_DIR" ] && [ ! -d "$UBOOTSRC_DIR" ] ; then
402 echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!"
430 echo "error: '${UBOOTSRC_DIR}' specified directory not found (UBOOTSRC_DIR)!"
403 exit 1
431 exit 1
404 fi
432 fi
405
433
406 # Check if specified FBTURBOSRC_DIR directory exists
434 # Check if specified FBTURBOSRC_DIR directory exists
407 if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then
435 if [ -n "$FBTURBOSRC_DIR" ] && [ ! -d "$FBTURBOSRC_DIR" ] ; then
408 echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!"
436 echo "error: '${FBTURBOSRC_DIR}' specified directory not found (FBTURBOSRC_DIR)!"
409 exit 1
437 exit 1
410 fi
438 fi
411
439
412 # Check if specified CHROOT_SCRIPTS directory exists
440 # Check if specified CHROOT_SCRIPTS directory exists
413 if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then
441 if [ -n "$CHROOT_SCRIPTS" ] && [ ! -d "$CHROOT_SCRIPTS" ] ; then
414 echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!"
442 echo "error: ${CHROOT_SCRIPTS} specified directory not found (CHROOT_SCRIPTS)!"
415 exit 1
443 exit 1
416 fi
444 fi
417
445
418 # Check if specified device mapping already exists (will be used by cryptsetup)
446 # Check if specified device mapping already exists (will be used by cryptsetup)
419 if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then
447 if [ -r "/dev/mapping/${CRYPTFS_MAPPING}" ] ; then
420 echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding"
448 echo "error: mapping /dev/mapping/${CRYPTFS_MAPPING} already exists, not proceeding"
421 exit 1
449 exit 1
422 fi
450 fi
423
451
424 # Don't clobber an old build
452 # Don't clobber an old build
425 if [ -e "$BUILDDIR" ] ; then
453 if [ -e "$BUILDDIR" ] ; then
426 echo "error: directory ${BUILDDIR} already exists, not proceeding"
454 echo "error: directory ${BUILDDIR} already exists, not proceeding"
427 exit 1
455 exit 1
428 fi
456 fi
429
457
430 # Setup chroot directory
458 # Setup chroot directory
431 mkdir -p "${R}"
459 mkdir -p "${R}"
432
460
433 # Check if build directory has enough of free disk space >512MB
461 # Check if build directory has enough of free disk space >512MB
434 if [ "$(df --output=avail ${BUILDDIR} | sed "1d")" -le "524288" ] ; then
462 if [ "$(df --output=avail ${BUILDDIR} | sed "1d")" -le "524288" ] ; then
435 echo "error: ${BUILDDIR} not enough space left to generate the output image!"
463 echo "error: ${BUILDDIR} not enough space left to generate the output image!"
436 exit 1
464 exit 1
437 fi
465 fi
438
466
439 set -x
467 set -x
440
468
441 # Call "cleanup" function on various signals and errors
469 # Call "cleanup" function on various signals and errors
442 trap cleanup 0 1 2 3 6
470 trap cleanup 0 1 2 3 6
443
471
444 # Add required packages for the minbase installation
472 # Add required packages for the minbase installation
445 if [ "$ENABLE_MINBASE" = true ] ; then
473 if [ "$ENABLE_MINBASE" = true ] ; then
446 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown"
474 APT_INCLUDES="${APT_INCLUDES},vim-tiny,netbase,net-tools,ifupdown"
447 fi
475 fi
448
476
449 # Add required locales packages
477 # Add required locales packages
450 if [ "$DEFLOCAL" != "en_US.UTF-8" ] || ([ -n XKB_MODEL ] || [ -n XKB_LAYOUT ] || [ -n XKB_VARIANT ] || [ -n XKB_OPTIONS ]); then
478 if [ "$DEFLOCAL" != "en_US.UTF-8" ] || { [ -n "$XKB_MODEL" ] || [ -n "$XKB_LAYOUT" ] || [ -n "$XKB_VARIANT" ] || [ -n "$XKB_OPTIONS" ] ; } ; then
451 APT_INCLUDES="${APT_INCLUDES},locales,keyboard-configuration,console-setup"
479 APT_INCLUDES="${APT_INCLUDES},locales,keyboard-configuration,console-setup"
452 fi
480 fi
453
481
454 # Add parted package, required to get partprobe utility
482 # Add parted package, required to get partprobe utility
455 if [ "$EXPANDROOT" = true ] ; then
483 if [ "$EXPANDROOT" = true ] ; then
456 APT_INCLUDES="${APT_INCLUDES},parted"
484 APT_INCLUDES="${APT_INCLUDES},parted"
457 fi
485 fi
458
486
459 # Add dbus package, recommended if using systemd
487 # Add dbus package, recommended if using systemd
460 if [ "$ENABLE_DBUS" = true ] ; then
488 if [ "$ENABLE_DBUS" = true ] ; then
461 APT_INCLUDES="${APT_INCLUDES},dbus"
489 APT_INCLUDES="${APT_INCLUDES},dbus"
462 fi
490 fi
463
491
464 # Add iptables IPv4/IPv6 package
492 # Add iptables IPv4/IPv6 package
465 if [ "$ENABLE_IPTABLES" = true ] ; then
493 if [ "$ENABLE_IPTABLES" = true ] ; then
466 APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent"
494 APT_INCLUDES="${APT_INCLUDES},iptables,iptables-persistent"
467 fi
495 fi
468
496
469 # Add openssh server package
497 # Add openssh server package
470 if [ "$ENABLE_SSHD" = true ] ; then
498 if [ "$ENABLE_SSHD" = true ] ; then
471 APT_INCLUDES="${APT_INCLUDES},openssh-server"
499 APT_INCLUDES="${APT_INCLUDES},openssh-server"
472 fi
500 fi
473
501
474 # Add alsa-utils package
502 # Add alsa-utils package
475 if [ "$ENABLE_SOUND" = true ] ; then
503 if [ "$ENABLE_SOUND" = true ] ; then
476 APT_INCLUDES="${APT_INCLUDES},alsa-utils"
504 APT_INCLUDES="${APT_INCLUDES},alsa-utils"
477 fi
505 fi
478
506
479 # Add rng-tools package
507 # Add rng-tools package
480 if [ "$ENABLE_HWRANDOM" = true ] ; then
508 if [ "$ENABLE_HWRANDOM" = true ] ; then
481 APT_INCLUDES="${APT_INCLUDES},rng-tools"
509 APT_INCLUDES="${APT_INCLUDES},rng-tools"
482 fi
510 fi
483
511
484 # Add fbturbo video driver
512 # Add fbturbo video driver
485 if [ "$ENABLE_FBTURBO" = true ] ; then
513 if [ "$ENABLE_FBTURBO" = true ] ; then
486 # Enable xorg package dependencies
514 # Enable xorg package dependencies
487 ENABLE_XORG=true
515 ENABLE_XORG=true
488 fi
516 fi
489
517
490 # Add user defined window manager package
518 # Add user defined window manager package
491 if [ -n "$ENABLE_WM" ] ; then
519 if [ -n "$ENABLE_WM" ] ; then
492 APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
520 APT_INCLUDES="${APT_INCLUDES},${ENABLE_WM}"
493
521
494 # Enable xorg package dependencies
522 # Enable xorg package dependencies
495 ENABLE_XORG=true
523 ENABLE_XORG=true
496 fi
524 fi
497
525
498 # Add xorg package
526 # Add xorg package
499 if [ "$ENABLE_XORG" = true ] ; then
527 if [ "$ENABLE_XORG" = true ] ; then
500 APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11"
528 APT_INCLUDES="${APT_INCLUDES},xorg,dbus-x11"
501 fi
529 fi
502
530
503 # Replace selected packages with smaller clones
531 # Replace selected packages with smaller clones
504 if [ "$ENABLE_REDUCE" = true ] ; then
532 if [ "$ENABLE_REDUCE" = true ] ; then
505 # Add levee package instead of vim-tiny
533 # Add levee package instead of vim-tiny
506 if [ "$REDUCE_VIM" = true ] ; then
534 if [ "$REDUCE_VIM" = true ] ; then
507 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")"
535 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/vim-tiny/levee/")"
508 fi
536 fi
509
537
510 # Add dropbear package instead of openssh-server
538 # Add dropbear package instead of openssh-server
511 if [ "$REDUCE_SSHD" = true ] ; then
539 if [ "$REDUCE_SSHD" = true ] ; then
512 APT_INCLUDES="$(echo ${APT_INCLUDES} | sed "s/openssh-server/dropbear/")"
540 APT_INCLUDES="$(echo "${APT_INCLUDES}" | sed "s/openssh-server/dropbear/")"
513 fi
541 fi
514 fi
542 fi
515
543
516 #backwards compability to jessie - untested
517 if [ "$RELEASE" != "jessie" ] ; then
518 APT_INCLUDES="${APT_INCLUDES},libnss-systemd"
519 fi
520
521 # Configure kernel sources if no KERNELSRC_DIR
544 # Configure kernel sources if no KERNELSRC_DIR
522 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
545 if [ "$BUILD_KERNEL" = true ] && [ -z "$KERNELSRC_DIR" ] ; then
523 KERNELSRC_CONFIG=true
546 KERNELSRC_CONFIG=true
524 fi
547 fi
525
548
526 # Configure reduced kernel
549 # Configure reduced kernel
527 if [ "$KERNEL_REDUCE" = true ] ; then
550 if [ "$KERNEL_REDUCE" = true ] ; then
528 KERNELSRC_CONFIG=false
551 KERNELSRC_CONFIG=false
529 fi
552 fi
530
553
531 # Execute bootstrap scripts
554 # Execute bootstrap scripts
532 for SCRIPT in bootstrap.d/*.sh; do
555 for SCRIPT in bootstrap.d/*.sh; do
533 head -n 3 "$SCRIPT"
556 head -n 3 "$SCRIPT"
534 . "$SCRIPT"
557 . "$SCRIPT"
535 done
558 done
536
559
537 ## Execute custom bootstrap scripts
560 ## Execute custom bootstrap scripts
538 if [ -d "custom.d" ] ; then
561 if [ -d "custom.d" ] ; then
539 for SCRIPT in custom.d/*.sh; do
562 for SCRIPT in custom.d/*.sh; do
540 . "$SCRIPT"
563 . "$SCRIPT"
541 done
564 done
542 fi
565 fi
543
566
544 # Execute custom scripts inside the chroot
567 # Execute custom scripts inside the chroot
545 if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then
568 if [ -n "$CHROOT_SCRIPTS" ] && [ -d "$CHROOT_SCRIPTS" ] ; then
546 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
569 cp -r "${CHROOT_SCRIPTS}" "${R}/chroot_scripts"
547 chroot_exec /bin/bash -x <<'EOF'
570 chroot_exec /bin/bash -x <<'EOF'
548 for SCRIPT in /chroot_scripts/* ; do
571 for SCRIPT in /chroot_scripts/* ; do
549 if [ -f $SCRIPT -a -x $SCRIPT ] ; then
572 if [ -f $SCRIPT -a -x $SCRIPT ] ; then
550 $SCRIPT
573 $SCRIPT
551 fi
574 fi
552 done
575 done
553 EOF
576 EOF
554 rm -rf "${R}/chroot_scripts"
577 rm -rf "${R}/chroot_scripts"
555 fi
578 fi
556
579
557 # Remove c/c++ build environment from the chroot
580 # Remove c/c++ build environment from the chroot
558 chroot_remove_cc
581 chroot_remove_cc
559
582
560 # Remove apt-utils
561 if [ "$RELEASE" = "jessie" ] ; then
562 chroot_exec apt-get purge -qq -y --force-yes apt-utils
563 fi
564
565 # Generate required machine-id
583 # Generate required machine-id
566 MACHINE_ID=$(dbus-uuidgen)
584 MACHINE_ID=$(dbus-uuidgen)
567 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
585 echo -n "${MACHINE_ID}" > "${R}/var/lib/dbus/machine-id"
568 echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id"
586 echo -n "${MACHINE_ID}" > "${ETC_DIR}/machine-id"
569
587
570 # APT Cleanup
588 # APT Cleanup
571 chroot_exec apt-get -y clean
589 chroot_exec apt-get -y clean
572 chroot_exec apt-get -y autoclean
590 chroot_exec apt-get -y autoclean
573 chroot_exec apt-get -y autoremove
591 chroot_exec apt-get -y autoremove
574
592
575 # Unmount mounted filesystems
593 # Unmount mounted filesystems
576 umount -l "${R}/proc"
594 umount -l "${R}/proc"
577 umount -l "${R}/sys"
595 umount -l "${R}/sys"
578
596
579 # Clean up directories
597 # Clean up directories
580 rm -rf "${R}/run/*"
598 rm -rf "${R}/run/*"
581 rm -rf "${R}/tmp/*"
599 rm -rf "${R}/tmp/*"
582
600
583 # Clean up files
601 # Clean up files
584 rm -f "${ETC_DIR}/ssh/ssh_host_*"
602 rm -f "${ETC_DIR}/ssh/ssh_host_*"
585 rm -f "${ETC_DIR}/dropbear/dropbear_*"
603 rm -f "${ETC_DIR}/dropbear/dropbear_*"
586 rm -f "${ETC_DIR}/apt/sources.list.save"
604 rm -f "${ETC_DIR}/apt/sources.list.save"
587 rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original"
605 rm -f "${ETC_DIR}/resolvconf/resolv.conf.d/original"
588 rm -f "${ETC_DIR}/*-"
606 rm -f "${ETC_DIR}/*-"
589 rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy"
607 rm -f "${ETC_DIR}/apt/apt.conf.d/10proxy"
590 rm -f "${ETC_DIR}/resolv.conf"
608 rm -f "${ETC_DIR}/resolv.conf"
591 rm -f "${R}/root/.bash_history"
609 rm -f "${R}/root/.bash_history"
592 rm -f "${R}/var/lib/urandom/random-seed"
610 rm -f "${R}/var/lib/urandom/random-seed"
593 rm -f "${R}/initrd.img"
611 rm -f "${R}/initrd.img"
594 rm -f "${R}/vmlinuz"
612 rm -f "${R}/vmlinuz"
595 rm -f "${R}${QEMU_BINARY}"
613 rm -f "${R}${QEMU_BINARY}"
596
614
597 if [ "$ENABLE_QEMU" = true ] ; then
615 if [ "$ENABLE_QEMU" = true ] ; then
598 # Configure qemu compatible kernel
616 # Configure qemu compatible kernel
599 DTB_FILE=vexpress-v2p-ca15_a7.dtb
617 DTB_FILE=vexpress-v2p-ca15_a7.dtb
600 UBOOT_CONFIG=vexpress_ca15_tc2_defconfig
618 UBOOT_CONFIG=vexpress_ca15_tc2_defconfig
601 KERNEL_DEFCONFIG="vexpress_defconfig"
619 KERNEL_DEFCONFIG="vexpress_defconfig"
602 if [ "$KERNEL_MENUCONFIG" = false ] ; then
620 if [ "$KERNEL_MENUCONFIG" = false ] ; then
603 KERNEL_OLDDEFCONFIG=true
621 KERNEL_OLDDEFCONFIG=true
604 fi
622 fi
605
623
606 # Setup QEMU directory
624 # Setup QEMU directory
607 mkdir "${BASEDIR}/qemu"
625 mkdir "${BASEDIR}/qemu"
608
626
609 # Copy kernel image to QEMU directory
627 # Copy kernel image to QEMU directory
610 install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}"
628 install_readonly "${BOOT_DIR}/${KERNEL_IMAGE}" "${BASEDIR}/qemu/${KERNEL_IMAGE}"
611
629
612 # Copy kernel config to QEMU directory
630 # Copy kernel config to QEMU directory
613 install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}"
631 install_readonly "${R}/boot/config-${KERNEL_VERSION}" "${BASEDIR}/qemu/config-${KERNEL_VERSION}"
614
632
615 # Copy kernel dtbs to QEMU directory
633 # Copy kernel dtbs to QEMU directory
616 for dtb in "${BOOT_DIR}/"*.dtb ; do
634 for dtb in "${BOOT_DIR}/"*.dtb ; do
617 if [ -f "${dtb}" ] ; then
635 if [ -f "${dtb}" ] ; then
618 install_readonly "${dtb}" "${BASEDIR}/qemu/"
636 install_readonly "${dtb}" "${BASEDIR}/qemu/"
619 fi
637 fi
620 done
638 done
621
639
622 # Copy kernel overlays to QEMU directory
640 # Copy kernel overlays to QEMU directory
623 if [ -d "${BOOT_DIR}/overlays" ] ; then
641 if [ -d "${BOOT_DIR}/overlays" ] ; then
624 # Setup overlays dtbs directory
642 # Setup overlays dtbs directory
625 mkdir "${BASEDIR}/qemu/overlays"
643 mkdir "${BASEDIR}/qemu/overlays"
626
644
627 for dtb in "${BOOT_DIR}/overlays/"*.dtb ; do
645 for dtb in "${BOOT_DIR}/overlays/"*.dtb ; do
628 if [ -f "${dtb}" ] ; then
646 if [ -f "${dtb}" ] ; then
629 install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/"
647 install_readonly "${dtb}" "${BASEDIR}/qemu/overlays/"
630 fi
648 fi
631 done
649 done
632 fi
650 fi
633
651
634 # Copy u-boot files to QEMU directory
652 # Copy u-boot files to QEMU directory
635 if [ "$ENABLE_UBOOT" = true ] ; then
653 if [ "$ENABLE_UBOOT" = true ] ; then
636 if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then
654 if [ -f "${BOOT_DIR}/u-boot.bin" ] ; then
637 install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin"
655 install_readonly "${BOOT_DIR}/u-boot.bin" "${BASEDIR}/qemu/u-boot.bin"
638 fi
656 fi
639 if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then
657 if [ -f "${BOOT_DIR}/uboot.mkimage" ] ; then
640 install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage"
658 install_readonly "${BOOT_DIR}/uboot.mkimage" "${BASEDIR}/qemu/uboot.mkimage"
641 fi
659 fi
642 if [ -f "${BOOT_DIR}/boot.scr" ] ; then
660 if [ -f "${BOOT_DIR}/boot.scr" ] ; then
643 install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr"
661 install_readonly "${BOOT_DIR}/boot.scr" "${BASEDIR}/qemu/boot.scr"
644 fi
662 fi
645 fi
663 fi
646
664
647 # Copy initramfs to QEMU directory
665 # Copy initramfs to QEMU directory
648 if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then
666 if [ -f "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" ] ; then
649 install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}"
667 install_readonly "${BOOT_DIR}/initramfs-${KERNEL_VERSION}" "${BASEDIR}/qemu/initramfs-${KERNEL_VERSION}"
650 fi
668 fi
651 fi
669 fi
652
670
653 # Calculate size of the chroot directory in KB
671 # Calculate size of the chroot directory in KB
654 CHROOT_SIZE=$(expr `du -s "${R}" | awk '{ print $1 }'`)
672 CHROOT_SIZE=$(expr "$(du -s "${R}" | awk '{ print $1 }')")
655
673
656 # Calculate the amount of needed 512 Byte sectors
674 # Calculate the amount of needed 512 Byte sectors
657 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
675 TABLE_SECTORS=$(expr 1 \* 1024 \* 1024 \/ 512)
658 FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
676 FRMW_SECTORS=$(expr 64 \* 1024 \* 1024 \/ 512)
659 ROOT_OFFSET=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS})
677 ROOT_OFFSET=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}")
660
678
661 # The root partition is EXT4
679 # The root partition is EXT4
662 # This means more space than the actual used space of the chroot is used.
680 # This means more space than the actual used space of the chroot is used.
663 # As overhead for journaling and reserved blocks 35% are added.
681 # As overhead for journaling and reserved blocks 35% are added.
664 ROOT_SECTORS=$(expr $(expr ${CHROOT_SIZE} + ${CHROOT_SIZE} \/ 100 \* 35) \* 1024 \/ 512)
682 ROOT_SECTORS=$(expr "$(expr "${CHROOT_SIZE}" + "${CHROOT_SIZE}" \/ 100 \* 35)" \* 1024 \/ 512)
665
683
666 # Calculate required image size in 512 Byte sectors
684 # Calculate required image size in 512 Byte sectors
667 IMAGE_SECTORS=$(expr ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS})
685 IMAGE_SECTORS=$(expr "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}")
668
686
669 # Prepare image file
687 # Prepare image file
670 if [ "$ENABLE_SPLITFS" = true ] ; then
688 if [ "$ENABLE_SPLITFS" = true ] ; then
671 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=${TABLE_SECTORS}
689 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count="${TABLE_SECTORS}"
672 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek=${FRMW_SECTORS}
690 dd if=/dev/zero of="$IMAGE_NAME-frmw.img" bs=512 count=0 seek="${FRMW_SECTORS}"
673 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=${TABLE_SECTORS}
691 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count="${TABLE_SECTORS}"
674 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek=${ROOT_SECTORS}
692 dd if=/dev/zero of="$IMAGE_NAME-root.img" bs=512 count=0 seek="${ROOT_SECTORS}"
675
693
676 # Write firmware/boot partition tables
694 # Write firmware/boot partition tables
677 sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM
695 sfdisk -q -L -uS -f "$IMAGE_NAME-frmw.img" 2> /dev/null <<EOM
678 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
696 "${TABLE_SECTORS}","${FRMW_SECTORS}",c,*
679 EOM
697 EOM
680
698
681 # Write root partition table
699 # Write root partition table
682 sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM
700 sfdisk -q -L -uS -f "$IMAGE_NAME-root.img" 2> /dev/null <<EOM
683 ${TABLE_SECTORS},${ROOT_SECTORS},83
701 "${TABLE_SECTORS}","${ROOT_SECTORS}",83
684 EOM
702 EOM
685
703
686 # Setup temporary loop devices
704 # Setup temporary loop devices
687 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $IMAGE_NAME-frmw.img)"
705 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME"-frmw.img)"
688 ROOT_LOOP="$(losetup -o 1M -f --show $IMAGE_NAME-root.img)"
706 ROOT_LOOP="$(losetup -o 1M -f --show "$IMAGE_NAME"-root.img)"
689 else # ENABLE_SPLITFS=false
707 else # ENABLE_SPLITFS=false
690 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=${TABLE_SECTORS}
708 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count="${TABLE_SECTORS}"
691 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek=${IMAGE_SECTORS}
709 dd if=/dev/zero of="$IMAGE_NAME.img" bs=512 count=0 seek="${IMAGE_SECTORS}"
692
710
693 # Write partition table
711 # Write partition table
694 sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM
712 sfdisk -q -L -uS -f "$IMAGE_NAME.img" 2> /dev/null <<EOM
695 ${TABLE_SECTORS},${FRMW_SECTORS},c,*
713 "${TABLE_SECTORS}","${FRMW_SECTORS}",c,*
696 ${ROOT_OFFSET},${ROOT_SECTORS},83
714 "${ROOT_OFFSET}","${ROOT_SECTORS}",83
697 EOM
715 EOM
698
716
699 # Setup temporary loop devices
717 # Setup temporary loop devices
700 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show $IMAGE_NAME.img)"
718 FRMW_LOOP="$(losetup -o 1M --sizelimit 64M -f --show "$IMAGE_NAME".img)"
701 ROOT_LOOP="$(losetup -o 65M -f --show $IMAGE_NAME.img)"
719 ROOT_LOOP="$(losetup -o 65M -f --show "$IMAGE_NAME".img)"
702 fi
720 fi
703
721
704 if [ "$ENABLE_CRYPTFS" = true ] ; then
722 if [ "$ENABLE_CRYPTFS" = true ] ; then
705 # Create dummy ext4 fs
723 # Create dummy ext4 fs
706 mkfs.ext4 "$ROOT_LOOP"
724 mkfs.ext4 "$ROOT_LOOP"
707
725
708 # Setup password keyfile
726 # Setup password keyfile
709 touch .password
727 touch .password
710 chmod 600 .password
728 chmod 600 .password
711 echo -n ${CRYPTFS_PASSWORD} > .password
729 echo -n "${CRYPTFS_PASSWORD}" > .password
712
730
713 # Initialize encrypted partition
731 # Initialize encrypted partition
714 echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password
732 echo "YES" | cryptsetup luksFormat "${ROOT_LOOP}" -c "${CRYPTFS_CIPHER}" -s "${CRYPTFS_XTSKEYSIZE}" .password
715
733
716 # Open encrypted partition and setup mapping
734 # Open encrypted partition and setup mapping
717 cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}"
735 cryptsetup luksOpen "${ROOT_LOOP}" -d .password "${CRYPTFS_MAPPING}"
718
736
719 # Secure delete password keyfile
737 # Secure delete password keyfile
720 shred -zu .password
738 shred -zu .password
721
739
722 # Update temporary loop device
740 # Update temporary loop device
723 ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}"
741 ROOT_LOOP="/dev/mapper/${CRYPTFS_MAPPING}"
724
742
725 # Wipe encrypted partition (encryption cipher is used for randomness)
743 # Wipe encrypted partition (encryption cipher is used for randomness)
726 dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count=$(blockdev --getsz "${ROOT_LOOP}")
744 dd if=/dev/zero of="${ROOT_LOOP}" bs=512 count="$(blockdev --getsz "${ROOT_LOOP}")"
727 fi
745 fi
728
746
729 # Build filesystems
747 # Build filesystems
730 mkfs.vfat "$FRMW_LOOP"
748 mkfs.vfat "$FRMW_LOOP"
731 mkfs.ext4 "$ROOT_LOOP"
749 mkfs.ext4 "$ROOT_LOOP"
732
750
733 # Mount the temporary loop devices
751 # Mount the temporary loop devices
734 mkdir -p "$BUILDDIR/mount"
752 mkdir -p "$BUILDDIR/mount"
735 mount "$ROOT_LOOP" "$BUILDDIR/mount"
753 mount "$ROOT_LOOP" "$BUILDDIR/mount"
736
754
737 mkdir -p "$BUILDDIR/mount/boot/firmware"
755 mkdir -p "$BUILDDIR/mount/boot/firmware"
738 mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware"
756 mount "$FRMW_LOOP" "$BUILDDIR/mount/boot/firmware"
739
757
740 # Copy all files from the chroot to the loop device mount point directory
758 # Copy all files from the chroot to the loop device mount point directory
741 rsync -a "${R}/" "$BUILDDIR/mount/"
759 rsync -a "${R}/" "$BUILDDIR/mount/"
742
760
743 # Unmount all temporary loop devices and mount points
761 # Unmount all temporary loop devices and mount points
744 cleanup
762 cleanup
745
763
746 # Create block map file(s) of image(s)
764 # Create block map file(s) of image(s)
747 if [ "$ENABLE_SPLITFS" = true ] ; then
765 if [ "$ENABLE_SPLITFS" = true ] ; then
748 # Create block map files for "bmaptool"
766 # Create block map files for "bmaptool"
749 bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img"
767 bmaptool create -o "$IMAGE_NAME-frmw.bmap" "$IMAGE_NAME-frmw.img"
750 bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img"
768 bmaptool create -o "$IMAGE_NAME-root.bmap" "$IMAGE_NAME-root.img"
751
769
752 # Image was successfully created
770 # Image was successfully created
753 echo "$IMAGE_NAME-frmw.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
771 echo "$IMAGE_NAME-frmw.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
754 echo "$IMAGE_NAME-root.img ($(expr \( ${TABLE_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
772 echo "$IMAGE_NAME-root.img ($(expr \( "${TABLE_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
755 else
773 else
756 # Create block map file for "bmaptool"
774 # Create block map file for "bmaptool"
757 bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img"
775 bmaptool create -o "$IMAGE_NAME.bmap" "$IMAGE_NAME.img"
758
776
759 # Image was successfully created
777 # Image was successfully created
760 echo "$IMAGE_NAME.img ($(expr \( ${TABLE_SECTORS} + ${FRMW_SECTORS} + ${ROOT_SECTORS} \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
778 echo "$IMAGE_NAME.img ($(expr \( "${TABLE_SECTORS}" + "${FRMW_SECTORS}" + "${ROOT_SECTORS}" \) \* 512 \/ 1024 \/ 1024)M)" ": successfully created"
761
779
762 # Create qemu qcow2 image
780 # Create qemu qcow2 image
763 if [ "$ENABLE_QEMU" = true ] ; then
781 if [ "$ENABLE_QEMU" = true ] ; then
764 QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
782 QEMU_IMAGE=${QEMU_IMAGE:=${BASEDIR}/qemu/${DATE}-${KERNEL_ARCH}-CURRENT-rpi${RPI_MODEL}-${RELEASE}-${RELEASE_ARCH}}
765 QEMU_SIZE=16G
783 QEMU_SIZE=16G
766
784
767 qemu-img convert -f raw -O qcow2 $IMAGE_NAME.img $QEMU_IMAGE.qcow2
785 qemu-img convert -f raw -O qcow2 "$IMAGE_NAME".img "$QEMU_IMAGE".qcow2
768 qemu-img resize $QEMU_IMAGE.qcow2 $QEMU_SIZE
786 qemu-img resize "$QEMU_IMAGE".qcow2 $QEMU_SIZE
769
787
770 echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created"
788 echo "$QEMU_IMAGE.qcow2 ($QEMU_SIZE)" ": successfully created"
771 fi
789 fi
772 fi
790 fi
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant