~pwlars/ubuntu-mobile/mobile-scripts-aufs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
#
# script to spawn a chroot inside ubuntu mobile squashfs files for
# modifications and package installations. Make sure to have enough free
# space in the vfat image, if you need more than available, use the
# grow_image.sh script from this script collection
#
# Requires: squashfs-tools
#
# Copyright 2008 Canonical LTD.
# Authors: Oliver Grawert <ogra@ubuntu.com>
#          Emmet Hickory <persia@ubuntu.com>
#
# Lincensed under terms and conditions of the GPL v2

if [ -z $1 ];then
    echo 'i need a path to an imagefile as first argument'
    exit 0
fi

mkdir /tmp/image
mkdir /tmp/squashfs
mkdir /tmp/tmpfs
mkdir /tmp/mergemount

sudo modprobe unionfs

sudo mount -o loop $1 /tmp/image
sudo mount -o loop -t squashfs /tmp/image/casper/filesystem.squashfs /tmp/squashfs
sudo mount -t tmpfs tmpfs /tmp/tmpfs
sudo mount -t unionfs -o dirs=/tmp/tmpfs:/tmp/squashfs=ro none /tmp/mergemount

sudo chroot /tmp/mergemount mount -t proc proc /proc
sudo chroot /tmp/mergemount mount -t sysfs sysfs /sys
sudo chroot /tmp/mergemount mkdir -p /dev/pts
sudo chroot /tmp/mergemount mount -t devpts devpts -o noexec,nosuid,gid=5,mode=620 /dev/pts

sudo cp /etc/resolv.conf /tmp/mergemount/etc/

LANG=C sudo chroot /tmp/mergemount su
LANG=C sudo chroot /tmp/mergemount su - apt-get clean

sudo chroot /tmp/mergemount rm /etc/resolv.conf
sudo chroot /tmp/mergemount umount /proc
sudo chroot /tmp/mergemount umount /sys
sudo chroot /tmp/mergemount umount /dev/pts
sudo chroot /tmp/mergemount rm -rf /dev/pts


echo -n 'do you want to build a squashfs with the changes ? (y/n) '
read yesno
if [ -z $yesno ];then
    yesno='n'
fi

if [ $yesno = 'y' ];then
    sudo mksquashfs /tmp/mergemount /tmp/filesystem.squashfs
fi

sudo umount /tmp/mergemount
sudo umount /tmp/tmpfs
sudo umount /tmp/squashfs

if [ $yesno = 'y' ];then
    sudo cp /tmp/filesystem.squashfs /tmp/image/casper/
fi

sudo umount /tmp/image
sudo rm -rf /tmp/image /tmp/tmpfs /tmp/squashfs /tmp/mergemount /tmp/filesystem.squashfs