Skip to content

Commit

Permalink
Try to improve build on MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
ppkarwasz committed Oct 11, 2024
1 parent 1c85ca3 commit 55effa8
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 38 deletions.
17 changes: 7 additions & 10 deletions .github/workflows/package_code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ macos-latest, ubuntu-latest, windows-latest ]
os: [ macos-latest, ubuntu-latest ]

steps:
- name: Checkout repository
Expand Down Expand Up @@ -92,19 +92,16 @@ jobs:
current=CMakeFiles/dist/apache-log4cxx-$VERSION
reference=CMakeFiles/reference/apache-log4cxx-$VERSION
for format in tar.gz zip; do
for hash in sha256 sha512; do
if ! cmp --silent "$reference.$format.$hash" "$current.$format.$hash"; then
echo Files apache-log4cxx-$VERSION.$format differ\! >& 2
cat $reference.$format.$hash >& 2
cat $current.$format.$hash >& 2
exit 1
fi
done
if ! cmp --silent "$reference.$format" "$current.$format"; then
echo Files apache-log4cxx-$VERSION.$format differ\! >& 2
exit 1
fi
done
- name: Upload reproducibility results
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # 4.4.3
if: ${{ failure() && steps.check.conclusion == 'failure' }}
if: ${{ always() }}
#if: ${{ failure() && steps.check.conclusion == 'failure' }}
with:
name: apache-log4cxx-reproducibility-${{ matrix.os }}
path: |
Expand Down
53 changes: 25 additions & 28 deletions package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@ if ! echo "$OUTPUT_TIMESTAMP" | grep -Eq "^$d{4}-$d{2}-$d{2}T$d{2}:$d{2}:$d{2}Z$
exit 1
fi

# Build directory containing temporary files
# Build directory containing temporary files, all the paths are relative to it.
#
build=CMakeFiles

# Directory containing the distribution archives
#
dist="$build/dist"

# Create source directory
mkdir -p "$dist"
OUTPUT_DIR="$build/apache-log4cxx-$VERSION"
mkdir -p "$build/dist"
OUTPUT_DIR="apache-log4cxx-$VERSION"
if [ -f "$OUTPUT_DIR" ]; then
if [ ! -d "$OUTPUT_DIR" ]; then
echo File "$OUTPUT_DIR" is not a directory >& 2
Expand All @@ -39,7 +35,7 @@ if [ -f "$OUTPUT_DIR" ]; then
exit 1
fi
fi
mkdir -p "$OUTPUT_DIR"
mkdir -p "$build/$OUTPUT_DIR"

# Copy files to directory
cp -r \
Expand All @@ -52,13 +48,13 @@ cp -r \
src \
liblog4cxx.pc.in \
liblog4cxx-qt.pc.in \
"$OUTPUT_DIR"
rm -r "$OUTPUT_DIR"/src/main/abi-symbols
"$build/$OUTPUT_DIR"
rm -r "$build/$OUTPUT_DIR"/src/main/abi-symbols

# Create TAR file
#
# See https://reproducible-builds.org/docs/archives/ for reproducibility tips
TAR_ARCHIVE="$dist/apache-log4cxx-$VERSION.tar.gz"
TAR_ARCHIVE="dist/apache-log4cxx-$VERSION.tar.gz"
echo 'Tar version:'
tar --version | sed -e 's/^/\t/'
echo 'Gzip version:'
Expand All @@ -68,43 +64,44 @@ if [ -f "$TAR_ARCHIVE" ]; then
exit 1
fi

tar --transform="s!^$OUTPUT_DIR!apache-log4cxx-$VERSION!" \
--mtime="$OUTPUT_TIMESTAMP" \
--owner=0 --group=0 --numeric-owner \
--sort=name \
--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \
--create --gzip --file "$TAR_ARCHIVE" "$OUTPUT_DIR"

echo -e Tar archive: "$TAR_ARCHIVE"
(
cd "$build"
tar --mtime="$OUTPUT_TIMESTAMP" \
--owner=0 --group=0 --numeric-owner \
--sort=name \
--pax-option=exthdr.name=%d/PaxHeaders/%f,delete=atime,delete=ctime \
--create --gzip --file "$TAR_ARCHIVE" "$OUTPUT_DIR"
)
echo -e Tar archive: "$build/$TAR_ARCHIVE"

# Create ZIP file
#
# See https://reproducible-builds.org/docs/archives/ for reproducibility tips
# Change the mtime of all files
ZIP_ARCHIVE="$dist/apache-log4cxx-$VERSION.zip"
ZIP_ARCHIVE="dist/apache-log4cxx-$VERSION.zip"
echo 'Zip version:'
zip --version | sed 's/^/\t/'
if [ -f "$ZIP_ARCHIVE" ]; then
echo Archive "$ZIP_ARCHIVE" already exists >& 2
exit 1
fi

find "$OUTPUT_DIR" -exec touch --date="$OUTPUT_TIMESTAMP" -m {} +
find "$build/$OUTPUT_DIR" -exec touch --date="$OUTPUT_TIMESTAMP" -m {} +
# Sort files and zip.
(
cd "$build"
find apache-log4cxx-$VERSION -print0 |
find "$OUTPUT_DIR" -print0 |
LC_ALL=C sort -z |
xargs -0 zip -q -X dist/apache-log4cxx-$VERSION.zip
xargs -0 zip -q -X "$ZIP_ARCHIVE"
)

echo -e ZIP archive: "$ZIP_ARCHIVE"
echo -e ZIP archive: "$build/$ZIP_ARCHIVE"

# Generate hashes
(
cd "$dist"
for format in tar.gz zip; do
sha256sum apache-log4cxx-$VERSION.$format > apache-log4cxx-$VERSION.$format.sha256
sha512sum apache-log4cxx-$VERSION.$format > apache-log4cxx-$VERSION.$format.sha512
cd "$build/dist"
for file in *; do
sha256sum "$file" > "$file.sha256"
sha512sum "$file" > "$file.sha512"
done
)

0 comments on commit 55effa8

Please sign in to comment.