btrfs-progs/ci/gitlab/setup_image.sh
Lakshmipathi.G 6d59786363 btrfs-progs: ci: setup GitLab-CI
Make use of GitLab-CI nested virutal environment to start QEMU instance
inside containers and perform btrfs-progs build, execute unit test cases
and save the logs.

This allows to run the progs testsuite on a recent kernel, newer than
what CI instances usually provide. As this is is emulated, the runtime
is longer.

Issue: #171
Signed-off-by: Lakshmipathi.G <lakshmipathi.ganapathi@collabora.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-10-16 23:03:52 +02:00

43 lines
1.2 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# Setup debian image via debootstrap and include systemd service file.
set -x
apt-get update
apt-get -y install debootstrap wget unzip
# Setup rootfs
IMG="/qemu-image.img"
DIR="/target"
truncate -s2G $IMG
mkfs.ext4 $IMG
mkdir -p $DIR
for i in {0..7};do
mknod -m 0660 "/dev/loop$i" b 7 "$i"
done
# mount the image file
mount -o loop $IMG $DIR
# Install required pacakges
debootstrap --arch=amd64 --include=git,autoconf,automake,gcc,make,pkg-config,e2fslibs-dev,libblkid-dev,zlib1g-dev,liblzo2-dev,asciidoc,xmlto,libzstd-dev,python3.5,python3.5-dev,python3-dev,python3-setuptools,python-setuptools,xz-utils,acl,attr stretch $DIR http://ftp.de.debian.org/debian/
## Setup 9p mount
echo "btrfs-progs /mnt 9p trans=virtio 0 0" > $DIR/etc/fstab
# Setup autologin
sed -i 's/9600/9600 --autologin root/g' $DIR/lib/systemd/system/serial-getty@.service
# Setup systemd service
cp -v /repo/ci/gitlab/build_or_run_btrfs-progs.sh $DIR/usr/bin/
cp -v /repo/ci/gitlab/btrfs-progs-tests.service $DIR/etc/systemd/system/
## Enable service
ln -s $DIR/etc/systemd/system/btrfs-progs-tests.service $DIR/etc/systemd/system/getty.target.wants/btrfs-progs-tests.service
cd /
umount $DIR
rmdir $DIR
cp -v $IMG /repo