|
@@ -20,7 +20,9 @@ cat <<EOF
|
|
|
-n hostname (default: olinux)
|
|
|
-t target directory for debootstrap (default: /olinux/debootstrap)
|
|
|
-i install sunxi kernel files; you should have build them before.
|
|
|
- -y install yunohost (under development)
|
|
|
+ -y install yunohost (doesn't work with cross debootstrap)
|
|
|
+ -c cross debootstrap
|
|
|
+ -p use aptcacher proxy
|
|
|
|
|
|
EOF
|
|
|
exit 1
|
|
@@ -29,8 +31,9 @@ exit 1
|
|
|
DEBIAN_RELEASE=wheezy
|
|
|
TARGET_DIR=/olinux/debootstrap
|
|
|
DEB_HOSTNAME=olinux
|
|
|
+REP=$(dirname $0)
|
|
|
|
|
|
-while getopts ":a:b:d:n:t:iy" opt; do
|
|
|
+while getopts ":a:b:d:n:t:i:ycp" opt; do
|
|
|
case $opt in
|
|
|
d)
|
|
|
DEBIAN_RELEASE=$OPTARG
|
|
@@ -48,38 +51,45 @@ while getopts ":a:b:d:n:t:iy" opt; do
|
|
|
TARGET_DIR=$OPTARG
|
|
|
;;
|
|
|
i)
|
|
|
- INSTALL_KERNEL=yes
|
|
|
+ INSTALL_KERNEL=$OPTARG
|
|
|
;;
|
|
|
y)
|
|
|
INSTALL_YUNOHOST=yes
|
|
|
;;
|
|
|
+ c)
|
|
|
+ CROSS=yes
|
|
|
+ ;;
|
|
|
+ p)
|
|
|
+ APTCACHER=yes
|
|
|
+ ;;
|
|
|
\?)
|
|
|
show_usage
|
|
|
;;
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
-source /olinux/config_board.sh
|
|
|
+source ${REP}/config_board.sh
|
|
|
|
|
|
rm -rf $TARGET_DIR && mkdir -p $TARGET_DIR
|
|
|
|
|
|
chroot_deb (){
|
|
|
-
|
|
|
LC_ALL=C LANGUAGE=C LANG=C chroot $1 /bin/bash -c "$2"
|
|
|
-
|
|
|
}
|
|
|
|
|
|
-# install packages for debootstap
|
|
|
-apt-get install --force-yes -y debootstrap dpkg-dev qemu binfmt-support qemu-user-static dpkg-cross
|
|
|
-
|
|
|
-# Debootstrap
|
|
|
-mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
|
|
|
-bash /olinux/script/binfmt-misc-arm.sh unregister
|
|
|
-bash /olinux/script/binfmt-misc-arm.sh
|
|
|
-debootstrap --arch=armhf --foreign $DEBIAN_RELEASE $TARGET_DIR
|
|
|
-cp /usr/bin/qemu-arm-static $TARGET_DIR/usr/bin/
|
|
|
-cp /etc/resolv.conf $TARGET_DIR/etc
|
|
|
-chroot_deb $TARGET_DIR '/debootstrap/debootstrap --second-stage'
|
|
|
+if [ ${CROSS} ] ; then
|
|
|
+ # Debootstrap
|
|
|
+ mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc
|
|
|
+ bash ${REP}/script/binfmt-misc-arm.sh unregister
|
|
|
+ bash ${REP}/script/binfmt-misc-arm.sh
|
|
|
+ debootstrap --arch=armhf --foreign $DEBIAN_RELEASE $TARGET_DIR
|
|
|
+ cp /usr/bin/qemu-arm-static $TARGET_DIR/usr/bin/
|
|
|
+ cp /etc/resolv.conf $TARGET_DIR/etc
|
|
|
+ chroot_deb $TARGET_DIR '/debootstrap/debootstrap --second-stage'
|
|
|
+elif [ ${APTCACHER} ] ; then
|
|
|
+ debootstrap $DEBIAN_RELEASE $TARGET_DIR http://localhost:3142/ftp.fr.debian.org/debian/
|
|
|
+else
|
|
|
+ debootstrap $DEBIAN_RELEASE $TARGET_DIR
|
|
|
+fi
|
|
|
|
|
|
# mount proc, sys and dev
|
|
|
mount -t proc chproc $TARGET_DIR/proc
|
|
@@ -95,6 +105,13 @@ EOT
|
|
|
cat <<EOT > $TARGET_DIR/etc/apt/apt.conf.d/71-no-recommends
|
|
|
APT::Install-Suggests "0";
|
|
|
EOT
|
|
|
+
|
|
|
+if [ ${APTCACHER} ] ; then
|
|
|
+ cat <<EOT > $TARGET_DIR/etc/apt/apt.conf.d/01proxy
|
|
|
+Acquire::http::Proxy "http://localhost:3142";
|
|
|
+EOT
|
|
|
+fi
|
|
|
+
|
|
|
chroot_deb $TARGET_DIR 'apt-get update'
|
|
|
|
|
|
# Add ssh server and ntp client
|
|
@@ -147,22 +164,22 @@ chroot_deb $TARGET_DIR 'chmod g+s /var/mail/'
|
|
|
echo $DEB_HOSTNAME > $TARGET_DIR/etc/hostname
|
|
|
|
|
|
# Add firstrun and secondrun init script
|
|
|
-install -m 755 -o root -g root /olinux/script/secondrun $TARGET_DIR/etc/init.d/
|
|
|
-install -m 755 -o root -g root /olinux/script/firstrun $TARGET_DIR/etc/init.d/
|
|
|
+install -m 755 -o root -g root ${REP}/script/secondrun $TARGET_DIR/etc/init.d/
|
|
|
+install -m 755 -o root -g root ${REP}/script/firstrun $TARGET_DIR/etc/init.d/
|
|
|
chroot_deb $TARGET_DIR "insserv firstrun >> /dev/null"
|
|
|
|
|
|
if [ $INSTALL_KERNEL ] ; then
|
|
|
- cp /olinux/sunxi/*.deb $TARGET_DIR/tmp/
|
|
|
+ cp ${INSTALL_KERNEL}/*.deb $TARGET_DIR/tmp/
|
|
|
chroot_deb $TARGET_DIR 'dpkg -i /tmp/*.deb'
|
|
|
rm $TARGET_DIR/tmp/*
|
|
|
- cp /olinux/sunxi/boot.scr $TARGET_DIR/boot/
|
|
|
+ cp ${INSTALL_KERNEL}/boot.scr $TARGET_DIR/boot/
|
|
|
chroot_deb $TARGET_DIR "ln -s /boot/dtb/$DTB /boot/board.dtb"
|
|
|
fi
|
|
|
|
|
|
if [ $INSTALL_YUNOHOST ] ; then
|
|
|
chroot_deb $TARGET_DIR "apt-get install -y --force-yes git"
|
|
|
chroot_deb $TARGET_DIR "git clone https://github.com/YunoHost/install_script /tmp/install_script"
|
|
|
- chroot_deb $TARGET_DIR "cd /tmp/install_script && ./autoinstall_yunohostv2 test"
|
|
|
+ chroot_deb $TARGET_DIR "cd /tmp/install_script && ./autoinstall_yunohostv2 || exit 0"
|
|
|
fi
|
|
|
|
|
|
# Add 'olinux' for root password and force to change it at first login
|
|
@@ -172,7 +189,14 @@ chroot_deb $TARGET_DIR 'chage -d 0 root'
|
|
|
# Remove useless files
|
|
|
chroot_deb $TARGET_DIR 'apt-get clean'
|
|
|
rm $TARGET_DIR/etc/resolv.conf
|
|
|
-rm $TARGET_DIR/usr/bin/qemu-arm-static
|
|
|
+
|
|
|
+if [ ${CROSS} ] ; then
|
|
|
+ rm $TARGET_DIR/usr/bin/qemu-arm-static
|
|
|
+fi
|
|
|
+
|
|
|
+if [ ${APTCACHER} ] ; then
|
|
|
+ rm $TARGET_DIR/etc/apt/apt.conf.d/01proxy
|
|
|
+fi
|
|
|
|
|
|
# Umount proc, sys, and dev
|
|
|
umount -l $TARGET_DIR/dev/pts
|