@@ -15,6 +15,7 | |||||
15 | # Copyright (C) 2015 Luca Falavigna <dktrkranz@debian.org> |
|
15 | # Copyright (C) 2015 Luca Falavigna <dktrkranz@debian.org> | |
16 | ######################################################################## |
|
16 | ######################################################################## | |
17 |
|
17 | |||
|
18 | # Clean up all temporary mount points | |||
18 | cleanup (){ |
|
19 | cleanup (){ | |
19 | set +x |
|
20 | set +x | |
20 | set +e |
|
21 | set +e | |
@@ -32,6 +33,7 cleanup (){ | |||||
32 | set -e |
|
33 | set -e | |
33 | set -x |
|
34 | set -x | |
34 |
|
35 | |||
|
36 | # Debian release | |||
35 | RELEASE=${RELEASE:=jessie} |
|
37 | RELEASE=${RELEASE:=jessie} | |
36 |
|
38 | |||
37 | # Build settings |
|
39 | # Build settings | |
@@ -144,6 +146,11 if [ "$ENABLE_SSHD" = true ] ; then | |||||
144 | APT_INCLUDES="${APT_INCLUDES},openssh-server" |
|
146 | APT_INCLUDES="${APT_INCLUDES},openssh-server" | |
145 | fi |
|
147 | fi | |
146 |
|
148 | |||
|
149 | # Add alsa-utils package | |||
|
150 | if [ "$ENABLE_SOUND" = true ] ; then | |||
|
151 | APT_INCLUDES="${APT_INCLUDES},alsa-utils" | |||
|
152 | fi | |||
|
153 | ||||
147 | # Add rng-tools package |
|
154 | # Add rng-tools package | |
148 | if [ "$ENABLE_HWRANDOM" = true ] ; then |
|
155 | if [ "$ENABLE_HWRANDOM" = true ] ; then | |
149 | APT_INCLUDES="${APT_INCLUDES},rng-tools" |
|
156 | APT_INCLUDES="${APT_INCLUDES},rng-tools" | |
@@ -259,13 +266,14 wget -q -O $R/boot/firmware/start.elf https://github.com/raspberrypi/firmware/ra | |||||
259 | wget -q -O $R/boot/firmware/start_x.elf https://github.com/raspberrypi/firmware/raw/cd355a9dd4f1f4de2e79b0c8e102840885cdf1de/boot/start_x.elf |
|
266 | wget -q -O $R/boot/firmware/start_x.elf https://github.com/raspberrypi/firmware/raw/cd355a9dd4f1f4de2e79b0c8e102840885cdf1de/boot/start_x.elf | |
260 | cp $VMLINUZ $R/boot/firmware/kernel7.img |
|
267 | cp $VMLINUZ $R/boot/firmware/kernel7.img | |
261 |
|
268 | |||
262 | # Set up hosts |
|
269 | # Set up IPv4 hosts | |
263 | echo ${HOSTNAME} >$R/etc/hostname |
|
270 | echo ${HOSTNAME} >$R/etc/hostname | |
264 | cat <<EOM >$R/etc/hosts |
|
271 | cat <<EOM >$R/etc/hosts | |
265 | 127.0.0.1 localhost |
|
272 | 127.0.0.1 localhost | |
266 | 127.0.1.1 ${HOSTNAME} |
|
273 | 127.0.1.1 ${HOSTNAME} | |
267 | EOM |
|
274 | EOM | |
268 |
|
275 | |||
|
276 | # Set up IPv6 hosts | |||
269 | if [ "$ENABLE_IPV6" = true ] ; then |
|
277 | if [ "$ENABLE_IPV6" = true ] ; then | |
270 | cat <<EOM >>$R/etc/hosts |
|
278 | cat <<EOM >>$R/etc/hosts | |
271 |
|
279 | |||
@@ -275,6 +283,29 ff02::2 ip6-allrouters | |||||
275 | EOM |
|
283 | EOM | |
276 | fi |
|
284 | fi | |
277 |
|
285 | |||
|
286 | # Place hint about network configuration | |||
|
287 | cat <<EOM >$R/etc/network/interfaces | |||
|
288 | # Debian switched to systemd-networkd configuration files. | |||
|
289 | # please configure your networks in '/etc/systemd/network/' | |||
|
290 | EOM | |||
|
291 | ||||
|
292 | # Enable systemd-networkd DHCP configuration for interface eth0 | |||
|
293 | cat <<EOM >$R/etc/systemd/network/eth.network | |||
|
294 | [Match] | |||
|
295 | Name=eth0 | |||
|
296 | ||||
|
297 | [Network] | |||
|
298 | DHCP=yes | |||
|
299 | EOM | |||
|
300 | ||||
|
301 | # Set DHCP configuration to IPv4 only | |||
|
302 | if [ "$ENABLE_IPV6" = false ] ; then | |||
|
303 | sed -i "s/=yes/=v4/" $R/etc/systemd/network/eth.network | |||
|
304 | fi | |||
|
305 | ||||
|
306 | # Enable systemd-networkd service | |||
|
307 | LANG=C chroot $R systemctl enable systemd-networkd | |||
|
308 | ||||
278 | # Generate crypt(3) password string |
|
309 | # Generate crypt(3) password string | |
279 | ENCRYPTED_PASSWORD=`mkpasswd -m sha-512 ${PASSWORD}` |
|
310 | ENCRYPTED_PASSWORD=`mkpasswd -m sha-512 ${PASSWORD}` | |
280 |
|
311 | |||
@@ -285,21 +316,6 LANG=C chroot $R usermod -a -G sudo -p "${ENCRYPTED_PASSWORD}" pi | |||||
285 | # Set up root password |
|
316 | # Set up root password | |
286 | LANG=C chroot $R usermod -p "${ENCRYPTED_PASSWORD}" root |
|
317 | LANG=C chroot $R usermod -p "${ENCRYPTED_PASSWORD}" root | |
287 |
|
318 | |||
288 | # Set up interfaces |
|
|||
289 | cat <<EOM >$R/etc/network/interfaces |
|
|||
290 | # interfaces(5) file used by ifup(8) and ifdown(8) |
|
|||
291 | # Include files from /etc/network/interfaces.d: |
|
|||
292 | source-directory /etc/network/interfaces.d |
|
|||
293 |
|
||||
294 | # The loopback network interface |
|
|||
295 | auto lo |
|
|||
296 | iface lo inet loopback |
|
|||
297 |
|
||||
298 | # The primary network interface |
|
|||
299 | allow-hotplug eth0 |
|
|||
300 | iface eth0 inet dhcp |
|
|||
301 | EOM |
|
|||
302 |
|
||||
303 | # Set up firmware boot cmdline |
|
319 | # Set up firmware boot cmdline | |
304 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait net.ifnames=1 console=tty1" |
|
320 | CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait net.ifnames=1 console=tty1" | |
305 |
|
321 | |||
@@ -362,6 +378,11 cat <<EOM >$R/boot/firmware/config.txt | |||||
362 | #arm_freq=800 |
|
378 | #arm_freq=800 | |
363 | EOM |
|
379 | EOM | |
364 |
|
380 | |||
|
381 | # Load snd_bcm2835 kernel module at boot time | |||
|
382 | if [ "$ENABLE_SOUND" = true ] ; then | |||
|
383 | echo "snd_bcm2835" >>$R/etc/modules | |||
|
384 | fi | |||
|
385 | ||||
365 | # Set smallest possible GPU memory allocation size: 16MB (no X) |
|
386 | # Set smallest possible GPU memory allocation size: 16MB (no X) | |
366 | if [ "$ENABLE_MINGPU" = true ] ; then |
|
387 | if [ "$ENABLE_MINGPU" = true ] ; then | |
367 | echo "gpu_mem=16" >>$R/boot/firmware/config.txt |
|
388 | echo "gpu_mem=16" >>$R/boot/firmware/config.txt | |
@@ -684,7 +705,6 fi | |||||
684 |
|
705 | |||
685 | # Install gcc/c++ build environment inside the chroot |
|
706 | # Install gcc/c++ build environment inside the chroot | |
686 | if [ "$ENABLE_UBOOT" = true ] || [ "$ENABLE_FBTURBO" = true ]; then |
|
707 | if [ "$ENABLE_UBOOT" = true ] || [ "$ENABLE_FBTURBO" = true ]; then | |
687 | # Install minimal gcc/g++ build environment |
|
|||
688 |
|
|
708 | LANG=C chroot $R apt-get install -q -y --force-yes --no-install-recommends linux-compiler-gcc-4.9-arm g++ make bc | |
689 | fi |
|
709 | fi | |
690 |
|
710 | |||
@@ -722,7 +742,6 EOM | |||||
722 | LANG=C chroot $R 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 |
|
742 | LANG=C chroot $R 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 | |
723 | fi |
|
743 | fi | |
724 |
|
744 | |||
725 |
|
||||
726 | # Fetch and build fbturbo Xorg driver |
|
745 | # Fetch and build fbturbo Xorg driver | |
727 | if [ "$ENABLE_FBTURBO" = true ] ; then |
|
746 | if [ "$ENABLE_FBTURBO" = true ] ; then | |
728 | # Fetch fbturbo driver sources |
|
747 | # Fetch fbturbo driver sources | |
@@ -750,27 +769,9 fi | |||||
750 |
|
769 | |||
751 | # Remove gcc/c++ build environment from the chroot |
|
770 | # Remove gcc/c++ build environment from the chroot | |
752 | if [ "$ENABLE_UBOOT" = true ] || [ "$ENABLE_FBTURBO" = true ]; then |
|
771 | if [ "$ENABLE_UBOOT" = true ] || [ "$ENABLE_FBTURBO" = true ]; then | |
753 | # Remove minimal gcc/c++ build environment |
|
|||
754 |
|
|
772 | LANG=C chroot $R apt-get -y -q purge --auto-remove bc binutils cpp cpp-4.9 g++ g++-4.9 gcc gcc-4.9 libasan1 libatomic1 libc-dev-bin libc6-dev libcloog-isl4 libgcc-4.9-dev libgomp1 libisl10 libmpc3 libmpfr4 libstdc++-4.9-dev libubsan0 linux-compiler-gcc-4.9-arm linux-libc-dev make | |
755 | fi |
|
773 | fi | |
756 |
|
774 | |||
757 | # Enable systemd-networkd DHCP configuration for the eth0 interface |
|
|||
758 | printf "[Match]\nName=eth0\n\n[Network]\nDHCP=yes\n" > $R/etc/systemd/network/eth.network |
|
|||
759 |
|
||||
760 | # Set DHCP configuration to IPv4 only |
|
|||
761 | if [ "$ENABLE_IPV6" = false ] ; then |
|
|||
762 | sed -i "s/=yes/=v4/" $R/etc/systemd/network/eth.network |
|
|||
763 | fi |
|
|||
764 |
|
||||
765 | # Enable systemd-networkd service |
|
|||
766 | LANG=C chroot $R systemctl enable systemd-networkd |
|
|||
767 |
|
||||
768 | # Place hint about netowrk configuration |
|
|||
769 | cat <<EOM >$R/etc/network/interfaces |
|
|||
770 | # Debian switched to systemd-networkd configuration files. |
|
|||
771 | # please configure your networks in '/etc/systemd/network/' |
|
|||
772 | EOM |
|
|||
773 |
|
||||
774 | # Clean cached downloads |
|
775 | # Clean cached downloads | |
775 | LANG=C chroot $R apt-get -y clean |
|
776 | LANG=C chroot $R apt-get -y clean | |
776 | LANG=C chroot $R apt-get -y autoclean |
|
777 | LANG=C chroot $R apt-get -y autoclean |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant