-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
141 lines (112 loc) · 4.48 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
SHELL := /bin/bash
all:
# cp /vagrant/run_jupyter.sh ~/
apt-get update -y
#AHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
sudo apt-mark hold grub*
# apt-get upgrade -y
apt-get install -y curl git mc net-tools
apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev
apt-get install -y libreadline-dev libsqlite3-dev wget curl libncurses5-dev libncursesw5-dev
apt-get install -y xz-utils tk-dev libffi-dev liblzma-dev python3-openssl
apt-get install -y gcc-avr
apt-get install -y avr-libc
apt-get install -y gcc-arm-none-eabi
apt-get install -y make
apt-get install -y dos2unix
apt-get install -y libmpfr-dev libmpc-dev
apt-get install -y usbutils
apt-get install -y libusb-1.0.0-dev
dos2unix /home/vagrant/pyenv.tail
apt-get install -y openocd
apt-get clean
su vagrant - -c "make stage2"
#find /home/vagrant/work/projects -exec dos2unix {} \;
# USB permissions
cp /home/vagrant/work/projects/chipwhisperer/hardware/50-newae.rules /etc/udev/rules.d/
groupadd chipwhisperer
usermod -a -G chipwhisperer vagrant
usermod -a -G plugdev vagrant
usermod -a -G dialout vagrant
udevadm control --reload-rules
# copy cron script from vagrant folder
# cp /vagrant/run_jupyter.sh /home/vagrant/
dos2unix /home/vagrant/run_jupyter.sh
chown -R vagrant:vagrant /home/vagrant/run_jupyter.sh
chmod +x /home/vagrant/run_jupyter.sh
# jupyter stuff
su vagrant - -c "source /home/vagrant/pyenv.tail; pyenv activate cw; jupyter contrib nbextension install --user"
# copy jupyter config
mkdir -p /home/vagrant/.jupyter
# cp /vagrant/jupyter_notebook_config.py /home/vagrant/.jupyter/
# make sure jupyter is under the vagrant user
# maybe just make /home/vagrant all vagrant?
chown vagrant:vagrant -R /home/vagrant/
# check if cron job already inserted, and if not insert it
#(if !(crontab -u vagrant -l | grep "run_jupyter\.sh"); then \
(crontab -u vagrant -l 2>/dev/null; echo "@reboot /home/vagrant/run_jupyter.sh") | crontab -u vagrant -
#fi \
#)
printf "\
if grep -q \"password\" \"/home/vagrant/.jupyter/jupyter_notebook_config.json\"; then \\n \
if ps aux | grep \"jupyter-notebook\" | grep "versions"; \\n \
then echo \"Jupyter notebook server started\"; \\n \
else \\n \
echo \"Jupyter notebook process not started. Check logs in work/projects\" \\n \
fi \\n \
else \\n \
echo \"Please set password for Jupyter:\"; \\n \
jupyter notebook password; echo \"Thank you. Reboot to start Jupyter\"; \\n \
fi\
" >> /home/vagrant/.bashrc
#setup pyenv for user
su vagrant - -c "source /home/vagrant/pyenv.tail; pyenv global 3.9.7/envs/cw"
#pyenv global 3.6.7/envs/cw
#done now reboot
reboot
stage2:
curl https://pyenv.run | bash
cat pyenv.tail >> ~/.bashrc
echo "export BOKEH_RESOURCES=inline" >> ~/.bashrc
(\
source /home/vagrant/pyenv.tail; \
make stage3; \
)
stage3:
git config --global user.name "Vagrant"
git config --global user.email "[email protected]"
mkdir -p /home/vagrant/work/projects
cd /home/vagrant/work/projects && git clone https://github.com/newaetech/chipwhisperer --depth 1 --shallow-submodules --sparse 2>&1
cd /home/vagrant/work/projects/chipwhisperer && \
git sparse-checkout set "/*" \!hardware/victims/cw305_artixtarget \!hardware/victims/firmware/hal/silabs_sdk \!hardware/victims/firmware/esp32
cd /home/vagrant/work/projects/chipwhisperer && rm -rf jupyter && git clone --depth 1 --sparse https://github.com/newaetech/chipwhisperer-jupyter jupyter && \
cd jupyter && git sparse-checkout set "/*" \!courses/sca101/traces \!courses/sca201/traces
# cd /home/vagrant/work/projects && git clone https://github.com/newaetech/phywhispererusb
# cd /home/vagrant/work/projects && git clone https://github.com/Ledger-Donjon/lascar
# cd /home/vagrant/work/projects/chipwhisperer \
# && find ./hardware/victims/cw305_artixtarget -type f -exec shred -uzfn 1 "{}" \; \
# && find ./hardware/victims/firmware/hal/silabs_sdk -type f -exec shred -uzfn 1 "{}" \; \
# && find ./hardware/victims/firmware/esp32 -type f -exec shred -uzfn 1 "{}" \; \
pyenv install 3.9.7
pyenv virtualenv 3.9.7 cw
make stage4
stage4:
( \
set -x; \
set -e; \
source /home/vagrant/pyenv.tail; \
pyenv activate cw; \
pip install wheel; \
pip install --upgrade pip; \
pip install phoenixAES terminaltables; \
pip install numpy; \
pip install nbparameterise; \
pip install gmpy2; \
pip install fastdtw; \
cd /home/vagrant/work/projects/chipwhisperer/jupyter; \
ls; \
pip install -r requirements.txt; \
pip install tqdm --upgrade; \
cd ..; \
python3 setup.py develop; \
)