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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104 | On-device chroot
Ref: https://wiki.ubuntu.com/DebootstrapChroot
All this done on the device in $HOME.
Preparation
sudo apt install debootstrap
Create a chroot
sudo debootstrap vivid $HOME/vivid-chroot
sudo cp /etc/apt/sources.list $HOME/vivid-chroot/etc/apt/sources.list
sudo cp /etc/apt/sources.list.d/extra-ppas.list $HOME/vivid-chroot/etc/apt/sources.list.d
At the end of this paste is a script. Paste the contents into "ch" script in your $HOME.
Enter chroot:
sudo ./ch -r vivid-chroot/
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ECF1204C
sudo apt update
sudo apt install language-pack-en
usermod -G sudo phablet
passwd phablet <- set a password for the user, so user can sudo
The -r switch to "ch" enters as root user.
You can do what you like in here, and not use up disk space of the root partition of the phone.
"ch" script:
#!/bin/bash
usage() {
[ -n "$2" ] && ( echo $2; echo )
echo "Usage:"
echo " sudo $0 [OPTIONS] CHROOT_PATH"
echo
echo " Options:"
echo " -h|--help displays this help message"
echo " -r|--root chroot as root, not current user"
exit $1
}
ARGS=$(getopt -o r,h --long "root,help" -n "$0" -- "$@");
if [ $? -ne 0 ];
then
usage 3
fi
eval set -- "$ARGS";
while true; do
case "$1" in
-h|--help)
usage
;;
-r|--root)
shift;
USERSPEC=0:0
TARGET_UID=0
;;
--)
shift;
break;
;;
esac
done
setup_chroot() {
# $1 is chroot path
# $2 is user id
# add current user in the chroot if doesn't exist
chroot $1 id $2 &> /dev/null || useradd -R $1 -u $2 -m phablet
# make the prompt hint when chrooted
echo `id -un ${TARGET_UID:-$2}`@`basename $1` > $1/etc/debian_chroot
mount -t proc none $1/proc
mount -t sysfs none $1/sys
mount --bind /dev $1/dev
mount --bind $HOME $1/$HOME
cleanup() {
umount $1/proc $1/sys $1/dev $1/$HOME
}
trap "cleanup $1" EXIT
}
[ `id -u` == 0 ] || usage 2 "This script must be ran as root."
[ -d "$1" ] || usage 1 "You need to pass a valid chroot path as argument."
CHROOT=`readlink -f $1` || exit 2
shift
BASE_UID=`id -u $( logname )`
BASE_GID=`id -g $( logname )`
setup_chroot $CHROOT $BASE_UID
chroot --userspec ${USERSPEC:-$BASE_UID:$BASE_GID} $CHROOT $@
|