Skip to content

Commit eeec2e2

Browse files
committed
Add reproducibility verification
1 parent 6583772 commit eeec2e2

File tree

4 files changed

+209
-69
lines changed

4 files changed

+209
-69
lines changed

.editorconfig

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
root = true
22

3-
[.editorconfig]
4-
charset = utf-8
5-
end_of_line = lf
6-
indent_size = 4
7-
indent_style = tab
8-
insert_final_newline = true
9-
tab_width = 4
10-
trim_trailing_whitespace = true
11-
123
[*]
134
charset = utf-8
145
end_of_line = lf
@@ -18,20 +9,7 @@ insert_final_newline = true
189
tab_width = 4
1910
trim_trailing_whitespace = true
2011

21-
[*.sh]
22-
charset = utf-8
23-
end_of_line = lf
24-
indent_size = 2
25-
indent_style = space
26-
insert_final_newline = true
27-
tab_width = 2
28-
trim_trailing_whitespace = true
29-
30-
[CMakeLists.txt]
31-
charset = utf-8
32-
end_of_line = lf
12+
[{*.sh,*.yml,CMakeLists.txt}]
3313
indent_size = 2
3414
indent_style = space
35-
insert_final_newline = true
3615
tab_width = 2
37-
trim_trailing_whitespace = true

.github/workflows/package_code.yml

Lines changed: 79 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -15,54 +15,91 @@
1515
name: Generate release files
1616

1717
on:
18+
workflow_call:
1819
push:
1920
branches:
2021
- master
21-
# pull_request:
22-
# branches:
23-
# - master
22+
23+
permissions: read-all
2424

2525
jobs:
26-
job1:
27-
name: 'Package code for release'
28-
runs-on: ubuntu-20.04
29-
timeout-minutes: 38
30-
strategy:
31-
fail-fast: false
26+
27+
package:
28+
name: Package code
29+
runs-on: ubuntu-latest
3230

3331
steps:
34-
- uses: actions/checkout@v4
35-
with:
36-
persist-credentials: false # do not persist auth token in the local git config
37-
path: clean-checkout
32+
- name: Checkout repository
33+
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # 4.2.1
34+
with:
35+
persist-credentials: false # do not persist auth token in the local git config
3836

39-
# Consider using CPack when it supports a white-list for included files
40-
# - name: 'Install minimum dependencies'
41-
# run: |
42-
# sudo apt-get install -y libapr1-dev libaprutil1-dev
43-
#
44-
# - name: 'Create release files'
45-
# run: |
46-
# cmake -B package -S clean-checkout -DAPACHE_MAINTAINER=yes -DCPACK_PACKAGE_DIRECTORY=`pwd`
47-
# cmake --build package --target dist
48-
#
49-
- name: 'Create release files'
50-
run: |
51-
cd clean-checkout
52-
rm -r src/main/abi-symbols
53-
VERSION=`grep 'set(log4cxx_VER ' src/cmake/projectVersionDetails.cmake|sed -Ee 's/.*log4cxx_VER ([0-9]*)\.([0-9]*)\.([0-9]*).*/\1.\2.\3/'`
54-
tar -zcf "../apache-log4cxx-$VERSION.tar.gz" "--transform=s,^,apache-log4cxx-$VERSION/," INSTALL LICENSE NOTICE README.md CMakeLists.txt src liblog4cxx.pc.in liblog4cxx-qt.pc.in KEYS
55-
cd ..
56-
sha512sum "apache-log4cxx-$VERSION.tar.gz" > "apache-log4cxx-$VERSION.tar.gz.sha512"
57-
sha256sum "apache-log4cxx-$VERSION.tar.gz" > "apache-log4cxx-$VERSION.tar.gz.sha256"
58-
tar xf "apache-log4cxx-$VERSION.tar.gz"
59-
zip -rm "apache-log4cxx-$VERSION.zip" apache-log4cxx-$VERSION
60-
sha512sum "apache-log4cxx-$VERSION.zip" > "apache-log4cxx-$VERSION.zip.sha512"
61-
sha256sum "apache-log4cxx-$VERSION.zip" > "apache-log4cxx-$VERSION.zip.sha256"
37+
- name: Determine version
38+
shell: bash
39+
run: |
40+
VERSION=$(grep -Po '(?<=set\(log4cxx_VER ")(.*)(?="\))' src/cmake/projectVersionDetails.cmake)
41+
echo "VERSION=$VERSION" >> $GITHUB_ENV
42+
43+
- name: Create release files
44+
shell: bash
45+
run: |
46+
./package.sh
47+
48+
- name: Upload artifacts
49+
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # 4.4.3
50+
if: always()
51+
with:
52+
name: apache-log4cxx
53+
path: |
54+
CMakeLists/apache-log4cxx-*
55+
56+
verify-reproducibility:
57+
name: Verify reproducibility
58+
needs: package
59+
runs-on:
60+
- ubuntu-latest
61+
- macos-latest
62+
- windows-latest
63+
64+
steps:
65+
- name: Checkout repository
66+
uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # 4.2.1
67+
with:
68+
persist-credentials: false # do not persist auth token in the local git config
69+
70+
- name: Determine version
71+
shell: bash
72+
run: |
73+
VERSION=$(grep -Po '(?<=set\(log4cxx_VER ")(.*)(?="\))' src/cmake/projectVersionDetails.cmake)
74+
echo "VERSION=$VERSION" >> $GITHUB_ENV
75+
76+
- name: Download artifacts
77+
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # 4.1.8
78+
with:
79+
name: apache-log4cxx
80+
path: |
81+
CMakeLists/reference
82+
83+
- name: Check release files
84+
id: check
85+
shell: bash
86+
run: |
87+
./package.sh
88+
current=CMakeLists/apache-log4cxx-$VERSION
89+
reference=CMakeLists/reference/apache-log4cxx-$VERSION
90+
for format in tar.gz zip; do
91+
for hash in sha256 sha512; do
92+
if cmp --silent "$reference.$format.$hash" "$current.$format.$hash"; then
93+
echo Files apache-log4cxx-$VERSION.$format differ\! >& 2
94+
exit 1
95+
fi
96+
done
97+
done
6298
63-
- uses: actions/upload-artifact@v4
64-
if: always()
65-
with:
66-
name: 'Upload release files'
67-
path: |
68-
apache-log4cxx-*
99+
- name: Upload reproducibility results
100+
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # 4.4.3
101+
if: ${{ failure() && steps.check.conclusion == 'failure' }}
102+
with:
103+
name: apache-log4cxx-reproducibility-${{ runner.os }}
104+
path: |
105+
CMakeLists/apache-log4cxx-*

package.sh

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
#!/bin/bash
2+
#
3+
set -e
4+
5+
# Determine the version and build timestamp
6+
VERSION=$(grep -Po '(?<=set\(log4cxx_VER ")(.*)(?="\))' src/cmake/projectVersionDetails.cmake)
7+
if ! echo "$VERSION" | grep -Pq '^\d+\.\d+\.\d+$'; then
8+
echo Invalid version number: "$VERSION" >& 2
9+
exit 1
10+
fi
11+
12+
OUTPUT_TIMESTAMP=$(grep -Po '(?<=set\(log4cxx_OUTPUT_TIMESTAMP ")(.*)(?="\))' src/cmake/projectVersionDetails.cmake)
13+
if ! echo "$OUTPUT_TIMESTAMP" | grep -Pq '^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$'; then
14+
echo Invalid build timestamp: "$OUTPUT_TIMESTAMP" >& 2
15+
echo Run '`'date -u +%Y-%m-%dT%H:%M:%SZ'`' to generate it
16+
exit 1
17+
fi
18+
19+
# Build directory
20+
build=CMakeFiles
21+
22+
# Create source directory
23+
mkdir -p "$build"
24+
OUTPUT_DIR="$build/apache-log4cxx-$VERSION"
25+
if [ -f "$OUTPUT_DIR" ]; then
26+
if [ ! -d "$OUTPUT_DIR" ]; then
27+
echo File "$OUTPUT_DIR" is not a directory >& 2
28+
exit 1
29+
fi
30+
if [ ! -z "$(ls -A "$OUTPUT_DIR")" ]; then
31+
echo Directory "$OUTPUT_DIR" is not empty >& 2
32+
exit 1
33+
fi
34+
fi
35+
mkdir -p "$OUTPUT_DIR"
36+
37+
# Copy files to directory
38+
cp -r \
39+
CMakeLists.txt \
40+
KEYS \
41+
INSTALL \
42+
LICENSE \
43+
NOTICE \
44+
README.md \
45+
src \
46+
liblog4cxx.pc.in \
47+
liblog4cxx-qt.pc.in \
48+
"$OUTPUT_DIR"
49+
rm -r "$OUTPUT_DIR"/src/main/abi-symbols
50+
51+
# Create TAR file
52+
#
53+
# See https://reproducible-builds.org/docs/archives/ for reproducibility tips
54+
TAR_ARCHIVE="$build/apache-log4cxx-$VERSION.tar.gz"
55+
echo 'Tar version:'
56+
tar --version | sed -e 's/^/\t/'
57+
echo 'Gzip version:'
58+
gzip --version | sed -e 's/^/\t/'
59+
if [ -f "$TAR_ARCHIVE" ]; then
60+
echo Archive "$TAR_ARCHIVE" already exists >& 2
61+
exit 1
62+
fi
63+
64+
tar --transform="s!^$OUTPUT_DIR!apache-log4cxx-$VERSION!" \
65+
--mtime="$OUTPUT_TIMESTAMP" \
66+
--owner=0 --group=0 --numeric-owner \
67+
--sort=name \
68+
--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \
69+
--create --gzip --file "$TAR_ARCHIVE" "$OUTPUT_DIR"
70+
71+
echo -e Tar archive: "$TAR_ARCHIVE"
72+
73+
# Create ZIP file
74+
#
75+
# See https://reproducible-builds.org/docs/archives/ for reproducibility tips
76+
# Change the mtime of all files
77+
ZIP_ARCHIVE="$build/apache-log4cxx-$VERSION.zip"
78+
echo 'Zip version:'
79+
zip --version | sed 's/^/\t/'
80+
if [ -f "$ZIP_ARCHIVE" ]; then
81+
echo Archive "$ZIP_ARCHIVE" already exists >& 2
82+
exit 1
83+
fi
84+
85+
find "$OUTPUT_DIR" -exec touch --date="$OUTPUT_TIMESTAMP" -m {} +
86+
# Sort files and zip.
87+
(
88+
cd "$build"
89+
find apache-log4cxx-$VERSION -print0 |
90+
LC_ALL=C sort -z |
91+
xargs -0 zip -q -X apache-log4cxx-$VERSION.zip
92+
)
93+
94+
echo -e ZIP archive: "$ZIP_ARCHIVE"
95+
96+
# Generate hashes
97+
(
98+
cd "$build"
99+
for format in tar.gz zip; do
100+
sha256sum apache-log4cxx-$VERSION.$format > apache-log4cxx-$VERSION.$format.sha256
101+
sha512sum apache-log4cxx-$VERSION.$format > apache-log4cxx-$VERSION.$format.sha512
102+
done
103+
)

src/cmake/projectVersionDetails.cmake

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
1-
# This file should contain nothing but the following line
2-
# setting the project version. The variable name must not
3-
# clash with the log4cxx_VERSION* variables automatically
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one or more
3+
# contributor license agreements. See the NOTICE file distributed with
4+
# this work for additional information regarding copyright ownership.
5+
# The ASF licenses this file to You under the Apache License, Version 2.0
6+
# (the "License"); you may not use this file except in compliance with
7+
# the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
##
18+
# This file should contain only the current version and the build timestamp
19+
20+
# The variable name must not clash with the log4cxx_VERSION* variables automatically
421
# defined by the project() command.
5-
set(log4cxx_VER 1.3.0.0)
22+
set(log4cxx_VER "1.3.0")
23+
24+
# Timestamp used for the source archive to guarantee reproducible builds in ISO 8601 format.
25+
#
26+
# To generate use: date -u +%Y-%m-%dT%H:%M:%SZ
27+
set(log4cxx_OUTPUT_TIMESTAMP "2024-10-11T14:35:14Z")

0 commit comments

Comments
 (0)