Browse Source
[ci] Make it POSIX-compliant
[ci] Make it POSIX-compliant
* tested on Ubuntu 25.04 Signed-off-by: Caio Oliveira <caiooliveirafarias0@gmail.com>pull/397/head
committed by
crueter
4 changed files with 73 additions and 28 deletions
@ -1,25 +1,59 @@ |
|||||
#!/bin/bash -ex |
|
||||
|
#!/bin/sh -e |
||||
|
|
||||
# SPDX-FileCopyrightText: 2025 Eden Emulator Project |
# SPDX-FileCopyrightText: 2025 Eden Emulator Project |
||||
# SPDX-License-Identifier: GPL-3.0-or-later |
# SPDX-License-Identifier: GPL-3.0-or-later |
||||
|
|
||||
# git-archive-all |
|
||||
export PATH="$PATH:/home/$USER/.local/bin" |
|
||||
|
|
||||
GITDATE="$(git show -s --date=short --format='%ad' | sed 's/-//g')" |
|
||||
GITREV="$(git show -s --format='%h')" |
|
||||
|
GITDATE=$(git show -s --date=short --format='%ad' | sed 's/-//g') |
||||
|
GITREV=$(git show -s --format='%h') |
||||
REV_NAME="eden-unified-source-${GITDATE}-${GITREV}" |
REV_NAME="eden-unified-source-${GITDATE}-${GITREV}" |
||||
|
|
||||
COMPAT_LIST='dist/compatibility_list/compatibility_list.json' |
|
||||
|
COMPAT_LIST="dist/compatibility_list/compatibility_list.json" |
||||
|
ARTIFACT_DIR="artifacts" |
||||
|
ARCHIVE_PATH="${ARTIFACT_DIR}/${REV_NAME}.tar" |
||||
|
XZ_PATH="${ARCHIVE_PATH}.xz" |
||||
|
SHA_PATH="${XZ_PATH}.sha256sum" |
||||
|
|
||||
|
# Abort if archive already exists |
||||
|
if [ -e "$XZ_PATH" ]; then |
||||
|
echo "Error: Archive '$XZ_PATH' already exists. Aborting." |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
|
# Create output directory |
||||
|
mkdir -p "$ARTIFACT_DIR" |
||||
|
|
||||
|
# Create temporary directory |
||||
|
TMPDIR=$(mktemp -d) |
||||
|
|
||||
|
# Ensure compatibility list file exists |
||||
|
touch "$COMPAT_LIST" |
||||
|
cp "$COMPAT_LIST" "$TMPDIR/" |
||||
|
|
||||
|
# Create base archive from git |
||||
|
git archive --format=tar --prefix="${REV_NAME}/" HEAD > "$ARCHIVE_PATH" |
||||
|
|
||||
|
# Create commit and tag files with correct names |
||||
|
git describe --abbrev=0 --always HEAD > "$TMPDIR/GIT-COMMIT" |
||||
|
if ! git describe --tags HEAD > "$TMPDIR/GIT-TAG" 2>/dev/null; then |
||||
|
echo "unknown" > "$TMPDIR/GIT-TAG" |
||||
|
fi |
||||
|
|
||||
|
# Append extra files to archive |
||||
|
tar --append --file="$ARCHIVE_PATH" -C "$TMPDIR" "$(basename "$COMPAT_LIST")" GIT-COMMIT GIT-TAG |
||||
|
|
||||
|
# Remove temporary directory |
||||
|
rm -rf "$TMPDIR" |
||||
|
|
||||
mkdir artifacts |
|
||||
|
# Compress using xz |
||||
|
xz -9 "$ARCHIVE_PATH" |
||||
|
|
||||
touch "${COMPAT_LIST}" |
|
||||
git describe --abbrev=0 --always HEAD > GIT-COMMIT |
|
||||
git describe --tags HEAD > GIT-TAG || echo 'unknown' > GIT-TAG |
|
||||
git-archive-all --include "${COMPAT_LIST}" --include GIT-COMMIT --include GIT-TAG --force-submodules artifacts/"${REV_NAME}.tar" |
|
||||
|
# Generate SHA-256 checksum (GNU vs BSD/macOS) |
||||
|
if command -v sha256sum >/dev/null 2>&1; then |
||||
|
sha256sum "$XZ_PATH" > "$SHA_PATH" |
||||
|
elif command -v shasum >/dev/null 2>&1; then |
||||
|
shasum -a 256 "$XZ_PATH" > "$SHA_PATH" |
||||
|
else |
||||
|
echo "No SHA-256 tool found (sha256sum or shasum required)" >&2 |
||||
|
exit 1 |
||||
|
fi |
||||
|
|
||||
cd artifacts/ |
|
||||
xz -T0 -9 "${REV_NAME}.tar" |
|
||||
sha256sum "${REV_NAME}.tar.xz" > "${REV_NAME}.tar.xz.sha256sum" |
|
||||
cd .. |
|
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue