File tree Expand file tree Collapse file tree 4 files changed +111
-6
lines changed
docker/s390x-unknown-linux-gnu Expand file tree Collapse file tree 4 files changed +111
-6
lines changed Original file line number Diff line number Diff line change 11FROM ubuntu:17.10
22
33RUN apt-get update && apt-get install -y --no-install-recommends \
4- gcc libc6-dev qemu-user ca-certificates \
5- gcc-s390x-linux-gnu libc6-dev-s390x-cross
4+ curl ca-certificates \
5+ gcc libc6-dev \
6+ gcc-s390x-linux-gnu libc6-dev-s390x-cross \
7+ debian-archive-keyring debootstrap cpio \
8+ qemu-user-static qemu-system-s390x \
9+ sshpass openssh-client
610
11+ COPY linux-image.sh /
12+ RUN bash linux-image.sh "" s390x stretch
13+
14+ RUN cd / && curl -LO https://github.com/qemu/qemu/raw/master/pc-bios/s390-ccw.img
15+
16+ ARG USERID
17+ RUN adduser --uid $USERID --disabled-login --gecos cross cross
18+
19+ COPY test-runner-s390x /
720ENV CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_LINKER=s390x-linux-gnu-gcc \
8- # TODO: in theory we should execute this, but qemu segfaults immediately :(
9- # CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER="qemu-s390x -L /usr/s390x-linux-gnu" \
10- CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER=true \
21+ CARGO_TARGET_S390X_UNKNOWN_LINUX_GNU_RUNNER="/test-runner-s390x" \
1122 CC_s390x_unknown_linux_gnu=s390x-linux-gnu-gcc \
1223 PATH=$PATH:/rust/bin
Original file line number Diff line number Diff line change 1+ set -ex
2+
3+ params=$1
4+ arch=$2
5+ suite=$3
6+ mirror=$4
7+ dest=/qemu-root
8+
9+ mkdir -p $dest
10+ cd $dest
11+
12+ qemu-debootstrap \
13+ --arch=$arch \
14+ --variant=minbase \
15+ --include=" linux-image-$arch ,systemd-sysv,openssh-server" \
16+ $params \
17+ $suite \
18+ $dest \
19+ $mirror || true
20+
21+ # HACK: debootstrap calls mount, but mount cannot be executed inside a docker
22+ # container, so qemu-debootstrap fails. We replace mount with true and continue
23+ # the bootstrap process. We restore mount after the bootstrap.
24+ rm -f $dest /var/lib/dpkg/status
25+ mv $dest /bin/mount /mount.bak
26+ cp $dest /bin/true $dest /bin/mount
27+ chroot $dest /debootstrap/debootstrap --second-stage
28+ mv -f /mount.bak $dest /bin/mount
29+
30+ # ssh
31+ chroot $dest adduser --disabled-password --gecos " " cross
32+ echo " cross:cross" | chroot $dest chpasswd
33+
34+ # init
35+ cat << EOF > $dest /init
36+ #!/bin/sh
37+ exec /sbin/init
38+ EOF
39+ chmod +x $dest /init
40+
41+ # networking
42+ chroot $dest systemctl enable systemd-networkd
43+
44+ cat << EOF > $dest /etc/hostname
45+ qemu
46+ EOF
47+
48+ cat << EOF > $dest /etc/hosts
49+ 127.0.0.1 localhost
50+ EOF
51+
52+ cat << EOF > $dest /etc/systemd/network/80-dhcp.network
53+ [Match]
54+ Name=*
55+ [Network]
56+ DHCP=v4
57+ EOF
58+
59+ # copy vmlinuz and create initrd.img
60+ cp -f $dest /vmlinuz /qemu-vmlinuz
61+
62+ rm -rf $dest /usr/lib/* -linux-* /gconv \
63+ $dest /usr/lib/* -linux-* /perl-base \
64+ $dest /usr/share/ \
65+ $dest /boot \
66+ $dest /var/cache \
67+ $dest /var/lib/apt \
68+ $dest /var/lib/dpkg \
69+ $dest /var/log/*
70+
71+ cd $dest
72+ find . -print0 | cpio --null -ov --format=newc | gzip > /qemu-initrd.img
73+ cd -
74+
75+ # clean up
76+ rm -rf $dest
Original file line number Diff line number Diff line change 66run () {
77 echo $1
88 # use -f so we can use ci/ as build context
9- docker build -t libc -f ci/docker/$1 /Dockerfile ci/
9+ docker build --build-arg USERID= ` id -u ` - t libc -f ci/docker/$1 /Dockerfile ci/
1010 mkdir -p target
1111 if [ -w /dev/kvm ]; then
1212 kvm=" --volume /dev/kvm:/dev/kvm"
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ set -e
4+
5+ cd /
6+
7+ (
8+ flock -n 200 || exit 0
9+ qemu-system-s390x -m 1024 -nographic \
10+ -kernel /qemu-vmlinuz \
11+ -initrd /qemu-initrd.img \
12+ -netdev user,id=net0,hostfwd=tcp::10022-:22 \
13+ -device virtio-net-ccw,netdev=net0 > /dev/null &
14+ sleep 30
15+ ) 200> /tmp/qemu.lock
16+
17+ sshpass -p" cross" scp -q -o StrictHostKeyChecking=no -P 10022 $1 cross@localhost:/tmp
18+ sshpass -p" cross" ssh -q -o StrictHostKeyChecking=no -p 10022 cross@localhost /tmp/$( basename $1 )
You can’t perform that action at this time.
0 commit comments