|
| 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 |
0 commit comments