coriolis2-chroot: Script updated to run all the steps outlined in bug #714.
[dev-env-setup.git] / coriolis2-chroot
1 #!/bin/bash
2 if [ "$EUID" -ne 0 ]
3 then echo "Please run as root"
4 exit
5 fi
6 # Terminal echo colours
7 RED='\033[1;91m'
8 NC='\033[0m'
9
10 # Default name for the new chroot
11 chroot_name="coriolis"
12
13 if [ -e /opt/chroot/$chroot_name ]; then
14 echo -e "
15 ${RED}Chroot \"$chroot_name\" exists! Delete with \"rm-deb-chroot\" or
16 run parts of this script separately${NC}
17 "
18 echo "See https://libre-soc.org/HDL_workflow/coriolis2/ for more info.
19 "
20 exit
21 fi
22
23 echo "Creating a new chroot \"$chroot_name\" using \"mk-deb-chroot\""
24 ./mk-deb-chroot $chroot_name
25 echo "Copying scripts to chroot \"$chroot_name\" using \"cp-scripts-to-chroot\""
26 ./cp-scripts-to-chroot $chroot_name
27
28 # Run coriolis installation script as a normal user
29 echo "Entering \"$chroot_name\" and setting Coriolis and its dependencies!"
30 runuser $SUDO_USER -c "schroot -c $chroot_name --directory=/tmp /bin/bash << EOF
31 cd /home/$SUDO_USER/dev-env-setup
32 ./coriolis-install
33 EOF"
34
35
36 echo "Your new Coriolis chroot should now be setup and ready to go!"
37 echo -e "
38 ${RED}To get inside the new chroot, execute the following (as normal user):${NC}"
39 echo -e "
40 ${RED}schroot -c $chroot_name --directory=/home/$SUDO_USER${NC}
41 "
42