Current location

narf Source control manager Git

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetter Reinholdtsen <pere@hungry.com>2013-10-27 19:52:32 +0100
committerPetter Reinholdtsen <pere@hungry.com>2013-10-27 19:52:32 +0100
commit8f11deaabcca36b8e75dd3ae83caa1fd5b8d2daa (patch)
tree093abe11ee8faeaf35d30eb4c5b1b348d35b7f19 /bin/freedombox-customize
parentede1c5a824e32216506e5c273bd62195997cb944 (diff)
Rewrite build system to use vmdebootstrap and add support for Raspberry Pi.
Diffstat (limited to 'bin/freedombox-customize')
-rwxr-xr-xbin/freedombox-customize131
1 files changed, 131 insertions, 0 deletions
diff --git a/bin/freedombox-customize b/bin/freedombox-customize
new file mode 100755
index 0000000..e5f73a4
--- /dev/null
+++ b/bin/freedombox-customize
@@ -0,0 +1,131 @@
+#!/bin/sh
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+set -e
+set -x
+rootdir="$1"
+cd "$rootdir"
+
+export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true
+export LC_ALL=C LANGUAGE=C LANG=C
+
+# FIXME disable source fetching while debugging
+export NOSOURCE=true
+
+username=fbx
+password=frdm
+chroot $rootdir adduser --gecos $username --disabled-password $username
+echo $username:$password | chroot $rootdir /usr/sbin/chpasswd
+
+suite=jessie
+
+cat <<EOF > etc/apt/sources.list
+deb http://http.debian.net/debian/ $suite main contrib non-free
+deb-src http://http.debian.net/debian/ $suite main contrib non-free
+
+#deb http://security.debian.org/ $suite/updates main
+#deb-src http://security.debian.org/ $suite/updates main
+EOF
+
+cat <<EOF > etc/apt/sources.list.d/reinholdtsen-freedombox.list
+deb http://www.reinholdtsen.name/freedombox wheezy main
+deb-src http://www.reinholdtsen.name/freedombox wheezy main
+EOF
+wget -O - http://www.reinholdtsen.name/freedombox/BE1A583D.asc | \
+ chroot $rootdir apt-key add -
+chroot $rootdir apt-get update
+
+cat > $rootdir/usr/sbin/policy-rc.d <<EOF
+#!/bin/sh
+exit 101
+EOF
+chmod a+rx $rootdir/usr/sbin/policy-rc.d
+
+chroot $rootdir apt-get install -y freedombox-setup
+
+rm $rootdir/usr/sbin/policy-rc.d
+
+# Install non-free binary blob needed to boot Raspberry Pi. This pull
+# in a kernel too.
+if [ "$MACHINE" = raspberry ] ; then
+ # Packages used by rpi-update to make Raspberry Pi bootable
+ apt-get install -y git-core binutils ca-certificates wget kmod
+ cat <<EOF > $rootdir/usr/lib/freedombox/setup.d/95_raspberry-pi
+#!/bin/sh
+wget https://raw.github.com/Hexxeh/rpi-update/master/rpi-update \
+ -O /usr/bin/rpi-update
+chmod a+x /usr/bin/rpi-update
+mkdir -p /lib/modules
+touch /boot/start.elf
+chroot rpi-update > /root/rpi-update.log
+EOF
+ chmod a+rx $rootdir/usr/lib/freedombox/setup.d/95_raspberry-pi
+fi
+
+if [ "$MACHINE" = dreamplug ] ; then
+
+ # allow flash-kernel to work without valid /proc contents
+ # ** this doesn't *really* work, since there are too many checks
+ # that fail in an emulated environment! We'll have to do it by
+ # hand below anyway...
+ export FK_MACHINE="Globalscale Technologies Dreamplug"
+
+ # Installing flash-kernel here, as installing it using debootstrap
+ # causes all kernel related options so stop working.
+
+ chroot $rootdir apt-get install -y flash-kernel
+cat <<EOF > $rootdir/usr/lib/freedombox/setup.d/95_dreamplug-kernel
+#!/bin/sh
+# process installed kernel to create uImage, uInitrd, dtb
+# using flash-kernel would be a good approach, except it fails in the
+# cross build environment due to too many environment checks...
+#FK_MACHINE="Globalscale Technologies Dreamplug" flash-kernel
+# so, let's do it manually...
+
+# flash-kernel's hook-functions provided to mkinitramfs have the
+# unfortunate side-effect of creating /conf/param.conf in the initrd
+# when run from our emulated chroot environment, which means our root=
+# on the kernel command line is completely ignored! repack the initrd
+# to remove this evil...
+
+mkdir /tmp/initrd-repack
+
+(cd /tmp/initrd-repack ; \
+ zcat /boot/$initRd | cpio -i ; \
+ rm -f conf/param.conf ; \
+ find . | cpio --quiet -o -H newc | \
+ gzip -9 > /boot/$initRd )
+
+rm -rf /tmp/initrd-repack
+
+(cd /boot ; \
+ cp /usr/lib/$kernelVersion/kirkwood-dreamplug.dtb dtb ; \
+ cat $vmlinuz dtb >> temp-kernel ; \
+ mkimage -A arm -O linux -T kernel -n "Debian kernel ${version}" \
+ -C none -a 0x8000 -e 0x8000 -d temp-kernel uImage ; \
+ rm -f temp-kernel ; \
+ mkimage -A arm -O linux -T ramdisk -C gzip -a 0x0 -e 0x0 \
+ -n "Debian ramdisk ${version}" \
+ -d $initRd uInitrd )
+
+# By default, spawn a console on the serial port
+echo "Adding a getty on the serial port"
+echo "T0:12345:respawn:/sbin/getty -L ttyS0 115200 vt100" >> /etc/inittab
+
+EOF
+ chmod a+rx $rootdir/usr/lib/freedombox/setup.d/95_dreamplug-kernel
+fi
+
+chroot $rootdir /usr/lib/freedombox/setup