Fix correct commit hash for release 0.7.0 of openXC7
[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 # Check if default chroot name should be used or not
14 if [ -z $1 ]; then
15 echo "Not provided a chroot name, using default chroot \"$chroot_name\""
16 else
17 chroot_name="$1"
18 echo "Using specified chroot name \"$chroot_name\""
19 fi
20
21 if [ -e /opt/chroot/$chroot_name ]; then
22 echo -e "
23 ${RED}Chroot \"$chroot_name\" exists! Delete with \"rm-deb-chroot\" or
24 run parts of this script separately${NC}
25 "
26 echo "See https://libre-soc.org/HDL_workflow/coriolis2/ for more info.
27 "
28 exit
29 fi
30
31 echo "Creating a new chroot \"$chroot_name\" using \"mk-deb-chroot\""
32 ./mk-deb-chroot $chroot_name
33 echo "Copying scripts to chroot \"$chroot_name\" using \"cp-scripts-to-chroot\""
34 ./cp-scripts-to-chroot $chroot_name
35
36 # Run coriolis installation script as a normal user
37 echo "Entering \"$chroot_name\" and setting Coriolis and its dependencies!"
38 runuser $SUDO_USER -c "schroot -c $chroot_name --directory=/tmp /bin/bash << EOF
39 cd /home/$SUDO_USER/dev-env-setup
40 ./coriolis-install
41 EOF"
42
43
44 echo "Your new Coriolis chroot should now be setup and ready to go!"
45 echo -e "
46 ${RED}To get inside the new chroot, execute the following (as normal user):${NC}"
47 echo -e "
48 ${RED}schroot -c $chroot_name --directory=/home/$SUDO_USER${NC}
49 "
50