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