Installing Debian as an upgrade/script

From OLPC
< Installing Debian as an upgrade
Revision as of 05:46, 16 December 2007 by 65.75.18.227 (talk) (New page: The following script, which only follows the instructions on Installing Debian as an upgrade, should install Debian on your XO. Just copy/paste it into a file on the XO, chmod +x, and...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

The following script, which only follows the instructions on Installing Debian as an upgrade, should install Debian on your XO. Just copy/paste it into a file on the XO, chmod +x, and run. I just tested it, and it worked. YMMV. It will stop midway if there is any error, including in the wget image download.

By the way, it's totally unsafe to run code from a wiki like this without reading it.


#!/bin/sh -ex

tgz_url="http://dev.laptop.org/~cscott/xo-debian.tgz"

cd /versions/pristine
mkdir debian
cd debian

# wget -O- "$tgz_url" | tar xz
wget -q -O- "$tgz_url" | tar xvz

cp /etc/{hosts,fstab} /versions/pristine/debian/etc/
cp -r /lib/modules/* /versions/pristine/debian/lib/modules
cp -r /lib/firmware/* /versions/pristine/debian/lib/firmware
mkdir -p /versions/pristine/debian/{versions,security,var/cache/apt/cache}
rm -rf /versions/pristine/debian/boot
cp -r /boot /versions/pristine/debian

cat <<END > /versions/pristine/debian/etc/rcS.d/S00unfreeze.sh
#! /bin/sh
mount -t sysfs /sys /sys
echo 0 > /sys/devices/platform/dcon/freeze
umount /sys
END

chmod a+rx /versions/pristine/debian/etc/rcS.d/S00unfreeze.sh

echo 'tmpfs   /var/cache/apt/cache  tmpfs defaults 0 0' >> /versions/pristine/debian/etc/fstab 

cat <<END > /versions/pristine/debian/etc/apt/apt.conf.d/00-tmpfs-cache
 Dir {
  Cache "var/cache/apt/" {
   srcpkgcache "cache/srcpkgcache.bin";
   pkgcache "cache/pkgcache.bin";
  };
 };
END

cd /versions/boot
rm -rf alt
ln -s /versions/pristine/debian alt
cp -rl /versions/pristine/debian /versions/run/debian
/usr/sbin/setattr -R --iunlink /versions/run/debian
echo 'Debian is installed!  Reboot and hold down the game key labelled "O"'