From fd471612151614094bf8d4592a0b2276df31315c Mon Sep 17 00:00:00 2001 From: Bruno Lopes Date: Sun, 15 Jun 2025 15:50:40 -0300 Subject: [PATCH] gitlab, build, tools: Port bashisms to POSIX-compliant code Although these scripts are not called by Meson, portability outside the build system is always welcome (specially on macOS or non-GNU OSes). --- .gitlab-ci.yml | 20 +- .gitlab/run_meson_health_diff.sh | 273 +++++++++--------- .gitlab/run_style_check_diff.sh | 8 +- .gitlab/search-common-ancestor.sh | 12 +- .../linux/appimage/3_dist-gimp-goappimage.sh | 122 ++++---- build/linux/flatpak/1_build-deps-flatpak.sh | 33 ++- build/linux/flatpak/2_build-gimp-flatpak.sh | 16 +- build/linux/flatpak/3_dist-gimp-flatpak.sh | 18 +- tools/flatpak-releases | 22 +- tools/generate-news | 34 ++- tools/generate_changelog.sh | 11 +- tools/performance-log-viewer | 2 +- 12 files changed, 288 insertions(+), 283 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cbdff2b99c..3caf4e3131 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -279,9 +279,9 @@ gimp-debian: - echo -e "\e[0Ksection_end:`date +%s`:gimp_build\r\e[0K" # Create bundle - echo -e "\e[0Ksection_start:`date +%s`:gimp_bundle[collapsed=true]\r\e[0KCreating bundle" - - ninja install &> ninja_install.log || cat ninja_install.log + - ninja install > ninja_install.log 2>&1 || { cat ninja_install.log; exit 1; } - cd .. - - bash build/linux/appimage/3_dist-gimp-goappimage.sh --bundle-only &> goappimage.log || cat goappimage.log + - sh build/linux/appimage/3_dist-gimp-goappimage.sh --bundle-only > goappimage.log 2>&1 || { cat goappimage.log; exit 1; } - echo -e "\e[0Ksection_end:`date +%s`:gimp_bundle\r\e[0K" artifacts: paths: @@ -356,12 +356,12 @@ gimp-debian-x64: exit 1; fi - if [ "$VARIANT" != "-gcc" ] && [ "$VARIANT" != "-raster" ] && [ "$CI_PIPELINE_SOURCE" != "merge_request_event" ]; then - ninja dist &> ninja_dist.txt || cat ninja_dist.txt; + ninja dist > ninja_dist.log 2>&1 || { cat ninja_dist.log; exit 1; }; fi - echo -e "\e[0Ksection_end:`date +%s`:gimp_tar\r\e[0K" # Check install - echo -e "\e[0Ksection_start:`date +%s`:gimp_install[collapsed=true]\r\e[0KChecking GIMP installation" - - ninja install &> ninja_install.txt || cat ninja_install.txt; + - ninja install > ninja_install.log 2>&1 || { cat ninja_install.log; exit 1; }; - echo -e "\e[0Ksection_end:`date +%s`:gimp_install\r\e[0K" artifacts: paths: @@ -397,7 +397,7 @@ deps-flatpak-x64: #paths: #- .flatpak-builder/ script: - - bash build/linux/flatpak/1_build-deps-flatpak.sh + - sh build/linux/flatpak/1_build-deps-flatpak.sh artifacts: paths: - .flatpak-builder.tar @@ -413,7 +413,7 @@ gimp-flatpak-x64: variables: GIT_SUBMODULE_STRATEGY: recursive script: - - bash build/linux/flatpak/2_build-gimp-flatpak.sh + - sh build/linux/flatpak/2_build-gimp-flatpak.sh artifacts: paths: - repo.tar @@ -603,7 +603,7 @@ meson-health: script: - apt-get update - apt-get install -y git - - bash .gitlab/run_meson_health_diff.sh + - sh .gitlab/run_meson_health_diff.sh allow_failure: true clang-format: @@ -615,7 +615,7 @@ clang-format: - apt-get update - apt-get install -y clang-format git - - .gitlab/run_style_check_diff.sh + - sh .gitlab/run_style_check_diff.sh allow_failure: true artifacts: when: on_failure @@ -730,7 +730,7 @@ dist-appimage-weekly: needs: ["gimp-debian"] stage: distribution script: - - bash build/linux/appimage/3_dist-gimp-goappimage.sh + - sh build/linux/appimage/3_dist-gimp-goappimage.sh artifacts: expose_as: 'Linux appimage' paths: @@ -752,7 +752,7 @@ dist-flatpak-weekly: needs: ["gimp-flatpak-x64"] stage: distribution script: - - bash build/linux/flatpak/3_dist-gimp-flatpak.sh + - sh build/linux/flatpak/3_dist-gimp-flatpak.sh artifacts: expose_as: 'Linux flatpak' paths: diff --git a/.gitlab/run_meson_health_diff.sh b/.gitlab/run_meson_health_diff.sh index 37e67342a9..f16990465f 100644 --- a/.gitlab/run_meson_health_diff.sh +++ b/.gitlab/run_meson_health_diff.sh @@ -1,167 +1,168 @@ -#!/bin/bash +#!/bin/sh -source .gitlab/search-common-ancestor.sh +. .gitlab/search-common-ancestor.sh diff=$(git diff -U0 --no-color "${newest_common_ancestor_sha}" -- '*.build' '*.py' | grep -E '^\+[^+]' | sed 's/^+//') #List of commonly used utilities on Unix world #See the context: https://gitlab.gnome.org/GNOME/gimp/-/issues/11385 -coreutils_array=( - ".sh" - "'sh'" - "'bash'" - "'\['" - "'arch'" - "'awk'" - "'b2sum'" - "'base32'" - "'base64'" - "'basename'" - "'basenc'" - "'cat'" - "'chcon'" - "'chgrp'" - "'chmod'" - "'chown'" - "'chroot'" - "'cksum'" - "'cmp'" - "'comm'" - "'cp'" - "'csplit'" - "'cut'" - "'date'" - "'dd'" - "'df'" - "'diff'" - "'dir'" - "'dircolors'" - "'dirname'" - "'du'" - "'echo'" - "'env'" - "'expand'" - "'expr'" - "'factor'" - "'false'" - "'find'" - "'fmt'" - "'fold'" - "'gkill'" - "'grep'" - "'groups'" - "'head'" - "'hostid'" - "'hostname'" - "'id'" - "'install'" - "'join'" - "'link'" - "'ln'" - "'logname'" - "'ls'" - "'md5sum'" - "'mkdir'" - "'mkfifo'" - "'mknod'" - "'mktemp'" - "'mv'" - "'nice'" - "'nl'" - "'nohup'" - "'nproc'" - "'numfmt'" - "'od'" - "'paste'" - "'pathchk'" - "'pinky'" - "'pr'" - "'printenv'" - "'printf'" - "'ptx'" - "'pwd'" - "'readlink'" - "'realpath'" - "'rm'" - "'rmdir'" - "'runcon'" - "'sed'" - "'seq'" - "'sha1sum'" - "'sha224sum'" - "'sha256sum'" - "'sha384sum'" - "'sha512sum'" - "'shred'" - "'shuf'" - "'sleep'" - "'sort'" - "'split'" - "'stat'" - "'stdbuf'" - "'stty'" - "'sum'" - "'sync'" - "'tac'" - "'tail'" - "'tee'" - "'test'" - "'timeout'" - "'touch'" - "'tr'" - "'true'" - "'truncate'" - "'tsort'" - "'tty'" - "'uname'" - "'unexpand'" - "'uniq'" - "'unlink'" - "'users'" - "'vdir'" - "'wc'" - "'who'" - "'whoami'" - "'yes'" -) +coreutils_list=" + .sh \ + 'sh' \ + 'bash' \ + '\[' \ + 'arch' \ + 'awk' \ + 'b2sum' \ + 'base32' \ + 'base64' \ + 'basename' \ + 'basenc' \ + 'cat' \ + 'chcon' \ + 'chgrp' \ + 'chmod' \ + 'chown' \ + 'chroot' \ + 'cksum' \ + 'cmp' \ + 'comm' \ + 'cp' \ + 'csplit' \ + 'cut' \ + 'date' \ + 'dd' \ + 'df' \ + 'diff' \ + 'dir' \ + 'dircolors' \ + 'dirname' \ + 'du' \ + 'echo' \ + 'env' \ + 'expand' \ + 'expr' \ + 'factor' \ + 'false' \ + 'find' \ + 'fmt' \ + 'fold' \ + 'gkill' \ + 'grep' \ + 'groups' \ + 'head' \ + 'hostid' \ + 'hostname' \ + 'id' \ + 'install' \ + 'join' \ + 'link' \ + 'ln' \ + 'logname' \ + 'ls' \ + 'md5sum' \ + 'mkdir' \ + 'mkfifo' \ + 'mknod' \ + 'mktemp' \ + 'mv' \ + 'nice' \ + 'nl' \ + 'nohup' \ + 'nproc' \ + 'numfmt' \ + 'od' \ + 'paste' \ + 'pathchk' \ + 'pinky' \ + 'pr' \ + 'printenv' \ + 'printf' \ + 'ptx' \ + 'pwd' \ + 'readlink' \ + 'realpath' \ + 'rm' \ + 'rmdir' \ + 'runcon' \ + 'sed' \ + 'seq' \ + 'sha1sum' \ + 'sha224sum' \ + 'sha256sum' \ + 'sha384sum' \ + 'sha512sum' \ + 'shred' \ + 'shuf' \ + 'sleep' \ + 'sort' \ + 'split' \ + 'stat' \ + 'stdbuf' \ + 'stty' \ + 'sum' \ + 'sync' \ + 'tac' \ + 'tail' \ + 'tee' \ + 'test' \ + 'timeout' \ + 'touch' \ + 'tr' \ + 'true' \ + 'truncate' \ + 'tsort' \ + 'tty' \ + 'uname' \ + 'unexpand' \ + 'uniq' \ + 'unlink' \ + 'users' \ + 'vdir' \ + 'wc' \ + 'who' \ + 'whoami' \ + 'yes' +" -for coreutil in "${coreutils_array[@]}"; do +for coreutil in $coreutils_list; do if echo "$diff" | grep -q "$coreutil"; then - found_coreutils+=" $coreutil" + found_coreutils="$found_coreutils $coreutil" fi done if [ "$found_coreutils" ]; then - echo -e '\033[31m(ERROR)\033[0m: Seems that you are trying to add an Unix-specific dependency to be called by Meson.' - echo " Please, port to Python (which is crossplatform), your use of:${found_coreutils}." + printf '\033[31m(ERROR)\033[0m: Seems that you are trying to add an Unix-specific dependency to be called by Meson.\n' + printf " Please, port to Python (which is crossplatform), your use of:${found_coreutils}.\n" fi #Limited list of commonly used utilities on Windows world -ntutils_array=( - ".bat" - ".cmd" - ".ps1" - "'cmd'" - "'powershell'" -) +ntutils_list=" + .bat \ + .cmd \ + .ps1 \ + 'cmd' \ + 'powershell' +" -for ntutil in "${ntutils_array[@]}"; do +for ntutil in $ntutils_list; do if echo "$diff" | grep -q "$ntutil"; then - found_ntutils+=" $ntutil" + found_ntutils="$found_ntutils $ntutil" fi done if [ "$found_ntutils" ]; then - echo -e '\033[31m(ERROR)\033[0m: Seems that you are trying to add a NT-specific dependency to be called by Meson.' - echo " Please, port to Python (which is crossplatform), your use of:${found_ntutils}." + printf '\033[31m(ERROR)\033[0m: Seems that you are trying to add a NT-specific dependency to be called by Meson.\n' + printf " Please, port to Python (which is crossplatform), your use of:${found_ntutils}.\n" fi if [ "$found_coreutils" ] || [ "$found_ntutils" ]; then + echo "$diff" exit 1 fi -echo 'Meson .build files are alright regarding crossplatform.' +printf 'Meson .build files are alright regarding crossplatform.\n' exit 0 diff --git a/.gitlab/run_style_check_diff.sh b/.gitlab/run_style_check_diff.sh index beeca0c1b9..7ee32fcc6c 100755 --- a/.gitlab/run_style_check_diff.sh +++ b/.gitlab/run_style_check_diff.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh set -e @@ -13,15 +13,15 @@ clang-format --version # Wrap everything in a subshell so we can propagate the exit status. ( -source .gitlab/search-common-ancestor.sh +. .gitlab/search-common-ancestor.sh git diff -U0 --no-color "${newest_common_ancestor_sha}" | clang-format-diff -p1 > format-diff.log ) exit_status=$? -[ ${exit_status} == 0 ] || exit ${exit_status} +[ ${exit_status} = 0 ] || exit ${exit_status} -format_diff="$(/dev/null 2>&1 ; then git remote add upstream https://gitlab.gnome.org/GNOME/gimp.git fi -git fetch --shallow-since="$(date --date="${ancestor_horizon} days ago" +%Y-%m-%d)" upstream &> ./fetch_upstream.log +git fetch --shallow-since="$(date --date="${ancestor_horizon} days ago" +%Y-%m-%d)" upstream > ./fetch_upstream.log 2>&1 # Work out the newest common ancestor between the detached HEAD that this CI job # has checked out, and the upstream target branch (which will typically be @@ -28,10 +28,12 @@ git fetch --shallow-since="$(date --date="${ancestor_horizon} days ago" +%Y-%m-% git remote add patch-origin ${CI_MERGE_REQUEST_SOURCE_PROJECT_URL:-${CI_PROJECT_URL}} source_branch="${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME:-${CI_COMMIT_BRANCH}}" -git fetch --shallow-since="$(date --date="${ancestor_horizon} days ago" +%Y-%m-%d)" patch-origin "${source_branch}" &> ./fetch_origin.log +git fetch --shallow-since="$(date --date="${ancestor_horizon} days ago" +%Y-%m-%d)" patch-origin "${source_branch}" > ./fetch_origin.log 2>&1 -newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' <(git rev-list --first-parent "upstream/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}") <(git rev-list --first-parent "patch-origin/${source_branch}") | head -1) -if [ -z "${newest_common_ancestor_sha}" ]; then +git rev-list --first-parent "upstream/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}" > "temp_upstream" 2>&1 +git rev-list --first-parent "patch-origin/${source_branch}" > "temp_patch-origin" 2>&1 +newest_common_ancestor_sha=$(diff --old-line-format='' --new-line-format='' "temp_upstream" "temp_patch-origin" | head -n 1) +if [ -z "${newest_common_ancestor_sha}" ] || [ "${newest_common_ancestor_sha}" = '' ]; then echo "Couldn’t find common ancestor with upstream main branch. This typically" echo "happens if you branched from main a long time ago. Please update" echo "your clone, rebase, and re-push your branch." diff --git a/build/linux/appimage/3_dist-gimp-goappimage.sh b/build/linux/appimage/3_dist-gimp-goappimage.sh index 7daef5be7e..04a0e905d5 100644 --- a/build/linux/appimage/3_dist-gimp-goappimage.sh +++ b/build/linux/appimage/3_dist-gimp-goappimage.sh @@ -2,7 +2,7 @@ # Parameters REVISION="$1" -if [[ "$GIMP_CI_APPIMAGE" =~ [1-9] ]] && [ "$CI_PIPELINE_SOURCE" != 'schedule' ]; then +if echo "$GIMP_CI_APPIMAGE" | grep -q '[1-9]' && [ "$CI_PIPELINE_SOURCE" != 'schedule' ]; then export REVISION="$GIMP_CI_APPIMAGE" fi MODE="$2" @@ -11,14 +11,19 @@ if [ "$REVISION" = '--bundle-only' ]; then fi BUILD_DIR="$3" +case $(readlink /proc/$$/exe) in + *bash) + set -o posix + ;; +esac set -e if [ -z "$GITLAB_CI" ]; then # Make the script work locally - if [ "$0" != 'build/linux/appimage/3_dist-gimp-goappimage.sh' ] && [ ${PWD/*\//} != 'appimage' ]; then - echo -e '\033[31m(ERROR)\033[0m: Script called from wrong dir. Please, call this script from the root of gimp git dir' + if [ "$0" != 'build/linux/appimage/3_dist-gimp-goappimage.sh' ] && [ $(basename "$PWD") != 'appimage' ]; then + printf '\033[31m(ERROR)\033[0m: Script called from wrong dir. Please, call this script from the root of gimp git dir\n' exit 1 - elif [ ${PWD/*\//} = 'appimage' ]; then + elif [ $(basename "$PWD") = 'appimage' ]; then cd ../../.. fi @@ -27,7 +32,7 @@ fi # 1. INSTALL BUNDLING TOOL AND STANDARD APPIMAGE DISTRIBUTION TOOLS -echo -e "\e[0Ksection_start:`date +%s`:apmg_tlkt\r\e[0KInstalling appimage tools" +printf "\e[0Ksection_start:`date +%s`:apmg_tlkt\r\e[0KInstalling appimage tools\n" GIMP_DIR="$PWD/" cd ${GIMP_DIR}${PARENT_DIR} if [ "$GITLAB_CI" ]; then @@ -69,8 +74,8 @@ if [ "$MODE" != '--bundle-only' ]; then chmod +x "./runtime-$HOST_ARCH" static_runtime_version_downloaded=$("./runtime-$HOST_ARCH" --appimage-version 2>&1) chmod -x "./runtime-$HOST_ARCH" - if [ "${static_runtime_version_downloaded#*commit/}" != "${static_runtime_version_online:0:7}" ]; then - echo -e '\033[31m(ERROR)\033[0m: Downloaded runtime version differs from the one released online. Please, run again this script.' + if [ "${static_runtime_version_downloaded#*commit/}" != "$(echo "$static_runtime_version_online" | cut -c1-7)" ]; then + printf '\033[31m(ERROR)\033[0m: Downloaded runtime version differs from the one released online. Please, run again this script.\n' exit 1 fi standard_appimagetool_text="appimagetool commit: $standard_appimagetool_version | type2-runtime commit: ${static_runtime_version_downloaded#*commit/}" @@ -79,17 +84,17 @@ if [ ! "$(find $GIMP_DIR -maxdepth 1 -iname "AppDir*")" ] && [ "$MODE" != '--bun separator=' | ' fi cd $GIMP_DIR -echo "(INFO): ${bundler_text}${separator}${standard_appimagetool_text}" -echo -e "\e[0Ksection_end:`date +%s`:apmg_tlkt\r\e[0K" +printf "(INFO): ${bundler_text}${separator}${standard_appimagetool_text}\n" +printf "\e[0Ksection_end:`date +%s`:apmg_tlkt\r\e[0K\n" # 2. GET GLOBAL VARIABLES -echo -e "\e[0Ksection_start:`date +%s`:apmg_info\r\e[0KGetting AppImage global info" +printf "\e[0Ksection_start:`date +%s`:apmg_info\r\e[0KGetting AppImage global info\n" if [ "$BUILD_DIR" = '' ]; then export BUILD_DIR=$(find $PWD -maxdepth 1 -iname "_build*$RUNNER" | head -n 1) fi if [ ! -f "$BUILD_DIR/config.h" ]; then - echo -e "\033[31m(ERROR)\033[0m: config.h file not found. You can configure GIMP with meson to generate it." + printf "\033[31m(ERROR)\033[0m: config.h file not found. You can configure GIMP with meson to generate it.\n" exit 1 fi eval $(sed -n 's/^#define *\([^ ]*\) *\(.*\) *$/export \1=\2/p' $BUILD_DIR/config.h) @@ -106,21 +111,21 @@ export APP_ID="org.gimp.GIMP.$CHANNEL" ## Get info about GIMP version export CUSTOM_GIMP_VERSION="$GIMP_VERSION" -if [[ ! "$REVISION" =~ [1-9] ]]; then +if ! echo "$REVISION" | grep -q '[1-9]'; then export REVISION="0" else export CUSTOM_GIMP_VERSION="${GIMP_VERSION}-${REVISION}" fi -echo "(INFO): App ID: $APP_ID | Version: $CUSTOM_GIMP_VERSION" -echo -e "\e[0Ksection_end:`date +%s`:apmg_info\r\e[0K" +printf "(INFO): App ID: $APP_ID | Version: $CUSTOM_GIMP_VERSION\n" +printf "\e[0Ksection_end:`date +%s`:apmg_info\r\e[0K\n" # 3. GIMP FILES (IN APPDIR) if [ ! "$(find . -maxdepth 1 -iname "AppDir*")" ] || [ "$MODE" = '--bundle-only' ]; then -echo -e "\e[0Ksection_start:`date +%s`:apmg_files[collapsed=true]\r\e[0KPreparing GIMP files in AppDir-$HOST_ARCH/usr" +printf "\e[0Ksection_start:`date +%s`:apmg_files[collapsed=true]\r\e[0KPreparing GIMP files in AppDir-$HOST_ARCH/usr\n" grep -q 'relocatable-bundle=yes' $BUILD_DIR/meson-logs/meson-log.txt && export RELOCATABLE_BUNDLE_ON=1 if [ -z "$RELOCATABLE_BUNDLE_ON" ]; then - echo -e "\033[31m(ERROR)\033[0m: No relocatable GIMP build found. You can build GIMP with '-Drelocatable-bundle=yes' to make a build suitable for AppImage." + printf "\033[31m(ERROR)\033[0m: No relocatable GIMP build found. You can build GIMP with '-Drelocatable-bundle=yes' to make a build suitable for AppImage.\n" exit 1 fi @@ -130,11 +135,7 @@ if [ -z "$GITLAB_CI" ] && [ -z "$GIMP_PREFIX" ]; then export GIMP_PREFIX="$PWD/../_install" fi if [ -z "$GITLAB_CI" ]; then - IFS=$'\n' VAR_ARRAY=($(cat .gitlab-ci.yml | sed -n '/multi-os/,/multiarch/p' | sed 's/- //')) - IFS=$' \t\n' - for VAR in "${VAR_ARRAY[@]}"; do - eval "$VAR" - done + eval "$(sed -n -e '/multi-os/,/multiarch/p' -e 's/- //' .gitlab-ci.yml)" fi #Paths to receive copied files @@ -157,25 +158,24 @@ bund_usr () #Paths where to search case $2 in bin*) - search_path=("$1/bin" "$1/sbin" "$1/libexec") + search_path="$1/bin $1/sbin $1/libexec" ;; lib*) - search_path=("$(dirname $(echo $2 | sed "s|lib/|$1/${LIB_DIR}/${LIB_SUBDIR}|g" | sed "s|*|no_scape|g"))" - "$(dirname $(echo $2 | sed "s|lib/|/usr/${LIB_DIR}/|g" | sed "s|*|no_scape|g"))") + search_path="$(dirname $(echo $2 | sed "s|lib/|$1/${LIB_DIR}/${LIB_SUBDIR}|g" | sed "s|*|no_scape|g")) \ + $(dirname $(echo $2 | sed "s|lib/|/usr/${LIB_DIR}/|g" | sed "s|*|no_scape|g"))" ;; share*|include*|etc*) - search_path=("$(dirname $(echo $2 | sed "s|${2%%/*}|$1/${2%%/*}|g" | sed "s|*|no_scape|g"))") + search_path="$(dirname $(echo $2 | sed "s|${2%%/*}|$1/${2%%/*}|g" | sed "s|*|no_scape|g"))" ;; esac - for path in "${search_path[@]}"; do + for path in $search_path; do expanded_path=$(echo $(echo $path | sed "s|no_scape|*|g")) if [ ! -d "$expanded_path" ]; then continue fi #Copy found targets from search_path to bundle dir - target_array=($(find $expanded_path -maxdepth 1 -name ${2##*/})) - for target_path in "${target_array[@]}"; do + for target_path in $(find $expanded_path -maxdepth 1 -name ${2##*/}); do dest_path="$(dirname $(echo $target_path | sed "s|$1/|${USR_DIR}/|g"))" output_dest_path="$dest_path" if [ "$3" = '--dest' ] || [ "$3" = '--rename' ]; then @@ -186,9 +186,9 @@ bund_usr () fi dest_path="$output_dest_path/tmp" fi - + if [ "$3" != '--bundler' ] && [ "$5" != '--bundler' ]; then - echo "(INFO): bundling $target_path to $output_dest_path" + printf "(INFO): bundling $target_path to $output_dest_path\n" mkdir -p $dest_path cp -ru $target_path $dest_path >/dev/null 2>&1 || continue @@ -198,9 +198,9 @@ bund_usr () rm -r "$dest_path" fi else - echo "(INFO): skipping $target_path (will be bundled by the tool)" - if [[ "$target_path" =~ 'bin' ]] || [[ "$target_path" =~ '.so' ]]; then - export APPENDED_LIST+="$target_path " + printf "(INFO): skipping $target_path (will be bundled by the tool)\n" + if echo "$target_path" | grep -q 'bin' || echo "$target_path" | grep -q '.so'; then + export APPENDED_LIST="$APPENDED_LIST $target_path " fi fi done @@ -228,7 +228,7 @@ conf_app () unset appdir_path var_path="$2" fi - + #Set expanded var in AppRun (and in environ if needed by this script or by the bundler) if [ "$3" != '--bundler' ] && [ "$4" != '--bundler' ]; then apprun="build/linux/appimage/AppRun" @@ -258,8 +258,8 @@ fi ## Bundle base (bare minimum to run GTK apps) ### Glib needed files (to be able to use URIs and file dialogs). See: #12937 and #13082 bund_usr "$UNIX_PREFIX" "lib/glib-*/gio-launch-desktop" --dest "bin" -prep_pkg "xapps-common" -bund_usr "$UNIX_PREFIX" "share/glib-*/schemas" +prep_pkg "xapps-common" +bund_usr "$UNIX_PREFIX" "share/glib-*/schemas" ### Glib commonly required modules bund_usr "$UNIX_PREFIX" "lib/gvfs/*.so" bund_usr "$UNIX_PREFIX" "lib/gio/modules/*" @@ -293,10 +293,8 @@ conf_app GEGL_PATH "${LIB_DIR}/${LIB_SUBDIR}gegl-*" bund_usr "$GIMP_PREFIX" "lib/libgimp*" bund_usr "$GIMP_PREFIX" "lib/gimp" bund_usr "$GIMP_PREFIX" "share/gimp" -lang_array=($(echo $(ls po/*.po | - sed -e 's|po/||g' -e 's|.po||g' | sort) | - tr '\n\r' ' ')) -for lang in "${lang_array[@]}"; do +lang_list=$(echo $(ls po/*.po | sed -e 's|po/||g' -e 's|.po||g' | sort) | tr '\n\r' ' ') +for lang in $lang_list; do bund_usr "$GIMP_PREFIX" share/locale/$lang/LC_MESSAGES # Needed for eventually used widgets, GTK inspector etc bund_usr "$UNIX_PREFIX" share/locale/$lang/LC_MESSAGES/gtk3*.mo @@ -367,7 +365,7 @@ bund_usr "$GIMP_PREFIX" 'bin/gimp*' bund_usr "$GIMP_PREFIX" "bin/gegl" bund_usr "$GIMP_PREFIX" "share/applications/*.desktop" #go-appimagetool have too polluted output so we save as log. See: https://github.com/probonopd/go-appimage/issues/314 -"$bundler" -s deploy $(echo "$USR_DIR/share/applications/*.desktop") &> appimagetool.log || cat appimagetool.log +"$bundler" -s deploy $(echo "$USR_DIR/share/applications/*.desktop") > appimagetool.log 2>&1 || { cat appimagetool.log; exit 1; } ## Manual adjustments after running the bundling tool ### Undo the mess which breaks babl and GEGL. See: https://github.com/probonopd/go-appimage/issues/315 @@ -381,9 +379,9 @@ if [ "$HOST_ARCH" = 'x86_64' ]; then rm -r $APP_DIR/lib64 fi chmod +x "$APP_DIR/$LD_LINUX" -exec_array=($(find "$USR_DIR/bin" "$USR_DIR/$LIB_DIR" ! -iname "*.so*" -type f -exec head -c 4 {} \; -exec echo " {}" \; | grep ^.ELF)) -for exec in "${exec_array[@]}"; do - if [[ ! "$exec" =~ 'ELF' ]]; then +exec_list=$(find "$USR_DIR/bin" "$USR_DIR/$LIB_DIR" ! -iname "*.so*" -type f -exec head -c 4 {} \; -exec echo " {}" \; | grep ^.ELF) +for exec in $exec_list; do + if ! echo "$exec" | grep -q 'ELF'; then patchelf --set-interpreter "./$LD_LINUX" "$exec" >/dev/null 2>&1 || continue fi done @@ -397,10 +395,9 @@ done #if [ "$GITLAB_CI" ]; then # export DEBUGINFOD_URLS="https://debuginfod.debian.net" #fi -#bin_array=($(find "$USR_DIR/bin" "$USR_DIR/$LIB_DIR" "$(dirname $APP_DIR/$LD_LINUX)" ! -iname "*.dumb*" -type f -exec head -c 4 {} \; -exec echo " {}" \; | grep ^.ELF)) -#for bin in "${bin_array[@]}"; do -# if [[ ! "$bin" =~ 'ELF' ]] && [[ ! "$bin" =~ '.debug' ]]; then -# grep -a -q '.gnu_debuglink' $bin && echo "(INFO): bundling $bin debug symbols to $(dirname $bin)" && cp -f $(debuginfod-find debuginfo $bin) "$(dirname $bin)/$(readelf --string-dump=.gnu_debuglink $bin | sed -n '/]/{s/.* //;p;q}')" || $true +#for bin in $(find "$USR_DIR/bin" "$USR_DIR/$LIB_DIR" "$(dirname $APP_DIR/$LD_LINUX)" ! -iname "*.dumb*" -type f -exec head -c 4 {} \; -exec echo " {}" \; | grep ^.ELF); do +# if ! echo "$bin" | grep -q 'ELF' && ! echo "$bin" | grep -q '.debug'; then +# grep -a -q '.gnu_debuglink' $bin && printf "(INFO): bundling $bin debug symbols to $(dirname $bin)\n" && cp -f $(debuginfod-find debuginfo $bin) "$(dirname $bin)/$(readelf --string-dump=.gnu_debuglink $bin | sed -n '/]/{s/.* //;p;q}')" || $true # fi #done @@ -420,7 +417,7 @@ echo "usr/${LIB_DIR}/${LIB_SUBDIR}gconv before=$(cat "$(echo $USR_DIR/share/gimp/*/gimp-release)" | grep 'revision') after="revision=$REVISION" sed -i "s|$before|$after|" "$(echo $USR_DIR/share/gimp/*/gimp-release)" -echo -e "\e[0Ksection_end:`date +%s`:apmg_files\r\e[0K" +printf "\e[0Ksection_end:`date +%s`:apmg_files\r\e[0K\n" fi if [ "$MODE" = '--bundle-only' ]; then exit 0 @@ -428,27 +425,26 @@ fi # 4. PREPARE .APPIMAGE-SPECIFIC "SOURCE" -appdir_array=($(find . -maxdepth 1 -iname "AppDir*")) -for APP_DIR in "${appdir_array[@]}"; do +for APP_DIR in $(find . -maxdepth 1 -iname "AppDir*"); do export ARCH=$(echo $APP_DIR | sed -e 's|AppDir-||' -e 's|./||') -echo -e "\e[0Ksection_start:`date +%s`:${ARCH}_source[collapsed=true]\r\e[0KMaking AppImage assets for $ARCH" +printf "\e[0Ksection_start:`date +%s`:${ARCH}_source[collapsed=true]\r\e[0KMaking AppImage assets for $ARCH\n" export USR_DIR="$APP_DIR/usr" ## 4.1. Finish AppRun configuration -echo '(INFO): finishing AppRun configuration' +printf '(INFO): finishing AppRun configuration\n' ln -sfr "$USR_DIR/bin/gimp-$GIMP_APP_VERSION" "$USR_DIR/bin/$APP_ID" printf "\nexec \"\$APPDIR\"/usr/bin/$APP_ID \"\$@\"" >> "$APP_DIR/AppRun" chmod +x $APP_DIR/AppRun ## 4.2. Copy icon assets (similarly to flatpaks's 'rename-icon') -echo "(INFO): copying $APP_ID.svg asset to AppDir" +printf "(INFO): copying $APP_ID.svg asset to AppDir\n" find "$USR_DIR/share/icons/hicolor" \( -iname *.svg -and ! -iname $APP_ID*.svg \) -execdir ln -sf "{}" $APP_ID.svg \; find "$USR_DIR/share/icons/hicolor" \( -iname *.png -and ! -iname $APP_ID*.png \) -execdir ln -sf "{}" $APP_ID.png \; cp -L "$USR_DIR/share/icons/hicolor/scalable/apps/$APP_ID.svg" $APP_DIR ln -sfr "$APP_DIR/$APP_ID.svg" $APP_DIR/.DirIcon ## 4.3. Configure .desktop asset (similarly to flatpaks's 'rename-desktop-file') -echo "(INFO): configuring $APP_ID.desktop" +printf "(INFO): configuring $APP_ID.desktop\n" find "$USR_DIR/share/applications" \( -iname *.desktop -and ! -iname $APP_ID*.desktop \) -execdir mv "{}" $APP_ID.desktop \; sed -i "s/gimp-$GIMP_APP_VERSION/$APP_ID/g" "$USR_DIR/share/applications/${APP_ID}.desktop" sed -i "s/^StartupWMClass=.*/StartupWMClass=$APP_ID/g" "$USR_DIR/share/applications/${APP_ID}.desktop" @@ -456,17 +452,17 @@ sed -i "s/^Icon=.*/Icon=$APP_ID/" "$USR_DIR/share/applications/${APP_ID}.desktop ln -sfr "$USR_DIR/share/applications/${APP_ID}.desktop" $APP_DIR ## 4.4. Configure appdata asset (similarly to flatpaks's 'rename-appdata-file') -echo "(INFO): configuring $APP_ID.appdata.xml" +printf "(INFO): configuring $APP_ID.appdata.xml\n" find "$USR_DIR/share/metainfo" \( -iname *.appdata.xml -and ! -iname $APP_ID*.appdata.xml \) -execdir mv "{}" $APP_ID.appdata.xml \; sed -i "s/org.gimp.GIMP/dev/null 2>&1 mv ${APPIMAGETOOL_APP_NAME}.zsync GIMP-${CHANNEL}-${ARCH}.AppImage.zsync fi -echo -e "\e[0Ksection_end:`date +%s`:${ARCH}_making\r\e[0K" +printf "\e[0Ksection_end:`date +%s`:${ARCH}_making\r\e[0K\n" # 6. GENERATE SHASUMS -echo -e "\e[0Ksection_start:`date +%s`:${ARCH}_trust[collapsed=true]\r\e[0KChecksumming $APPIMAGETOOL_APP_NAME" +printf "\e[0Ksection_start:`date +%s`:${ARCH}_trust[collapsed=true]\r\e[0KChecksumming $APPIMAGETOOL_APP_NAME\n" if [ "$GIMP_RELEASE" ] && [ -z "$GIMP_IS_RC_GIT" ]; then sha256sum $APPIMAGETOOL_APP_NAME > $APPIMAGETOOL_APP_NAME.SHA256SUMS fi -echo "(INFO): $APPIMAGETOOL_APP_NAME SHA-256: $(sha256sum $APPIMAGETOOL_APP_NAME | cut -d ' ' -f 1)" +printf "(INFO): $APPIMAGETOOL_APP_NAME SHA-256: $(sha256sum $APPIMAGETOOL_APP_NAME | cut -d ' ' -f 1)\n" if [ "$GIMP_RELEASE" ] && [ -z "$GIMP_IS_RC_GIT" ]; then sha512sum $APPIMAGETOOL_APP_NAME > $APPIMAGETOOL_APP_NAME.SHA512SUMS fi -echo "(INFO): $APPIMAGETOOL_APP_NAME SHA-512: $(sha512sum $APPIMAGETOOL_APP_NAME | cut -d ' ' -f 1)" -echo -e "\e[0Ksection_end:`date +%s`:${ARCH}_trust\r\e[0K" +printf "(INFO): $APPIMAGETOOL_APP_NAME SHA-512: $(sha512sum $APPIMAGETOOL_APP_NAME | cut -d ' ' -f 1)\n" +printf "\e[0Ksection_end:`date +%s`:${ARCH}_trust\r\e[0K\n" if [ "$GITLAB_CI" ]; then diff --git a/build/linux/flatpak/1_build-deps-flatpak.sh b/build/linux/flatpak/1_build-deps-flatpak.sh index 05a89c5f89..5337f4b594 100644 --- a/build/linux/flatpak/1_build-deps-flatpak.sh +++ b/build/linux/flatpak/1_build-deps-flatpak.sh @@ -9,8 +9,8 @@ set -e if [ -z "$GITLAB_CI" ]; then # Make the script work locally - if [ "$0" != 'build/linux/flatpak/1_build-deps-flatpak.sh' ] && [ ${PWD/*\//} != 'flatpak' ]; then - echo -e '\033[31m(ERROR)\033[0m: Script called from wrong dir. Please, read: https://developer.gimp.org/core/setup/build/linux/' + if [ "$0" != 'build/linux/flatpak/1_build-deps-flatpak.sh' ] && [ $(basename "$PWD") != 'flatpak' ]; then + printf '\033[31m(ERROR)\033[0m: Script called from wrong dir. Please, read: https://developer.gimp.org/core/setup/build/linux/\n' exit 1 elif [ $(basename "$PWD") = 'flatpak' ]; then cd ../../.. @@ -19,20 +19,20 @@ fi # Install part of the deps -if [ $(which flatpak-builder 2>/dev/null) ]; then +if which flatpak-builder >/dev/null 2>&1; then export FLATPAK_BUILDER='flatpak-builder' elif [ -f '/var/lib/flatpak/exports/bin/org.flatpak.Builder' ]; then export FLATPAK_BUILDER='flatpak run --system org.flatpak.Builder' elif [ -f "${XDG_DATA_HOME:-$HOME/.local/share}/flatpak/exports/bin/org.flatpak.Builder" ]; then export FLATPAK_BUILDER='flatpak run --user org.flatpak.Builder' else - echo -e '\033[31m(ERROR)\033[0m: flatpak-builder not found. Please, install it using your package manager.' + printf '\033[31m(ERROR)\033[0m: flatpak-builder not found. Please, install it using your package manager.\n' exit 1 fi builder_version=$(eval $FLATPAK_BUILDER --version | sed 's/flatpak-builder//' | sed 's/-//' | sed 's/ //' | sed 's/\.//g') if [ "$builder_version" -lt '143' ]; then ## Pre-1.4.3 flatpak-builder fails at Cmake deps, let's prevent this - echo -e "\033[31m(ERROR)\033[0m: Installed flatpak-builder is too old. Our .json manifest requires at least 1.4.3." + printf "\033[31m(ERROR)\033[0m: Installed flatpak-builder is too old. Our .json manifest requires at least 1.4.3.\n" exit 1 fi #End of check @@ -55,35 +55,40 @@ if [ -z "$GITLAB_CI" ] && [ "$1" != '--ci' ]; then "$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json 2>&1 | tee flatpak-builder.log elif [ "$GITLAB_CI" ] || [ "$1" = '--ci' ]; then - echo -e "\e[0Ksection_start:`date +%s`:deps_build[collapsed=true]\r\e[0KBuilding dependencies not present in GNOME runtime" + printf "\e[0Ksection_start:`date +%s`:deps_build[collapsed=true]\r\e[0KBuilding dependencies not present in GNOME runtime\n" if [ "$CI_PIPELINE_SOURCE" = 'schedule' ]; then # Check dependencies versions with flatpak-external-data-checker export FLATPAK_SYSTEM_HELPER_ON_SESSION=foo flatpak install --user https://dl.flathub.org/repo/appstream/org.flathub.flatpak-external-data-checker.flatpakref -y - flatpak run --user --filesystem=$CI_PROJECT_DIR org.flathub.flatpak-external-data-checker --check-outdated build/linux/flatpak/org.gimp.GIMP-nightly.json - echo "(INFO): All dependencies sources are up to date. Building them..." + if ! flatpak run --user --filesystem=$CI_PROJECT_DIR org.flathub.flatpak-external-data-checker \ + --check-outdated build/linux/flatpak/org.gimp.GIMP-nightly.json; then + printf "\033[31m(ERROR)\033[0m: Some dependencies sources are outdated. Please, update them on the manifest.\n" + exit 1 + else + printf "(INFO): All dependencies sources are up to date. Building them...\n" + fi fi ## (The deps building is too long and no complete output would be collected, ## even from GitLab runner messages. So, let's silent and save logs as a file.) eval $FLATPAK_BUILDER --force-clean --user --disable-rofiles-fuse --keep-build-dirs --build-only --stop-at=babl \ - "$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json &> flatpak-builder.log - echo -e "\e[0Ksection_end:`date +%s`:deps_build\r\e[0K" + "$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json > flatpak-builder.log 2>&1 + printf "\e[0Ksection_end:`date +%s`:deps_build\r\e[0K\n" - echo -e "\e[0Ksection_start:`date +%s`:babl_build[collapsed=true]\r\e[0KBuilding babl" + printf "\e[0Ksection_start:`date +%s`:babl_build[collapsed=true]\r\e[0KBuilding babl\n" eval $FLATPAK_BUILDER --force-clean --user --disable-rofiles-fuse --keep-build-dirs --build-only --stop-at=gegl \ "$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json if [ "$GITLAB_CI" ]; then tar cf babl-meson-log.tar .flatpak-builder/build/babl-1/_flatpak_build/meson-logs/meson-log.txt fi - echo -e "\e[0Ksection_end:`date +%s`:babl_build\r\e[0K" + printf "\e[0Ksection_end:`date +%s`:babl_build\r\e[0K\n" - echo -e "\e[0Ksection_start:`date +%s`:gegl_build[collapsed=true]\r\e[0KBuilding gegl" + printf "\e[0Ksection_start:`date +%s`:gegl_build[collapsed=true]\r\e[0KBuilding gegl\n" eval $FLATPAK_BUILDER --force-clean --user --disable-rofiles-fuse --keep-build-dirs --build-only --stop-at=gimp \ "$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json if [ "$GITLAB_CI" ]; then tar cf gegl-meson-log.tar .flatpak-builder/build/gegl-1/_flatpak_build/meson-logs/meson-log.txt - echo -e "\e[0Ksection_end:`date +%s`:gegl_build\r\e[0K" + printf "\e[0Ksection_end:`date +%s`:gegl_build\r\e[0K\n" ## Save built deps for 'gimp-flatpak-x64' job tar cf .flatpak-builder.tar .flatpak-builder/ diff --git a/build/linux/flatpak/2_build-gimp-flatpak.sh b/build/linux/flatpak/2_build-gimp-flatpak.sh index b67531628c..82b32e16fe 100644 --- a/build/linux/flatpak/2_build-gimp-flatpak.sh +++ b/build/linux/flatpak/2_build-gimp-flatpak.sh @@ -9,8 +9,8 @@ set -e if [ -z "$GITLAB_CI" ]; then # Make the script work locally - if [ "$0" != 'build/linux/flatpak/2_build-gimp-flatpak.sh' ] && [ ${PWD/*\//} != 'flatpak' ]; then - echo -e '\033[31m(ERROR)\033[0m: Script called from wrong dir. Please, read: https://developer.gimp.org/core/setup/build/linux/' + if [ "$0" != 'build/linux/flatpak/2_build-gimp-flatpak.sh' ] && [ $(basename "$PWD") != 'flatpak' ]; then + printf '\033[31m(ERROR)\033[0m: Script called from wrong dir. Please, read: https://developer.gimp.org/core/setup/build/linux/\n' exit 1 elif [ $(basename "$PWD") = 'flatpak' ]; then cd ../../.. @@ -21,7 +21,7 @@ fi # Install part of the deps -source <(cat build/linux/flatpak/1_build-deps-flatpak.sh | sed -n "/Install part/,/End of check/p") +eval "$(sed -n '/Install part/,/End of check/p' build/linux/flatpak/1_build-deps-flatpak.sh)" if [ "$GITLAB_CI" ]; then # Extract deps from previous job @@ -48,21 +48,21 @@ if [ -z "$GITLAB_CI" ] && [ "$1" != '--ci' ]; then eval $FLATPAK_BUILDER --run "$GIMP_PREFIX" ../build/linux/flatpak/org.gimp.GIMP-nightly.json ninja install elif [ "$GITLAB_CI" ] || [ "$1" = '--ci' ]; then - echo -e "\e[0Ksection_start:`date +%s`:gimp_build[collapsed=true]\r\e[0KBuilding GIMP" + printf "\e[0Ksection_start:`date +%s`:gimp_build[collapsed=true]\r\e[0KBuilding GIMP\n" eval $FLATPAK_BUILDER --force-clean --user --disable-rofiles-fuse --keep-build-dirs --build-only --disable-download \ - "$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json &> gimp-flatpak-builder.log || cat gimp-flatpak-builder.log + "$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json > gimp-flatpak-builder.log 2>&1 || { cat gimp-flatpak-builder.log; exit 1; } if [ "$GITLAB_CI" ]; then tar cf gimp-meson-log.tar .flatpak-builder/build/gimp-1/_flatpak_build/meson-logs/meson-log.txt fi - echo -e "\e[0Ksection_end:`date +%s`:gimp_build\r\e[0K" + printf "\e[0Ksection_end:`date +%s`:gimp_build\r\e[0K\n" ## Cleanup GIMP_PREFIX (not working) and export it to OSTree repo ## https://github.com/flatpak/flatpak-builder/issues/14 - echo -e "\e[0Ksection_start:`date +%s`:gimp_bundle[collapsed=true]\r\e[0KCreating OSTree repo" + printf "\e[0Ksection_start:`date +%s`:gimp_bundle[collapsed=true]\r\e[0KCreating OSTree repo\n" eval $FLATPAK_BUILDER --user --disable-rofiles-fuse --finish-only --repo=repo \ "$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json if [ "$GITLAB_CI" ]; then tar cf repo.tar repo/ fi - echo -e "\e[0Ksection_end:`date +%s`:gimp_bundle\r\e[0K" + printf "\e[0Ksection_end:`date +%s`:gimp_bundle\r\e[0K\n" fi diff --git a/build/linux/flatpak/3_dist-gimp-flatpak.sh b/build/linux/flatpak/3_dist-gimp-flatpak.sh index b9d3012395..f955d31e4b 100644 --- a/build/linux/flatpak/3_dist-gimp-flatpak.sh +++ b/build/linux/flatpak/3_dist-gimp-flatpak.sh @@ -22,16 +22,16 @@ fi # CONSTRUCT .FLATPAK # Generate a Flatpak "bundle" to be tested with GNOME runtime installed # (it is NOT a real/full bundle, deps from GNOME runtime are not bundled) -echo -e "\e[0Ksection_start:`date +%s`:flat_making[collapsed=true]\r\e[0KPackaging repo as ${APP_ID}.flatpak" +printf "\e[0Ksection_start:`date +%s`:flat_making[collapsed=true]\r\e[0KPackaging repo as ${APP_ID}.flatpak\n" flatpak build-bundle repo ${APP_ID}.flatpak --runtime-repo=https://nightly.gnome.org/gnome-nightly.flatpakrepo ${APP_ID} ${BRANCH} -echo -e "\e[0Ksection_end:`date +%s`:flat_making\r\e[0K" +printf "\e[0Ksection_end:`date +%s`:flat_making\r\e[0K\n" # GENERATE SHASUMS FOR .FLATPAK -echo -e "\e[0Ksection_start:`date +%s`:flat_trust[collapsed=true]\r\e[0KChecksumming ${APP_ID}.flatpak" -echo "(INFO): ${APP_ID}.flatpak SHA-256: $(sha256sum ${APP_ID}.flatpak | cut -d ' ' -f 1)" -echo "(INFO): ${APP_ID}.flatpak SHA-512: $(sha512sum ${APP_ID}.flatpak | cut -d ' ' -f 1)" -echo -e "\e[0Ksection_end:`date +%s`:flat_trust\r\e[0K" +printf "\e[0Ksection_start:`date +%s`:flat_trust[collapsed=true]\r\e[0KChecksumming ${APP_ID}.flatpak\n" +printf "(INFO): ${APP_ID}.flatpak SHA-256: $(sha256sum ${APP_ID}.flatpak | cut -d ' ' -f 1)\n" +printf "(INFO): ${APP_ID}.flatpak SHA-512: $(sha512sum ${APP_ID}.flatpak | cut -d ' ' -f 1)\n" +printf "\e[0Ksection_end:`date +%s`:flat_trust\r\e[0K\n" if [ "$GITLAB_CI" ]; then @@ -44,8 +44,8 @@ fi # PUBLISH GIMP REPO IN GNOME NIGHTLY # We take the commands from 'flatpak_ci_initiative.yml' if [ "$GITLAB_CI" ] && [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then - echo -e "\e[0Ksection_start:`date +%s`:flat_publish[collapsed=true]\r\e[0KPublishing repo to GNOME nightly" + printf "\e[0Ksection_start:`date +%s`:flat_publish[collapsed=true]\r\e[0KPublishing repo to GNOME nightly\n" curl https://gitlab.gnome.org/GNOME/citemplates/raw/master/flatpak/flatpak_ci_initiative.yml --output flatpak_ci_initiative.yml - source <(cat flatpak_ci_initiative.yml | sed -n '/flatpak build-update-repo/,/exit $result\"/p' | sed 's/ - //') - echo -e "\e[0Ksection_end:`date +%s`:flat_publish\r\e[0K" + eval "$(sed -n -e '/flatpak build-update-repo/,/exit $result/ { s/ - //; p }' flatpak_ci_initiative.yml)" + printf "\e[0Ksection_end:`date +%s`:flat_publish\r\e[0K\n" fi diff --git a/tools/flatpak-releases b/tools/flatpak-releases index dcf82e90e8..8c0074c2c0 100755 --- a/tools/flatpak-releases +++ b/tools/flatpak-releases @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # This is a very basic script for developer usage. It has a few known # limitations (feel free to send patches for these): @@ -16,10 +16,6 @@ # - It also assumes the flathub remotes are installed at all (it can't # search without them being installed and won't install these for # you). -# - It uses bash because I lazily didn't bother making it portable as -# it's really just a tool for core dev testing. Yet we of course -# welcome patches if some syntax needs to be rewritten for -# portability. install=-1 show_runtime=0 @@ -29,19 +25,19 @@ branch='stable' prefix='--user' for var in "$@" do - if [[ $var =~ ^-([0-9]+)$ ]]; then - install=${BASH_REMATCH[1]} - elif [[ $var = '--beta' ]]; then + if echo "$var" | grep -qE '^-[0-9]+$'; then + install=${var#-} + elif [ $var = '--beta' ]; then remote='flathub-beta' branch='beta' - elif [[ $var = '--nightly' ]]; then + elif [ $var = '--nightly' ]; then remote='gnome-nightly' branch='master' - elif [[ $var = '--system' ]]; then + elif [ $var = '--system' ]; then prefix='--system' - elif [[ $var = '--runtime' ]]; then + elif [ $var = '--runtime' ]; then show_runtime=1 - elif [[ $var =~ ^- ]]; then + elif echo "$var" | grep -q '^-'; then echo "Usage: ./flathub-releases [--beta] [--system] [-X] [org.example.app]" echo echo "List all flatpak builds stored on Flathub or GNOME repository." @@ -109,7 +105,7 @@ elif [ "$show_runtime" -eq 1 ]; then runtime=`echo "$package_info" | grep Runtime: |sed 's/^ *Runtime: //'` appid=$runtime # The beta runtime is in the stable repository. - if [[ $branch = 'beta' ]]; then + if [ $branch = 'beta' ]; then remote='flathub' fi package_info_cmd="flatpak remote-info $user_system $remote $appid//$branch" diff --git a/tools/generate-news b/tools/generate-news index 073d30ebaa..c26093182f 100755 --- a/tools/generate-news +++ b/tools/generate-news @@ -1,30 +1,34 @@ -#!/bin/bash +#!/bin/sh # Copyright (C) 2015 Ville Pätsi -SCRIPT_FOLDER=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) +SCRIPT_FOLDER=$( cd "$( dirname "$0")" && pwd ) FIRST_COMMIT="$1" [ -z "$FIRST_COMMIT" ] && FIRST_COMMIT="950412fbdc720fe2600f58f04f25145d9073895d" # First after tag 2.8.0 -declare -a FOLDERS=('app tools menus etc' \ - 'libgimp libgimpbase libgimpcolor libgimpconfig libgimpmath libgimpmodule libgimpthumb libgimpwidgets' \ - 'plug-ins' \ - 'modules' - 'build' \ - 'themes icons') +FOLDERS="app;tools;menus;etc \ + libgimp;libgimpbase;libgimpcolor;libgimpconfig;libgimpmath;libgimpmodule;libgimpthumb;libgimpwidgets \ + plug-ins \ + modules \ + build \ + themes" OUTPUTFILE=${SCRIPT_FOLDER}/../NEWS_since_"${FIRST_COMMIT}" -pushd ${SCRIPT_FOLDER}/.. +old_dir=$(pwd) +cd ${SCRIPT_FOLDER}/.. -for folderloop in "${FOLDERS[@]}" -do uppercase_folderloop="`echo ${folderloop:0:1} | tr '[:lower:]' '[:upper:]'`${folderloop:1}" - echo -e "${uppercase_folderloop}:\n" >> "${OUTPUTFILE}" - git log --date-order --reverse --date=short --pretty=format:"- %h %s" "${FIRST_COMMIT}"..HEAD ${folderloop} >> "${OUTPUTFILE}" - echo -e "\n\n" >> "${OUTPUTFILE}" +for folderloop in $FOLDERS; do + folderloop=$(echo "$folderloop" | sed "s/;/ /g") + uppercase_folderloop="`echo ${folderloop} | cut -c1 | tr '[:lower:]' '[:upper:]'``echo ${folderloop} | cut -c2-`" + printf "\n${uppercase_folderloop}:\n\n" >> "${OUTPUTFILE}" + for folder in $folderloop; do + git log --date-order --reverse --date=short --pretty=format:"- %h %s" "${FIRST_COMMIT}"..HEAD ${folder} >> "${OUTPUTFILE}" + done + printf "\n\n" >> "${OUTPUTFILE}" done -popd +cd $old_dir echo "NEWS generated into ${OUTPUTFILE}" diff --git a/tools/generate_changelog.sh b/tools/generate_changelog.sh index 6311626397..9616799a16 100755 --- a/tools/generate_changelog.sh +++ b/tools/generate_changelog.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh srcdir="$1" output="$2" @@ -7,7 +7,7 @@ echo "Creating ${output} based on git log" gitdir="${srcdir}/.git" -if [[ ! -d "${gitdir}" ]]; then +if [ ! -d "${gitdir}" ]; then echo "A git checkout and git-log is required to write changelog in ${output}." \ | tee ${output} >&2 exit 1 @@ -17,9 +17,10 @@ fi CHANGELOG_START=74424325abb54620b370f2595445b2b2a19fe5e7 ( \ - git log "${CHANGELOG_START}^.." --stat "${srcdir}" | fmt --split-only \ - > "${output}.tmp" \ - && [ ${PIPESTATUS[0]} -eq 0 ] \ + git log "${CHANGELOG_START}^.." --stat "${srcdir}" > temp_log.tmp + status=$? + cat temp_log.tmp | fmt --split-only > "${output}.tmp" | rm temp_log.tmp \ + && [ "$status" -eq 0 ] \ && mv "${output}.tmp" "${output}" -f \ && echo "Appending ChangeLog.pre-git" \ && cat "${srcdir}/ChangeLog.pre-git" >> "${output}" \ diff --git a/tools/performance-log-viewer b/tools/performance-log-viewer index 2ef7f38b85..cb66f358f9 100755 --- a/tools/performance-log-viewer +++ b/tools/performance-log-viewer @@ -25,7 +25,7 @@ if [ "$#" -ne 1 ]; then exit 1 fi -tools_dir="$(dirname "$(command -v -- "$0")")" +tools_dir="$(dirname "$(command -v "$0")")" file="$1" < "$file" || exit 1