#!/bin/bash
if [ "`dpkg-architecture -qDEB_HOST_ARCH_BITS`" != 32 ]; then
set -e
workdir=$(mktemp -d)
cleanup() {
    rm -rf "$workdir"
}
trap cleanup EXIT
gcc --pedantic -Wall -Werror -o "$workdir/checky2106" -x c - <<EOF
#include <stdio.h>
int main() { printf("%zu\n", sizeof(unsigned long)); return 0; }
EOF
sz=$("$workdir/checky2106")
if [ "$sz" -lt 8 ]; then
    limit='in the far future'
    if [ "$sz" -eq 4 ]; then
        limit='after 2106-02-07 06:28:16Z'
    fi
    printf "unsigned long on this platform is %d octets.
This means that GPGME will fail when encountering expiration
dates %s.

Please see https://dev.gnupg.org/T4766 for more details.
" "$sz" "$limit"
    exit 1
fi
else
    echo "this test will obviously fail on 32bit systems"
    exit 0
fi
