FROM fedora:latest

# Install generic dependencies to check style
RUN true \
        && dnf update -y --refresh \
        && dnf install -y nss nss-devel python2 python3 gcc java-devel \
        && mkdir -p /home/sandbox \
        && dnf clean -y all \
        && rm -rf /usr/share/doc /usr/share/doc-base \
                  /usr/share/man /usr/share/locale /usr/share/zoneinfo \
        && true

# Link in the current version of jss from the git repository
WORKDIR /home/sandbox
COPY . /home/sandbox/jss

# Generate a new PKCS11Constants.java and compare the differences
WORKDIR /home/sandbox/jss
CMD true \
        && python2 ./tools/build_pkcs11_constants.py \
                   --pkcs11t /usr/include/nss3/pkcs11t.h \
                   --pkcs11n /usr/include/nss3/pkcs11n.h \
                   -o PKCS11Constants-py2.java \
        && python3 ./tools/build_pkcs11_constants.py -s \
                   --pkcs11t /usr/include/nss3/pkcs11t.h \
                   --pkcs11n /usr/include/nss3/pkcs11n.h \
                   -o PKCS11Constants-py3.java \
        && diff PKCS11Constants-py2.java PKCS11Constants-py3.java \
        && diff PKCS11Constants-py3.java org/mozilla/jss/pkcs11/PKCS11Constants.java \
        && true
