From 6cbc98951767e939c228329f2eea0c3c914d99cb Mon Sep 17 00:00:00 2001 From: Caio Oliveira Date: Tue, 9 Sep 2025 18:03:23 -0300 Subject: [PATCH] [ci] Make it POSIX-compliant * tested on Ubuntu 25.04 Signed-off-by: Caio Oliveira --- .ci/license-header.sh | 13 +++++---- .ci/source.sh | 66 ++++++++++++++++++++++++++++++++----------- .ci/translate.sh | 4 +-- .ci/update-icons.sh | 18 ++++++++++-- 4 files changed, 73 insertions(+), 28 deletions(-) diff --git a/.ci/license-header.sh b/.ci/license-header.sh index 98e88b5824..997c4d1519 100755 --- a/.ci/license-header.sh +++ b/.ci/license-header.sh @@ -58,7 +58,7 @@ check_cmake_header() { for file in $FILES; do [ -f "$file" ] || continue - if [ "$(basename -- "$file")" = "CMakeLists.txt" ]; then + if [ "$(basename "$file")" = "CMakeLists.txt" ]; then check_cmake_header "$file" continue fi @@ -133,24 +133,24 @@ if [ "$FIX" = "true" ]; then echo "license-header.sh: FIX set to true, fixing headers..." for file in $BAD_FILES; do - cp -- "$file" "$file.bak" + cp "$file" "$file.bak" cat .ci/license/header.txt > "$file" echo >> "$file" cat "$file.bak" >> "$file" - rm -- "$file.bak" + rm "$file.bak" git add "$file" done for file in $BAD_CMAKE; do - cp -- "$file" "$file.bak" + cp "$file" "$file.bak" cat .ci/license/header-hash.txt > "$file" echo >> "$file" cat "$file.bak" >> "$file" - rm -- "$file.bak" + rm "$file.bak" git add "$file" done @@ -164,8 +164,9 @@ if [ "$FIX" = "true" ]; then git commit -m "[license] Fix license headers" echo - echo "license-header.sh: Changes committed. You may now push." + echo "license-header.sh: Changes committed. You may now push." fi else exit 1 fi + diff --git a/.ci/source.sh b/.ci/source.sh index a1d602c61f..0db2a6c67c 100755 --- a/.ci/source.sh +++ b/.ci/source.sh @@ -1,25 +1,59 @@ -#!/bin/bash -ex +#!/bin/sh -e # SPDX-FileCopyrightText: 2025 Eden Emulator Project # 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}" -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" -mkdir artifacts +# Abort if archive already exists +if [ -e "$XZ_PATH" ]; then + echo "Error: Archive '$XZ_PATH' already exists. Aborting." + exit 1 +fi -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" +# 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" + +# Compress using xz +xz -9 "$ARCHIVE_PATH" + +# 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 .. diff --git a/.ci/translate.sh b/.ci/translate.sh index d840cab652..b582bd7f78 100755 --- a/.ci/translate.sh +++ b/.ci/translate.sh @@ -6,9 +6,7 @@ for i in dist/languages/*.ts; do SRC=en_US TARGET=$(head -n1 "$i" | awk -F 'language="' '{split($2, a, "\""); print a[1]}') - - # requires fd - SOURCES=$(fd . src/yuzu -tf -e ui -e cpp -e h -e plist) + SOURCES=$(find src/yuzu -type f \( -name '*.ui' -o -name '*.cpp' -o -name '*.h' -o -name '*.plist' \)) lupdate -source-language $SRC -target-language "$TARGET" "$SOURCES" -ts /data/code/eden/"$i" done diff --git a/.ci/update-icons.sh b/.ci/update-icons.sh index f77bfce376..55bbd3dd4d 100755 --- a/.ci/update-icons.sh +++ b/.ci/update-icons.sh @@ -5,7 +5,7 @@ # Check dependencies for cmd in png2icns magick svgo; do - if ! which "$cmd" >/dev/null 2>&1; then + if ! command -v "$cmd" >/dev/null 2>&1; then pkg="$cmd" case "$cmd" in png2icns) pkg="icnsutils" ;; @@ -16,20 +16,32 @@ for cmd in png2icns magick svgo; do fi done -export EDEN_SVG_ICO="dist/dev.eden_emu.eden.svg" -TMP_PNG="$(mktemp /tmp/eden-tmp-XXXXXX.png)" +EDEN_SVG_ICO="dist/dev.eden_emu.eden.svg" +# Create temporary PNG file safely (and POSIX-compliant) +TMP_PNG=$(mktemp /tmp/eden-tmp-XXXXXX) +TMP_PNG="${TMP_PNG}.png" + +# Optimize SVG svgo --multipass "$EDEN_SVG_ICO" +# Generate ICO magick \ -density 256x256 -background transparent "$EDEN_SVG_ICO" \ -define icon:auto-resize -colors 256 "dist/eden.ico" +# Generate BMP magick "$EDEN_SVG_ICO" -resize 256x256 -background transparent "dist/yuzu.bmp" +# Generate PNG for ICNS magick -size 1024x1024 -background transparent "$EDEN_SVG_ICO" "$TMP_PNG" +# Generate ICNS png2icns "dist/eden.icns" "$TMP_PNG" +# Copy ICNS to Yuzu file cp "dist/eden.icns" "dist/yuzu.icns" + +# Remove temporary PNG rm -f "$TMP_PNG" +