create_arm_debootstrap.sh 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #/bin/sh
  2. ######################
  3. # Debootstrap part #
  4. ######################
  5. targetdir=/olinux/debootstrap
  6. distro=wheezy
  7. rm -rf $targetdir && mkdir -p $targetdir
  8. # install packages for debootstap
  9. apt-get install --force-yes -y debootstrap dpkg-dev qemu binfmt-support qemu-user-static dpkg-cross
  10. update-binfmts --disable
  11. mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
  12. update-binfmts --enable
  13. # Debootstrap
  14. debootstrap --arch=armhf --foreign $distro $targetdir
  15. cp /usr/bin/qemu-arm-static $targetdir/usr/bin/
  16. cp /etc/resolv.conf $targetdir/etc
  17. chroot $targetdir /debootstrap/debootstrap --second-stage
  18. # Configure debian apt repository
  19. cat <<EOT > $targetdir/etc/apt/sources.list
  20. deb http://ftp.fr.debian.org/debian $distro main contrib non-free
  21. EOT
  22. cat <<EOT > $targerdir/etc/apt/apt.conf.d/71-no-recommends
  23. APT::Install-Suggests "0";
  24. EOT
  25. chroot $targetdir apt-get update
  26. # Add ssh server and ntp client
  27. chroot $targetdir apt-get install -y --force-yes openssh-server ntp
  28. # Use dhcp on boot
  29. cat <<EOT > $targetdir/etc/network/interfaces
  30. auto lo
  31. iface lo inet loopback
  32. allow-hotplug eth0
  33. iface eth0 inet dhcp
  34. EOT
  35. # Configure tty
  36. echo T0:2345:respawn:/sbin/getty -L ttyS0 115200 vt100 >> $targetdir/etc/inittab
  37. # add 'olimex' for root password
  38. sed -i -e 's/root:*/root:$6$20Vo8onH$rsNB42ksO1i84CzCTt8e90ludfzIFiIGygYeCNlHYPcDOwvAEPGQQaQsK.GYU2IiZNHG.e3tRFizLmD5lnaHH/' $targetdir/etc/shadow
  39. # Remove useless files
  40. chroot $targetdir apt-get clean
  41. rm $targetdir/etc/resolv.conf
  42. rm $targetdir/usr/bin/qemu-arm-static