Skip to content

Commit 86bafec

Browse files
authored
Improve quality of packages built through docker (#5)
* improve packaging quality * removed debug instruction from script
1 parent 1b35a5a commit 86bafec

11 files changed

+77
-42
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,9 @@ pkcs11rc
4343
# emacs
4444
TAGS
4545
*~
46+
47+
# debugging stuff
48+
pkcs11.txt
49+
cert9.db
50+
key4.db
4651
 

Makefile.am

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,5 @@ EXTRA_DIST = include/cryptoki.h \
2929
README.md \
3030
CHANGELOG.md
3131

32-
32+
install-exec-hook:
33+
chmod 644 $(DESTDIR)$(libdir)/libpkcs11shim.so.*

buildx.sh

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ function usage() {
5757
echo "Options:"
5858
echo " --repo URL, -r URL Specify the repository URL (default: $GITHUB_REPO)"
5959
echo " --commit COMMIT, -c COMMIT Specify the commit hash, tag or branch to build (default: $GITHUB_REPO_COMMIT)"
60+
echo " --skip-git-sslverify, -k Skip SSL verification for git clone"
6061
echo " --verbose, -v Increase verbosity (can be specified multiple times)"
6162
echo " --max-procs N, -j N Specify the maximum number of processes"
6263
exit 1
@@ -112,6 +113,7 @@ function create_build() {
112113
local verbose="$3"
113114
local repo_url="$4"
114115
local repo_commit="$5"
116+
local repo_sslverify="$6"
115117

116118
local verbosearg="--quiet"
117119

@@ -132,14 +134,15 @@ function create_build() {
132134

133135
local containername=$(gen_random_container_name)
134136
docker buildx build $verbosearg \
135-
--platform linux/$platformarch \
137+
--platform linux/$arch \
136138
--build-arg REPO_URL=$repo_url \
137139
--build-arg REPO_COMMIT_OR_TAG=$repo_commit \
140+
--build-arg REPO_SSLVERIFY=$repo_sslverify \
138141
-t libpkcs11shim-build-$distro-$arch \
139142
-f $(get_script_dir)/buildx/Dockerfile.$distro \
140143
$(get_script_dir)/buildx
141144

142-
local artifacts=$(docker run --platform linux/$platformarch --name $containername libpkcs11shim-build-$distro-$arch)
145+
local artifacts=$(docker run --platform linux/$arch --name $containername libpkcs11shim-build-$distro-$arch)
143146
for artifact in $artifacts; do
144147
docker cp --quiet $containername:$artifact $(get_current_dir)/
145148
done
@@ -158,6 +161,7 @@ function create_build() {
158161
function parse_and_build() {
159162
local repo_url="$GITHUB_REPO"
160163
local repo_commit="HEAD"
164+
local repo_sslverify="true"
161165
local verbose=0
162166
local args=()
163167
local numprocs=$(nproc)
@@ -173,6 +177,9 @@ function parse_and_build() {
173177
shift
174178
repo_commit="$1"
175179
;;
180+
--skip-git-sslverify|-k)
181+
repo_sslverify="false"
182+
;;
176183
--verbose|-v)
177184
if [ "$verbose" -lt 2 ]; then
178185
verbose=$(($verbose + 1))
@@ -209,31 +216,31 @@ function parse_and_build() {
209216
if [[ "$arg" == "all/all" ]]; then
210217
for distro in $SUPPORTED_DISTROS; do
211218
for arch in $SUPPORTED_ARCHS; do
212-
build_args+=("$distro $arch $verbose $repo_url $repo_commit")
219+
build_args+=("$distro $arch $verbose $repo_url $repo_commit $repo_sslverify")
213220
done
214221
done
215222
elif [[ "$arg" == "all" ]]; then
216223
local host_arch=$(uname -m)
217224
for distro in $SUPPORTED_DISTROS; do
218-
build_args+=("$distro $host_arch $verbose $repo_url $repo_commit")
225+
build_args+=("$distro $host_arch $verbose $repo_url $repo_commit $repo_sslverify")
219226
done
220227
elif [[ "$arg" == */* ]]; then
221228
IFS='/' read -r distro arch_list <<< "$arg"
222229
if [[ "$arch_list" == "all" ]]; then
223230
for arch in $SUPPORTED_ARCHS; do
224-
build_args+=("$distro $arch $verbose $repo_url $repo_commit")
231+
build_args+=("$distro $arch $verbose $repo_url $repo_commit $repo_sslverify")
225232
done
226233
else
227234
IFS=',' read -ra archs <<< "$arch_list"
228235
for arch in "${archs[@]}"; do
229-
build_args+=("$distro $arch $verbose $repo_url $repo_commit")
236+
build_args+=("$distro $arch $verbose $repo_url $repo_commit $repo_sslverify")
230237
done
231238
fi
232239
else
233240
IFS=',' read -ra distros <<< "$arg"
234241
local host_arch=${rev_arch_map[$(uname -m)]:-$(uname -m)}
235242
for distro in "${distros[@]}"; do
236-
build_args+=("$distro $host_arch $verbose $repo_url $repo_commit")
243+
build_args+=("$distro $host_arch $verbose $repo_url $repo_commit $repo_sslverify")
237244
done
238245
fi
239246
done

buildx/Dockerfile.alpine321

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
ARG REPO_URL="https://github.com/Mastercard/libpkcs11shim"
2525
ARG REPO_COMMIT_OR_TAG="HEAD"
26+
ARG REPO_SSLVERIFY="true"
2627
ARG DISTRO_NAME="alpine"
2728
ARG DISTRO_VERSION="3.21"
2829
ARG DISTRO_SHORT_NAME="alpine321"
@@ -57,13 +58,15 @@ RUN apk add --no-cache \
5758
FROM base AS gitcloned
5859
ARG REPO_URL
5960
ARG REPO_COMMIT_OR_TAG
61+
ARG REPO_SSLVERIFY
6062

6163
# The meta directory is used to store the version and maintainer information
6264
# for the RPM package
6365
RUN mkdir -p /meta
6466

6567
# Clone the repository
6668
WORKDIR /src
69+
RUN if [ "$REPO_SSLVERIFY" != "true" ]; then git config --global http.sslVerify false; fi
6770
RUN git clone $REPO_URL .
6871
RUN git checkout $REPO_COMMIT_OR_TAG
6972

@@ -100,11 +103,11 @@ FROM gitcloned AS builder
100103
RUN ./bootstrap.sh \
101104
&& ./configure --prefix=/usr \
102105
&& make -j $(nproc) \
103-
&& make install DESTDIR=/build
106+
&& make install-strip DESTDIR=/build
104107

105108
# Install documentation
106109
RUN mkdir -p /build/usr/share/doc/libpkcs11shim \
107-
&& install -m 444 -t /build/usr/share/doc/libpkcs11shim README.md CHANGELOG.md COPYING
110+
&& install -m 644 -t /build/usr/share/doc/libpkcs11shim README.md CHANGELOG.md COPYING
108111

109112

110113
# Final stage

buildx/Dockerfile.amzn2023

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
ARG REPO_URL="https://github.com/Mastercard/libpkcs11shim"
2424
ARG REPO_COMMIT_OR_TAG="HEAD"
25+
ARG REPO_SSLVERIFY="true"
2526
ARG DISTRO_NAME="amazonlinux"
2627
ARG DISTRO_VERSION="2023"
2728
ARG DISTRO_SHORT_NAME="amzn2023"
@@ -52,13 +53,15 @@ RUN DISTROARCH=$(arch | sed 's/aarch64/arm64/;s/x86_64/amd64/') \
5253
FROM base AS gitcloned
5354
ARG REPO_URL
5455
ARG REPO_COMMIT_OR_TAG
56+
ARG REPO_SSLVERIFY
5557

5658
# The meta directory is used to store the version and maintainer information
5759
# for the RPM package
5860
RUN mkdir -p /meta
5961

6062
# Clone the repository
6163
WORKDIR /src
64+
RUN if [ "$REPO_SSLVERIFY" != "true" ]; then git config --global http.sslVerify false; fi
6265
RUN git clone $REPO_URL .
6366
RUN git checkout $REPO_COMMIT_OR_TAG
6467

@@ -104,21 +107,21 @@ FROM gitcloned AS builder
104107
RUN ./bootstrap.sh \
105108
&& ./configure \
106109
&& make -j $(nproc) \
107-
&& make install DESTDIR=/tar_build
110+
&& make install-strip DESTDIR=/tar_build
108111

109112
# Install documentation
110113
RUN mkdir -p /tar_build/usr/local/share/doc/libpkcs11shim \
111-
&& install -m 444 -t /tar_build/usr/local/share/doc/libpkcs11shim README.md CHANGELOG.md COPYING
114+
&& install -m 644 -t /tar_build/usr/local/share/doc/libpkcs11shim README.md CHANGELOG.md COPYING
112115

113116
# Build again the project for deb package (/usr)
114117
RUN make distclean \
115118
&& ./configure --prefix=/usr \
116119
&& make -j $(nproc) \
117-
&& make install DESTDIR=/rpm_build
120+
&& make install-strip DESTDIR=/rpm_build
118121

119122
# Install documentation
120123
RUN mkdir -p /rpm_build/usr/share/doc/libpkcs11shim \
121-
&& install -m 444 -t /rpm_build/usr/share/doc/libpkcs11shim README.md CHANGELOG.md COPYING
124+
&& install -m 644 -t /rpm_build/usr/share/doc/libpkcs11shim README.md CHANGELOG.md COPYING
122125

123126

124127
# Final stage

buildx/Dockerfile.deb12

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
ARG REPO_URL="https://github.com/Mastercard/libpkcs11shim"
2424
ARG REPO_COMMIT_OR_TAG="HEAD"
25+
ARG REPO_SSLVERIFY="true"
2526
ARG DISTRO_NAME="debian"
2627
ARG DISTRO_VERSION="12"
2728
ARG DISTRO_SHORT_NAME="deb12"
@@ -47,13 +48,15 @@ RUN apt-get update && apt-get install -y \
4748
FROM base AS gitcloned
4849
ARG REPO_URL
4950
ARG REPO_COMMIT_OR_TAG
51+
ARG REPO_SSLVERIFY
5052

5153
# The meta directory is used to store the version and maintainer information
5254
# for the DEB package
5355
RUN mkdir -p /meta
5456

5557
# Clone the repository
5658
WORKDIR /src
59+
RUN if [ "$REPO_SSLVERIFY" != "true" ]; then git config --global http.sslVerify false; fi
5760
RUN git clone $REPO_URL .
5861
RUN git checkout $REPO_COMMIT_OR_TAG
5962

@@ -91,31 +94,29 @@ RUN PKG_DESCRIPTION=$(cat README.md \
9194
| sed '1!s/^/ /')\
9295
&& echo "PKG_DESCRIPTION=\"$PKG_DESCRIPTION\"" >> /meta/env
9396

94-
9597
RUN echo "export PKG_GITSUFFIX PKG_VERSION PKG_RELEASE PKG_GITCOMMIT PKG_MAINTAINER PKG_ARCH" >> /meta/env
9698

97-
9899
FROM gitcloned AS builder
99100

100101
# Build the project for tar package (/usr/local)
101102
RUN ./bootstrap.sh \
102103
&& ./configure \
103104
&& make -j $(nproc)\
104-
&& make install DESTDIR=/tar_build
105+
&& make install-strip DESTDIR=/tar_build
105106

106107
# Install documentation
107108
RUN mkdir -p /tar_build/usr/local/share/doc/libpkcs11shim \
108-
&& install -m 444 -t /tar_build/usr/local/share/doc/libpkcs11shim README.md CHANGELOG.md COPYING
109+
&& install -m 644 -t /tar_build/usr/local/share/doc/libpkcs11shim README.md CHANGELOG.md COPYING
109110

110111
# Build again the project for deb package (/usr)
111112
RUN make distclean \
112113
&& ./configure --prefix=/usr --libdir=/usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH) \
113114
&& make -j $(nproc) \
114-
&& make install DESTDIR=/deb_build
115+
&& make install-strip DESTDIR=/deb_build
115116

116117
# Install documentation
117118
RUN mkdir -p /deb_build/usr/share/doc/libpkcs11shim \
118-
&& install -m 444 -t /deb_build/usr/share/doc/libpkcs11shim README.md CHANGELOG.md COPYING
119+
&& install -m 644 -t /deb_build/usr/share/doc/libpkcs11shim README.md CHANGELOG.md COPYING
119120

120121

121122
# Final stage

buildx/Dockerfile.ol7

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
ARG REPO_URL="https://github.com/Mastercard/libpkcs11shim"
2424
ARG REPO_COMMIT_OR_TAG="HEAD"
25+
ARG REPO_SSLVERIFY="true"
2526
ARG DISTRO_NAME="oraclelinux"
2627
ARG DISTRO_VERSION="7"
2728
ARG DISTRO_SHORT_NAME="ol7"
@@ -57,13 +58,15 @@ RUN DISTROARCH=$(arch | sed 's/aarch64/arm64/;s/x86_64/amd64/') \
5758
FROM base AS gitcloned
5859
ARG REPO_URL
5960
ARG REPO_COMMIT_OR_TAG
61+
ARG REPO_SSLVERIFY
6062

6163
# The meta directory is used to store the version and maintainer information
6264
# for the RPM package
6365
RUN mkdir -p /meta
6466

6567
# Clone the repository
6668
WORKDIR /src
69+
RUN if [ "$REPO_SSLVERIFY" != "true" ]; then git config --global http.sslVerify false; fi
6770
RUN git clone $REPO_URL .
6871
RUN git checkout $REPO_COMMIT_OR_TAG
6972

@@ -110,11 +113,11 @@ RUN scl enable devtoolset-10 \
110113
'./bootstrap.sh \
111114
&& ./configure \
112115
&& make -j $(nproc) \
113-
&& make install DESTDIR=/tar_build'
116+
&& make install-strip DESTDIR=/tar_build'
114117

115118
# install documentation
116119
RUN mkdir -p /tar_build/usr/local/share/doc/libpkcs11shim \
117-
&& install -m 444 -t /tar_build/usr/local/share/doc/libpkcs11shim README.md CHANGELOG.md COPYING
120+
&& install -m 644 -t /tar_build/usr/local/share/doc/libpkcs11shim README.md CHANGELOG.md COPYING
118121

119122
# Build again the project for deb package (/usr)
120123
# Note: oraclelinux:7-slim is strict on the library path. We need extra logic
@@ -126,11 +129,11 @@ RUN scl enable devtoolset-10 \
126129

127130
RUN scl enable devtoolset-10 \
128131
"make -j $(nproc) \
129-
&& make install DESTDIR=/rpm_build"
132+
&& make install-strip DESTDIR=/rpm_build"
130133

131134
# Install documentation
132135
RUN mkdir -p /rpm_build/usr/share/doc/libpkcs11shim \
133-
&& install -m 444 -t /rpm_build/usr/share/doc/libpkcs11shim README.md CHANGELOG.md COPYING
136+
&& install -m 644 -t /rpm_build/usr/share/doc/libpkcs11shim README.md CHANGELOG.md COPYING
134137

135138
RUN find /rpm_build
136139

buildx/Dockerfile.ol8

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
ARG REPO_URL="https://github.com/Mastercard/libpkcs11shim"
2424
ARG REPO_COMMIT_OR_TAG="HEAD"
25+
ARG REPO_SSLVERIFY="true"
2526
ARG DISTRO_NAME="oraclelinux"
2627
ARG DISTRO_VERSION="8"
2728
ARG DISTRO_SHORT_NAME="ol8"
@@ -58,13 +59,15 @@ RUN DISTROARCH=$(arch | sed 's/aarch64/arm64/;s/x86_64/amd64/') \
5859
FROM base AS gitcloned
5960
ARG REPO_URL
6061
ARG REPO_COMMIT_OR_TAG
62+
ARG REPO_SSLVERIFY
6163

6264
# The meta directory is used to store the version and maintainer information
6365
# for the RPM package
6466
RUN mkdir -p /meta
6567

6668
# Clone the repository
6769
WORKDIR /src
70+
RUN if [ "$REPO_SSLVERIFY" != "true" ]; then git config --global http.sslVerify false; fi
6871
RUN git clone $REPO_URL .
6972
RUN git checkout $REPO_COMMIT_OR_TAG
7073

@@ -110,21 +113,21 @@ FROM gitcloned AS builder
110113
RUN ./bootstrap.sh \
111114
&& ./configure \
112115
&& make -j $(nproc) \
113-
&& make install DESTDIR=/tar_build
116+
&& make install-strip DESTDIR=/tar_build
114117

115118
# install documentation
116119
RUN mkdir -p /tar_build/usr/local/share/doc/libpkcs11shim \
117-
&& install -m 444 -t /tar_build/usr/local/share/doc/libpkcs11shim README.md CHANGELOG.md COPYING
120+
&& install -m 644 -t /tar_build/usr/local/share/doc/libpkcs11shim README.md CHANGELOG.md COPYING
118121

119122
# Build again the project for deb package (/usr)
120123
RUN make distclean \
121124
&& ./configure --prefix=/usr \
122125
&& make -j $(nproc) \
123-
&& make install DESTDIR=/rpm_build
126+
&& make install-strip DESTDIR=/rpm_build
124127

125128
# Install documentation
126129
RUN mkdir -p /rpm_build/usr/share/doc/libpkcs11shim \
127-
&& install -m 444 -t /rpm_build/usr/share/doc/libpkcs11shim README.md CHANGELOG.md COPYING
130+
&& install -m 644 -t /rpm_build/usr/share/doc/libpkcs11shim README.md CHANGELOG.md COPYING
128131

129132

130133
# Final stage

0 commit comments

Comments
 (0)