Setting up an sh4 sbuild environment based on qemu-sh4
NOTE: Due to a bug in jessie's qemu, it doesn't work on 64-bit hosts. Use unstable/stretch or qemu-user-static:i386.
The whole sbuild setup is rather simple and deviates only slightly from a regular sbuild setup on a native architecture. The only additions are installing support packages for qemu and copying the binary qemu-sh4-static into /usr/bin of the chroot:
root@jessie32:~> apt-get install sbuild qemu-user-static binfmt-support schroot devscripts debian-ports-archive-keyring root@jessie32:/srv/chroots> cd /srv/chroots root@jessie32:/srv/chroots> debootstrap --variant=buildd --foreign --arch=sh4 --include=debian-ports-archive-keyring unstable sid-sh4-sbuild http://ftp.ports.debian.org/debian-ports/ root@jessie32:/srv/chroots> mkdir ~/.gnupg root@jessie32:/srv/chroots> sbuild-update --keygen root@jessie32:/srv/chroots> cat /etc/schroot/chroot.d/sid-sh4-sbuild [sid-sh4-sbuild] description=Debian sid chroot for sh4 type=directory directory=/srv/chroots/sid-sh4-sbuild #groups=Debian,guest,d-i #profile=dsa #aliases=sid groups=root,sbuild,glaubitz,buildd root-groups=root,sbuild,glaubitz,buildd #command-prefix= #source-root-users=glaubitz,sbuild,buildd #run-setup-scripts=true #run-exec-scripts=true root@jessie32:/srv/chroots> adduser glaubitz sbuild root@jessie32:/srv/chroots> cp -av /usr/bin/qemu-sh4-static /srv/chroots/sid-sh4-sbuild/usr/bin root@jessie32:/srv/chroots> chroot sid-sh4-sbuild bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8) I have no name!@jessie32:/# ./debootstrap/debootstrap --second-stage
After that, we just need to configure apt in the chroot:
root@jessie32:/# cat /etc/apt/sources.list # binary default deb http://ftp.ports.debian.org/debian-ports/ unstable main deb http://ftp.ports.debian.org/debian-ports/ unreleased main deb http://incoming.ports.debian.org/buildd/ unstable main # source deb-src http://ftp.debian.org/debian/ unstable main deb-src http://incoming.debian.org/debian-buildd buildd-unstable main #deb-src http://ftp.debian.org/debian/ experimental main #deb-src http://incoming.debian.org/debian-buildd buildd-experimental main # binary experimental #deb http://ftp.ports.debian.org/debian-ports/ experimental main #deb http://incoming.debian.org/debian-buildd buildd-experimental main # source experimental #deb-src http://ftp.debian.org/debian/ experimental main
After that, it should be possible to build packages for sh4 for any user in the sbuild group:
glaubitz@jessie32:~> mkdir sh4 glaubitz@jessie32:~> cd sh4 glaubitz@jessie32:~/sh4> dget -u http://http.debian.net/debian/pool/main/x/xbill/xbill_2.1-8.dsc glaubitz@jessie32:~/sh4> sbuild --arch=sh4 --arch-all --source --force-orig-source -d sid xbill_2.1-8.dsc
In order to speed up the build process by disabling make check, set "nobench" and "nocheck" as DEB_BUILD_OPTIONS:
glaubitz@jessie32:~/sh4> export DEB_BUILD_OPTIONS="nobench nocheck" ; sbuild --arch=sh4 --arch-all --source --force-orig-source -d sid xbill_2.1-8.dsc
Of course, you can just chroot into the sh4 chroot and run any application like you would do on a native system.
Bugs
There are several minor issues with qemu-sh4 which currently need workarounds or patches.
fakeroot command gets stuck
During package builds, it was observed that the fakeroot command which is usually invoked during package build may get stuck when running fakeroot debian/rules clean or other commands. In order to workaround this issue, just set the name of the fakeroot binary to an empty string in /etc/sbuild/sbuild.conf on the qemu host:
# FAKEROOT # Type: STRING # Path to fakeroot binary $fakeroot = '';
Unsupported syscall: 186
Another issue with qemu-sh4 is the missing implementation of the sigaltstack syscall (see: https://bugs.launchpad.net/qemu/+bug/1516408) which becomes apparent with the following qemu message when installing any python packages in the chroot:
qemu: Unsupported syscall: 186
The aforementioned qemu upstream bug report contains the necessary patch to enable sigaltstack in qemu-sh4.