create_arm_debootstrap.sh 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #/bin/sh
  2. ######################
  3. # Sunxi part #
  4. ######################
  5. # Sunxi u-boot
  6. if [ -d /olinux/sunxi/u-boot-sunxi/ ] ; then
  7. cd /olinux/sunxi/u-boot-sunxi/ && make clean && git pull
  8. else
  9. git clone -b sunxi https://github.com/linux-sunxi/u-boot-sunxi.git /olinux/sunxi/u-boot-sunxi
  10. fi
  11. cd /olinux/sunxi/u-boot-sunxi && make CROSS_COMPILE=arm-linux-gnueabihf A20-OLinuXino-Lime_config && make CROSS_COMPILE=arm-linux-gnueabihf-
  12. # Sunxi kernel
  13. if [ -d /olinux/sunxi/linux-sunxi/ ] ; then
  14. cd /olinux/sunxi/linux-sunxi/ && make clean && git pull
  15. else
  16. git clone https://github.com/linux-sunxi/linux-sunxi -b stage/sunxi-3.4 /olinux/sunxi/linux-sunxi
  17. fi
  18. cp /olinux/a20_defconfig /olinux/sunxi/linux-sunxi/arch/arm/configs/.
  19. cd /olinux/sunxi/linux-sunxi/ && make ARCH=arm a20_defconfig
  20. cd /olinux/sunxi/linux-sunxi/ && make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j2 uImage
  21. cd /olinux/sunxi/linux-sunxi/ && make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j2 INSTALL_MOD_PATH=out modules
  22. cd /olinux/sunxi/linux-sunxi/ && make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j2 INSTALL_MOD_PATH=out modules_install
  23. # Sunxi fex2bin
  24. if [ -d /olinux/sunxi/sunxi-tools/ ] ; then
  25. cd /olinux/sunxi/sunxi-tools/ && make clean && git pull
  26. else
  27. git clone https://github.com/linux-sunxi/sunxi-tools /olinux/sunxi/sunxi-tools
  28. fi
  29. cd /olinux/sunxi/sunxi-tools/ && make
  30. cd /olinux/sunxi/ && ./sunxi-tools/fex2bin ../script.fex script.bin
  31. cd /olinux/sunxi/ && chown +x script.bin
  32. ######################
  33. # Debootstrap part #
  34. ######################
  35. targetdir=/olinux/debootstrap
  36. distro=wheezy
  37. rm -rf $targetdir && mkdir -p $targetdir
  38. # install packages for debootstap
  39. apt-get install --force-yes -y debootstrap dpkg-dev qemu binfmt-support qemu-user-static dpkg-cross
  40. mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
  41. update-binfmts --enable
  42. # Debootstrap
  43. debootstrap --arch=armhf --foreign $distro $targetdir
  44. cp /usr/bin/qemu-arm-static $targetdir/usr/bin/
  45. cp /etc/resolv.conf $targetdir/etc
  46. chroot $targetdir /debootstrap/debootstrap --second-stage
  47. # Configure debian apt repository
  48. cat <<EOT > $targetdir/etc/apt/sources.list
  49. deb http://ftp.fr.debian.org/debian $distro main contrib non-free
  50. EOT
  51. cat <<EOT > $targerdir/etc/apt/apt.conf.d/71-no-recommends
  52. APT::Install-Suggests "0";
  53. EOT
  54. chroot $targetdir apt-get update
  55. # Add ssh server and ntp client
  56. chroot $targetdir apt-get install -y --force-yes openssh-server ntp
  57. # Use dhcp on boot
  58. echo <<EOT > $targetdir/etc/network/interfaces
  59. auto lo
  60. iface lo inet loopback
  61. allow-hotplug eth0
  62. iface eth0 inet dhcp
  63. EOT
  64. # Configure tty
  65. echo T0:2345:respawn:/sbin/getty -L ttyS0 115200 vt100 >> $targetdir/etc/inittab
  66. # Remove useless files
  67. chroot $targetdir apt-get clean
  68. rm $targetdir/etc/resolv.conf
  69. rm $targetdir/usr/bin/qemu-arm-static