Fix correct commit hash for release 0.7.0 of openXC7
[dev-env-setup.git] / coriolis2-chroot
index e1d72a19e211cde661c713e845713ad26d270c9d..1ba4e35ee7fdb9802d1a5a8feda234a711dc8ee3 100755 (executable)
@@ -3,126 +3,48 @@ if [ "$EUID" -ne 0 ]
   then echo "Please run as root"
   exit
 fi
-cat <<'EOF' >> /etc/fstab
-/dev      /opt/chroot/coriolis/dev      none   bind   0   0
-/dev/pts  /opt/chroot/coriolis/dev/pts  none   bind   0   0
-/proc     /opt/chroot/coriolis/proc     none   bind   0   0
-/sys      /opt/chroot/coriolis/sys      none   bind   0   0
-/tmp      /opt/chroot/coriolis/tmp      none   bind   0   0
-EOF
-mkdir -p /opt/chroot/coriolis
-apt install -y debootstrap schroot
-/usr/sbin/debootstrap buster /opt/chroot/coriolis http://ftp.debian.org/debian
-mount /opt/chroot/coriolis/dev
-mount /opt/chroot/coriolis/dev/pts
-mount /opt/chroot/coriolis/proc
-mount /opt/chroot/coriolis/sys
-mount /opt/chroot/coriolis/tmp
-echo "coriolis2" > /opt/chroot/coriolis/etc/debian_chroot
-export MYNAME=`id 1000 | awk '{print $1}' | sed 's/.*(\(.*\))/\1/'`
-export CHU_HOME=/home/$MYNAME
-chroot /opt/chroot/coriolis /bin/bash << EOF
-echo Installing necessary apt dependencies in the chroot
-apt-get update -y
-apt-get upgrade -y
-apt-get install -y automake binutils-dev bison build-essential \
-ccache cmake doxygen dvipng flex gcc git graphviz imagemagick \
-libboost-all-dev libboost-python-dev libbz2-dev libmotif-dev \
-libqwt-dev libtool libx11-dev libxaw7-dev libxml2-dev libxpm-dev \
-libxt-dev python3.7 python3-jinja2 python3-pip python3-setuptools \
-python-dev python-qt4 python-sphinx qt4-dev-tools rapidjson-dev \
-texlive texlive-fonts-extra texlive-lang-french texlive-latex-extra \
-texlive-pictures xfig yosys zlib1g-dev
-
-
-
-useradd -m -p `python -c 'import crypt; print crypt.crypt("1234","Fx")'` -s /bin/bash $MYNAME -k /etc/skel
-echo -e "
-Added user ${MYNAME} with \e[1;91mpassword: 1234\e[0m"
+# Terminal echo colours
+RED='\033[1;91m'
+NC='\033[0m'
+
+# Default name for the new chroot
+chroot_name="coriolis"
+
+# Check if default chroot name should be used or not
+if [ -z $1 ]; then
+    echo "Not provided a chroot name, using default chroot \"$chroot_name\""
+else
+       chroot_name="$1"
+       echo "Using specified chroot name \"$chroot_name\""
+fi
 
-echo -e "
-\e[1;91mPlease use command 'passwd ${MYNAME}' to change this immediately after this script is run for security purposes.\e[0m
+if [ -e /opt/chroot/$chroot_name ]; then
+    echo -e "
+${RED}Chroot \"$chroot_name\" exists! Delete with \"rm-deb-chroot\" or
+run parts of this script separately${NC}
 "
-
-echo -e 'export PATH=/usr/lib/ccache:"\044PATH"\nexport DISPLAY=:0.0\nexport ALLIANCE_TOP=$CHU_HOME/alliance/install\nexport LD_LIBRARY_PATH=\044{ALLIANCE_TOP}/lib:\044{LD_LIBRARY_PATH}\nexport LD_LIBRARY_PATH=\044{ALLIANCE_TOP}/lib64:\044{LD_LIBRARY_PATH}' > $CHU_HOME/.bash_profile
-chown $MYNAME $CHU_HOME/.bash_profile
-chgrp $MYNAME $CHU_HOME/.bash_profile
-
-echo -e "Added 'export PATH=/usr/lib/ccache:\"\044PATH\"\nexport DISPLAY=:0.0' to $CHU_HOME/.bash_profile to speed up rebuilds"
-EOF
-
-cat <<EOF >>/etc/schroot/schroot.conf
-[coriolis]
-description=Debian Buster for Coriolis
-directory=/opt/chroot/coriolis
-groups=sbuild-security,$MYNAME,users
-EOF
-
-echo "Adding the following coriolis section to /etc/schroot/schroot.conf:
-
-[coriolis]
-description=Debian Buster for Coriolis
-directory=/opt/chroot/coriolis
-groups=sbuild-security,$MYNAME,users
-
-This enables you to chroot into coriolis as an unprivileged user by running
-'schroot -c coriolis /bin/bash'
+    echo "See https://libre-soc.org/HDL_workflow/coriolis2/ for more info.
 "
-runuser $MYNAME --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
-cd $CHU_HOME
-mkdir -p $CHU_HOME/alliance/build $CHU_HOME/alliance/install
-cd $CHU_HOME/alliance
-git clone https://gitlab.lip6.fr/vlsi-eda/alliance.git
-cd alliance/alliance/src
-./autostuff
-cd $CHU_HOME/alliance/build
-../alliance/alliance/src/configure --prefix=$ALLIANCE_TOP --enable-alc-shared
-EOF'
-
-chroot /opt/chroot/coriolis /bin/bash << EOF
-cd $CHU_HOME/alliance/build
-make -j1 install
-EOF
-
-
-echo MYNAME $MYNAME
-echo CHU_HOME $CHU_HOME
-
-
-runuser $MYNAME --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
-cd $CHU_HOME
-mkdir -p $CHU_HOME/coriolis-2.x/src
-cd $CHU_HOME/coriolis-2.x/src
-git clone https://gitlab.lip6.fr/vlsi-eda/coriolis.git
-cd coriolis
-git checkout devel
-./bootstrap/ccb.py --project=coriolis --make="-j4 install"
+    exit
+fi
 
-#ln -s $CHU_HOME/coriolis-2.x/Linux.x86_64/Release.Shared/install/lib64 $CHU_HOME/coriolis-2.x/Linux.x86_64/Release.Shared/install/lib
-#./bootstrap/ccb.py --project=coriolis --make="-j4 install"
+echo "Creating a new chroot \"$chroot_name\" using \"mk-deb-chroot\""
+./mk-deb-chroot $chroot_name
+echo "Copying scripts to chroot \"$chroot_name\" using \"cp-scripts-to-chroot\""
+./cp-scripts-to-chroot $chroot_name
 
-$CHU_HOME/coriolis-2.x/src/coriolis/bootstrap/coriolisEnv.py > $CHU_HOME/coriolisenv
-source $CHU_HOME/coriolisenv
-cd ~/coriolis-2.x/Linux.x86_64/Release.Shared/install/bin
-./cgt
-EOF'
+# Run coriolis installation script as a normal user
+echo "Entering \"$chroot_name\" and setting Coriolis and its dependencies!"
+runuser $SUDO_USER -c "schroot -c $chroot_name --directory=/tmp /bin/bash << EOF
+cd /home/$SUDO_USER/dev-env-setup
+./coriolis-install
+EOF"
 
 
+echo "Your new Coriolis chroot should now be setup and ready to go!"
+echo -e "
+${RED}To get inside the new chroot, execute the following (as normal user):${NC}"
+echo -e "
+${RED}schroot -c $chroot_name --directory=/home/$SUDO_USER${NC}
+"
 
-#chroot /opt/chroot/coriolis /bin/bash << EOF
-#apt-get update -y 
-#apt-get build-dep yosys -y
-#apt-get install clang tcl tcl-tclreadline tcl-dev libreadline-dev -y
-#apt-get remove yosys -y
-#EOF
-#runuser $MYNAME --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
-#cd $CHU_HOME
-#git clone https://github.com/cliffordwolf/yosys.git
-#cd yosys
-#make config-clang
-#make -j4
-#EOF'
-#chroot /opt/chroot/coriolis /bin/bash << EOF
-#cd $CHU_HOME/yosys
-#make install
-#EOF