##// END OF EJS Templates
spliting more files, fix-uboot, fix-fbturbo, fix-locale
Jan Wagner -
r67:4aa8ac698568
parent child
Show More
@@ -0,0 +1,1
1 Acquire::http:Proxy "";
@@ -0,0 +1,3
1 Package: flash-kernel
2 Pin: origin repositories.collabora.co.uk
3 Pin-Priority: 1000
@@ -0,0 +1,10
1 deb http://ftp.debian.org/debian jessie main contrib
2 #deb-src http://ftp.debian.org/debian jessie main contrib
3
4 deb http://ftp.debian.org/debian/ jessie-updates main contrib
5 #deb-src http://ftp.debian.org/debian/ jessie-updates main contrib
6
7 deb http://security.debian.org/ jessie/updates main contrib
8 #deb-src http://security.debian.org/ jessie/updates main contrib
9
10 deb https://repositories.collabora.co.uk/debian jessie rpi2
@@ -0,0 +1,11
1 # Tell Linux that it is booting on a Raspberry Pi2
2 setenv machid 0x00000c42
3
4 # Save these changes to u-boot's environment
5 saveenv
6
7 # Load the existing Linux kernel into RAM
8 fatload mmc 0:1 ${kernel_addr_r} kernel7.img
9
10 # Boot the kernel we have just loaded
11 bootz ${kernel_addr_r}
@@ -0,0 +1,3
1 # File generated by rpi2-gen-image
2 LANG=C
3 LC_ALL=C
@@ -0,0 +1,5
1 [Match]
2 Name=eth0
3
4 [Network]
5 DHCP=yes
@@ -0,0 +1,1
1 rpi2-jessie
@@ -0,0 +1,2
1 127.0.0.1 localhost
2 127.0.1.1 rpi2-jessie
@@ -0,0 +1,2
1 # Debian switched to systemd-networkd configuration files.
2 # please configure your networks in '/etc/systemd/network/'
@@ -0,0 +1,6
1 Section "Device"
2 Identifier "Allwinner A10/A13 FBDEV"
3 Driver "fbturbo"
4 Option "fbdev" "/dev/fb0"
5 Option "SwapbuffersWait" "true"
6 EndSection
@@ -18,7 +18,8 ENABLE_WM=xfce4 ENABLE_FBTURBO=true ENABLE_MINBASE=true ./rpi2-gen-image.sh
18 18 ENABLE_HARDNET=true ENABLE_IPTABLES=true /rpi2-gen-image.sh
19 19 APT_SERVER=ftp.de.debian.org APT_PROXY="http://127.0.0.1:3142/" ./rpi2-gen-image.sh
20 20 ENABLE_MINBASE=true ./rpi2-gen-image.sh
21 ```
21 BUILD_KERNEL=true ENABLE_MINBASE=true ENABLE_IPV6=false ./rpi2-gen-image.sh
22 ```
22 23
23 24 #### APT settings:
24 25 ##### `APT_SERVER`="ftp.debian.org"
@@ -49,25 +50,25 Expand the root partition and filesystem automatically on first boot.
49 50 #### Keyboard settings:
50 51 These options are used to configure keyboard layout in `/etc/default/keyboard` for console and Xorg. These settings can also be changed inside the running OS using the `dpkg-reconfigure keyboard-configuration` command.
51 52
52 ##### `XKBMODEL`=""
53 ##### `XKB_MODEL`=""
53 54 Set the name of the model of your keyboard type.
54 55
55 ##### `XKBLAYOUT`=""
56 ##### `XKB_LAYOUT`=""
56 57 Set the supported keyboard layout(s).
57 58
58 ##### `XKBVARIANT`=""
59 ##### `XKB_VARIANT`=""
59 60 Set the supported variant(s) of the keyboard layout(s).
60 61
61 ##### `XKBOPTIONS`=""
62 ##### `XKB_OPTIONS`=""
62 63 Set extra xkb configuration options.
63 64
64 #### Networking settings (DHCP)
65 #### Networking settings (DHCP):
65 66 This setting is used to set up networking auto configuration in `/etc/systemd/network/eth.network`.
66 67
67 68 #####`ENABLE_DHCP`=true
68 69 Set the system to use DHCP. This requires an DHCP server.
69 70
70 #### Networking settings (static)
71 #### Networking settings (static):
71 72 These settings are used to set up a static networking configuration in /etc/systemd/network/eth.network. The following static networking settings are only supported if `ENABLE_DHCP` was set to `false`.
72 73
73 74 #####`NET_ADDRESS`=""
@@ -156,8 +157,14 Path to a directory with scripts that should be run in the chroot before the ima
156 157 ##### `BUILD_KERNEL`=false
157 158 Build and install the latest RPi2 linux kernel. Currently only the default RPi2 kernel configuration is used. Detailed configuration parameters for customizing the kernel and minor bug fixes still need to get implemented. feel free to help.
158 159
160 ##### `KERNEL_THREADS`=1
161 Number of parallel kernel building threads. If the parameter is left untouched the script will automatically determine the number of CPU cores to set the number of parallel threads to speed the kernel compilation.
162
159 163 ##### `KERNEL_HEADERS`=true
160 If true, also install kernel headers with built kernel.
164 Install kernel headers with built kernel.
165
166 ##### `KERNEL_RMSRC`=true
167 Remove all kernel sources from the generated OS image after building.
161 168
162 169 ## Understanding the script
163 170 The functions of this script that are required for the different stages of the bootstrapping are split up into single files located inside the `bootstrap.d` directory. During the bootstrapping every script in this directory gets executed in lexicographical order:
@@ -169,11 +176,11 The functions of this script that are required for the different stages of the b
169 176 | `12-locale.sh` | Setup Locales and keyboard settings |
170 177 | `13-kernel.sh` | Build and install RPi2 Kernel |
171 178 | `20-networking.sh` | Setup Networking |
172 | `21-firewall.sh` | Setup iptables Firewall |
173 | `30-security.sh` | Setup users and security settings |
174 | `31-logging.sh` | Setup logging |
179 | `21-firewall.sh` | Setup Firewall |
180 | `30-security.sh` | Setup Users and Security settings |
181 | `31-logging.sh` | Setup Logging |
175 182 | `41-uboot.sh` | Build and Setup Uboot |
176 | `42-fbturbo.sh` | Buld and Setup fbturbo Xorg driver |
183 | `42-fbturbo.sh` | Build and Setup fbturbo Xorg driver |
177 184 | `50-firstboot.sh` | First boot actions |
178 185
179 186 All the required configuration files that will be copied to the generated OS image are located inside the `files` directory. It is not recommended to modify these configuration files manually.
@@ -183,6 +190,7 All the required configuration files that will be copied to the generated OS ima
183 190 | `boot` | Boot and RPi2 configuration files |
184 191 | `firstboot` | Scripts that get executed on first boot |
185 192 | `iptables` | Firewall configuration files |
193 | `locales` | Locales configuration |
186 194 | `modprobe.d` | Kernel Module Blacklist configuration |
187 195 | `mount` | Fstab configuration |
188 196 | `network` | Networking configuration files |
@@ -2,6 +2,7
2 2 # Debootstrap basic system
3 3 #
4 4
5 # Load utility functions
5 6 . ./functions.sh
6 7
7 8 # Base debootstrap (unpack only)
@@ -2,19 +2,17
2 2 # Setup APT repositories
3 3 #
4 4
5 # Load utility functions
5 6 . ./functions.sh
6 7
7 8 # Use proxy inside chroot
8 9 if [ -z "$APT_PROXY" ] ; then
9 echo "Acquire::http::Proxy \"$APT_PROXY\";" >> $R/etc/apt/apt.conf.d/10proxy
10 install_readonly files/apt/10proxy $R/etc/apt/apt.conf.d/10proxy
11 sed -i -e "s/\"\"/\"${APT_PROXY}\"/" $R/etc/apt/apt.conf.d/10proxy
10 12 fi
11 13
12 14 # Pin package flash-kernel to repositories.collabora.co.uk
13 cat <<EOM >$R/etc/apt/preferences.d/flash-kernel
14 Package: flash-kernel
15 Pin: origin repositories.collabora.co.uk
16 Pin-Priority: 1000
17 EOM
15 install_readonly files/apt/flash-kernel $R/etc/apt/preferences.d/flash-kernel
18 16
19 17 # Upgrade collabora package index and install collabora keyring
20 18 echo "deb https://repositories.collabora.co.uk/debian ${RELEASE} rpi2" >$R/etc/apt/sources.list
@@ -22,18 +20,9 chroot_exec apt-get -qq -y update
22 20 chroot_exec apt-get -qq -y --force-yes install collabora-obs-archive-keyring
23 21
24 22 # Set up initial sources.list
25 cat <<EOM >$R/etc/apt/sources.list
26 deb http://${APT_SERVER}/debian ${RELEASE} main contrib
27 #deb-src http://${APT_SERVER}/debian ${RELEASE} main contrib
28
29 deb http://${APT_SERVER}/debian/ ${RELEASE}-updates main contrib
30 #deb-src http://${APT_SERVER}/debian/ ${RELEASE}-updates main contrib
31
32 deb http://security.debian.org/ ${RELEASE}/updates main contrib
33 #deb-src http://security.debian.org/ ${RELEASE}/updates main contrib
34
35 deb https://repositories.collabora.co.uk/debian ${RELEASE} rpi2
36 EOM
23 install_readonly files/apt/sources.list $R/etc/apt/sources.list
24 sed -i -e "s/\/ftp.debian.org\//\/${APT_SERVER}\//" $R/etc/apt/sources.list
25 sed -i -e "s/ jessie/ ${RELEASE}/" $R/etc/apt/sources.list
37 26
38 27 # Upgrade package index and update all installed packages and changed dependencies
39 28 chroot_exec apt-get -qq -y update
@@ -1,7 +1,8
1 1 #
2 # Setup locales and keyboard settings
2 # Setup Locales and keyboard settings
3 3 #
4 4
5 # Load utility functions
5 6 . ./functions.sh
6 7
7 8 # Set up timezone
@@ -20,25 +21,27 if [ "$ENABLE_MINBASE" = false ] ; then
20 21 chroot_exec echo "locales locales/locales_to_be_generated multiselect en_US.UTF-8 UTF-8, ${DEFLOCAL} UTF-8" | debconf-set-selections
21 22 chroot_exec sed -i "/en_US.UTF-8/s/^#//" /etc/locale.gen
22 23 fi
24
23 25 chroot_exec sed -i "/${DEFLOCAL}/s/^#//" /etc/locale.gen
24 26 chroot_exec echo "locales locales/default_environment_locale select ${DEFLOCAL}" | debconf-set-selections
25 27 chroot_exec locale-gen
26 28 chroot_exec update-locale LANG=${DEFLOCAL}
27 29
28 30 # Keyboard configuration, if requested
29 if [ "$XKBMODEL" != "" ] ; then
30 chroot_exec sed -i "s/^XKBMODEL.*/XKBMODEL=\"${XKBMODEL}\"/" /etc/default/keyboard
31 if [ "$XKB_MODEL" != "" ] ; then
32 chroot_exec sed -i "s/^XKBMODEL.*/XKBMODEL=\"${XKB_MODEL}\"/" /etc/default/keyboard
31 33 fi
32 if [ "$XKBLAYOUT" != "" ] ; then
33 chroot_exec sed -i "s/^XKBLAYOUT.*/XKBLAYOUT=\"${XKBLAYOUT}\"/" /etc/default/keyboard
34 if [ "$XKB_LAYOUT" != "" ] ; then
35 chroot_exec sed -i "s/^XKBLAYOUT.*/XKBLAYOUT=\"${XKB_LAYOUT}\"/" /etc/default/keyboard
34 36 fi
35 if [ "$XKBVARIANT" != "" ] ; then
36 chroot_exec sed -i "s/^XKBVARIANT.*/XKBVARIANT=\"${XKBVARIANT}\"/" /etc/default/keyboard
37 if [ "$XKB_VARIANT" != "" ] ; then
38 chroot_exec sed -i "s/^XKBVARIANT.*/XKBVARIANT=\"${XKB_VARIANT}\"/" /etc/default/keyboard
37 39 fi
38 if [ "$XKBOPTIONS" != "" ] ; then
39 chroot_exec sed -i "s/^XKBOPTIONS.*/XKBOPTIONS=\"${XKBOPTIONS}\"/" /etc/default/keyboard
40 if [ "$XKB_OPTIONS" != "" ] ; then
41 chroot_exec sed -i "s/^XKBOPTIONS.*/XKBOPTIONS=\"${XKB_OPTIONS}\"/" /etc/default/keyboard
40 42 fi
41 43 chroot_exec dpkg-reconfigure -f noninteractive keyboard-configuration
44
42 45 # Set up font console
43 46 case "${DEFLOCAL}" in
44 47 *UTF-8)
@@ -49,4 +52,7 if [ "$ENABLE_MINBASE" = false ] ; then
49 52 ;;
50 53 esac
51 54 chroot_exec dpkg-reconfigure -f noninteractive console-setup
55 else
56 # Set POSIX default locales
57 install_readonly files/locales/locale $R/etc/default/locale
52 58 fi
@@ -1,43 +1,56
1 1 #
2 # Kernel installation
2 # Build and Setup RPi2 Kernel
3 3 #
4 4
5 # Load utility functions
5 6 . ./functions.sh
6 7
7 8 # Fetch and build latest raspberry kernel
8 9 if [ "$BUILD_KERNEL" = true ] ; then
9 10 # Fetch current raspberrypi kernel sources
10 git -C $R/usr/local/src clone --depth=1 https://github.com/raspberrypi/linux
11 git -C $R/usr/src clone --depth=1 https://github.com/raspberrypi/linux
11 12
12 13 # Load default raspberry kernel configuration
13 make -C $R/usr/local/src/linux ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig
14 make -C $R/usr/src/linux ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- bcm2709_defconfig
15
16 # Calculate optimal number of kernel building threads
17 if [ "KERNEL_THREADS" = 1 ] ; then
18 if [ -f /proc/cpuinfo ] ; then
19 KERNEL_THREADS=$(grep -c processor /proc/cpuinfo)
20 fi
21 fi
14 22
15 23 # Cross compile kernel and modules
16 make -C $R/usr/local/src/linux -j$(grep -c processor /proc/cpuinfo) ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs
24 make -C $R/usr/src/linux -j${KERNEL_THREADS} ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage modules dtbs
17 25
18 26 # Install kernel modules
19 make -C $R/usr/local/src/linux ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=../.. modules_install
27 make -C $R/usr/src/linux ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=../../.. modules_install
20 28
21 29 # Install kernel headers
22 30 if [ "$KERNEL_HEADERS" = true ]; then
23 make -C $R/usr/local/src/linux ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_HDR_PATH=../../usr headers_install
31 make -C $R/usr/src/linux ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_HDR_PATH=../.. headers_install
24 32 fi
25 33
26 34 # Copy and rename compiled kernel to boot directory
27 35 mkdir $R/boot/firmware/
28 $R/usr/local/src/linux/scripts/mkknlimg $R/usr/local/src/linux/arch/arm/boot/zImage $R/boot/firmware/kernel7.img
36 $R/usr/src/linux/scripts/mkknlimg $R/usr/src/linux/arch/arm/boot/zImage $R/boot/firmware/kernel7.img
29 37
30 38 # Copy dts and dtb device definitions
31 39 mkdir $R/boot/firmware/overlays/
32 cp $R/usr/local/src/linux/arch/arm/boot/dts/*.dtb $R/boot/firmware/
33 cp $R/usr/local/src/linux/arch/arm/boot/dts/overlays/*.dtb* $R/boot/firmware/overlays/
34 cp $R/usr/local/src/linux/arch/arm/boot/dts/overlays/README $R/boot/firmware/overlays/
40 cp $R/usr/src/linux/arch/arm/boot/dts/*.dtb $R/boot/firmware/
41 cp $R/usr/src/linux/arch/arm/boot/dts/overlays/*.dtb* $R/boot/firmware/overlays/
42 cp $R/usr/src/linux/arch/arm/boot/dts/overlays/README $R/boot/firmware/overlays/
43
44 # Remove kernel sources
45 if [ "$KERNEL_RMSRC" = true ]; then
46 rm -fr $R/usr/src/linux
47 fi
35 48
36 49 # Install raspberry bootloader and flash-kernel
37 50 chroot_exec apt-get -qq -y --no-install-recommends install raspberrypi-bootloader-nokernel
38 51 else
39 52 # Kernel installation
40 chroot_exec apt-get -qq -y --no-install-recommends install linux-image-${KERNEL} raspberrypi-bootloader-nokernel
53 chroot_exec apt-get -qq -y --no-install-recommends install linux-image-${COLLABORA_KERNEL} raspberrypi-bootloader-nokernel
41 54
42 55 # Install flash-kernel last so it doesn't try (and fail) to detect the platform in the chroot
43 56 chroot_exec apt-get -qq -y install flash-kernel
@@ -63,7 +76,7 fi
63 76 echo "${CMDLINE}" >$R/boot/firmware/cmdline.txt
64 77
65 78 # Set up firmware config
66 install -o root -g root -m 644 files/config.txt $R/boot/firmware/config.txt
79 install_readonly files/boot/config.txt $R/boot/firmware/config.txt
67 80
68 81 # Load snd_bcm2835 kernel module at boot time
69 82 if [ "$ENABLE_SOUND" = true ] ; then
@@ -93,10 +106,10 fi
93 106 mkdir -p $R/etc/modprobe.d/
94 107
95 108 # Blacklist sound modules
96 install -o root -g root -m 644 files/modprobe.d/raspi-blacklist.conf $R/etc/modprobe.d/raspi-blacklist.conf
109 install_readonly files/modprobe.d/raspi-blacklist.conf $R/etc/modprobe.d/raspi-blacklist.conf
97 110
98 111 # Create default fstab
99 install -o root -g root -m 644 files/fstab $R/etc/fstab
112 install_readonly files/mount/fstab $R/etc/fstab
100 113
101 114 # Avoid swapping and increase cache sizes
102 install -o root -g root -m 644 files/sysctl.d/81-rpi-vm.conf $R/etc/sysctl.d/81-rpi-vm.conf
115 install_readonly files/sysctl.d/81-rpi-vm.conf $R/etc/sysctl.d/81-rpi-vm.conf
@@ -1,24 +1,25
1 1 #
2 # Setup networking
2 # Setup Networking
3 3 #
4 4
5 # Load utility functions
5 6 . ./functions.sh
6 7
7 8 # Set up IPv4 hosts
8 echo ${HOSTNAME} >$R/etc/hostname
9 cat <<EOM >$R/etc/hosts
10 127.0.0.1 localhost
11 127.0.1.1 ${HOSTNAME}
12 EOM
9 install_readonly files/network/hostname $R/etc/hostname
10 sed -i -e "s/^rpi2-jessie/${HOSTNAME}/" $R/etc/hostname
11
12 install_readonly files/network/hosts $R/etc/hosts
13 sed -i -e "s/rpi2-jessie/${HOSTNAME}/" $R/etc/hosts
13 14
14 15 if [ "$NET_ADDRESS" != "" ] ; then
15 NET_IP=$(echo ${NET_ADDRESS} | cut -f 1 -d'/')
16 sed -i "s/^127.0.1.1/${NET_IP}/" $R/etc/hosts
16 NET_IP=$(echo ${NET_ADDRESS} | cut -f 1 -d'/')
17 sed -i "s/^127.0.1.1/${NET_IP}/" $R/etc/hosts
17 18 fi
18 19
19 20 # Set up IPv6 hosts
20 21 if [ "$ENABLE_IPV6" = true ] ; then
21 cat <<EOM >>$R/etc/hosts
22 cat <<EOM >>$R/etc/hosts
22 23
23 24 ::1 localhost ip6-localhost ip6-loopback
24 25 ff02::1 ip6-allnodes
@@ -27,28 +28,18 EOM
27 28 fi
28 29
29 30 # Place hint about network configuration
30 cat <<EOM >$R/etc/network/interfaces
31 # Debian switched to systemd-networkd configuration files.
32 # please configure your networks in '/etc/systemd/network/'
33 source /etc/interfaces.d/*.conf
34 EOM
31 install_readonly files/network/interfaces $R/etc/network/interfaces
35 32
36 33 if [ "$ENABLE_DHCP" = true ] ; then
37 34 # Enable systemd-networkd DHCP configuration for interface eth0
38 cat <<EOM >$R/etc/systemd/network/eth.network
39 [Match]
40 Name=eth0
41
42 [Network]
43 DHCP=yes
44 EOM
35 install_readonly files/network/eth.network $R/etc/systemd/network/eth.network
45 36
46 37 # Set DHCP configuration to IPv4 only
47 if [ "$ENABLE_IPV6" = false ] ; then
48 sed -i "s/^DHCP=yes/DHCP=v4/" $R/etc/systemd/network/eth.network
49 fi
38 if [ "$ENABLE_IPV6" = false ] ; then
39 sed -i "s/^DHCP=yes/DHCP=v4/" $R/etc/systemd/network/eth.network
40 fi
50 41 else # ENABLE_DHCP=false
51 cat <<EOM >$R/etc/systemd/network/eth.network
42 cat <<EOM >$R/etc/systemd/network/eth.network
52 43 [Match]
53 44 Name=eth0
54 45
@@ -69,7 +60,7 chroot_exec systemctl enable systemd-networkd
69 60
70 61 # Enable network stack hardening
71 62 if [ "$ENABLE_HARDNET" = true ] ; then
72 install -o root -g root -m 644 files/sysctl.d/81-rpi-net-hardening.conf $R/etc/sysctl.d/81-rpi-net-hardening.conf
63 install_readonly files/sysctl.d/81-rpi-net-hardening.conf $R/etc/sysctl.d/81-rpi-net-hardening.conf
73 64
74 65 # Enable resolver warnings about spoofed addresses
75 66 cat <<EOM >>$R/etc/host.conf
@@ -1,7 +1,8
1 1 #
2 # Enable firewall based on iptables started by systemd service
2 # Setup Firewall
3 3 #
4 4
5 # Load utility functions
5 6 . ./functions.sh
6 7
7 8 if [ "$ENABLE_IPTABLES" = true ] ; then
@@ -9,13 +10,13 if [ "$ENABLE_IPTABLES" = true ] ; then
9 10 mkdir -p "$R/etc/iptables"
10 11
11 12 # Create iptables systemd service
12 install -o root -g root -m 644 files/iptables/iptables.service $R/etc/systemd/system/iptables.service
13 install_readonly files/iptables/iptables.service $R/etc/systemd/system/iptables.service
13 14
14 15 # Create flush-table script called by iptables service
15 install -o root -g root -m 755 files/iptables/flush-iptables.sh $R/etc/iptables/flush-iptables.sh
16 install_exec files/iptables/flush-iptables.sh $R/etc/iptables/flush-iptables.sh
16 17
17 18 # Create iptables rule file
18 install -o root -g root -m 644 files/iptables/iptables.rules $R/etc/iptables/iptables.rules
19 install_readonly files/iptables/iptables.rules $R/etc/iptables/iptables.rules
19 20
20 21 # Reload systemd configuration and enable iptables service
21 22 chroot_exec systemctl daemon-reload
@@ -23,12 +24,12 if [ "$ENABLE_IPTABLES" = true ] ; then
23 24
24 25 if [ "$ENABLE_IPV6" = true ] ; then
25 26 # Create ip6tables systemd service
26 install -o root -g root -m 644 files/iptables/ip6tables.service $R/etc/systemd/system/ip6tables.service
27 install_readonly files/iptables/ip6tables.service $R/etc/systemd/system/ip6tables.service
27 28
28 29 # Create ip6tables file
29 install -o root -g root -m 755 files/iptables/flush-ip6tables.sh $R/etc/iptables/flush-ip6tables.sh
30 install_exec files/iptables/flush-ip6tables.sh $R/etc/iptables/flush-ip6tables.sh
30 31
31 install -o root -g root -m 644 files/iptables/ip6tables.rules $R/etc/iptables/ip6tables.rules
32 install_readonly files/iptables/ip6tables.rules $R/etc/iptables/ip6tables.rules
32 33
33 34 # Reload systemd configuration and enable iptables service
34 35 chroot_exec systemctl daemon-reload
@@ -2,6 +2,7
2 2 # Setup users and security settings
3 3 #
4 4
5 # Load utility functions
5 6 . ./functions.sh
6 7
7 8 # Generate crypt(3) password string
@@ -1,7 +1,8
1 1 #
2 # Setup logging
2 # Setup Logging
3 3 #
4 4
5 # Load utility functions
5 6 . ./functions.sh
6 7
7 8 # Disable rsyslog
@@ -1,7 +1,8
1 1 #
2 # Setup Uboot
2 # Build and Setup Uboot
3 3 #
4 4
5 # Load utility functions
5 6 . ./functions.sh
6 7
7 8 # Install gcc/c++ build environment inside the chroot
@@ -22,23 +23,9 if [ "$ENABLE_UBOOT" = true ] ; then
22 23 printf "\n# boot u-boot kernel\nkernel=u-boot.bin\n" >> $R/boot/firmware/config.txt
23 24
24 25 # Set U-Boot command file
25 cat <<EOM >$R/boot/firmware/uboot.mkimage
26 # Tell Linux that it is booting on a Raspberry Pi2
27 setenv machid 0x00000c42
28
29 # Set the kernel boot command line
30 setenv bootargs "earlyprintk ${CMDLINE}"
31
32 # Save these changes to u-boot's environment
33 saveenv
34
35 # Load the existing Linux kernel into RAM
36 fatload mmc 0:1 \${kernel_addr_r} kernel7.img
37
38 # Boot the kernel we have just loaded
39 bootz \${kernel_addr_r}
40 EOM
26 install_readonly files/boot/uboot.mkimage $R/boot/firmware/uboot.mkimage
27 printf "# Set the kernel boot command line\nsetenv bootargs \"earlyprintk ${CMDLINE}\"\n\n$(cat $R/boot/firmware/uboot.mkimage)" > $R/boot/firmware/uboot.mkimage
41 28
42 29 # Generate U-Boot image from command file
43 chroot_exec mkimage -A arm -O linux -T script -C none -a 0x00000000 -e 0x00000000 -n "RPi2 Boot Script" -d /boot/firmware/uboot.mkimage /boot/firmware/boot.scr
30 chroot_exec /tmp/u-boot/tools/mkimage -A arm -O linux -T script -C none -a 0x00000000 -e 0x00000000 -n RPi2 -d /boot/firmware/uboot.mkimage /boot/firmware/boot.scr
44 31 fi
@@ -1,7 +1,8
1 1 #
2 # Fetch and build fbturbo Xorg driver
2 # Build and Setup fbturbo Xorg driver
3 3 #
4 4
5 # Load utility functions
5 6 . ./functions.sh
6 7
7 8 if [ "$ENABLE_FBTURBO" = true ] ; then
@@ -12,17 +13,16 if [ "$ENABLE_FBTURBO" = true ] ; then
12 13 chroot_exec apt-get install -q -y --no-install-recommends xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev
13 14
14 15 # Build and install fbturbo driver inside chroot
15 chroot_exec /bin/bash -c "cd /tmp/xf86-video-fbturbo; autoreconf -vi; ./configure --prefix=/usr; make; make install"
16 chroot_exec /bin/bash -x <<'EOF'
17 cd /tmp/xf86-video-fbturbo
18 autoreconf -vi
19 ./configure --prefix=/usr
20 make
21 make install
22 EOF
16 23
17 24 # Add fbturbo driver to Xorg configuration
18 cat <<EOM >$R/usr/share/X11/xorg.conf.d/99-fbturbo.conf
19 Section "Device"
20 Identifier "Allwinner A10/A13 FBDEV"
21 Driver "fbturbo"
22 Option "fbdev" "/dev/fb0"
23 Option "SwapbuffersWait" "true"
24 EndSection
25 EOM
25 install_readonly files/xorg/99-fbturbo.conf $R/usr/share/X11/xorg.conf.d/99-fbturbo.conf
26 26
27 27 # Remove Xorg build dependencies
28 28 chroot_exec apt-get -q -y purge --auto-remove xorg-dev xutils-dev x11proto-dri2-dev libltdl-dev libtool automake libdrm-dev
@@ -2,8 +2,10
2 2 # First boot actions
3 3 #
4 4
5 # Load utility functions
5 6 . ./functions.sh
6 7
8 # Prepare rc.firstboot script
7 9 cat files/firstboot/10-begin.sh > $R/etc/rc.firstboot
8 10
9 11 # Ensure openssh server host keys are regenerated on first boot
@@ -12,13 +14,16 if [ "$ENABLE_SSHD" = true ] ; then
12 14 rm -f $R/etc/ssh/ssh_host_*
13 15 fi
14 16
17 # Prepare filesystem auto expand
15 18 if [ "$EXPANDROOT" = true ] ; then
16 19 cat files/firstboot/22-expandroot.sh >> $R/etc/rc.firstboot
17 20 fi
18 21
22 # Finalize rc.firstboot script
19 23 cat files/firstboot/99-finish.sh >> $R/etc/rc.firstboot
20 24 chmod +x $R/etc/rc.firstboot
21 25
26 # Add rc.firstboot script to rc.local
22 27 sed -i '/exit 0/d' $R/etc/rc.local
23 28 echo /etc/rc.firstboot >> $R/etc/rc.local
24 29 echo exit 0 >> $R/etc/rc.local
1 NO CONTENT: file renamed from files/config.txt to files/boot/config.txt
1 NO CONTENT: file renamed from files/fstab to files/mount/fstab
@@ -1,11 +1,16
1 # This file contains utility functions used by rpi2-gen-image.sh
2
1 3 cleanup (){
2 # Clean up all temporary mount points
3 4 set +x
4 5 set +e
6
7 # Identify and kill all processes still using files
5 8 echo "killing processes using mount point ..."
6 9 fuser -k $R
7 10 sleep 3
8 11 fuser -9 -k -v $R
12
13 # Clean up all temporary mount points
9 14 echo "removing temporary mount points ..."
10 15 umount -l $R/proc 2> /dev/null
11 16 umount -l $R/sys 2> /dev/null
@@ -21,3 +26,13 chroot_exec() {
21 26 # Exec command in chroot
22 27 LANG=C LC_ALL=C DEBIAN_FRONTEND=noninteractive chroot $R $*
23 28 }
29
30 install_readonly() {
31 # Install file with user read-only permissions
32 install -o root -g root -m 644 $*
33 }
34
35 install_exec() {
36 # Install file with root exec permissions
37 install -o root -g root -m 744 $*
38 }
@@ -15,14 +15,16
15 15 # Copyright (C) 2015 Luca Falavigna <dktrkranz@debian.org>
16 16 ########################################################################
17 17
18 source ./functions.sh
18 # Load utility functions
19 . ./functions.sh
19 20
20 21 set -e
22 echo -n -e "\n#\n# RPi2 Bootstrap Settings\n#\n"
21 23 set -x
22 24
23 25 # Debian release
24 26 RELEASE=${RELEASE:=jessie}
25 KERNEL=${KERNEL:=3.18.0-trunk-rpi2}
27 COLLABORA_KERNEL=${COLLABORA_KERNEL:=3.18.0-trunk-rpi2}
26 28
27 29 # Build settings
28 30 BASEDIR=$(pwd)/images/${RELEASE}
@@ -33,16 +35,19 HOSTNAME=${HOSTNAME:=rpi2-${RELEASE}}
33 35 PASSWORD=${PASSWORD:=raspberry}
34 36 DEFLOCAL=${DEFLOCAL:="en_US.UTF-8"}
35 37 TIMEZONE=${TIMEZONE:="Europe/Berlin"}
36 XKBMODEL=${XKBMODEL:=""}
37 XKBLAYOUT=${XKBLAYOUT:=""}
38 XKBVARIANT=${XKBVARIANT:=""}
39 XKBOPTIONS=${XKBOPTIONS:=""}
40 38 EXPANDROOT=${EXPANDROOT:=true}
41 39
42 # Network settings
40 # Keyboard settings
41 XKB_MODEL=${XKB_MODEL:=""}
42 XKB_LAYOUT=${XKB_LAYOUT:=""}
43 XKB_VARIANT=${XKB_VARIANT:=""}
44 XKB_OPTIONS=${XKB_OPTIONS:=""}
45
46 # Network settings (DHCP)
43 47 ENABLE_DHCP=${ENABLE_DHCP:=true}
44 # NET_* settings are ignored when ENABLE_DHCP=true
45 # NET_ADDRESS is an IPv4 or IPv6 address and its prefix, separated by "/"
48
49 # Network settings (static)
50 # only used on ENABLE_DHCP=false
46 51 NET_ADDRESS=${NET_ADDRESS:=""}
47 52 NET_GATEWAY=${NET_GATEWAY:=""}
48 53 NET_DNS_1=${NET_DNS_1:=""}
@@ -79,7 +84,9 ENABLE_IPTABLES=${ENABLE_IPTABLES:=false}
79 84
80 85 # Kernel compilation settings
81 86 BUILD_KERNEL=${BUILD_KERNEL:=false}
87 KERNEL_THREADS=${KERNEL_THREADS:=1}
82 88 KERNEL_HEADERS=${KERNEL_HEADERS:=true}
89 KERNEL_RMSRC=${KERNEL_RMSRC:=true}
83 90
84 91 # Image chroot path
85 92 R=${BUILDDIR}/chroot
@@ -206,6 +213,7 fi
206 213
207 214 ## Main bootstrap
208 215 for i in bootstrap.d/*.sh; do
216 head -n 3 $i
209 217 . $i
210 218 done
211 219
@@ -298,7 +306,7 rsync -a "$R/" "$BUILDDIR/mount/"
298 306 # Unmount all temporary loop devices and mount points
299 307 cleanup
300 308
301 # (optinal) create block map file for "bmaptool"
309 # Create block map file for "bmaptool"
302 310 bmaptool create -o "$BASEDIR/${DATE}-debian-${RELEASE}.bmap" "$BASEDIR/${DATE}-debian-${RELEASE}.img"
303 311
304 312 # Image was successfully created
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant