this_one=i386

abinfo 'Removing $PKGDIR ...'
rm -rfv "$PKGDIR"

abinfo "Installing static user emulator for ${this_one} ..."
install -Dvm755 "$SRCDIR"/staticbin/qemu-${this_one} \
    "$PKGDIR"/usr/bin/qemu-${this_one}-static

if ! ab_match_arch amd64 && \
   ! ab_match_arch i486; then
    abinfo "Installing binfmt files for ${this_one} ..."
    install -Dvm644 "$SRCDIR"/autobuild/qemu-${this_one}.conf \
        "$PKGDIR"/usr/lib/binfmt.alternatives/qemu-${this_one}.conf

    abinfo "Generating alternatives configuration for ${this_one} ..."
    cat > "$SRCDIR"/autobuild/alternatives << EOF
alternative /usr/lib/binfmt.d/emu-i386.conf /usr/lib/binfmt.alternatives/qemu-i386.conf 50
EOF
fi
