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).
This commit is contained in:
Bruno Lopes 2025-06-15 15:50:40 -03:00
parent b9d30cb3a2
commit fd47161215
No known key found for this signature in database
12 changed files with 288 additions and 283 deletions

View file

@ -279,9 +279,9 @@ gimp-debian:
- echo -e "\e[0Ksection_end:`date +%s`:gimp_build\r\e[0K" - echo -e "\e[0Ksection_end:`date +%s`:gimp_build\r\e[0K"
# Create bundle # Create bundle
- echo -e "\e[0Ksection_start:`date +%s`:gimp_bundle[collapsed=true]\r\e[0KCreating 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 .. - 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" - echo -e "\e[0Ksection_end:`date +%s`:gimp_bundle\r\e[0K"
artifacts: artifacts:
paths: paths:
@ -356,12 +356,12 @@ gimp-debian-x64:
exit 1; exit 1;
fi fi
- if [ "$VARIANT" != "-gcc" ] && [ "$VARIANT" != "-raster" ] && [ "$CI_PIPELINE_SOURCE" != "merge_request_event" ]; then - 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 fi
- echo -e "\e[0Ksection_end:`date +%s`:gimp_tar\r\e[0K" - echo -e "\e[0Ksection_end:`date +%s`:gimp_tar\r\e[0K"
# Check install # Check install
- echo -e "\e[0Ksection_start:`date +%s`:gimp_install[collapsed=true]\r\e[0KChecking GIMP installation" - 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" - echo -e "\e[0Ksection_end:`date +%s`:gimp_install\r\e[0K"
artifacts: artifacts:
paths: paths:
@ -397,7 +397,7 @@ deps-flatpak-x64:
#paths: #paths:
#- .flatpak-builder/ #- .flatpak-builder/
script: script:
- bash build/linux/flatpak/1_build-deps-flatpak.sh - sh build/linux/flatpak/1_build-deps-flatpak.sh
artifacts: artifacts:
paths: paths:
- .flatpak-builder.tar - .flatpak-builder.tar
@ -413,7 +413,7 @@ gimp-flatpak-x64:
variables: variables:
GIT_SUBMODULE_STRATEGY: recursive GIT_SUBMODULE_STRATEGY: recursive
script: script:
- bash build/linux/flatpak/2_build-gimp-flatpak.sh - sh build/linux/flatpak/2_build-gimp-flatpak.sh
artifacts: artifacts:
paths: paths:
- repo.tar - repo.tar
@ -603,7 +603,7 @@ meson-health:
script: script:
- apt-get update - apt-get update
- apt-get install -y git - apt-get install -y git
- bash .gitlab/run_meson_health_diff.sh - sh .gitlab/run_meson_health_diff.sh
allow_failure: true allow_failure: true
clang-format: clang-format:
@ -615,7 +615,7 @@ clang-format:
- apt-get update - apt-get update
- apt-get install -y clang-format - apt-get install -y clang-format
git git
- .gitlab/run_style_check_diff.sh - sh .gitlab/run_style_check_diff.sh
allow_failure: true allow_failure: true
artifacts: artifacts:
when: on_failure when: on_failure
@ -730,7 +730,7 @@ dist-appimage-weekly:
needs: ["gimp-debian"] needs: ["gimp-debian"]
stage: distribution stage: distribution
script: script:
- bash build/linux/appimage/3_dist-gimp-goappimage.sh - sh build/linux/appimage/3_dist-gimp-goappimage.sh
artifacts: artifacts:
expose_as: 'Linux appimage' expose_as: 'Linux appimage'
paths: paths:
@ -752,7 +752,7 @@ dist-flatpak-weekly:
needs: ["gimp-flatpak-x64"] needs: ["gimp-flatpak-x64"]
stage: distribution stage: distribution
script: script:
- bash build/linux/flatpak/3_dist-gimp-flatpak.sh - sh build/linux/flatpak/3_dist-gimp-flatpak.sh
artifacts: artifacts:
expose_as: 'Linux flatpak' expose_as: 'Linux flatpak'
paths: paths:

View file

@ -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/^+//') diff=$(git diff -U0 --no-color "${newest_common_ancestor_sha}" -- '*.build' '*.py' | grep -E '^\+[^+]' | sed 's/^+//')
#List of commonly used utilities on Unix world #List of commonly used utilities on Unix world
#See the context: https://gitlab.gnome.org/GNOME/gimp/-/issues/11385 #See the context: https://gitlab.gnome.org/GNOME/gimp/-/issues/11385
coreutils_array=( coreutils_list="
".sh" .sh \
"'sh'" 'sh' \
"'bash'" 'bash' \
"'\['" '\[' \
"'arch'" 'arch' \
"'awk'" 'awk' \
"'b2sum'" 'b2sum' \
"'base32'" 'base32' \
"'base64'" 'base64' \
"'basename'" 'basename' \
"'basenc'" 'basenc' \
"'cat'" 'cat' \
"'chcon'" 'chcon' \
"'chgrp'" 'chgrp' \
"'chmod'" 'chmod' \
"'chown'" 'chown' \
"'chroot'" 'chroot' \
"'cksum'" 'cksum' \
"'cmp'" 'cmp' \
"'comm'" 'comm' \
"'cp'" 'cp' \
"'csplit'" 'csplit' \
"'cut'" 'cut' \
"'date'" 'date' \
"'dd'" 'dd' \
"'df'" 'df' \
"'diff'" 'diff' \
"'dir'" 'dir' \
"'dircolors'" 'dircolors' \
"'dirname'" 'dirname' \
"'du'" 'du' \
"'echo'" 'echo' \
"'env'" 'env' \
"'expand'" 'expand' \
"'expr'" 'expr' \
"'factor'" 'factor' \
"'false'" 'false' \
"'find'" 'find' \
"'fmt'" 'fmt' \
"'fold'" 'fold' \
"'gkill'" 'gkill' \
"'grep'" 'grep' \
"'groups'" 'groups' \
"'head'" 'head' \
"'hostid'" 'hostid' \
"'hostname'" 'hostname' \
"'id'" 'id' \
"'install'" 'install' \
"'join'" 'join' \
"'link'" 'link' \
"'ln'" 'ln' \
"'logname'" 'logname' \
"'ls'" 'ls' \
"'md5sum'" 'md5sum' \
"'mkdir'" 'mkdir' \
"'mkfifo'" 'mkfifo' \
"'mknod'" 'mknod' \
"'mktemp'" 'mktemp' \
"'mv'" 'mv' \
"'nice'" 'nice' \
"'nl'" 'nl' \
"'nohup'" 'nohup' \
"'nproc'" 'nproc' \
"'numfmt'" 'numfmt' \
"'od'" 'od' \
"'paste'" 'paste' \
"'pathchk'" 'pathchk' \
"'pinky'" 'pinky' \
"'pr'" 'pr' \
"'printenv'" 'printenv' \
"'printf'" 'printf' \
"'ptx'" 'ptx' \
"'pwd'" 'pwd' \
"'readlink'" 'readlink' \
"'realpath'" 'realpath' \
"'rm'" 'rm' \
"'rmdir'" 'rmdir' \
"'runcon'" 'runcon' \
"'sed'" 'sed' \
"'seq'" 'seq' \
"'sha1sum'" 'sha1sum' \
"'sha224sum'" 'sha224sum' \
"'sha256sum'" 'sha256sum' \
"'sha384sum'" 'sha384sum' \
"'sha512sum'" 'sha512sum' \
"'shred'" 'shred' \
"'shuf'" 'shuf' \
"'sleep'" 'sleep' \
"'sort'" 'sort' \
"'split'" 'split' \
"'stat'" 'stat' \
"'stdbuf'" 'stdbuf' \
"'stty'" 'stty' \
"'sum'" 'sum' \
"'sync'" 'sync' \
"'tac'" 'tac' \
"'tail'" 'tail' \
"'tee'" 'tee' \
"'test'" 'test' \
"'timeout'" 'timeout' \
"'touch'" 'touch' \
"'tr'" 'tr' \
"'true'" 'true' \
"'truncate'" 'truncate' \
"'tsort'" 'tsort' \
"'tty'" 'tty' \
"'uname'" 'uname' \
"'unexpand'" 'unexpand' \
"'uniq'" 'uniq' \
"'unlink'" 'unlink' \
"'users'" 'users' \
"'vdir'" 'vdir' \
"'wc'" 'wc' \
"'who'" 'who' \
"'whoami'" 'whoami' \
"'yes'" 'yes'
) "
for coreutil in "${coreutils_array[@]}"; do for coreutil in $coreutils_list; do
if echo "$diff" | grep -q "$coreutil"; then if echo "$diff" | grep -q "$coreutil"; then
found_coreutils+=" $coreutil" found_coreutils="$found_coreutils $coreutil"
fi fi
done done
if [ "$found_coreutils" ]; then 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.' printf '\033[31m(ERROR)\033[0m: Seems that you are trying to add an Unix-specific dependency to be called by Meson.\n'
echo " Please, port to Python (which is crossplatform), your use of:${found_coreutils}." printf " Please, port to Python (which is crossplatform), your use of:${found_coreutils}.\n"
fi fi
#Limited list of commonly used utilities on Windows world #Limited list of commonly used utilities on Windows world
ntutils_array=( ntutils_list="
".bat" .bat \
".cmd" .cmd \
".ps1" .ps1 \
"'cmd'" 'cmd' \
"'powershell'" 'powershell'
) "
for ntutil in "${ntutils_array[@]}"; do for ntutil in $ntutils_list; do
if echo "$diff" | grep -q "$ntutil"; then if echo "$diff" | grep -q "$ntutil"; then
found_ntutils+=" $ntutil" found_ntutils="$found_ntutils $ntutil"
fi fi
done done
if [ "$found_ntutils" ]; then 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.' printf '\033[31m(ERROR)\033[0m: Seems that you are trying to add a NT-specific dependency to be called by Meson.\n'
echo " Please, port to Python (which is crossplatform), your use of:${found_ntutils}." printf " Please, port to Python (which is crossplatform), your use of:${found_ntutils}.\n"
fi fi
if [ "$found_coreutils" ] || [ "$found_ntutils" ]; then if [ "$found_coreutils" ] || [ "$found_ntutils" ]; then
echo "$diff"
exit 1 exit 1
fi fi
echo 'Meson .build files are alright regarding crossplatform.' printf 'Meson .build files are alright regarding crossplatform.\n'
exit 0 exit 0

View file

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
set -e set -e
@ -13,15 +13,15 @@ clang-format --version
# Wrap everything in a subshell so we can propagate the exit status. # 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 git diff -U0 --no-color "${newest_common_ancestor_sha}" | clang-format-diff -p1 > format-diff.log
) )
exit_status=$? exit_status=$?
[ ${exit_status} == 0 ] || exit ${exit_status} [ ${exit_status} = 0 ] || exit ${exit_status}
format_diff="$(<format-diff.log)" format_diff="$(cat format-diff.log)"
if [ -n "${format_diff}" ]; then if [ -n "${format_diff}" ]; then
cat format-diff.log cat format-diff.log

View file

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
set -e set -e
@ -14,7 +14,7 @@ ancestor_horizon=28 # days (4 weeks)
if ! git ls-remote --exit-code upstream >/dev/null 2>&1 ; then if ! git ls-remote --exit-code upstream >/dev/null 2>&1 ; then
git remote add upstream https://gitlab.gnome.org/GNOME/gimp.git git remote add upstream https://gitlab.gnome.org/GNOME/gimp.git
fi 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 # 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 # 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}} 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}}" 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) git rev-list --first-parent "upstream/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME:-${CI_DEFAULT_BRANCH}}" > "temp_upstream" 2>&1
if [ -z "${newest_common_ancestor_sha}" ]; then 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 "Couldnt find common ancestor with upstream main branch. This typically" echo "Couldnt find common ancestor with upstream main branch. This typically"
echo "happens if you branched from main a long time ago. Please update" echo "happens if you branched from main a long time ago. Please update"
echo "your clone, rebase, and re-push your branch." echo "your clone, rebase, and re-push your branch."

View file

@ -2,7 +2,7 @@
# Parameters # Parameters
REVISION="$1" 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" export REVISION="$GIMP_CI_APPIMAGE"
fi fi
MODE="$2" MODE="$2"
@ -11,14 +11,19 @@ if [ "$REVISION" = '--bundle-only' ]; then
fi fi
BUILD_DIR="$3" BUILD_DIR="$3"
case $(readlink /proc/$$/exe) in
*bash)
set -o posix
;;
esac
set -e set -e
if [ -z "$GITLAB_CI" ]; then if [ -z "$GITLAB_CI" ]; then
# Make the script work locally # Make the script work locally
if [ "$0" != 'build/linux/appimage/3_dist-gimp-goappimage.sh' ] && [ ${PWD/*\//} != 'appimage' ]; then if [ "$0" != 'build/linux/appimage/3_dist-gimp-goappimage.sh' ] && [ $(basename "$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' 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 exit 1
elif [ ${PWD/*\//} = 'appimage' ]; then elif [ $(basename "$PWD") = 'appimage' ]; then
cd ../../.. cd ../../..
fi fi
@ -27,7 +32,7 @@ fi
# 1. INSTALL BUNDLING TOOL AND STANDARD APPIMAGE DISTRIBUTION TOOLS # 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/" GIMP_DIR="$PWD/"
cd ${GIMP_DIR}${PARENT_DIR} cd ${GIMP_DIR}${PARENT_DIR}
if [ "$GITLAB_CI" ]; then if [ "$GITLAB_CI" ]; then
@ -69,8 +74,8 @@ if [ "$MODE" != '--bundle-only' ]; then
chmod +x "./runtime-$HOST_ARCH" chmod +x "./runtime-$HOST_ARCH"
static_runtime_version_downloaded=$("./runtime-$HOST_ARCH" --appimage-version 2>&1) static_runtime_version_downloaded=$("./runtime-$HOST_ARCH" --appimage-version 2>&1)
chmod -x "./runtime-$HOST_ARCH" chmod -x "./runtime-$HOST_ARCH"
if [ "${static_runtime_version_downloaded#*commit/}" != "${static_runtime_version_online:0:7}" ]; then if [ "${static_runtime_version_downloaded#*commit/}" != "$(echo "$static_runtime_version_online" | cut -c1-7)" ]; then
echo -e '\033[31m(ERROR)\033[0m: Downloaded runtime version differs from the one released online. Please, run again this script.' printf '\033[31m(ERROR)\033[0m: Downloaded runtime version differs from the one released online. Please, run again this script.\n'
exit 1 exit 1
fi fi
standard_appimagetool_text="appimagetool commit: $standard_appimagetool_version | type2-runtime commit: ${static_runtime_version_downloaded#*commit/}" 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=' | ' separator=' | '
fi fi
cd $GIMP_DIR cd $GIMP_DIR
echo "(INFO): ${bundler_text}${separator}${standard_appimagetool_text}" printf "(INFO): ${bundler_text}${separator}${standard_appimagetool_text}\n"
echo -e "\e[0Ksection_end:`date +%s`:apmg_tlkt\r\e[0K" printf "\e[0Ksection_end:`date +%s`:apmg_tlkt\r\e[0K\n"
# 2. GET GLOBAL VARIABLES # 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 if [ "$BUILD_DIR" = '' ]; then
export BUILD_DIR=$(find $PWD -maxdepth 1 -iname "_build*$RUNNER" | head -n 1) export BUILD_DIR=$(find $PWD -maxdepth 1 -iname "_build*$RUNNER" | head -n 1)
fi fi
if [ ! -f "$BUILD_DIR/config.h" ]; then 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 exit 1
fi fi
eval $(sed -n 's/^#define *\([^ ]*\) *\(.*\) *$/export \1=\2/p' $BUILD_DIR/config.h) 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 ## Get info about GIMP version
export CUSTOM_GIMP_VERSION="$GIMP_VERSION" export CUSTOM_GIMP_VERSION="$GIMP_VERSION"
if [[ ! "$REVISION" =~ [1-9] ]]; then if ! echo "$REVISION" | grep -q '[1-9]'; then
export REVISION="0" export REVISION="0"
else else
export CUSTOM_GIMP_VERSION="${GIMP_VERSION}-${REVISION}" export CUSTOM_GIMP_VERSION="${GIMP_VERSION}-${REVISION}"
fi fi
echo "(INFO): App ID: $APP_ID | Version: $CUSTOM_GIMP_VERSION" printf "(INFO): App ID: $APP_ID | Version: $CUSTOM_GIMP_VERSION\n"
echo -e "\e[0Ksection_end:`date +%s`:apmg_info\r\e[0K" printf "\e[0Ksection_end:`date +%s`:apmg_info\r\e[0K\n"
# 3. GIMP FILES (IN APPDIR) # 3. GIMP FILES (IN APPDIR)
if [ ! "$(find . -maxdepth 1 -iname "AppDir*")" ] || [ "$MODE" = '--bundle-only' ]; then 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 grep -q 'relocatable-bundle=yes' $BUILD_DIR/meson-logs/meson-log.txt && export RELOCATABLE_BUNDLE_ON=1
if [ -z "$RELOCATABLE_BUNDLE_ON" ]; then 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 exit 1
fi fi
@ -130,11 +135,7 @@ if [ -z "$GITLAB_CI" ] && [ -z "$GIMP_PREFIX" ]; then
export GIMP_PREFIX="$PWD/../_install" export GIMP_PREFIX="$PWD/../_install"
fi fi
if [ -z "$GITLAB_CI" ]; then if [ -z "$GITLAB_CI" ]; then
IFS=$'\n' VAR_ARRAY=($(cat .gitlab-ci.yml | sed -n '/multi-os/,/multiarch/p' | sed 's/- //')) eval "$(sed -n -e '/multi-os/,/multiarch/p' -e 's/- //' .gitlab-ci.yml)"
IFS=$' \t\n'
for VAR in "${VAR_ARRAY[@]}"; do
eval "$VAR"
done
fi fi
#Paths to receive copied files #Paths to receive copied files
@ -157,25 +158,24 @@ bund_usr ()
#Paths where to search #Paths where to search
case $2 in case $2 in
bin*) bin*)
search_path=("$1/bin" "$1/sbin" "$1/libexec") search_path="$1/bin $1/sbin $1/libexec"
;; ;;
lib*) lib*)
search_path=("$(dirname $(echo $2 | sed "s|lib/|$1/${LIB_DIR}/${LIB_SUBDIR}|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"))") $(dirname $(echo $2 | sed "s|lib/|/usr/${LIB_DIR}/|g" | sed "s|*|no_scape|g"))"
;; ;;
share*|include*|etc*) 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 esac
for path in "${search_path[@]}"; do for path in $search_path; do
expanded_path=$(echo $(echo $path | sed "s|no_scape|*|g")) expanded_path=$(echo $(echo $path | sed "s|no_scape|*|g"))
if [ ! -d "$expanded_path" ]; then if [ ! -d "$expanded_path" ]; then
continue continue
fi fi
#Copy found targets from search_path to bundle dir #Copy found targets from search_path to bundle dir
target_array=($(find $expanded_path -maxdepth 1 -name ${2##*/})) for target_path in $(find $expanded_path -maxdepth 1 -name ${2##*/}); do
for target_path in "${target_array[@]}"; do
dest_path="$(dirname $(echo $target_path | sed "s|$1/|${USR_DIR}/|g"))" dest_path="$(dirname $(echo $target_path | sed "s|$1/|${USR_DIR}/|g"))"
output_dest_path="$dest_path" output_dest_path="$dest_path"
if [ "$3" = '--dest' ] || [ "$3" = '--rename' ]; then if [ "$3" = '--dest' ] || [ "$3" = '--rename' ]; then
@ -188,7 +188,7 @@ bund_usr ()
fi fi
if [ "$3" != '--bundler' ] && [ "$5" != '--bundler' ]; then 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 mkdir -p $dest_path
cp -ru $target_path $dest_path >/dev/null 2>&1 || continue cp -ru $target_path $dest_path >/dev/null 2>&1 || continue
@ -198,9 +198,9 @@ bund_usr ()
rm -r "$dest_path" rm -r "$dest_path"
fi fi
else else
echo "(INFO): skipping $target_path (will be bundled by the tool)" printf "(INFO): skipping $target_path (will be bundled by the tool)\n"
if [[ "$target_path" =~ 'bin' ]] || [[ "$target_path" =~ '.so' ]]; then if echo "$target_path" | grep -q 'bin' || echo "$target_path" | grep -q '.so'; then
export APPENDED_LIST+="$target_path " export APPENDED_LIST="$APPENDED_LIST $target_path "
fi fi
fi fi
done done
@ -293,10 +293,8 @@ conf_app GEGL_PATH "${LIB_DIR}/${LIB_SUBDIR}gegl-*"
bund_usr "$GIMP_PREFIX" "lib/libgimp*" bund_usr "$GIMP_PREFIX" "lib/libgimp*"
bund_usr "$GIMP_PREFIX" "lib/gimp" bund_usr "$GIMP_PREFIX" "lib/gimp"
bund_usr "$GIMP_PREFIX" "share/gimp" bund_usr "$GIMP_PREFIX" "share/gimp"
lang_array=($(echo $(ls po/*.po | lang_list=$(echo $(ls po/*.po | sed -e 's|po/||g' -e 's|.po||g' | sort) | tr '\n\r' ' ')
sed -e 's|po/||g' -e 's|.po||g' | sort) | for lang in $lang_list; do
tr '\n\r' ' '))
for lang in "${lang_array[@]}"; do
bund_usr "$GIMP_PREFIX" share/locale/$lang/LC_MESSAGES bund_usr "$GIMP_PREFIX" share/locale/$lang/LC_MESSAGES
# Needed for eventually used widgets, GTK inspector etc # Needed for eventually used widgets, GTK inspector etc
bund_usr "$UNIX_PREFIX" share/locale/$lang/LC_MESSAGES/gtk3*.mo 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" "bin/gegl"
bund_usr "$GIMP_PREFIX" "share/applications/*.desktop" 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 #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 ## Manual adjustments after running the bundling tool
### Undo the mess which breaks babl and GEGL. See: https://github.com/probonopd/go-appimage/issues/315 ### 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 rm -r $APP_DIR/lib64
fi fi
chmod +x "$APP_DIR/$LD_LINUX" 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)) 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_array[@]}"; do for exec in $exec_list; do
if [[ ! "$exec" =~ 'ELF' ]]; then if ! echo "$exec" | grep -q 'ELF'; then
patchelf --set-interpreter "./$LD_LINUX" "$exec" >/dev/null 2>&1 || continue patchelf --set-interpreter "./$LD_LINUX" "$exec" >/dev/null 2>&1 || continue
fi fi
done done
@ -397,10 +395,9 @@ done
#if [ "$GITLAB_CI" ]; then #if [ "$GITLAB_CI" ]; then
# export DEBUGINFOD_URLS="https://debuginfod.debian.net" # export DEBUGINFOD_URLS="https://debuginfod.debian.net"
#fi #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 $(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
#for bin in "${bin_array[@]}"; do # if ! echo "$bin" | grep -q 'ELF' && ! echo "$bin" | grep -q '.debug'; then
# if [[ ! "$bin" =~ 'ELF' ]] && [[ ! "$bin" =~ '.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
# 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
# fi # fi
#done #done
@ -420,7 +417,7 @@ echo "usr/${LIB_DIR}/${LIB_SUBDIR}gconv
before=$(cat "$(echo $USR_DIR/share/gimp/*/gimp-release)" | grep 'revision') before=$(cat "$(echo $USR_DIR/share/gimp/*/gimp-release)" | grep 'revision')
after="revision=$REVISION" after="revision=$REVISION"
sed -i "s|$before|$after|" "$(echo $USR_DIR/share/gimp/*/gimp-release)" 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 fi
if [ "$MODE" = '--bundle-only' ]; then if [ "$MODE" = '--bundle-only' ]; then
exit 0 exit 0
@ -428,27 +425,26 @@ fi
# 4. PREPARE .APPIMAGE-SPECIFIC "SOURCE" # 4. PREPARE .APPIMAGE-SPECIFIC "SOURCE"
appdir_array=($(find . -maxdepth 1 -iname "AppDir*")) for APP_DIR in $(find . -maxdepth 1 -iname "AppDir*"); do
for APP_DIR in "${appdir_array[@]}"; do
export ARCH=$(echo $APP_DIR | sed -e 's|AppDir-||' -e 's|./||') 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" export USR_DIR="$APP_DIR/usr"
## 4.1. Finish AppRun configuration ## 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" ln -sfr "$USR_DIR/bin/gimp-$GIMP_APP_VERSION" "$USR_DIR/bin/$APP_ID"
printf "\nexec \"\$APPDIR\"/usr/bin/$APP_ID \"\$@\"" >> "$APP_DIR/AppRun" printf "\nexec \"\$APPDIR\"/usr/bin/$APP_ID \"\$@\"" >> "$APP_DIR/AppRun"
chmod +x $APP_DIR/AppRun chmod +x $APP_DIR/AppRun
## 4.2. Copy icon assets (similarly to flatpaks's 'rename-icon') ## 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 *.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 \; 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 cp -L "$USR_DIR/share/icons/hicolor/scalable/apps/$APP_ID.svg" $APP_DIR
ln -sfr "$APP_DIR/$APP_ID.svg" $APP_DIR/.DirIcon ln -sfr "$APP_DIR/$APP_ID.svg" $APP_DIR/.DirIcon
## 4.3. Configure .desktop asset (similarly to flatpaks's 'rename-desktop-file') ## 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 \; 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/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" 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 ln -sfr "$USR_DIR/share/applications/${APP_ID}.desktop" $APP_DIR
## 4.4. Configure appdata asset (similarly to flatpaks's 'rename-appdata-file') ## 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 \; 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</${APP_ID}</g" "$USR_DIR/share/metainfo/${APP_ID}.appdata.xml" sed -i "s/org.gimp.GIMP</${APP_ID}</g" "$USR_DIR/share/metainfo/${APP_ID}.appdata.xml"
sed -i "s/gimp.desktop/${APP_ID}.desktop/g" "$USR_DIR/share/metainfo/${APP_ID}.appdata.xml" sed -i "s/gimp.desktop/${APP_ID}.desktop/g" "$USR_DIR/share/metainfo/${APP_ID}.appdata.xml"
sed -i "s/date=\"TODO\"/date=\"`date --iso-8601`\"/" "$USR_DIR/share/metainfo/${APP_ID}.appdata.xml" sed -i "s/date=\"TODO\"/date=\"`date --iso-8601`\"/" "$USR_DIR/share/metainfo/${APP_ID}.appdata.xml"
echo -e "\e[0Ksection_end:`date +%s`:${ARCH}_source\r\e[0K" printf "\e[0Ksection_end:`date +%s`:${ARCH}_source\r\e[0K\n"
# 5. CONSTRUCT .APPIMAGE # 5. CONSTRUCT .APPIMAGE
APPIMAGETOOL_APP_NAME="GIMP-${CUSTOM_GIMP_VERSION}-${ARCH}.AppImage" APPIMAGETOOL_APP_NAME="GIMP-${CUSTOM_GIMP_VERSION}-${ARCH}.AppImage"
echo -e "\e[0Ksection_start:`date +%s`:${ARCH}_making[collapsed=true]\r\e[0KSquashing $APPIMAGETOOL_APP_NAME" printf "\e[0Ksection_start:`date +%s`:${ARCH}_making[collapsed=true]\r\e[0KSquashing $APPIMAGETOOL_APP_NAME\n"
if [ "$GIMP_RELEASE" ] && [ -z "$GIMP_IS_RC_GIT" ]; then if [ "$GIMP_RELEASE" ] && [ -z "$GIMP_IS_RC_GIT" ]; then
update_info="--updateinformation zsync|https://download.gimp.org/gimp/GIMP-${CHANNEL}-${ARCH}.AppImage.zsync" update_info="--updateinformation zsync|https://download.gimp.org/gimp/GIMP-${CHANNEL}-${ARCH}.AppImage.zsync"
fi fi
@ -480,20 +476,20 @@ if [ -f "${APPIMAGETOOL_APP_NAME}.zsync" ]; then
sed -i "s|$before|$after|" "$APPIMAGETOOL_APP_NAME.zsync" >/dev/null 2>&1 sed -i "s|$before|$after|" "$APPIMAGETOOL_APP_NAME.zsync" >/dev/null 2>&1
mv ${APPIMAGETOOL_APP_NAME}.zsync GIMP-${CHANNEL}-${ARCH}.AppImage.zsync mv ${APPIMAGETOOL_APP_NAME}.zsync GIMP-${CHANNEL}-${ARCH}.AppImage.zsync
fi 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 # 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 if [ "$GIMP_RELEASE" ] && [ -z "$GIMP_IS_RC_GIT" ]; then
sha256sum $APPIMAGETOOL_APP_NAME > $APPIMAGETOOL_APP_NAME.SHA256SUMS sha256sum $APPIMAGETOOL_APP_NAME > $APPIMAGETOOL_APP_NAME.SHA256SUMS
fi 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 if [ "$GIMP_RELEASE" ] && [ -z "$GIMP_IS_RC_GIT" ]; then
sha512sum $APPIMAGETOOL_APP_NAME > $APPIMAGETOOL_APP_NAME.SHA512SUMS sha512sum $APPIMAGETOOL_APP_NAME > $APPIMAGETOOL_APP_NAME.SHA512SUMS
fi fi
echo "(INFO): $APPIMAGETOOL_APP_NAME SHA-512: $(sha512sum $APPIMAGETOOL_APP_NAME | cut -d ' ' -f 1)" printf "(INFO): $APPIMAGETOOL_APP_NAME SHA-512: $(sha512sum $APPIMAGETOOL_APP_NAME | cut -d ' ' -f 1)\n"
echo -e "\e[0Ksection_end:`date +%s`:${ARCH}_trust\r\e[0K" printf "\e[0Ksection_end:`date +%s`:${ARCH}_trust\r\e[0K\n"
if [ "$GITLAB_CI" ]; then if [ "$GITLAB_CI" ]; then

View file

@ -9,8 +9,8 @@ set -e
if [ -z "$GITLAB_CI" ]; then if [ -z "$GITLAB_CI" ]; then
# Make the script work locally # Make the script work locally
if [ "$0" != 'build/linux/flatpak/1_build-deps-flatpak.sh' ] && [ ${PWD/*\//} != 'flatpak' ]; then if [ "$0" != 'build/linux/flatpak/1_build-deps-flatpak.sh' ] && [ $(basename "$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/' printf '\033[31m(ERROR)\033[0m: Script called from wrong dir. Please, read: https://developer.gimp.org/core/setup/build/linux/\n'
exit 1 exit 1
elif [ $(basename "$PWD") = 'flatpak' ]; then elif [ $(basename "$PWD") = 'flatpak' ]; then
cd ../../.. cd ../../..
@ -19,20 +19,20 @@ fi
# Install part of the deps # 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' export FLATPAK_BUILDER='flatpak-builder'
elif [ -f '/var/lib/flatpak/exports/bin/org.flatpak.Builder' ]; then elif [ -f '/var/lib/flatpak/exports/bin/org.flatpak.Builder' ]; then
export FLATPAK_BUILDER='flatpak run --system org.flatpak.Builder' export FLATPAK_BUILDER='flatpak run --system org.flatpak.Builder'
elif [ -f "${XDG_DATA_HOME:-$HOME/.local/share}/flatpak/exports/bin/org.flatpak.Builder" ]; then elif [ -f "${XDG_DATA_HOME:-$HOME/.local/share}/flatpak/exports/bin/org.flatpak.Builder" ]; then
export FLATPAK_BUILDER='flatpak run --user org.flatpak.Builder' export FLATPAK_BUILDER='flatpak run --user org.flatpak.Builder'
else 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 exit 1
fi fi
builder_version=$(eval $FLATPAK_BUILDER --version | sed 's/flatpak-builder//' | sed 's/-//' | sed 's/ //' | sed 's/\.//g') builder_version=$(eval $FLATPAK_BUILDER --version | sed 's/flatpak-builder//' | sed 's/-//' | sed 's/ //' | sed 's/\.//g')
if [ "$builder_version" -lt '143' ]; then if [ "$builder_version" -lt '143' ]; then
## Pre-1.4.3 flatpak-builder fails at Cmake deps, let's prevent this ## 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 exit 1
fi #End of check 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 "$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json 2>&1 | tee flatpak-builder.log
elif [ "$GITLAB_CI" ] || [ "$1" = '--ci' ]; then 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 if [ "$CI_PIPELINE_SOURCE" = 'schedule' ]; then
# Check dependencies versions with flatpak-external-data-checker # Check dependencies versions with flatpak-external-data-checker
export FLATPAK_SYSTEM_HELPER_ON_SESSION=foo 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 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 if ! flatpak run --user --filesystem=$CI_PROJECT_DIR org.flathub.flatpak-external-data-checker \
echo "(INFO): All dependencies sources are up to date. Building them..." --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 fi
## (The deps building is too long and no complete output would be collected, ## (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.) ## 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 \ 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 "$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json > flatpak-builder.log 2>&1
echo -e "\e[0Ksection_end:`date +%s`:deps_build\r\e[0K" 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 \ 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 "$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json
if [ "$GITLAB_CI" ]; then if [ "$GITLAB_CI" ]; then
tar cf babl-meson-log.tar .flatpak-builder/build/babl-1/_flatpak_build/meson-logs/meson-log.txt tar cf babl-meson-log.tar .flatpak-builder/build/babl-1/_flatpak_build/meson-logs/meson-log.txt
fi 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 \ 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 "$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json
if [ "$GITLAB_CI" ]; then if [ "$GITLAB_CI" ]; then
tar cf gegl-meson-log.tar .flatpak-builder/build/gegl-1/_flatpak_build/meson-logs/meson-log.txt 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 ## Save built deps for 'gimp-flatpak-x64' job
tar cf .flatpak-builder.tar .flatpak-builder/ tar cf .flatpak-builder.tar .flatpak-builder/

View file

@ -9,8 +9,8 @@ set -e
if [ -z "$GITLAB_CI" ]; then if [ -z "$GITLAB_CI" ]; then
# Make the script work locally # Make the script work locally
if [ "$0" != 'build/linux/flatpak/2_build-gimp-flatpak.sh' ] && [ ${PWD/*\//} != 'flatpak' ]; then if [ "$0" != 'build/linux/flatpak/2_build-gimp-flatpak.sh' ] && [ $(basename "$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/' printf '\033[31m(ERROR)\033[0m: Script called from wrong dir. Please, read: https://developer.gimp.org/core/setup/build/linux/\n'
exit 1 exit 1
elif [ $(basename "$PWD") = 'flatpak' ]; then elif [ $(basename "$PWD") = 'flatpak' ]; then
cd ../../.. cd ../../..
@ -21,7 +21,7 @@ fi
# Install part of the deps # 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 if [ "$GITLAB_CI" ]; then
# Extract deps from previous job # 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 eval $FLATPAK_BUILDER --run "$GIMP_PREFIX" ../build/linux/flatpak/org.gimp.GIMP-nightly.json ninja install
elif [ "$GITLAB_CI" ] || [ "$1" = '--ci' ]; then 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 \ 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 if [ "$GITLAB_CI" ]; then
tar cf gimp-meson-log.tar .flatpak-builder/build/gimp-1/_flatpak_build/meson-logs/meson-log.txt tar cf gimp-meson-log.tar .flatpak-builder/build/gimp-1/_flatpak_build/meson-logs/meson-log.txt
fi 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 ## Cleanup GIMP_PREFIX (not working) and export it to OSTree repo
## https://github.com/flatpak/flatpak-builder/issues/14 ## 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 \ eval $FLATPAK_BUILDER --user --disable-rofiles-fuse --finish-only --repo=repo \
"$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json "$GIMP_PREFIX" build/linux/flatpak/org.gimp.GIMP-nightly.json
if [ "$GITLAB_CI" ]; then if [ "$GITLAB_CI" ]; then
tar cf repo.tar repo/ tar cf repo.tar repo/
fi 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 fi

View file

@ -22,16 +22,16 @@ fi
# CONSTRUCT .FLATPAK # CONSTRUCT .FLATPAK
# Generate a Flatpak "bundle" to be tested with GNOME runtime installed # 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) # (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} 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 # GENERATE SHASUMS FOR .FLATPAK
echo -e "\e[0Ksection_start:`date +%s`:flat_trust[collapsed=true]\r\e[0KChecksumming ${APP_ID}.flatpak" printf "\e[0Ksection_start:`date +%s`:flat_trust[collapsed=true]\r\e[0KChecksumming ${APP_ID}.flatpak\n"
echo "(INFO): ${APP_ID}.flatpak SHA-256: $(sha256sum ${APP_ID}.flatpak | cut -d ' ' -f 1)" printf "(INFO): ${APP_ID}.flatpak SHA-256: $(sha256sum ${APP_ID}.flatpak | cut -d ' ' -f 1)\n"
echo "(INFO): ${APP_ID}.flatpak SHA-512: $(sha512sum ${APP_ID}.flatpak | cut -d ' ' -f 1)" printf "(INFO): ${APP_ID}.flatpak SHA-512: $(sha512sum ${APP_ID}.flatpak | cut -d ' ' -f 1)\n"
echo -e "\e[0Ksection_end:`date +%s`:flat_trust\r\e[0K" printf "\e[0Ksection_end:`date +%s`:flat_trust\r\e[0K\n"
if [ "$GITLAB_CI" ]; then if [ "$GITLAB_CI" ]; then
@ -44,8 +44,8 @@ fi
# PUBLISH GIMP REPO IN GNOME NIGHTLY # PUBLISH GIMP REPO IN GNOME NIGHTLY
# We take the commands from 'flatpak_ci_initiative.yml' # We take the commands from 'flatpak_ci_initiative.yml'
if [ "$GITLAB_CI" ] && [ "$CI_COMMIT_BRANCH" = "$CI_DEFAULT_BRANCH" ]; then 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 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/ - //') eval "$(sed -n -e '/flatpak build-update-repo/,/exit $result/ { s/ - //; p }' flatpak_ci_initiative.yml)"
echo -e "\e[0Ksection_end:`date +%s`:flat_publish\r\e[0K" printf "\e[0Ksection_end:`date +%s`:flat_publish\r\e[0K\n"
fi fi

View file

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
# This is a very basic script for developer usage. It has a few known # This is a very basic script for developer usage. It has a few known
# limitations (feel free to send patches for these): # 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 # - It also assumes the flathub remotes are installed at all (it can't
# search without them being installed and won't install these for # search without them being installed and won't install these for
# you). # 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 install=-1
show_runtime=0 show_runtime=0
@ -29,19 +25,19 @@ branch='stable'
prefix='--user' prefix='--user'
for var in "$@" for var in "$@"
do do
if [[ $var =~ ^-([0-9]+)$ ]]; then if echo "$var" | grep -qE '^-[0-9]+$'; then
install=${BASH_REMATCH[1]} install=${var#-}
elif [[ $var = '--beta' ]]; then elif [ $var = '--beta' ]; then
remote='flathub-beta' remote='flathub-beta'
branch='beta' branch='beta'
elif [[ $var = '--nightly' ]]; then elif [ $var = '--nightly' ]; then
remote='gnome-nightly' remote='gnome-nightly'
branch='master' branch='master'
elif [[ $var = '--system' ]]; then elif [ $var = '--system' ]; then
prefix='--system' prefix='--system'
elif [[ $var = '--runtime' ]]; then elif [ $var = '--runtime' ]; then
show_runtime=1 show_runtime=1
elif [[ $var =~ ^- ]]; then elif echo "$var" | grep -q '^-'; then
echo "Usage: ./flathub-releases [--beta] [--system] [-X] [org.example.app]" echo "Usage: ./flathub-releases [--beta] [--system] [-X] [org.example.app]"
echo echo
echo "List all flatpak builds stored on Flathub or GNOME repository." 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: //'` runtime=`echo "$package_info" | grep Runtime: |sed 's/^ *Runtime: //'`
appid=$runtime appid=$runtime
# The beta runtime is in the stable repository. # The beta runtime is in the stable repository.
if [[ $branch = 'beta' ]]; then if [ $branch = 'beta' ]; then
remote='flathub' remote='flathub'
fi fi
package_info_cmd="flatpak remote-info $user_system $remote $appid//$branch" package_info_cmd="flatpak remote-info $user_system $remote $appid//$branch"

View file

@ -1,30 +1,34 @@
#!/bin/bash #!/bin/sh
# Copyright (C) 2015 Ville Pätsi <drc@gimp.org> # Copyright (C) 2015 Ville Pätsi <drc@gimp.org>
SCRIPT_FOLDER=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) SCRIPT_FOLDER=$( cd "$( dirname "$0")" && pwd )
FIRST_COMMIT="$1" FIRST_COMMIT="$1"
[ -z "$FIRST_COMMIT" ] && FIRST_COMMIT="950412fbdc720fe2600f58f04f25145d9073895d" # First after tag 2.8.0 [ -z "$FIRST_COMMIT" ] && FIRST_COMMIT="950412fbdc720fe2600f58f04f25145d9073895d" # First after tag 2.8.0
declare -a FOLDERS=('app tools menus etc' \ FOLDERS="app;tools;menus;etc \
'libgimp libgimpbase libgimpcolor libgimpconfig libgimpmath libgimpmodule libgimpthumb libgimpwidgets' \ libgimp;libgimpbase;libgimpcolor;libgimpconfig;libgimpmath;libgimpmodule;libgimpthumb;libgimpwidgets \
'plug-ins' \ plug-ins \
'modules' modules \
'build' \ build \
'themes icons') themes"
OUTPUTFILE=${SCRIPT_FOLDER}/../NEWS_since_"${FIRST_COMMIT}" OUTPUTFILE=${SCRIPT_FOLDER}/../NEWS_since_"${FIRST_COMMIT}"
pushd ${SCRIPT_FOLDER}/.. old_dir=$(pwd)
cd ${SCRIPT_FOLDER}/..
for folderloop in "${FOLDERS[@]}" for folderloop in $FOLDERS; do
do uppercase_folderloop="`echo ${folderloop:0:1} | tr '[:lower:]' '[:upper:]'`${folderloop:1}" folderloop=$(echo "$folderloop" | sed "s/;/ /g")
echo -e "${uppercase_folderloop}:\n" >> "${OUTPUTFILE}" uppercase_folderloop="`echo ${folderloop} | cut -c1 | tr '[:lower:]' '[:upper:]'``echo ${folderloop} | cut -c2-`"
git log --date-order --reverse --date=short --pretty=format:"- %h %s" "${FIRST_COMMIT}"..HEAD ${folderloop} >> "${OUTPUTFILE}" printf "\n${uppercase_folderloop}:\n\n" >> "${OUTPUTFILE}"
echo -e "\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 done
popd cd $old_dir
echo "NEWS generated into ${OUTPUTFILE}" echo "NEWS generated into ${OUTPUTFILE}"

View file

@ -1,4 +1,4 @@
#!/bin/bash #!/bin/sh
srcdir="$1" srcdir="$1"
output="$2" output="$2"
@ -7,7 +7,7 @@ echo "Creating ${output} based on git log"
gitdir="${srcdir}/.git" 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}." \ echo "A git checkout and git-log is required to write changelog in ${output}." \
| tee ${output} >&2 | tee ${output} >&2
exit 1 exit 1
@ -17,9 +17,10 @@ fi
CHANGELOG_START=74424325abb54620b370f2595445b2b2a19fe5e7 CHANGELOG_START=74424325abb54620b370f2595445b2b2a19fe5e7
( \ ( \
git log "${CHANGELOG_START}^.." --stat "${srcdir}" | fmt --split-only \ git log "${CHANGELOG_START}^.." --stat "${srcdir}" > temp_log.tmp
> "${output}.tmp" \ status=$?
&& [ ${PIPESTATUS[0]} -eq 0 ] \ cat temp_log.tmp | fmt --split-only > "${output}.tmp" | rm temp_log.tmp \
&& [ "$status" -eq 0 ] \
&& mv "${output}.tmp" "${output}" -f \ && mv "${output}.tmp" "${output}" -f \
&& echo "Appending ChangeLog.pre-git" \ && echo "Appending ChangeLog.pre-git" \
&& cat "${srcdir}/ChangeLog.pre-git" >> "${output}" \ && cat "${srcdir}/ChangeLog.pre-git" >> "${output}" \

View file

@ -25,7 +25,7 @@ if [ "$#" -ne 1 ]; then
exit 1 exit 1
fi fi
tools_dir="$(dirname "$(command -v -- "$0")")" tools_dir="$(dirname "$(command -v "$0")")"
file="$1" file="$1"
< "$file" || exit 1 < "$file" || exit 1