-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-tinyipa.sh
executable file
·103 lines (76 loc) · 3.22 KB
/
build-tinyipa.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
set -ex
cwd=`pwd`
builddir="tinyipabuild"
# Log into sudo so that it can be used throughout the script
sudo -v
# If an old build directory exists remove it
if [ -d "$builddir" ]; then
sudo rm -rf $builddir
fi
# Download and cache required files from tinycorelinux
cd build_files
wget -N http://distro.ibiblio.org/tinycorelinux/6.x/x86_64/release/distribution_files/corepure64.gz
wget -N http://distro.ibiblio.org/tinycorelinux/6.x/x86_64/release/distribution_files/vmlinuz64
wget -N http://tarballs.openstack.org/ironic-python-agent/ironic-python-agent-master.tar.gz
cd $cwd
# Make directory for building in
mkdir $builddir
# Extract rootfs from .gz file
( cd $builddir && zcat ../build_files/corepure64.gz | sudo cpio -i -H newc -d )
# Create directory for python local mirror
mkdir -p $builddir/tmp/localpip
# Download get-pip into ramdisk
( cd $builddir/tmp && wget https://bootstrap.pypa.io/get-pip.py )
# Download all IPA python requirements
pip install --no-use-wheel --download $builddir/tmp/localpip build_files/ironic-python-agent-master.tar.gz
# Download setuptools
pip install --no-use-wheel --download $builddir/tmp/localpip setuptools
# Download pip
pip install --no-use-wheel --download $builddir/tmp/localpip pip
# Download wheel
pip install --no-use-wheel --download $builddir/tmp/localpip wheel
# Download virtualenv
pip install --no-use-wheel --download $builddir/tmp/localpip virtualenv
# Create directory for builtin extensions
mkdir -p $builddir/tmp/builtin/optional
# Copy onboot.lst to builtin
cp build_files/onboot.lst $builddir/tmp/builtin/.
# Pull tinycore extensions and deps
cd $builddir/tmp/builtin/optional
# Download required tczs
cat ../onboot.lst | sed "s/\(.*\)/http:\/\/distro\.ibiblio\.org\/tinycorelinux\/6\.x\/x86_64\/tcz\/\1/" | xargs wget -N -nv --progress=bar
set +e
ls *.tcz | sed "s/\(.*\)/http:\/\/distro\.ibiblio\.org\/tinycorelinux\/6\.x\/x86_64\/tcz\/\1.dep/" | xargs wget -N -q
set -e
# Install qemu utils
cp $cwd/build_files/qemu-utils.* .
echo "qemu-utils.tcz" >> ../onboot.lst
# Install tgt
cp $cwd/build_files/tgt.* .
echo "tgt.tcz" >> ../onboot.lst
# Get inital list of dependencies to pull
files="`comm -23 <(awk 1 *.dep | sed -e "s/\s//" | grep -v ^$ | sort -u) <(ls *.tcz | sort -u)`"
# Loop until all dependencies are satified
while [ ! -z "$files" ]
do
# Parse dep files and download missing tczs
awk 1 *.dep | grep -v ^$ | sort -u | sed "s/\(.*\)/http:\/\/distro\.ibiblio\.org\/tinycorelinux\/6\.x\/x86_64\/tcz\/\1/" | xargs wget -N --progress=bar
# Pull dep files for downloaded tczs
set +e
ls *.tcz | sed "s/\(.*\)/http:\/\/distro\.ibiblio\.org\/tinycorelinux\/6\.x\/x86_64\/tcz\/\1.dep/" | xargs wget -N -q
set -e
files="`comm -23 <(awk 1 *.dep | sed -e "s/\s//" | grep -v ^$ | sort -u) <(ls *.tcz | sort -u)`"
done
cd $cwd
# Copy bootlocal.sh to opt
sudo cp build_files/bootlocal.sh $builddir/opt/.
# Disable ZSwap
sudo sed -i '/# Main/a NOZSWAP=1' $builddir/etc/init.d/tc-config
# Rebuild build directory into gz file
( cd $builddir && sudo find | sudo cpio -o -H newc | gzip -2 > ../tinyipa.gz )
# Attempt to compress the gz more
advdef -z4 tinyipa.gz
# Copy vmlinuz to new name
cp build_files/vmlinuz64 ./tinyipa.vmlinuz
# Remove builddir now that its been compressed
# sudo rm -rf $builddir