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
# Install apt dependencies in the chroot
chroot /opt/chroot/coriolis /bin/bash << EOF
echo Installing necessary apt dependencies in the chroot
# Create user with same UID in the chroot
-useradd -m -p `python -c 'import crypt; print crypt.crypt("1234","Fx")'` -s /bin/bash $MYNAME -k /etc/skel
+useradd -m -p `python -c 'import crypt; print crypt.crypt("1234","Fx")'` -s /bin/bash $SUDO_USER -k /etc/skel
echo -e "
-Added user ${MYNAME} with \e[1;91mpassword: 1234\e[0m"
+Added user ${SUDO_USER} with \e[1;91mpassword: 1234\e[0m"
echo -e "
-\e[1;91mPlease use command 'passwd ${MYNAME}' to change this immediately after this script is run for security purposes.\e[0m
+\e[1;91mPlease use command 'passwd ${SUDO_USER}' to change this immediately after this script is run for security purposes.\e[0m
"
# Add convenience variable to chroot user .bash_profile
-echo -e 'export PATH=/usr/lib/ccache:"\044PATH"\nexport DISPLAY=:0.0\nexport ALLIANCE_TOP=$CHU_HOME/alliance/install\nexport YOSYS_TOP=$CHU_HOME/yosys\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 'export PATH=/usr/lib/ccache:"\044PATH"\nexport DISPLAY=:0.0\nexport ALLIANCE_TOP=/home/$SUDO_USER/alliance/install\nexport YOSYS_TOP=/home/$SUDO_USER/yosys\nexport LD_LIBRARY_PATH=\044{ALLIANCE_TOP}/lib:\044{LD_LIBRARY_PATH}\nexport LD_LIBRARY_PATH=\044{ALLIANCE_TOP}/lib64:\044{LD_LIBRARY_PATH}' > /home/$SUDO_USER/.bash_profile
+chown $SUDO_USER /home/$SUDO_USER/.bash_profile
+chgrp $SUDO_USER /home/$SUDO_USER/.bash_profile
-echo -e "Added 'export PATH=/usr/lib/ccache:\"\044PATH\"\nexport DISPLAY=:0.0' to $CHU_HOME/.bash_profile to speed up rebuilds"
+echo -e "Added 'export PATH=/usr/lib/ccache:\"\044PATH\"\nexport DISPLAY=:0.0' to /home/$SUDO_USER/.bash_profile to speed up rebuilds"
EOF
# Add coriolis config to schroot.conf
[coriolis]
description=Debian Buster for Coriolis
directory=/opt/chroot/coriolis
-groups=sbuild-security,$MYNAME,users
+groups=sbuild-security,$SUDO_USER,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
+groups=sbuild-security,$SUDO_USER,users
This enables you to chroot into coriolis as an unprivileged user by running
'schroot -c coriolis /bin/bash'
apt-get build-dep yosys -y
apt-get remove yosys -y
EOF
-runuser $MYNAME --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
-cd $CHU_HOME
+runuser $SUDO_USER --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
+cd /home/$SUDO_USER
git clone https://github.com/cliffordwolf/yosys.git
cd yosys
make config-clang
EOF'
chroot /opt/chroot/coriolis /bin/bash << EOF
-cd $CHU_HOME/yosys
+cd /home/$SUDO_USER/yosys
make install
EOF
# Install coriolis2 from source
-runuser $MYNAME --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
-cd $CHU_HOME
+runuser $SUDO_USER --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
+cd /home/$SUDO_USER
source .bash_profile
-mkdir -p $CHU_HOME/coriolis-2.x/src
-cd $CHU_HOME/coriolis-2.x/src
+mkdir -p /home/$SUDO_USER/coriolis-2.x/src
+cd /home/$SUDO_USER/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="-j$(nproc) install"
# Setup and test coriolisenv
-$CHU_HOME/coriolis-2.x/src/coriolis/bootstrap/coriolisEnv.py > $CHU_HOME/coriolisenv
-source $CHU_HOME/.bash_profile
-source $CHU_HOME/coriolisenv
+/home/$SUDO_USER/coriolis-2.x/src/coriolis/bootstrap/coriolisEnv.py > /home/$SUDO_USER/coriolisenv
+source /home/$SUDO_USER/.bash_profile
+source /home/$SUDO_USER/coriolisenv
EOF'
# Install alliance from source
-runuser $MYNAME --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
-cd $CHU_HOME
+runuser $SUDO_USER --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
+cd /home/$SUDO_USER
source coriolisenv
git clone https://gitlab.lip6.fr/vlsi-eda/alliance.git
-mkdir -p $CHU_HOME/alliance/build $CHU_HOME/alliance/install
+mkdir -p /home/$SUDO_USER/alliance/build /home/$SUDO_USER/alliance/install
mv alliance/alliance/src alliance
rm -rf alliance/alliance
cd alliance/src
./autostuff
-cd $CHU_HOME/alliance/build
-../src/configure --prefix=$CHU_HOME/alliance/install --enable-alc-shared
+cd /home/$SUDO_USER/alliance/build
+../src/configure --prefix=/home/$SUDO_USER/alliance/install --enable-alc-shared
EOF'
chroot /opt/chroot/coriolis /bin/bash << EOF
-cd $CHU_HOME/alliance/build
-source $CHU_HOME/coriolisenv
+cd /home/$SUDO_USER/alliance/build
+source /home/$SUDO_USER/coriolisenv
make -j1 install
EOF
# Install and configure alliance-check-toolkit
-runuser $MYNAME --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
-cd $CHU_HOME
+runuser $SUDO_USER --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
+cd /home/$SUDO_USER
git clone https://gitlab.lip6.fr/vlsi-eda/alliance-check-toolkit.git
source coriolisenv
-touch alliance-check-toolkit/etc/mk/users.d/user-$MYNAME.mk
-cat <<EOG >>alliance-check-toolkit/etc/mk/users.d/user-$MYNAME.mk
-export CORIOLIS_TOP=/home/$MYNAME/coriolis-2.x/Linux.x86_64/Release.Shared/install
-export ALLIANCE_TOP=/home/$MYNAME/alliance/install
-export CHECK_TOOLKIT=/home/$MYNAME/alliance-check-toolkit
-export YOSYS_TOP=/home/$MYNAME/yosys
+touch alliance-check-toolkit/etc/mk/users.d/user-$SUDO_USER.mk
+cat <<EOG >>alliance-check-toolkit/etc/mk/users.d/user-$SUDO_USER.mk
+export CORIOLIS_TOP=/home/$SUDO_USER/coriolis-2.x/Linux.x86_64/Release.Shared/install
+export ALLIANCE_TOP=/home/$SUDO_USER/alliance/install
+export CHECK_TOOLKIT=/home/$SUDO_USER/alliance-check-toolkit
+export YOSYS_TOP=/home/$SUDO_USER/yosys
EOG
-source $CHU_HOME/.bash_profile
+source /home/$SUDO_USER/.bash_profile
cd alliance-check-toolkit/benchs/ARM/cmos
make lvx
echo -e "