From 76d85a1364ce333d62be7e16665e2cf9f70ec024 Mon Sep 17 00:00:00 2001
From: Stephan Bergmann
Date: Wed, 22 Oct 2025 20:43:13 +0200
Subject: [PATCH] Parametrize assemble-flatpak over the flatpak ID
(solenv/bin/assemble-flatpak-desktop.sh in one place uses that parameterized
value in a sed s command replacement text, which could potentially cause syntax
errors. But since flatpak IDs shall be formed from a restricted alphabet, that
should not cause problems in practice. Similarly, various places across the
solenv/bin/assemble-flatpak*.sh scripts use that perameterized value in forming
pathnames, and assume that it does not contain any slahses.)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192883
Tested-by: Jenkins CollaboraOffice
Reviewed-by: Sarper Akdemir
(cherry picked from commit 15007243c11363c636d74c240946237da5a866b8)
Conflicts:
solenv/bin/assemble-flatpak-appdata.sh
solenv/bin/assemble-flatpak-desktop.sh
solenv/bin/assemble-flatpak.sh
solenv/flatpak-manifest.in
Change-Id: I5b4c031acf19b04ac8b501d9d8557924747fb38b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/194174
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann
---
solenv/bin/assemble-flatpak-appdata.sh | 17 +++++++++--------
solenv/bin/assemble-flatpak-desktop.sh | 19 ++++++++++---------
solenv/bin/assemble-flatpak.sh | 13 ++++++++-----
solenv/flatpak-manifest.in | 2 +-
4 files changed, 28 insertions(+), 23 deletions(-)
diff --git a/solenv/bin/assemble-flatpak-appdata.sh b/solenv/bin/assemble-flatpak-appdata.sh
index 874f23e1fc27..e47fae2405fc 100755
--- a/solenv/bin/assemble-flatpak-appdata.sh
+++ b/solenv/bin/assemble-flatpak-appdata.sh
@@ -12,20 +12,21 @@
#
# Arguments:
# $1 pathname, ending in a slash, of the directory into which to put the target
-# org.libreoffice.LibreOffice.appdata.xml file
+# $3.appdata.xml file
# $2 "1" if a section shall be included in the target
-# org.libreoffice.LibreOffice.appdata.xml file, "0" if not
+# $3.appdata.xml file, "0" if not
+# $3 the flatpak ID
set -e
-## org.libreoffice.LibreOffice.appdata.xml is manually derived from the various
+## $3.appdata.xml is manually derived from the various
## inst/share/metainfo/libreoffice-*.appdata.xml (at least recent GNOME Software
## doesn't show more than five screenshots anyway, so restrict to one each from
## the five libreoffice-*.appdata.xml: Writer, Calc, Impress, Draw, Base):
-cat <<\EOF >"${1?}"org.libreoffice.LibreOffice.appdata.xml
+cat <"${1?}${3?}".appdata.xml
- org.libreoffice.LibreOffice
+ ${3?}
CC0-1.0
MPL-2.0
LibreOffice
@@ -41,7 +42,7 @@ cat <<\EOF >"${1?}"org.libreoffice.LibreOffice.appdata.xml
you can easily share documents with users of other popular office suites
without worrying about compatibility.
- org.libreoffice.LibreOffice.desktop
+ ${3?}.desktop
http://www.libreoffice.org/discover/libreoffice/
https://bugs.documentfoundation.org/
https://donate.libreoffice.org/
@@ -83,7 +84,7 @@ EOF
if [ "${2?}" = 1 ]
then
- cat <>"${1?}"org.libreoffice.LibreOffice.appdata.xml
+ cat <>"${1?}${3?}".appdata.xml
>"${1?}"org.libreoffice.LibreOffice.appdata.xml
+cat <<\EOF >>"${1?}${3?}".appdata.xml
EOF
diff --git a/solenv/bin/assemble-flatpak-desktop.sh b/solenv/bin/assemble-flatpak-desktop.sh
index 6d06de4fbbbe..411a7feb469a 100755
--- a/solenv/bin/assemble-flatpak-desktop.sh
+++ b/solenv/bin/assemble-flatpak-desktop.sh
@@ -14,29 +14,30 @@
# $1 pathname, ending in a slash, of the directory containing the source libreoffice-*.desktop
# files
# $2 pathname, ending in a slash, of the directory into which to put the target
-# org.libreoffice.LibreOffice.*.desktop files
+# $3.*.desktop files
+# $3 the flatpak ID
set -e
-## libreoffice-*.desktop -> org.libreoffice.LibreOffice.*.desktop:
+## libreoffice-*.desktop -> $3.*.desktop:
for i in "${1?}"libreoffice-*.desktop
do
- sed -e 's/^Icon=libreoffice-/Icon=org.libreoffice.LibreOffice./' "$i" \
- >"${2?}"org.libreoffice.LibreOffice."${i#"${1?}"libreoffice-}"
+ sed -e "s/^Icon=libreoffice-/Icon=${3?}./" "$i" \
+ >"${2?}${3?}"."${i#"${1?}"libreoffice-}"
done
-mv "${2?}"org.libreoffice.LibreOffice.startcenter.desktop "${2?}"org.libreoffice.LibreOffice.desktop
+mv "${2?}${3?}".startcenter.desktop "${2?}${3?}".desktop
# Flatpak .desktop exports take precedence over system ones due to
# the order of XDG_DATA_DIRS - re-associating text/plain seems a bit much
-sed -i "s/text\/plain;//" "${2?}"org.libreoffice.LibreOffice.writer.desktop
+sed -i "s/text\/plain;//" "${2?}${3?}".writer.desktop
desktop-file-edit --set-key=X-Endless-Alias --set-value=libreoffice-startcenter \
--set-key=X-Flatpak-RenamedFrom --set-value='libreoffice-startcenter.desktop;' \
- "${2?}"org.libreoffice.LibreOffice.desktop
+ "${2?}${3?}".desktop
for i in base calc draw impress math writer xsltfilter
do
desktop-file-edit --set-key=X-Endless-Alias --set-value=libreoffice-"$i" \
--set-key=X-Flatpak-RenamedFrom \
- --set-value="libreoffice-$i.desktop;org.libreoffice.LibreOffice-$i.desktop;" \
- "${2?}"org.libreoffice.LibreOffice."$i".desktop
+ --set-value="libreoffice-$i.desktop;${3?}-$i.desktop;" \
+ "${2?}${3?}"."$i".desktop
done
diff --git a/solenv/bin/assemble-flatpak.sh b/solenv/bin/assemble-flatpak.sh
index 9ef9fe1b7d9d..96cf6edb745b 100755
--- a/solenv/bin/assemble-flatpak.sh
+++ b/solenv/bin/assemble-flatpak.sh
@@ -9,7 +9,10 @@
# Assemble Flatpak app files and metadata under /app/, copying from the
# installation tree generated by 'make distro-pack-install' (at
-# $PREFIXDIR):
+# $PREFIXDIR).
+#
+# Arguments:
+# $1 the flatpak ID
set -e
@@ -18,10 +21,10 @@ ln -s /app/libreoffice/program/soffice /app/bin/libreoffice
mkdir -p /app/share/applications
"${SRCDIR?}"/solenv/bin/assemble-flatpak-desktop.sh "${PREFIXDIR?}"/share/applications/ \
- /app/share/applications/
+ /app/share/applications/ "${1?}"
## icons/hicolor/*/apps/libreoffice-* ->
-## icons/hicolor/*/apps/org.libreoffice.LibreOffice-*:
+## icons/hicolor/*/apps/$1-*:
mkdir -p /app/share/icons
for i in "${PREFIXDIR?}"/share/icons/hicolor/*/apps/libreoffice-*
do
@@ -30,7 +33,7 @@ do
cp -a "$i" \
"$(dirname /app/share/icons/hicolor/"${i#"${PREFIXDIR?}"/share/icons/hicolor/}")"/"$(basename "$i")"
cp -a "$i" \
- "$(dirname /app/share/icons/hicolor/"${i#"${PREFIXDIR?}"/share/icons/hicolor/}")"/org.libreoffice.LibreOffice."${i##*/apps/libreoffice-}"
+ "$(dirname /app/share/icons/hicolor/"${i#"${PREFIXDIR?}"/share/icons/hicolor/}")"/"${1?}"."${i##*/apps/libreoffice-}"
done
mkdir -p /app/share/runtime/locale
@@ -67,7 +70,7 @@ do
done
mkdir -p /app/share/appdata
-"${SRCDIR?}"/solenv/bin/assemble-flatpak-appdata.sh /app/share/appdata/ 1
+"${SRCDIR?}"/solenv/bin/assemble-flatpak-appdata.sh /app/share/appdata/ 1 "${1?}"
## see for further places where build-finish would
diff --git a/solenv/flatpak-manifest.in b/solenv/flatpak-manifest.in
index 37405ea6613f..244ec3957051 100644
--- a/solenv/flatpak-manifest.in
+++ b/solenv/flatpak-manifest.in
@@ -899,7 +899,7 @@
"./autogen.sh --prefix=/run/build/libreoffice/inst --with-distro=LibreOfficeFlatpak",
"make check",
"make distro-pack-install",
- "make cmd cmd='$(SRCDIR)/solenv/bin/assemble-flatpak.sh'",
+ "make cmd cmd='$(SRCDIR)/solenv/bin/assemble-flatpak.sh org.libreoffice.LibreOffice'",
"printf '\\nfalse' >/app/libreoffice/share/registry/flatpak.xcd"
]
}