From 99cf9ac960409cb6201b5a60e17b837af87a76af Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Tue, 29 Jul 2025 22:08:30 -0400 Subject: [PATCH] ci: use actionlint and problem matchers (#4116) --- .gitattributes | 5 +- .github/matchers/copr-ci.json | 17 +++ .github/matchers/docker.json | 17 +++ .github/matchers/gcc-strip3.json | 17 +++ .github/matchers/gcc.json | 29 ++++ .github/workflows/ci-copr.yml | 4 + .github/workflows/ci-flatpak.yml | 41 +++--- .github/workflows/ci-homebrew.yml | 16 ++- .github/workflows/ci-linux.yml | 8 +- .github/workflows/ci-windows.yml | 10 +- .github/workflows/localize.yml | 8 +- cmake/prep/build_version.cmake | 8 +- docker/archlinux.dockerfile | 2 +- docker/clion-toolchain.dockerfile | 2 - docker/debian-bookworm.dockerfile | 1 - docker/ubuntu-22.04.dockerfile | 1 - docker/ubuntu-24.04.dockerfile | 1 - packaging/linux/fedora/Sunshine.spec | 3 - .../flatpak/scripts/additional-install.sh | 10 +- .../scripts/remove-additional-install.sh | 6 +- scripts/icons/convert_and_pack.sh | 124 +++++++++--------- scripts/linux_build.sh | 2 + src_assets/macos/misc/uninstall_pkg.sh | 3 +- 23 files changed, 215 insertions(+), 120 deletions(-) create mode 100644 .github/matchers/copr-ci.json create mode 100644 .github/matchers/docker.json create mode 100644 .github/matchers/gcc-strip3.json create mode 100644 .github/matchers/gcc.json diff --git a/.gitattributes b/.gitattributes index 3e0ae29c..a1b22303 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,5 @@ -# ensure dockerfiles are checked out with LF line endings +# ensure Linux specific files are checked out with LF line endings Dockerfile text eol=lf *.dockerfile text eol=lf - -# ensure flatpak lint json files are checked out with LF line endings *flatpak-lint-*.json text eol=lf +*.sh text eol=lf diff --git a/.github/matchers/copr-ci.json b/.github/matchers/copr-ci.json new file mode 100644 index 00000000..d884c61a --- /dev/null +++ b/.github/matchers/copr-ci.json @@ -0,0 +1,17 @@ +{ + "problemMatcher": [ + { + "owner": "copr-ci-gcc", + "pattern": [ + { + "regexp": "^/?(?:[^/]+/){5}([^:]+):(\\d+):(\\d+):\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + ] + } + ] +} diff --git a/.github/matchers/docker.json b/.github/matchers/docker.json new file mode 100644 index 00000000..df43ee03 --- /dev/null +++ b/.github/matchers/docker.json @@ -0,0 +1,17 @@ +{ + "problemMatcher": [ + { + "owner": "docker-gcc", + "pattern": [ + { + "regexp": "^(?:#\\d+\\s+\\d+\\.\\d+\\s+)?/?(?:[^/]+/){2}([^:]+):(\\d+):(\\d+):\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + ] + } + ] +} diff --git a/.github/matchers/gcc-strip3.json b/.github/matchers/gcc-strip3.json new file mode 100644 index 00000000..8b6027f2 --- /dev/null +++ b/.github/matchers/gcc-strip3.json @@ -0,0 +1,17 @@ +{ + "problemMatcher": [ + { + "owner": "gcc-strip3", + "pattern": [ + { + "regexp": "^/?(?:[^/]+/){3}([^:]+):(\\d+):(\\d+):\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + ] + } + ] +} diff --git a/.github/matchers/gcc.json b/.github/matchers/gcc.json new file mode 100644 index 00000000..13f987bf --- /dev/null +++ b/.github/matchers/gcc.json @@ -0,0 +1,29 @@ +{ + "problemMatcher": [ + { + "owner": "gcc", + "pattern": [ + { + "regexp": "^(.*):(\\d+):(\\d+):\\s+(?:fatal\\s+)?(warning|error):\\s+(.*)$", + "file": 1, + "line": 2, + "column": 3, + "severity": 4, + "message": 5 + } + ] + }, + { + "owner": "doxygen", + "pattern": [ + { + "regexp": "^.*?([A-Za-z]:[\\\\/][^:]+|[\\\\/][^:]+):(\\d+): ([a-zA-Z]+): (.+)$", + "file": 1, + "line": 2, + "severity": 3, + "message": 4 + } + ] + } + ] +} diff --git a/.github/workflows/ci-copr.yml b/.github/workflows/ci-copr.yml index 716a8be7..4981d4c4 100644 --- a/.github/workflows/ci-copr.yml +++ b/.github/workflows/ci-copr.yml @@ -16,6 +16,10 @@ on: required: false COPR_CLI_CONFIG: required: false + GH_BOT_TOKEN: + required: false + VIRUSTOTAL_API_KEY: + required: false concurrency: group: "_${{ github.workflow }}-${{ github.ref }}" diff --git a/.github/workflows/ci-flatpak.yml b/.github/workflows/ci-flatpak.yml index df02d98f..22456851 100644 --- a/.github/workflows/ci-flatpak.yml +++ b/.github/workflows/ci-flatpak.yml @@ -73,15 +73,16 @@ jobs: cmake \ flatpak - sudo su $(whoami) -c "flatpak --user remote-add --if-not-exists flathub \ - https://flathub.org/repo/flathub.flatpakrepo" + sudo su "$(whoami)" -c "flatpak --user remote-add --if-not-exists flathub \ + https://flathub.org/repo/flathub.flatpakrepo + " - sudo su $(whoami) -c "flatpak --user install -y flathub \ + sudo su "$(whoami)" -c "flatpak --user install -y flathub \ org.flatpak.Builder \ org.freedesktop.Platform/${{ matrix.arch }}/${PLATFORM_VERSION} \ org.freedesktop.Sdk/${{ matrix.arch }}/${PLATFORM_VERSION} \ org.freedesktop.Sdk.Extension.node${NODE_VERSION}/${{ matrix.arch }}/${PLATFORM_VERSION} \ - " + " flatpak run org.flatpak.Builder --version @@ -101,9 +102,11 @@ jobs: flatpak-${{ matrix.arch }}- - name: Configure Flatpak Manifest + env: + BRANCH: ${{ github.head_ref }} run: | # variables for manifest - branch="${{ github.head_ref }}" + branch="${{ env.BRANCH }}" build_version=${{ inputs.release_version }} commit=${{ inputs.release_commit }} @@ -137,19 +140,20 @@ jobs: - name: Debug Manifest working-directory: build - run: cat ${APP_ID}.yml + run: cat "${APP_ID}.yml" - name: Build Linux Flatpak working-directory: build run: | - sudo su $(whoami) -c "flatpak run org.flatpak.Builder \ + echo "::add-matcher::.github/matchers/gcc-strip3.json" + sudo su "$(whoami)" -c "flatpak run org.flatpak.Builder \ --arch=${{ matrix.arch }} \ --force-clean \ --repo=repo \ --sandbox \ --stop-at=cuda build-sunshine ${APP_ID}.yml" cp -r .flatpak-builder copy-of-flatpak-builder - sudo su $(whoami) -c "flatpak run org.flatpak.Builder \ + sudo su "$(whoami)" -c "flatpak run org.flatpak.Builder \ --arch=${{ matrix.arch }} \ --force-clean \ --repo=repo \ @@ -157,15 +161,16 @@ jobs: build-sunshine ${APP_ID}.yml" rm -rf .flatpak-builder mv copy-of-flatpak-builder .flatpak-builder - sudo su $(whoami) -c "flatpak build-bundle \ + sudo su "$(whoami)" -c "flatpak build-bundle \ --arch=${{ matrix.arch }} \ ./repo \ ../artifacts/sunshine_${{ matrix.arch }}.flatpak ${APP_ID}" - sudo su $(whoami) -c "flatpak build-bundle \ + sudo su "$(whoami)" -c "flatpak build-bundle \ --runtime \ --arch=${{ matrix.arch }} \ ./repo \ ../artifacts/sunshine_debug_${{ matrix.arch }}.flatpak ${APP_ID}.Debug" + echo "::remove-matcher owner=gcc-strip3::" - name: Lint Flatpak working-directory: build @@ -177,7 +182,7 @@ jobs: --exceptions \ --user-exceptions "${exceptions_file}" \ manifest \ - ${APP_ID}.yml + "${APP_ID}.yml" echo "Linting flatpak repo" # TODO: add arg @@ -193,13 +198,13 @@ jobs: if: matrix.arch == 'x86_64' run: | mkdir -p flathub/modules - cp ./build/generated-sources.json ./flathub/ - cp ./build/package-lock.json ./flathub/ - cp ./build/${APP_ID}.yml ./flathub/ - cp ./build/${APP_ID}.metainfo.xml ./flathub/ - cp ./packaging/linux/flatpak/README.md ./flathub/ - cp ./packaging/linux/flatpak/flathub.json ./flathub/ - cp -r ./packaging/linux/flatpak/modules/. ./flathub/modules/ + cp "./build/generated-sources.json" "./flathub/" + cp "./build/package-lock.json" "./flathub/" + cp "./build/${APP_ID}.yml" "./flathub/" + cp "./build/${APP_ID}.metainfo.xml" "./flathub/" + cp "./packaging/linux/flatpak/README.md" "./flathub/" + cp "./packaging/linux/flatpak/flathub.json" "./flathub/" + cp -r "./packaging/linux/flatpak/modules/." "./flathub/modules/" # submodules will need to be handled in the workflow that creates the PR # create the archive diff --git a/.github/workflows/ci-homebrew.yml b/.github/workflows/ci-homebrew.yml index 9c2564d1..1b8eb724 100644 --- a/.github/workflows/ci-homebrew.yml +++ b/.github/workflows/ci-homebrew.yml @@ -73,9 +73,13 @@ jobs: brew install python3 - name: Configure formula + env: + HEAD_REF: ${{ github.head_ref }} + PR_HEAD_REF: ${{ github.event.pull_request.head.ref }} + PR_DEFAULT_BRANCH: ${{ github.event.pull_request.head.repo.default_branch }} run: | # variables for formula - branch="${{ github.head_ref }}" + branch="${{ env.HEAD_REF }}" build_version=${{ inputs.release_version }} commit=${{ inputs.release_commit }} @@ -96,9 +100,9 @@ jobs: else echo "This is a PR event" clone_url=${{ github.event.pull_request.head.repo.clone_url }} - branch="${{ github.event.pull_request.head.ref }}" - default_branch="${{ github.event.pull_request.head.repo.default_branch }}" - tag="${{ github.event.pull_request.head.ref }}" + branch="${{ env.PR_HEAD_REF }}" + default_branch="${{ env.PR_DEFAULT_BRANCH }}" + tag="${{ env.PR_HEAD_REF }}" fi echo "Branch: ${branch}" echo "Clone URL: ${clone_url}" @@ -143,8 +147,9 @@ jobs: export DISPLAY=:1 Xvfb ${DISPLAY} -screen 0 1024x768x24 & - echo "DISPLAY=${DISPLAY}" >> $GITHUB_ENV + echo "DISPLAY=${DISPLAY}" >> "${GITHUB_ENV}" + - run: echo "::add-matcher::.github/matchers/gcc-strip3.json" - name: Validate Homebrew Formula id: test if: matrix.release != true @@ -156,6 +161,7 @@ jobs: publish: false token: ${{ secrets.GH_TOKEN }} validate: true + - run: echo "::remove-matcher owner=gcc-strip3::" - name: Setup python id: python diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 3e917505..c844300d 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -79,8 +79,8 @@ jobs: --enable-x11 \ --enable-glx \ --enable-wayland \ - --without-legacy # emgd, nvctrl, fglrx - make -j $(nproc) + --without-legacy + make -j "$(nproc)" sudo make install cd .. && rm -rf libva-* @@ -91,6 +91,7 @@ jobs: COMMIT: ${{ inputs.release_commit }} run: | chmod +x ./scripts/linux_build.sh + echo "::add-matcher::.github/matchers/gcc.json" ./scripts/linux_build.sh \ --publisher-name='${{ github.repository_owner }}' \ --publisher-website='https://app.lizardbyte.dev' \ @@ -98,12 +99,13 @@ jobs: --skip-cleanup \ --skip-package \ --ubuntu-test-repo ${{ matrix.EXTRA_ARGS }} + echo "::remove-matcher owner=gcc::" - name: Set AppImage Version if: matrix.name == 'AppImage' run: | version=${{ inputs.release_version }} - echo "VERSION=${version}" >> $GITHUB_ENV + echo "VERSION=${version}" >> "${GITHUB_ENV}" - name: Package Linux - AppImage if: matrix.name == 'AppImage' diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index e66f52da..03cb909b 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -199,12 +199,12 @@ jobs: ignore_list=$(IFS=,; echo "${ignore_packages[*]}") # install pinned dependencies - if [ -n "$tarballs" ]; then - pacman -U --noconfirm ${tarballs} + if [ -n "${tarballs}" ]; then + pacman -U --noconfirm "${tarballs}" fi # Only add --ignore if we have packages to ignore - if [ -n "$ignore_list" ]; then + if [ -n "${ignore_list}" ]; then pacman -Syu --noconfirm --ignore="${ignore_list}" "${dependencies[@]}" else pacman -Syu --noconfirm "${dependencies[@]}" @@ -251,7 +251,7 @@ jobs: # step output echo "python-path=${python_path}" - echo "python-path=${python_path}" >> $GITHUB_OUTPUT + echo "python-path=${python_path}" >> "${GITHUB_OUTPUT}" - name: Build Windows shell: msys2 {0} @@ -272,7 +272,9 @@ jobs: -DSUNSHINE_PUBLISHER_NAME='${{ github.repository_owner }}' \ -DSUNSHINE_PUBLISHER_WEBSITE='https://app.lizardbyte.dev' \ -DSUNSHINE_PUBLISHER_ISSUE_URL='https://app.lizardbyte.dev/support' + echo "::add-matcher::.github/matchers/gcc.json" ninja -C build + echo "::remove-matcher owner=gcc::" - name: Package Windows shell: msys2 {0} diff --git a/.github/workflows/localize.yml b/.github/workflows/localize.yml index 476f2f2c..cff329c4 100644 --- a/.github/workflows/localize.yml +++ b/.github/workflows/localize.yml @@ -48,9 +48,9 @@ jobs: if [ -f "${{ env.file }}" ]; then rm ${{ env.file }} - echo "new_file=false" >> $GITHUB_ENV + echo "new_file=false" >> "${GITHUB_ENV}" else - echo "new_file=true" >> $GITHUB_ENV + echo "new_file=true" >> "${GITHUB_ENV}" fi # extract the new strings @@ -67,7 +67,7 @@ jobs: # set the variable with minimal output, replacing `\t` with ` ` OUTPUT=$(git diff --numstat locale/sunshine.po | sed -e "s#\t# #g") - echo "git_diff=${OUTPUT}" >> $GITHUB_ENV + echo "git_diff=${OUTPUT}" >> "${GITHUB_ENV}" - name: git reset # only run if a single line changed (date/time) and file already existed @@ -79,7 +79,7 @@ jobs: - name: Get current date id: date - run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT + run: echo "date=$(date +'%Y-%m-%d')" >> "${GITHUB_OUTPUT}" - name: Create/Update Pull Request uses: peter-evans/create-pull-request@v7 diff --git a/cmake/prep/build_version.cmake b/cmake/prep/build_version.cmake index 80df777a..030e93c4 100644 --- a/cmake/prep/build_version.cmake +++ b/cmake/prep/build_version.cmake @@ -1,18 +1,18 @@ # Set build variables if env variables are defined # These are used in configured files such as manifests for different packages -if(DEFINED ENV{BRANCH}) # cmake-lint: disable=W0106 +if(DEFINED ENV{BRANCH}) set(GITHUB_BRANCH $ENV{BRANCH}) endif() if(DEFINED ENV{BUILD_VERSION}) # cmake-lint: disable=W0106 set(BUILD_VERSION $ENV{BUILD_VERSION}) endif() -if(DEFINED ENV{CLONE_URL}) # cmake-lint: disable=W0106 +if(DEFINED ENV{CLONE_URL}) set(GITHUB_CLONE_URL $ENV{CLONE_URL}) endif() -if(DEFINED ENV{COMMIT}) # cmake-lint: disable=W0106 +if(DEFINED ENV{COMMIT}) set(GITHUB_COMMIT $ENV{COMMIT}) endif() -if(DEFINED ENV{TAG}) # cmake-lint: disable=W0106 +if(DEFINED ENV{TAG}) set(GITHUB_TAG $ENV{TAG}) endif() diff --git a/docker/archlinux.dockerfile b/docker/archlinux.dockerfile index 89071f60..63a9be63 100644 --- a/docker/archlinux.dockerfile +++ b/docker/archlinux.dockerfile @@ -32,7 +32,6 @@ ENV CLONE_URL=${CLONE_URL} SHELL ["/bin/bash", "-o", "pipefail", "-c"] -# hadolint ignore=SC2016 RUN <<_SETUP #!/bin/bash set -e @@ -42,6 +41,7 @@ useradd -m builder echo 'builder ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers # patch the build flags +# shellcheck disable=SC2016 sed -i 's,#MAKEFLAGS="-j2",MAKEFLAGS="-j$(nproc)",g' /etc/makepkg.conf # install dependencies diff --git a/docker/clion-toolchain.dockerfile b/docker/clion-toolchain.dockerfile index ec54568c..f5080d18 100644 --- a/docker/clion-toolchain.dockerfile +++ b/docker/clion-toolchain.dockerfile @@ -19,7 +19,6 @@ ENV DISPLAY=:0 SHELL ["/bin/bash", "-o", "pipefail", "-c"] # install dependencies -# hadolint ignore=SC1091 RUN <<_DEPS #!/bin/bash set -e @@ -74,7 +73,6 @@ WORKDIR /build/cuda # versions: https://developer.nvidia.com/cuda-toolkit-archive ENV CUDA_VERSION="11.8.0" ENV CUDA_BUILD="520.61.05" -# hadolint ignore=SC3010 RUN <<_INSTALL_CUDA #!/bin/bash set -e diff --git a/docker/debian-bookworm.dockerfile b/docker/debian-bookworm.dockerfile index f88cea05..ffa68b7c 100644 --- a/docker/debian-bookworm.dockerfile +++ b/docker/debian-bookworm.dockerfile @@ -42,7 +42,6 @@ _BUILD # run tests WORKDIR /build/sunshine/build/tests -# hadolint ignore=SC1091 RUN <<_TEST #!/bin/bash set -e diff --git a/docker/ubuntu-22.04.dockerfile b/docker/ubuntu-22.04.dockerfile index 7bb24eb8..06032175 100644 --- a/docker/ubuntu-22.04.dockerfile +++ b/docker/ubuntu-22.04.dockerfile @@ -42,7 +42,6 @@ _BUILD # run tests WORKDIR /build/sunshine/build/tests -# hadolint ignore=SC1091 RUN <<_TEST #!/bin/bash set -e diff --git a/docker/ubuntu-24.04.dockerfile b/docker/ubuntu-24.04.dockerfile index 984cfdcb..e11f18b2 100644 --- a/docker/ubuntu-24.04.dockerfile +++ b/docker/ubuntu-24.04.dockerfile @@ -42,7 +42,6 @@ _BUILD # run tests WORKDIR /build/sunshine/build/tests -# hadolint ignore=SC1091 RUN <<_TEST #!/bin/bash set -e diff --git a/packaging/linux/fedora/Sunshine.spec b/packaging/linux/fedora/Sunshine.spec index 1f7a8782..798d0009 100644 --- a/packaging/linux/fedora/Sunshine.spec +++ b/packaging/linux/fedora/Sunshine.spec @@ -97,9 +97,6 @@ tar -xzf %{SOURCE0} -C %{_builddir}/Sunshine # list directory ls -a %{_builddir}/Sunshine -# patches -%autopatch -p1 - %build # exit on error set -e diff --git a/packaging/linux/flatpak/scripts/additional-install.sh b/packaging/linux/flatpak/scripts/additional-install.sh index a27db4e0..06c5835e 100644 --- a/packaging/linux/flatpak/scripts/additional-install.sh +++ b/packaging/linux/flatpak/scripts/additional-install.sh @@ -2,12 +2,12 @@ # User Service mkdir -p ~/.config/systemd/user -cp /app/share/sunshine/systemd/user/sunshine.service $HOME/.config/systemd/user/sunshine.service -echo Sunshine User Service has been installed. -echo Use [systemctl --user enable sunshine] once to autostart Sunshine on login. +cp "/app/share/sunshine/systemd/user/sunshine.service" "$HOME/.config/systemd/user/sunshine.service" +echo "Sunshine User Service has been installed." +echo "Use [systemctl --user enable sunshine] once to autostart Sunshine on login." # Udev rule UDEV=$(cat /app/share/sunshine/udev/rules.d/60-sunshine.rules) -echo Configuring mouse permission. +echo "Configuring mouse permission." flatpak-spawn --host pkexec sh -c "echo '$UDEV' > /etc/udev/rules.d/60-sunshine.rules" -echo Restart computer for mouse permission to take effect. +echo "Restart computer for mouse permission to take effect." diff --git a/packaging/linux/flatpak/scripts/remove-additional-install.sh b/packaging/linux/flatpak/scripts/remove-additional-install.sh index 27d7af03..ea2680ef 100644 --- a/packaging/linux/flatpak/scripts/remove-additional-install.sh +++ b/packaging/linux/flatpak/scripts/remove-additional-install.sh @@ -2,10 +2,10 @@ # User Service systemctl --user stop sunshine -rm $HOME/.config/systemd/user/sunshine.service +rm "$HOME/.config/systemd/user/sunshine.service" systemctl --user daemon-reload -echo Sunshine User Service has been removed. +echo "Sunshine User Service has been removed." # Udev rule flatpak-spawn --host pkexec sh -c "rm /etc/udev/rules.d/60-sunshine.rules" -echo Input rules removed. Restart computer to take effect. +echo "Input rules removed. Restart computer to take effect." diff --git a/scripts/icons/convert_and_pack.sh b/scripts/icons/convert_and_pack.sh index 950effc9..99d1822f 100644 --- a/scripts/icons/convert_and_pack.sh +++ b/scripts/icons/convert_and_pack.sh @@ -1,61 +1,63 @@ -#!/bin/bash - -if ! [ -x "$(command -v ./go-png2ico)" ]; then - echo "./go-png2ico not found" - echo "download the executable from https://github.com/J-Siu/go-png2ico" - echo "and drop it in this folder" - exit 1 -fi - -if ! [ -x "$(command -v ./oxipng)" ]; then - echo "./oxipng executable not found" - echo "download the executable from https://github.com/shssoichiro/oxipng" - echo "and drop it in this folder" - exit 1 -fi - -if ! [ -x "$(command -v inkscape)" ]; then - echo "inkscape executable not found" - exit 1 -fi - -icon_base_sizes=(16 64) -icon_sizes_keys=() # associative array to prevent duplicates -icon_sizes_keys[256]=1 - -for icon_base_size in ${icon_base_sizes[@]}; do - # increment in 25% till 400% - icon_size_increment=$((icon_base_size / 4)) - for ((i = 0; i <= 12; i++)); do - icon_sizes_keys[$((icon_base_size + i * icon_size_increment))]=1 - done -done - -# convert to normal array -icon_sizes=${!icon_sizes_keys[@]} - -echo "using icon sizes:" -echo ${icon_sizes[@]} - -src_vectors=("../../src_assets/common/assets/web/public/images/sunshine-locked.svg" - "../../src_assets/common/assets/web/public/images/sunshine-pausing.svg" - "../../src_assets/common/assets/web/public/images/sunshine-playing.svg" - "../../sunshine.svg") - -echo "using sources vectors:" -echo ${src_vectors[@]} - -for src_vector in ${src_vectors[@]}; do - file_name=`basename "$src_vector" .svg` - png_files=() - for icon_size in ${icon_sizes[@]}; do - png_file="${file_name}${icon_size}.png" - echo "converting ${png_file}" - inkscape -w $icon_size -h $icon_size "$src_vector" --export-filename "${png_file}" && - ./oxipng -o max --strip safe --alpha "${png_file}" && - png_files+=("${png_file}") - done - - echo "packing ${file_name}.ico" - ./go-png2ico "${png_files[@]}" "${file_name}.ico" -done +#!/bin/bash + +if ! [ -x "$(command -v ./go-png2ico)" ]; then + echo "./go-png2ico not found" + echo "download the executable from https://github.com/J-Siu/go-png2ico" + echo "and drop it in this folder" + exit 1 +fi + +if ! [ -x "$(command -v ./oxipng)" ]; then + echo "./oxipng executable not found" + echo "download the executable from https://github.com/shssoichiro/oxipng" + echo "and drop it in this folder" + exit 1 +fi + +if ! [ -x "$(command -v inkscape)" ]; then + echo "inkscape executable not found" + exit 1 +fi + +icon_base_sizes=(16 64) +icon_sizes_keys=() # associative array to prevent duplicates +icon_sizes_keys[256]=1 + +for icon_base_size in "${icon_base_sizes[@]}"; do + # increment in 25% till 400% + icon_size_increment=$((icon_base_size / 4)) + for ((i = 0; i <= 12; i++)); do + icon_sizes_keys[icon_base_size + i * icon_size_increment]=1 + done +done + +# convert to normal array +icon_sizes=("${!icon_sizes_keys[@]}") + +echo "using icon sizes:" +# shellcheck disable=SC2068 # intentionally word split +echo ${icon_sizes[@]} + +src_vectors=("../../src_assets/common/assets/web/public/images/sunshine-locked.svg" + "../../src_assets/common/assets/web/public/images/sunshine-pausing.svg" + "../../src_assets/common/assets/web/public/images/sunshine-playing.svg" + "../../sunshine.svg") + +echo "using sources vectors:" +# shellcheck disable=SC2068 # intentionally word split +echo ${src_vectors[@]} + +for src_vector in "${src_vectors[@]}"; do + file_name=$(basename "${src_vector}" .svg) + png_files=() + for icon_size in "${icon_sizes[@]}"; do + png_file="${file_name}${icon_size}.png" + echo "converting ${png_file}" + inkscape -w "${icon_size}" -h "${icon_size}" "${src_vector}" --export-filename "${png_file}" && + ./oxipng -o max --strip safe --alpha "${png_file}" && + png_files+=("${png_file}") + done + + echo "packing ${file_name}.ico" + ./go-png2ico "${png_files[@]}" "${file_name}.ico" +done diff --git a/scripts/linux_build.sh b/scripts/linux_build.sh index d175ad05..abab4754 100755 --- a/scripts/linux_build.sh +++ b/scripts/linux_build.sh @@ -460,6 +460,8 @@ function run_install() { nvm_url="https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh" echo "nvm url: ${nvm_url}" wget -qO- ${nvm_url} | bash + + # shellcheck source=/dev/null # we don't care that shellcheck cannot find nvm.sh source "$HOME/.nvm/nvm.sh" nvm install node nvm use node diff --git a/src_assets/macos/misc/uninstall_pkg.sh b/src_assets/macos/misc/uninstall_pkg.sh index 89e7bbfb..5f8f0c8e 100644 --- a/src_assets/macos/misc/uninstall_pkg.sh +++ b/src_assets/macos/misc/uninstall_pkg.sh @@ -27,7 +27,8 @@ for dir in ${DIRECTORIES}; do # remove the directory if it is empty if [[ $empty_dir != "" ]]; then # prevent the loop from running and failing if no directories found - for i in "${empty_dir}"; do # don't split words as we already know this will be a single directory + # shellcheck disable=SC2066 # don't split words as we already know this will be a single directory + for i in "${empty_dir}"; do echo "Removing empty directory: ${i}" rmdir "${i}" done