Skip to content

Commit 632c7e6

Browse files
committed
Add tinyipa to IPA imagebuild directory
TinyCoreLinux is a small 10mb base linux distribution which can easily be built into a ramdisk for PXE and ISO booting. This patch adds scripts and other required files to build a TinyCore based ramdisk which runs the Ironic Python Agent. Change-Id: I79fbec75de19b3d6feb19f87a3a0f662eae42bf3
1 parent 1e30946 commit 632c7e6

12 files changed

Lines changed: 377 additions & 0 deletions

File tree

imagebuild/README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ ironic-python-agent images
33

44
coreos - Builds a CoreOS Ramdisk and Kernel suitable for running
55
ironic-python-agent
6+
7+
tinyipa - Builds a TinyCoreLinux Ramdisk and Kernel suitable for running
8+
ironic-python-agent

imagebuild/tinyipa/.gitignore

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
*.gz
2+
*.zip
3+
*.tar.gz
4+
tinyipabuild
5+
tinyipafinal
6+
*.vmlinuz
7+
vmlinuz64
8+
*.iso
9+
*.tcz*
10+
squashfs-root
11+
syslinux*
12+
newiso

imagebuild/tinyipa/Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
default: build finalise
2+
3+
all: build finalise iso
4+
5+
build:
6+
./build-tinyipa.sh
7+
8+
finalise:
9+
./finalise-tinyipa.sh
10+
11+
iso:
12+
./build-iso.sh
13+
14+
clean: clean_build clean_iso
15+
16+
clean_build:
17+
sudo -v
18+
sudo rm -rf tinyipabuild
19+
sudo rm -rf tinyipafinal
20+
rm -f tinyipa.vmlinuz
21+
rm -f tinyipa.gz
22+
rm -f build_files/corepure64.gz
23+
rm -f build_files/vmlinuz64
24+
rm -f build_files/*.tcz
25+
rm -f build_files/*.tcz.*
26+
27+
clean_iso:
28+
rm -rf newiso
29+
rm -f build_files/syslinux-4.06.tar.gz
30+
rm -rf build_files/syslinux-4.06
31+
rm -f tinyipa.iso

imagebuild/tinyipa/README.rst

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
=============================
2+
Tiny Core Ironic Python Agent
3+
=============================
4+
5+
.. WARNING::
6+
This is experimental! Build tested on Ubuntu Server 14.04 and Debian Jessie
7+
8+
Build script requirements
9+
-------------------------
10+
For the main build script:
11+
12+
* wget
13+
* pip
14+
* unzip
15+
* sudo
16+
* awk
17+
18+
For building an ISO you'll also need:
19+
20+
* genisoimage
21+
22+
Instructions:
23+
-------------
24+
To create a new ramdisk, run::
25+
26+
make
27+
28+
or::
29+
30+
./build-tinyipa.sh && ./finalise-tinyipa.sh
31+
32+
This will create two new files once completed:
33+
34+
* tinyipa.vmlinuz
35+
* tinyipa.gz
36+
37+
These are your two files to upload to glance for use with Ironic.
38+
39+
Building an ISO from a previous make run:
40+
-----------------------------------------
41+
Once you've built tinyipa it is possible to pack it into an ISO if required. To
42+
create a bootable ISO, run::
43+
44+
make iso
45+
46+
or::
47+
48+
./build-iso.sh
49+
50+
This will create one new file once completed:
51+
52+
* tinyipa.iso
53+
54+
To build a fresh ramdisk and build an iso from it:
55+
--------------------------------------------------
56+
Run::
57+
58+
make all
59+
60+
To clean up the whole build environment run:
61+
--------------------------------------------
62+
Run::
63+
64+
make clean
65+
66+
For cleaning up just the iso or just the ramdisk build::
67+
68+
make clean_iso
69+
70+
or::
71+
72+
make clean_tinyipa
73+
74+
Advanced options
75+
----------------
76+
77+
If you want the build script to preinstall everything into the ramdisk,
78+
instead of loading some things at runtime (this results in a slightly bigger
79+
ramdisk), before running make or build-tinyipa.sh run::
80+
81+
export BUILD_AND_INSTALL_TINYIPA=true

imagebuild/tinyipa/build-iso.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
WORKDIR=$(realpath $0 | xargs dirname)
5+
6+
cd $WORKDIR/build_files
7+
wget -N https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-4.06.tar.gz && tar zxf syslinux-4.06.tar.gz
8+
9+
cd $WORKDIR
10+
rm -rf newiso
11+
mkdir -p newiso/boot/isolinux
12+
cp build_files/syslinux-4.06/core/isolinux.bin newiso/boot/isolinux/.
13+
cp build_files/isolinux.cfg newiso/boot/isolinux/.
14+
cp tinyipa.gz newiso/boot/corepure64.gz
15+
cp tinyipa.vmlinuz newiso/boot/vmlinuz64
16+
genisoimage -l -r -J -R -V TC-custom -no-emul-boot -boot-load-size 4 -boot-info-table -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat -o tinyipa.iso newiso
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/sh
2+
3+
set -ex
4+
WORKDIR=$(readlink -f $0 | xargs dirname)
5+
BUILDDIR="$WORKDIR/tinyipabuild"
6+
BUILD_AND_INSTALL_TINYIPA=${BUILD_AND_INSTALL_TINYIPA:-false}
7+
8+
CHROOT_PATH="/usr/local/sbin:/usr/local/bin:/apps/bin:/usr/sbin:/usr/bin:/sbin:/bin"
9+
CHROOT_CMD="sudo chroot $BUILDDIR /usr/bin/env PATH=$CHROOT_PATH"
10+
11+
# Ensure we have an extended sudo to prevent the need to enter a password over
12+
# and over again.
13+
sudo -v
14+
15+
# If an old build directory exists remove it
16+
if [ -d "$BUILDDIR" ]; then
17+
sudo rm -rf "$BUILDDIR"
18+
fi
19+
20+
##############################################
21+
# Download and Cache Tiny Core Files
22+
##############################################
23+
24+
cd $WORKDIR/build_files
25+
wget -N http://distro.ibiblio.org/tinycorelinux/6.x/x86_64/release/distribution_files/corepure64.gz
26+
wget -N http://distro.ibiblio.org/tinycorelinux/6.x/x86_64/release/distribution_files/vmlinuz64
27+
cd $WORKDIR
28+
29+
########################################################
30+
# Build Required Python Dependecies in a Build Directory
31+
########################################################
32+
33+
# Make directory for building in
34+
mkdir "$BUILDDIR"
35+
36+
# Extract rootfs from .gz file
37+
( cd "$BUILDDIR" && zcat $WORKDIR/build_files/corepure64.gz | sudo cpio -i -H newc -d )
38+
39+
# Download get-pip into ramdisk
40+
( cd "$BUILDDIR/tmp" && wget https://bootstrap.pypa.io/get-pip.py )
41+
42+
# Download TGT and Qemu-utils source
43+
git clone https://github.com/fujita/tgt.git $BUILDDIR/tmp/tgt --depth=1 --branch v1.0.62
44+
git clone git://git.qemu-project.org/qemu.git $BUILDDIR/tmp/qemu --depth=1 --branch v2.5.0
45+
46+
# Create directory for python local mirror
47+
mkdir -p "$BUILDDIR/tmp/localpip"
48+
49+
# Download IPA and requirements
50+
cd ../..
51+
rm -rf *.egg-info
52+
python setup.py sdist --dist-dir "$BUILDDIR/tmp/localpip" --quiet
53+
cd $WORKDIR
54+
55+
sudo cp /etc/resolv.conf $BUILDDIR/etc/resolv.conf
56+
sudo mount --bind /proc $BUILDDIR/proc
57+
$CHROOT_CMD mkdir /etc/sysconfig/tcedir
58+
$CHROOT_CMD chmod a+rwx /etc/sysconfig/tcedir
59+
$CHROOT_CMD touch /etc/sysconfig/tcuser
60+
$CHROOT_CMD chmod a+rwx /etc/sysconfig/tcuser
61+
62+
while read line; do
63+
sudo chroot --userspec=tc:staff $BUILDDIR /usr/bin/env PATH=$CHROOT_PATH tce-load -wci $line
64+
done < $WORKDIR/build_files/buildreqs.lst
65+
66+
sudo umount $BUILDDIR/proc
67+
68+
# Build python wheels
69+
$CHROOT_CMD python /tmp/get-pip.py
70+
$CHROOT_CMD pip install pbr
71+
$CHROOT_CMD pip wheel --wheel-dir /tmp/wheels setuptools
72+
$CHROOT_CMD pip wheel --wheel-dir /tmp/wheels pip
73+
$CHROOT_CMD pip wheel --pre --wheel-dir /tmp/wheels --find-links=/tmp/localpip ironic-python-agent
74+
75+
# Build tgt
76+
rm -rf $WORKDIR/build_files/tgt.tcz
77+
$CHROOT_CMD /bin/sh -c "cd /tmp/tgt && make && make install-programs install-conf install-scripts DESTDIR=/tmp/tgt-installed"
78+
cd $WORKDIR/build_files && mksquashfs $BUILDDIR/tmp/tgt-installed tgt.tcz && md5sum tgt.tcz > tgt.tcz.md5.txt
79+
# Build qemu-utils
80+
rm -rf $WORKDIR/build_files/qemu-utils.tcz
81+
$CHROOT_CMD /bin/sh -c "cd /tmp/qemu && ./configure --disable-system --disable-user --disable-linux-user --disable-bsd-user --disable-guest-agent && make && make install DESTDIR=/tmp/qemu-utils"
82+
cd $WORKDIR/build_files && mksquashfs $BUILDDIR/tmp/qemu-utils qemu-utils.tcz && md5sum qemu-utils.tcz > qemu-utils.tcz.md5.txt
83+
# Create qemu-utils.tcz.dep
84+
echo "glib2.tcz" > qemu-utils.tcz.dep
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
# put other system startup commands here
3+
4+
#exec > /tmp/installlogs 2>&1
5+
set -x
6+
7+
echo "Starting bootlocal script:"
8+
date
9+
10+
export HOME=/root
11+
12+
# Maybe save some RAM?
13+
#rm -rf /tmp/builtin
14+
15+
# Install IPA and dependecies
16+
if ! type "ironic-python-agent" > /dev/null ; then
17+
python /tmp/get-pip.py --no-wheel --no-index --find-links=file:///tmp/wheelhouse ironic_python_agent
18+
fi
19+
20+
# Run IPA
21+
ironic-python-agent
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
bash.tcz
2+
compiletc.tcz
3+
coreutils.tcz
4+
dmidecode.tcz
5+
gdisk.tcz
6+
hdparm.tcz
7+
parted.tcz
8+
python.tcz
9+
python-dev.tcz
10+
raid-dm-3.16.6-tinycore64.tcz
11+
scsi-3.16.6-tinycore64.tcz
12+
udev-lib.tcz
13+
util-linux.tcz
14+
pkg-config.tcz
15+
zlib_base-dev.tcz
16+
glib2-dev.tcz
17+
pixman-dev.tcz
18+
binutils.tcz
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
bash.tcz
2+
coreutils.tcz
3+
dmidecode.tcz
4+
gdisk.tcz
5+
hdparm.tcz
6+
parted.tcz
7+
python.tcz
8+
raid-dm-3.16.6-tinycore64.tcz
9+
scsi-3.16.6-tinycore64.tcz
10+
udev-lib.tcz
11+
util-linux.tcz
12+
glib2.tcz
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
display boot.msg
2+
default corepure64
3+
4+
label corepure64
5+
kernel /boot/vmlinuz64
6+
initrd /boot/corepure64.gz
7+
append loglevel=3 syslog showapps
8+
9+
implicit 0

0 commit comments

Comments
 (0)