Applied JP's patch to correctly set coriolisenv
[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 cat <<'EOF' >> /etc/fstab
7 /dev /opt/chroot/coriolis/dev none bind 0 0
8 /dev/pts /opt/chroot/coriolis/dev/pts none bind 0 0
9 /proc /opt/chroot/coriolis/proc none bind 0 0
10 /sys /opt/chroot/coriolis/sys none bind 0 0
11 /tmp /opt/chroot/coriolis/tmp none bind 0 0
12 EOF
13 mkdir -p /opt/chroot/coriolis
14 apt install -y debootstrap schroot
15 /usr/sbin/debootstrap buster /opt/chroot/coriolis http://ftp.debian.org/debian
16 mount /opt/chroot/coriolis/dev
17 mount /opt/chroot/coriolis/dev/pts
18 mount /opt/chroot/coriolis/proc
19 mount /opt/chroot/coriolis/sys
20 mount /opt/chroot/coriolis/tmp
21 echo "coriolis2" > /opt/chroot/coriolis/etc/debian_chroot
22 export MYNAME=`id 1000 | awk '{print $1}' | sed 's/.*(\(.*\))/\1/'`
23 export CHU_HOME=/home/$MYNAME
24 chroot /opt/chroot/coriolis /bin/bash << EOF
25 echo Installing necessary apt dependencies in the chroot
26 apt-get update -y
27 apt-get upgrade -y
28 apt-get install -y automake binutils-dev bison build-essential \
29 ccache cmake doxygen dvipng flex gcc git graphviz imagemagick \
30 libboost-all-dev libboost-python-dev libbz2-dev libmotif-dev \
31 libqwt-dev libtool libx11-dev libxaw7-dev libxml2-dev libxpm-dev \
32 libxt-dev python3.7 python3-jinja2 python3-pip python3-setuptools \
33 python-dev python-qt4 python-sphinx qt4-dev-tools rapidjson-dev \
34 texlive texlive-fonts-extra texlive-lang-french texlive-latex-extra \
35 texlive-pictures xfig yosys zlib1g-dev
36
37
38
39 useradd -m -p `python -c 'import crypt; print crypt.crypt("1234","Fx")'` -s /bin/bash $MYNAME -k /etc/skel
40 echo -e "
41 Added user ${MYNAME} with \e[1;91mpassword: 1234\e[0m"
42
43 echo -e "
44 \e[1;91mPlease use command 'passwd ${MYNAME}' to change this immediately after this script is run for security purposes.\e[0m
45 "
46
47 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
48 chown $MYNAME $CHU_HOME/.bash_profile
49 chgrp $MYNAME $CHU_HOME/.bash_profile
50
51 echo -e "Added 'export PATH=/usr/lib/ccache:\"\044PATH\"\nexport DISPLAY=:0.0' to $CHU_HOME/.bash_profile to speed up rebuilds"
52 EOF
53
54 cat <<EOF >>/etc/schroot/schroot.conf
55 [coriolis]
56 description=Debian Buster for Coriolis
57 directory=/opt/chroot/coriolis
58 groups=sbuild-security,$MYNAME,users
59 EOF
60
61 echo "Adding the following coriolis section to /etc/schroot/schroot.conf:
62
63 [coriolis]
64 description=Debian Buster for Coriolis
65 directory=/opt/chroot/coriolis
66 groups=sbuild-security,$MYNAME,users
67
68 This enables you to chroot into coriolis as an unprivileged user by running
69 'schroot -c coriolis /bin/bash'
70 "
71 runuser $MYNAME --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
72 cd $CHU_HOME
73 mkdir -p $CHU_HOME/alliance/build $CHU_HOME/alliance/install
74 cd $CHU_HOME/alliance
75 git clone https://gitlab.lip6.fr/vlsi-eda/alliance.git
76 cd alliance/alliance/src
77 ./autostuff
78 cd $CHU_HOME/alliance/build
79 ../alliance/alliance/src/configure --prefix=$ALLIANCE_TOP --enable-alc-shared
80 EOF'
81
82 chroot /opt/chroot/coriolis /bin/bash << EOF
83 cd $CHU_HOME/alliance/build
84 make -j1 install
85 EOF
86
87
88 echo MYNAME $MYNAME
89 echo CHU_HOME $CHU_HOME
90
91
92 runuser $MYNAME --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
93 cd $CHU_HOME
94 mkdir -p $CHU_HOME/coriolis-2.x/src
95 cd $CHU_HOME/coriolis-2.x/src
96 git clone https://gitlab.lip6.fr/vlsi-eda/coriolis.git
97 cd coriolis
98 git checkout devel
99 ./bootstrap/ccb.py --project=coriolis --make="-j4 install"
100
101 #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
102 #./bootstrap/ccb.py --project=coriolis --make="-j4 install"
103
104 $CHU_HOME/coriolis-2.x/src/coriolis/bootstrap/coriolisEnv.py > $CHU_HOME/coriolisenv
105 source $CHU_HOME/coriolisenv
106 cd ~/coriolis-2.x/Linux.x86_64/Release.Shared/install/bin
107 ./cgt
108 EOF'
109
110
111
112 #chroot /opt/chroot/coriolis /bin/bash << EOF
113 #apt-get update -y
114 #apt-get build-dep yosys -y
115 #apt-get install clang tcl tcl-tclreadline tcl-dev libreadline-dev -y
116 #apt-get remove yosys -y
117 #EOF
118 #runuser $MYNAME --preserve-environment -c 'schroot -c coriolis /bin/bash << EOF
119 #cd $CHU_HOME
120 #git clone https://github.com/cliffordwolf/yosys.git
121 #cd yosys
122 #make config-clang
123 #make -j4
124 #EOF'
125 #chroot /opt/chroot/coriolis /bin/bash << EOF
126 #cd $CHU_HOME/yosys
127 #make install
128 #EOF