summaryrefslogtreecommitdiff
path: root/tools/chroot.sh
blob: 1560d24bff4f2217781d1c8946bc06b8bab52c6b (plain)
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
#!/bin/sh

set -e

CHROOT_PREFIX=$1
DISTRO=$2
USER=$3

CHROOT_PATH=$CHROOT_PREFIX/$DISTRO

debootstrap $DISTRO $CHROOT_PATH http://archive.ubuntu.com/ubuntu

cp /etc/resolv.conf $CHROOT_PATH/etc/resolv.conf
cp /etc/hosts $CHROOT_PATH/etc/hosts

echo "$USER:x:1000:1000:$USER,,,:/home/$USER:/bin/bash" >> $CHROOT_PATH/etc/passwd
echo "$USER:x:1000:" >> $CHROOT_PATH/etc/group
echo "$USER ALL=NOPASSWD: ALL" >>$CHROOT_PATH/etc/sudoers

mkdir $CHROOT_PATH/home/$USER
cp ~/.gitconfig $CHROOT_PATH/home/$USER/
mkdir $CHROOT_PATH/home/$USER/.ssh
cp ~/.ssh/id_rsa $CHROOT_PATH/home/$USER/.ssh/
chmod -R 600 CHROOT_PATH/home/$USER/.ssh/
chown $USER:$USER $CHROOT_PATH/home/$USER

mkdir -p $CHROOT_PATH/home/$USER/git/cerbero
cp -r * $CHROOT_PATH/home/$USER/git/cerbero
cp -r .git $CHROOT_PATH/home/$USER/git/cerbero