diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..013a1d27 --- /dev/null +++ b/Makefile @@ -0,0 +1,35 @@ +# +# CryptoLib Makefile +# + +# The "LOCALTGTS" defines the top-level targets that are implemented in this makefile +# Any other target may also be given, in that case it will simply be passed through. +LOCALTGTS := all clean debug internal kmc wolf +OTHERTGTS := $(filter-out $(LOCALTGTS),$(MAKECMDGOALS)) + +# As this makefile does not build any real files, treat everything as a PHONY target +# This ensures that the rule gets executed even if a file by that name does exist +.PHONY: $(LOCALTGTS) $(OTHERTGTS) + +# +# Commands +# +all: + $(MAKE) internal + $(MAKE) kmc + $(MAKE) wolf + +clean: + rm -rf ./build + +debug: + ./support/scripts/docker_debug.sh + +internal: + ./support/scripts/internal_docker_build.sh + +kmc: + ./support/scripts/kmc_docker_build.sh + +wolf: + ./support/scripts/wolf_docker_build.sh diff --git a/support/Dockerfile b/support/Dockerfile index 08b55592..617d54a5 100644 --- a/support/Dockerfile +++ b/support/Dockerfile @@ -1,11 +1,23 @@ # CryptoLib Dockerfile # -# docker build -t ivvitc/cryptolib:latest . -# docker push ivvitc/cryptolib:latest +# Install latest docker from PPA: https://docs.docker.com/engine/install/ubuntu/ +# +# Debugging +# docker build -t ivvitc/cryptolib:dev . +# docker run -it ivvitc/cryptolib:dev /bin/bash # +# Follow multi-arch instructions: https://www.docker.com/blog/multi-arch-images/ +# docker login +# docker buildx create --name clbuilder +# docker buildx use clbuilder +# docker buildx build --platform linux/amd64 -t ivvitc/cryptolib:dev --push . +# +# TODO: +# docker buildx build --platform linux/amd64,linux/arm64 -t ivvitc/cryptolib:dev --push . +# ARG WOLFSSL_VERSION=5.6.0-stable -FROM ubuntu:jammy-20240212 AS CL0 +FROM ubuntu:jammy-20240530 AS cl0 ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update -y \ @@ -15,8 +27,6 @@ RUN apt-get update -y \ ca-certificates \ cmake \ curl \ - g++-multilib \ - gcc-multilib \ gettext \ git \ gdb\ @@ -32,7 +42,7 @@ RUN apt-get update -y \ && rm -rf /var/lib/apt/lists/* \ && pip3 install pycryptodome -FROM CL0 AS CL1 +FROM cl0 AS cl1 ARG GPG_ERROR_VERSION=1.50 ARG GCRYPT_VERSION=1.11.0 RUN curl \ @@ -50,7 +60,7 @@ RUN curl \ && ./configure \ && make install -FROM CL1 AS CL2 +FROM cl1 AS cl2 ARG WOLFSSL_VERSION=5.6.0-stable RUN curl \ -LS https://github.com/wolfSSL/wolfssl/archive/v${WOLFSSL_VERSION}.zip \ diff --git a/support/scripts/docker_debug.sh b/support/scripts/docker_debug.sh index 5cbeb307..a7bf2a7b 100755 --- a/support/scripts/docker_debug.sh +++ b/support/scripts/docker_debug.sh @@ -9,5 +9,5 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) source $SCRIPT_DIR/env.sh echo "Start docker container to debug in..." -$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR ivvitc/cryptolib bash +$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR $DBOX bash echo "" diff --git a/support/scripts/env.sh b/support/scripts/env.sh index 3f157be1..b469f37b 100755 --- a/support/scripts/env.sh +++ b/support/scripts/env.sh @@ -7,4 +7,7 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) export BASE_DIR=$(cd `dirname $SCRIPT_DIR`/.. && pwd) -export DFLAGS="docker run --rm -it" + +DFLAGS="docker run --rm -it -v /etc/passwd:/etc/passwd:ro -v /etc/group:/etc/group:ro -u $(id -u $(stat -c '%U' $SCRIPT_DIR/env.sh)):$(getent group $(stat -c '%G' $SCRIPT_DIR/env.sh) | cut -d: -f3)" + +DBOX="ivvitc/cryptolib:20240814" diff --git a/support/scripts/internal_docker_build.sh b/support/scripts/internal_docker_build.sh index b2ae8ba7..3c86a21d 100755 --- a/support/scripts/internal_docker_build.sh +++ b/support/scripts/internal_docker_build.sh @@ -13,9 +13,9 @@ mkdir $BASE_DIR/build > /dev/null 2>&1 rm -r $BASE_DIR/build/internal/* > /dev/null 2>&1 mkdir $BASE_DIR/build/internal > /dev/null 2>&1 -#$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/internal ivvitc/cryptolib /bin/bash +#$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/internal $DBOX /bin/bash echo "Internal build and test..." -$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/internal ivvitc/cryptolib bash -c \ +$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/internal $DBOX bash -c \ "../../support/scripts/build_support.sh" echo "" diff --git a/support/scripts/kmc_docker_build.sh b/support/scripts/kmc_docker_build.sh index 31718968..e9e9e803 100755 --- a/support/scripts/kmc_docker_build.sh +++ b/support/scripts/kmc_docker_build.sh @@ -13,10 +13,10 @@ mkdir $BASE_DIR/build > /dev/null 2>&1 rm -r $BASE_DIR/build/kmc/* > /dev/null 2>&1 mkdir $BASE_DIR/build/kmc > /dev/null 2>&1 -#$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/kmc ivvitc/cryptolib /bin/bash +#$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/kmc $DBOX /bin/bash echo "KMC build and test..." # Note that the `KMC_MDB_DB` flag is not in use as docker compose will need configured to enable these tests -$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/kmc ivvitc/cryptolib bash -c \ +$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/kmc $DBOX bash -c \ "../../support/scripts/build_kmc.sh" echo "" diff --git a/support/scripts/wolf_docker_build.sh b/support/scripts/wolf_docker_build.sh index 45bc5efb..f8dbfdac 100755 --- a/support/scripts/wolf_docker_build.sh +++ b/support/scripts/wolf_docker_build.sh @@ -13,9 +13,9 @@ mkdir $BASE_DIR/build > /dev/null 2>&1 rm -r $BASE_DIR/build/wolf/* > /dev/null 2>&1 mkdir $BASE_DIR/build/wolf > /dev/null 2>&1 -#$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/wolf ivvitc/cryptolib /bin/bash +#$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/wolf $DBOX /bin/bash echo "Wolf build and test..." -$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/wolf ivvitc/cryptolib bash -c \ +$DFLAGS -v $BASE_DIR:$BASE_DIR -w $BASE_DIR/build/wolf $DBOX bash -c \ "../../support/scripts/build_wolf.sh" echo ""