forked from environmentalomics/build-bio-linux
-
Notifications
You must be signed in to change notification settings - Fork 6
/
build_process_14.04.5.sh
executable file
·222 lines (184 loc) · 6.52 KB
/
build_process_14.04.5.sh
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
#!/bin/bash -f
#@(#)build_process_14.04.5.sh 2017-09-05 W.McCaffery and A.J.Travis
#
# Changelog 2017-08-19 last modified by A.J.Travis
#
# Executable bash script based on "build_process_14.04.5.txt"
#
# Build process:
# - Changed to "bash" syntax - zsh commands removed
# - Indentation of commands for readability
# This does not affect the copy/pasting of commands
# - Doesn't have to be run from an account called 'manager'
# - use of '~' has been replaced with $HOME
# - added [enter chroot] and [exit chroot] with separate indentation to
# clarify when commands are to be executed in chroot
# Bio-Linux:
# - Updated Ubuntu base from 14.04.2 to 14.04.5
# - Optional local .deb to stop usb maker from overlapping partitions
# - Removed broken splash from liveUSB self checker
# - Forced liveUSB fat partition to mount read only so that it doesn't
# get written to or become corrupted when usb removed prematurely
# - Added the following programs:
# - mdadm
# - rkhunter
# - chkrootkit
#
# Build process:
#
# 1) Set up the build machine and unpack the ISO
# 2) Make some changes to the unpacked ISO
# 3) Chroot into the unpacked ISO and install Bio-Linux
# 4) Remaster and publish
# 5) Auto-build the .ova (with Packer) - not described here, see README
#
##
## 1) Set up the build machine and unpack the ISO
##
# check which script is running
echo "build_process: running $0"
# use $HOME instead of '~' [set automatically by Linux]
echo "build_process: HOME = $HOME"
# if $HOME isn't set for some reason exit
if [ ! -n $HOME ]; then
echo "build_process: Error HOME not set"
exit
fi
# check the build scripts are available
if [ ! -d $HOME/bl8bits ]; then
echo "build_process: Error \'$HOME/bl8bits\' not available"
exit
fi
# use a non-interactive APT front-end
export DEBIAN_FRONTEND=noninteractive
# update the host OS if necessary
if [ -z "$(find -H /var/lib/apt/lists -maxdepth 0 -mtime -1)" ]; then
apt-get -y update
apt-get -y dist-upgrade
apt-get -y autoremove --purge
fi
# The following packages must be installed
sudo apt-get -y install squashfs-tools sharutils
# Ubuntu .iso image we're remastering
ISO=ubuntu-14.04.5-desktop-amd64.iso
echo "build_process: ISO = $ISO"
# download the .iso
if [ ! -f $ISO ]; then
echo "build_process: downloading $ISO ..."
wget -nv http://releases.ubuntu.com/trusty/$ISO
fi
# unpack the .iso
if [ ! -d reconstructor ]; then
mkdir reconstructor
cd reconstructor
mkdir initrd remaster root original_cd_image
sudo mkdir /mnt/cdrom1
sudo mount -t auto -o loop $HOME/$ISO /mnt/cdrom1
rsync -av /mnt/cdrom1/ $HOME/reconstructor/remaster/
chmod -R u+w remaster
rsync -av /mnt/cdrom1/ $HOME/reconstructor/original_cd_image/
chmod -R a-w original_cd_image
sudo umount /mnt/cdrom1
sudo rmdir /mnt/cdrom1
# taken from the 12.04 remaster instructions
cd initrd
sudo bash -c "lzcat -Slz ../remaster/casper/initrd.lz | cpio -i"
# Unpack rootfs
cd ../root
mkdir ../squashmount
sudo mount -t squashfs -o loop,ro ../remaster/casper/filesystem.squashfs ../squashmount/
sudo rsync -av ../squashmount/ .
sudo umount ../squashmount
rmdir ../squashmount
cd $HOME
fi
##
## 2) Make some changes to the unpacked ISO
##
# remove wubi and autorun [not required for Bio-Linux]
rm -f reconstructor/remaster/wubi.exe reconstructor/remaster/autorun.inf
#
# Install biolinuxfirstboot into chroot
#
# Note this is checked by recon.test.d but not auto-fixed
#
if [ ! -f reconstructor/root/etc/init.d/biolinuxfirstboot ]; then
cd reconstructor/root/etc/init.d
sudo cp $HOME/bl8bits/biolinuxfirstboot .
cd ../rc1.d
sudo ln -fs ../init.d/biolinuxfirstboot S99biolinuxfirstboot
cd ../rc2.d
sudo ln -fs ../init.d/biolinuxfirstboot S99biolinuxfirstboot
cd $HOME
fi
#
# Everything after here is checked by recon.test.d and fixed automagically :-)
# Details about the changes made by recon are given in the 14.04 build process.
#
# add Ubuntu universe and multiverse repositories to the chroot
if [ ! -f reconstructor/root/etc/apt/sources.list.orig ]; then
sudo mv reconstructor/root/etc/apt/sources.list \
reconstructor/root/etc/apt/sources.list.orig
sudo cp bl8bits/sources.list \
reconstructor/root/etc/apt/sources.list
fi
# copy script needed install Bio-Linux in the chroot
if [ ! -f reconstructor/root/tmp//upgrade8.sh ]; then
sudo cp bl8bits/upgrade_to_8/upgrade8.sh \
reconstructor/root/tmp/
fi
# copy updated bio-linux-usb-maker package for install within chroot
if [ ! -f reconstructor/root/var/cache/apt/archives/bio-linux-usb-maker_8.2-2_all.deb ]; then
sudo cp bl8bits/Bio-linux-usb-maker/bio-linux-usb-maker_8.2-2_all.deb \
reconstructor/root/var/cache/apt/archives/
fi
##
## 3) Chroot into the unpacked ISO and install Bio-Linux
##
# [enter chroot]
$HOME/bl8bits/bin/openchroot <<EOF
# update security key for Google APT repository
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1397BC53640DB551
# dist-upgrade the chroot
apt-get update
apt-get -y dist-upgrade
# make sure only the most recent Linux kernel is installed
purge=\$(dpkg -l | awk '/linux-image-[0-9]+/{print \$2}' | head -n -1)
if [ \$(echo \$purge | wc -w) > 1 ]; then
apt-get -y purge \$purge
fi
# make sure only the most recent kernel headers are installed
purge=\$(dpkg -l | awk '/linux-headers-[0-9]+/{print \$2}' | head -n -3)
if [ \$(echo \$purge | wc -w) > 1 ]; then
apt-get -y purge \$purge
fi
# required by "mdadm" [postfix is installed by default]
apt-get -y install exim4
#
# run Tim's upgrade_to_8 script
#
sh /tmp/upgrade8.sh
# post-installation fix-ups
apt-get -y install bio-linux-fixups
# install bio-linux-usb-maker within chroot
apt-get -y install gdebi
gdebi -n /var/cache/apt/archives/bio-linux-usb-maker_8.2-2_all.deb
# required for recon.test.d, which can be hard to please...
apt-get -y install ufw gufw
# remove unwanted packages
apt-get -y remove example-content aisleriot --auto-remove --purge
# Purge any packages marked 'rc'
apt-get -y purge \$(dpkg -l | awk '/^rc/{print \$2}')
apt-get -y autoremove --purge
apt-get -y autoclean
# [exit chroot]
exit
EOF
##
## 4) Remaster and publish
##
# recon may need to be run a few times before it completes
echo now run '$HOME/bl8bits/bin/recon 8.0.8'
##
## 5) Auto-build the .ova (with Packer) - not described here, see README
##