From b1aec80110e822d835f6c97a2320b7dfc5fba039 Mon Sep 17 00:00:00 2001 From: ficus Date: Sun, 23 Sep 2012 04:22:14 +0200 Subject: possibly functional image builder --- freedom-maker/TODO | 25 ------------ freedom-maker/bin/finalize | 6 ++- freedom-maker/bin/install.sh | 85 +++++++++++++++++++++++++++++++++++++++ freedom-maker/bin/projects | 33 --------------- freedom-maker/bin/projects-chroot | 1 - freedom-maker/buildrootfs.sh | 8 ---- freedom-maker/source/install.sh | 77 ----------------------------------- 7 files changed, 89 insertions(+), 146 deletions(-) delete mode 100644 freedom-maker/TODO create mode 100644 freedom-maker/bin/install.sh delete mode 100755 freedom-maker/bin/projects delete mode 100755 freedom-maker/bin/projects-chroot delete mode 100644 freedom-maker/source/install.sh (limited to 'freedom-maker') diff --git a/freedom-maker/TODO b/freedom-maker/TODO deleted file mode 100644 index 184aca5..0000000 --- a/freedom-maker/TODO +++ /dev/null @@ -1,25 +0,0 @@ -- [ ] initial boot configuration improvements, as there are a few - things we really do want to defer to first boot, or at least make it - trivial to fix up per-system - - - [X] ssh host keys - - [ ] root password -- [ ] add Sheeva as a build target -- [X] add x86 virtualized as a build target (use vmdebootstrap?) -- [ ] investigate and integrate software components that looks interesting - - channel-server, the buddycloud channels service for XMPP - - babeld, loop-free distance-vector routing protocol - - tahoe-lafs, secure distributed filesystem -- [ ] virtualbox should build with dreamplug configuration - -*** stuff to do for first feature release *** - - - [ ] pre-configured user interface - - [X] DHCP and HTTP servers on eth0 and/or eth1 - - [ ] plinth-based initial config interface - - - [ ] freedom buddy installed - - [ ] openvpn server setup - - [ ] the privoxy fork configured as a transparent proxy - - [ ] plinth configured to at display these config details and to - control whatever is feasible diff --git a/freedom-maker/bin/finalize b/freedom-maker/bin/finalize index a6cb7da..a530380 100755 --- a/freedom-maker/bin/finalize +++ b/freedom-maker/bin/finalize @@ -49,6 +49,10 @@ echo $hostname > $target/etc/hostname chown root:root $target/sbin/copy2dream chmod 744 $target/sbin/copy2dream +# copy over install script +cp bin/install.sh $target/ +chmod 744 $target/install.sh + # prepare chroot package finalization cp bin/packages-chroot $target/ @@ -57,8 +61,6 @@ chmod 755 $target/install.sh cp /usr/bin/qemu-arm-static $target/usr/bin echo "Running install script from source/install.sh" chroot $target /install.sh -echo "Running install script from bin/projects-chroot" -chroot $target /packages-chroot # clean up. rm "${target}/packages-chroot" diff --git a/freedom-maker/bin/install.sh b/freedom-maker/bin/install.sh new file mode 100644 index 0000000..01b063b --- /dev/null +++ b/freedom-maker/bin/install.sh @@ -0,0 +1,85 @@ +echo "Preconfiguring dash - else dash and bash will be left in a broken state" +/var/lib/dpkg/info/dash.preinst install + +# don't leave target image containing apt config of the build host +echo "Configuring all packages" +export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true +export LC_ALL=C LANGUAGE=C LANG=C + +# 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" + +# configure all packages unpacked earlier by multistrap +dpkg --configure -a + +echo "Adding source packages to filesystem" +dpkg --get-selections > /tmp/selections +mkdir -p /sourcecode +cd sourcecode +cut -f 1 < /tmp/selections | cut -d ':' -f 1 > /tmp/packages +# TODO: torouter +#apt-get source --download-only `cat /tmp/packages` + +# sshd may be left running by the postinst, clean that up +/etc/init.d/ssh stop + +echo "Running install script from bin/projects-chroot" +/packages-chroot + +# torouter setup +echo "Running torouter_preboot.sh..." +/usr/bin/torouter_preboot.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... + +echo "Mangling kernel..." +mkdir /tmp/initrd-repack +(cd /tmp/initrd-repack ; \ + zcat /boot/initrd.img-3.2.0-3-kirkwood | cpio -i ; \ + rm -f conf/param.conf ; \ + find . | cpio --quiet -o -H newc | \ + gzip -9 > /boot/initrd.img-3.2.0-3-kirkwood ) +rm -rf /tmp/initrd-repack + +(cd /boot ; \ + cp /usr/lib/linux-image-3.2.0-3-kirkwood/kirkwood-dreamplug.dtb dtb ; \ + cat vmlinuz-3.2.0-3-kirkwood dtb >> temp-kernel ; \ + mkimage -A arm -O linux -T kernel -n 'Debian kernel 3.2.0-3-kirkwood' \ + -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 3.2.0-3-kirkwood' \ + -d initrd.img-3.2.0-3-kirkwood uInitrd ) + +# Establish an initial root password +echo "Set root password to "$rootpassword +echo root:$rootpassword | /usr/sbin/chpasswd + +# Create a default user +echo "Creating $user user, password: $userpassword" +useradd $user +echo $user:$userpassword | /usr/sbin/chpasswd + +# 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 + +echo "Deleting this very same script" +rm -f /install.sh + +echo "Syncing filesystem just in case something didn't get written" +sync + +echo "End configuration progress by exiting from the chroot" +exit diff --git a/freedom-maker/bin/projects b/freedom-maker/bin/projects deleted file mode 100755 index 2b5ed3c..0000000 --- a/freedom-maker/bin/projects +++ /dev/null @@ -1,33 +0,0 @@ -#! /bin/bash -# -# Copyright 2012 by Nick Daly -# -# 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 . -# - -# projects -# -# Installs external projects to the system. - -# We don't tolerate errors. -set -e - - -echo "Adding a few FreedomBox projects to the image." - -git clone git://github.com/NickDaly/Plinth.git $homedir/plinth -git clone git://github.com/jvasile/freedombox-privoxy $homedir/freedombox-privoxy -git clone git://github.com/jvasile/withsqlite.git $homedir/withsqlite -# hg clone https://hg@bitbucket.org/nickdaly/plugserver $homedir/plugserver -chown -R 1000:1000 $homedir diff --git a/freedom-maker/bin/projects-chroot b/freedom-maker/bin/projects-chroot deleted file mode 100755 index 50d4884..0000000 --- a/freedom-maker/bin/projects-chroot +++ /dev/null @@ -1 +0,0 @@ -#! /bin/sh diff --git a/freedom-maker/buildrootfs.sh b/freedom-maker/buildrootfs.sh index 856f49f..10ba598 100755 --- a/freedom-maker/buildrootfs.sh +++ b/freedom-maker/buildrootfs.sh @@ -104,14 +104,6 @@ rsync -av $source/ $target # add extra packages to the image bin/packages -# torouter! -echo "Explicitly copying some torouter files..." -# TODO: these should be redundant -# Override the above stuff - we know better -cp ../packages/torouter-prep/configs/interfaces $target/etc/network/interfaces -# Stop the libertas module from loading -cp ../packages/torouter-prep/configs/modprobe.d-blacklist.conf $target/etc/modprobe.d/blacklist.conf - # cleanup and finalize the image so it boots correctly. echo "Finalizing..." bin/finalize diff --git a/freedom-maker/source/install.sh b/freedom-maker/source/install.sh deleted file mode 100644 index fc13d2b..0000000 --- a/freedom-maker/source/install.sh +++ /dev/null @@ -1,77 +0,0 @@ -echo "Preconfiguring dash - else dash and bash will be left in a broken state" -/var/lib/dpkg/info/dash.preinst install - -# don't leave target image containing apt config of the build host -echo "Configuring all packages" -export DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true -export LC_ALL=C LANGUAGE=C LANG=C - -# 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" - -# configure all packages unpacked earlier by multistrap -dpkg --configure -a - -echo "Adding source packages to filesystem" -dpkg --get-selections > /tmp/selections -mkdir -p /sourcecode -cd sourcecode -cut -f 1 < /tmp/selections | cut -d ':' -f 1 > /tmp/packages -# TODO: torouter -#apt-get source --download-only `cat /tmp/packages` - -# sshd may be left running by the postinst, clean that up -/etc/init.d/ssh stop - -# 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.img-3.2.0-3-kirkwood | cpio -i ; \ - rm -f conf/param.conf ; \ - find . | cpio --quiet -o -H newc | \ - gzip -9 > /boot/initrd.img-3.2.0-3-kirkwood ) -rm -rf /tmp/initrd-repack - -(cd /boot ; \ - cp /usr/lib/linux-image-3.2.0-3-kirkwood/kirkwood-dreamplug.dtb dtb ; \ - cat vmlinuz-3.2.0-3-kirkwood dtb >> temp-kernel ; \ - mkimage -A arm -O linux -T kernel -n 'Debian kernel 3.2.0-3-kirkwood' \ - -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 3.2.0-3-kirkwood' \ - -d initrd.img-3.2.0-3-kirkwood uInitrd ) - -# Establish an initial root password -echo "Set root password to "$rootpassword -echo root:$rootpassword | /usr/sbin/chpasswd - -# Create a default user -echo "Creating fbx user, password: $userpassword" -useradd $user -echo $user:$userpassword | /usr/sbin/chpasswd - -# 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 - -echo "Deleting this very same script" -rm -f /install.sh - -echo "Syncing filesystem just in case something didn't get written" -sync - -echo "End configuration progress by exiting from the chroot" -exit -- cgit v1.2.3