Blame SOURCES/0001-Restructure-solenv-bin-assemble-flatpak.sh.patch

eac0b7
From 54f42e1b75dd795f9d53dce181397f114eeae21b Mon Sep 17 00:00:00 2001
eac0b7
From: Stephan Bergmann <sbergman@redhat.com>
eac0b7
Date: Tue, 28 Apr 2020 16:43:31 +0200
eac0b7
Subject: [PATCH] Restructure solenv/bin/assemble-flatpak.sh
eac0b7
eac0b7
...so that parts of it can be reused by the Flatpak build done from Fedora RPMs
eac0b7
(see <https://src.fedoraproject.org/flatpaks/libreoffice>).  The reused parts
eac0b7
are split out into solenv/bin/assemble-flatpak-*.sh files.
eac0b7
eac0b7
(I can't remember any specific reason why I added the <releases> section to the
eac0b7
Flathub org.libreoffice.LibreOffice.appdata.xml; maybe just because the file
eac0b7
format allows for it and it appeared easy to generate the section when writing
eac0b7
the file.  For the Fedora LO RPMs, none of the existing appdata.xml files
eac0b7
contained such a section, and generating one for the Fedora Flatpak case would
eac0b7
require obtaining values for those LIBO_VERSION_* variables, so I just added a
eac0b7
switch to solenv/bin/assemble-flatpak-appdata-step1.sh allowing not to write
eac0b7
that section at all.  Splitting solenv/bin/assemble-flatpak-appdata.sh in two
eac0b7
steps is necessary because the Fedora Flatpak case wants to replace the
eac0b7
screenshots in the first part of the generated
eac0b7
org.libreoffice.LibreOffice.appdata.xml, but not in the appended original
eac0b7
appdata.xml files, so needs to hook in between those two steps.)
eac0b7
eac0b7
Change-Id: Ic527f3d88ccbee85e86dad3569b8e73776adf273
eac0b7
---
eac0b7
 solenv/bin/assemble-flatpak-appdata-step1.sh |  96 +++++++++++++++++
eac0b7
 solenv/bin/assemble-flatpak-appdata-step2.sh |  26 +++++
eac0b7
 solenv/bin/assemble-flatpak-desktop.sh       |  42 ++++++++
eac0b7
 solenv/bin/assemble-flatpak.sh               | 102 +------------------
eac0b7
 4 files changed, 169 insertions(+), 97 deletions(-)
eac0b7
 create mode 100755 solenv/bin/assemble-flatpak-appdata-step1.sh
eac0b7
 create mode 100755 solenv/bin/assemble-flatpak-appdata-step2.sh
eac0b7
 create mode 100755 solenv/bin/assemble-flatpak-desktop.sh
eac0b7
eac0b7
diff --git a/solenv/bin/assemble-flatpak-appdata-step1.sh b/solenv/bin/assemble-flatpak-appdata-step1.sh
eac0b7
new file mode 100755
eac0b7
index 000000000000..4658dd45d018
eac0b7
--- /dev/null
eac0b7
+++ b/solenv/bin/assemble-flatpak-appdata-step1.sh
eac0b7
@@ -0,0 +1,96 @@
eac0b7
+#! /bin/bash
eac0b7
+#
eac0b7
+# This file is part of the LibreOffice project.
eac0b7
+#
eac0b7
+# This Source Code Form is subject to the terms of the Mozilla Public
eac0b7
+# License, v. 2.0. If a copy of the MPL was not distributed with this
eac0b7
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
eac0b7
+#
eac0b7
+
eac0b7
+# Part of solenv/bin/assemble-flatpak.sh that is shared with a downstream mechanism of building a
eac0b7
+# Flatpak from a Fedora libreoffice.spec file.
eac0b7
+#
eac0b7
+# Arguments:
eac0b7
+# $1  pathname, ending in a slash, of the directory into which to put the target
eac0b7
+#     org.libreoffice.LibreOffice.appdata.xml file
eac0b7
+# $2  "1" if a <releases> section shall be included in the target
eac0b7
+#     org.libreoffice.LibreOffice.appdata.xml file, "0" if not
eac0b7
+
eac0b7
+set -e
eac0b7
+
eac0b7
+## org.libreoffice.LibreOffice.appdata.xml is manually derived from the various
eac0b7
+## inst/share/appdata/libreoffice-*.appdata.xml (at least recent GNOME Software
eac0b7
+## doesn't show more than five screenshots anyway, so restrict to one each from
eac0b7
+## the five libreoffice-*.appdata.xml: Writer, Calc, Impress, Draw, Base):
eac0b7
+cat <<\EOF >"${1?}"org.libreoffice.LibreOffice.appdata.xml
eac0b7
+
eac0b7
+<component type="desktop">
eac0b7
+ <id>org.libreoffice.LibreOffice.desktop</id>
eac0b7
+ <metadata_license>CC0-1.0</metadata_license>
eac0b7
+ <project_license>MPL-2.0</project_license>
eac0b7
+ <name>LibreOffice</name>
eac0b7
+ <summary>The LibreOffice productivity suite</summary>
eac0b7
+ <description>
eac0b7
+  

LibreOffice is a powerful office suite. Its clean interface and

eac0b7
+  feature-rich tools help you unleash your creativity and enhance your
eac0b7
+  productivity.  LibreOffice includes several applications that make it the most
eac0b7
+  powerful Free and Open Source office suite on the market: Writer (word
eac0b7
+  processing), Calc (spreadsheets), Impress (presentations), Draw (vector
eac0b7
+  graphics and flowcharts), Base (databases), and Math (formula editing).

eac0b7
+  

LibreOffice supports opening and saving into a wide variety of formats, so

eac0b7
+  you can easily share documents with users of other popular office suites
eac0b7
+  without worrying about compatibility.

eac0b7
+ </description>
eac0b7
+ <url type="homepage">http://www.libreoffice.org/discover/libreoffice/</url>
eac0b7
+ <url type="bugtracker">https://bugs.documentfoundation.org/</url>
eac0b7
+ <url type="donation">https://donate.libreoffice.org/</url>
eac0b7
+ <url type="faq">https://wiki.documentfoundation.org/Faq</url>
eac0b7
+ <url type="help">http://www.libreoffice.org/get-help/documentation/</url>
eac0b7
+ <url type="translate">https://wiki.documentfoundation.org/Translating_LibreOffice</url>
eac0b7
+ <screenshots>
eac0b7
+  <screenshot type="default">
eac0b7
+   <image>https://hub.libreoffice.org/screenshots/writer-01.png</image>
eac0b7
+   <caption></caption>
eac0b7
+  </screenshot>
eac0b7
+  <screenshot>
eac0b7
+   <image>https://hub.libreoffice.org/screenshots/calc-02.png</image>
eac0b7
+   <caption></caption>
eac0b7
+  </screenshot>
eac0b7
+  <screenshot>
eac0b7
+   <image>https://hub.libreoffice.org/screenshots/impress-01.png</image>
eac0b7
+   <caption></caption>
eac0b7
+  </screenshot>
eac0b7
+  <screenshot>
eac0b7
+   <image>https://hub.libreoffice.org/screenshots/draw-02.png</image>
eac0b7
+   <caption></caption>
eac0b7
+  </screenshot>
eac0b7
+  <screenshot>
eac0b7
+   <image>https://hub.libreoffice.org/screenshots/base-02.png</image>
eac0b7
+   <caption></caption>
eac0b7
+  </screenshot>
eac0b7
+ </screenshots>
eac0b7
+ <developer_name>The Document Foundation</developer_name>
eac0b7
+ <update_contact>libreoffice_at_lists.freedesktop.org</update_contact>
eac0b7
+ <kudos>
eac0b7
+  <kudo>HiDpiIcon</kudo>
eac0b7
+  <kudo>HighContrast</kudo>
eac0b7
+  <kudo>ModernToolkit</kudo>
eac0b7
+  <kudo>UserDocs</kudo>
eac0b7
+ </kudos>
eac0b7
+ <content_rating type="oars-1.0"/>
eac0b7
+EOF
eac0b7
+
eac0b7
+if [ "${2?}" = 1 ]
eac0b7
+then
eac0b7
+ cat <<EOF >>"${1?}"org.libreoffice.LibreOffice.appdata.xml
eac0b7
+ <releases>
eac0b7
+  
eac0b7
+    version="${LIBO_VERSION_MAJOR?}.${LIBO_VERSION_MINOR?}.${LIBO_VERSION_MICRO?}.${LIBO_VERSION_PATCH?}"
eac0b7
+    date="$(date +%Y-%m-%d)"/>
eac0b7
+ </releases>
eac0b7
+EOF
eac0b7
+fi
eac0b7
+
eac0b7
+cat <<\EOF >>"${1?}"org.libreoffice.LibreOffice.appdata.xml
eac0b7
+</component>
eac0b7
+EOF
eac0b7
diff --git a/solenv/bin/assemble-flatpak-appdata-step2.sh b/solenv/bin/assemble-flatpak-appdata-step2.sh
eac0b7
new file mode 100755
eac0b7
index 000000000000..4f06e6b19148
eac0b7
--- /dev/null
eac0b7
+++ b/solenv/bin/assemble-flatpak-appdata-step2.sh
eac0b7
@@ -0,0 +1,26 @@
eac0b7
+#! /bin/bash
eac0b7
+#
eac0b7
+# This file is part of the LibreOffice project.
eac0b7
+#
eac0b7
+# This Source Code Form is subject to the terms of the Mozilla Public
eac0b7
+# License, v. 2.0. If a copy of the MPL was not distributed with this
eac0b7
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
eac0b7
+#
eac0b7
+
eac0b7
+# Part of solenv/bin/assemble-flatpak.sh that is shared with a downstream mechanism of building a
eac0b7
+# Flatpak from a Fedora libreoffice.spec file.
eac0b7
+#
eac0b7
+# Arguments:
eac0b7
+# $1  pathname, ending in a slash, of the directory containing the source libreoffice-*.appdata.xml
eac0b7
+#     files
eac0b7
+# $2  pathname, ending in a slash, of the directory containing the target
eac0b7
+#     org.libreoffice.LibreOffice.appdata.xml file
eac0b7
+
eac0b7
+set -e
eac0b7
+
eac0b7
+# append the appdata for the different components
eac0b7
+for i in "${1?}"libreoffice-*.appdata.xml
eac0b7
+do
eac0b7
+  sed "1 d; s/<id>libreoffice-/<id>org.libreoffice.LibreOffice./" "$i" \
eac0b7
+    >>"${2?}"org.libreoffice.LibreOffice.appdata.xml
eac0b7
+done
eac0b7
diff --git a/solenv/bin/assemble-flatpak-desktop.sh b/solenv/bin/assemble-flatpak-desktop.sh
eac0b7
new file mode 100755
eac0b7
index 000000000000..6d06de4fbbbe
eac0b7
--- /dev/null
eac0b7
+++ b/solenv/bin/assemble-flatpak-desktop.sh
eac0b7
@@ -0,0 +1,42 @@
eac0b7
+#! /bin/bash
eac0b7
+#
eac0b7
+# This file is part of the LibreOffice project.
eac0b7
+#
eac0b7
+# This Source Code Form is subject to the terms of the Mozilla Public
eac0b7
+# License, v. 2.0. If a copy of the MPL was not distributed with this
eac0b7
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
eac0b7
+#
eac0b7
+
eac0b7
+# Part of solenv/bin/assemble-flatpak.sh that is shared with a downstream mechanism of building a
eac0b7
+# Flatpak from a Fedora libreoffice.spec file.
eac0b7
+#
eac0b7
+# Arguments:
eac0b7
+# $1  pathname, ending in a slash, of the directory containing the source libreoffice-*.desktop
eac0b7
+#     files
eac0b7
+# $2  pathname, ending in a slash, of the directory into which to put the target
eac0b7
+#     org.libreoffice.LibreOffice.*.desktop files
eac0b7
+
eac0b7
+set -e
eac0b7
+
eac0b7
+## libreoffice-*.desktop -> org.libreoffice.LibreOffice.*.desktop:
eac0b7
+for i in "${1?}"libreoffice-*.desktop
eac0b7
+do
eac0b7
+ sed -e 's/^Icon=libreoffice-/Icon=org.libreoffice.LibreOffice./' "$i" \
eac0b7
+  >"${2?}"org.libreoffice.LibreOffice."${i#"${1?}"libreoffice-}"
eac0b7
+done
eac0b7
+mv "${2?}"org.libreoffice.LibreOffice.startcenter.desktop "${2?}"org.libreoffice.LibreOffice.desktop
eac0b7
+
eac0b7
+# Flatpak .desktop exports take precedence over system ones due to
eac0b7
+# the order of XDG_DATA_DIRS - re-associating text/plain seems a bit much
eac0b7
+sed -i "s/text\/plain;//" "${2?}"org.libreoffice.LibreOffice.writer.desktop
eac0b7
+
eac0b7
+desktop-file-edit --set-key=X-Endless-Alias --set-value=libreoffice-startcenter \
eac0b7
+ --set-key=X-Flatpak-RenamedFrom --set-value='libreoffice-startcenter.desktop;' \
eac0b7
+ "${2?}"org.libreoffice.LibreOffice.desktop
eac0b7
+for i in base calc draw impress math writer xsltfilter
eac0b7
+do
eac0b7
+ desktop-file-edit --set-key=X-Endless-Alias --set-value=libreoffice-"$i" \
eac0b7
+  --set-key=X-Flatpak-RenamedFrom \
eac0b7
+  --set-value="libreoffice-$i.desktop;org.libreoffice.LibreOffice-$i.desktop;" \
eac0b7
+  "${2?}"org.libreoffice.LibreOffice."$i".desktop
eac0b7
+done
eac0b7
diff --git a/solenv/bin/assemble-flatpak.sh b/solenv/bin/assemble-flatpak.sh
eac0b7
index 0738fcd59ad2..8ca5bcf08c41 100755
eac0b7
--- a/solenv/bin/assemble-flatpak.sh
eac0b7
+++ b/solenv/bin/assemble-flatpak.sh
eac0b7
@@ -16,30 +16,9 @@ set -e
eac0b7
 cp -r "${PREFIXDIR?}"/lib/libreoffice /app/
eac0b7
 ln -s /app/libreoffice/program/soffice /app/bin/libreoffice
eac0b7
 
eac0b7
-## libreoffice-*.desktop -> org.libreoffice.LibreOffice.*.desktop:
eac0b7
 mkdir -p /app/share/applications
eac0b7
-for i in "${PREFIXDIR?}"/share/applications/libreoffice-*.desktop
eac0b7
-do
eac0b7
- sed -e 's/^Icon=libreoffice-/Icon=org.libreoffice.LibreOffice./' "$i" \
eac0b7
-  >/app/share/applications/org.libreoffice.LibreOffice."${i#"${PREFIXDIR?}"/share/applications/libreoffice-}"
eac0b7
-done
eac0b7
-mv /app/share/applications/org.libreoffice.LibreOffice.startcenter.desktop \
eac0b7
- /app/share/applications/org.libreoffice.LibreOffice.desktop
eac0b7
-
eac0b7
-# Flatpak .desktop exports take precedence over system ones due to
eac0b7
-# the order of XDG_DATA_DIRS - re-associating text/plain seems a bit much
eac0b7
-sed -i "s/text\/plain;//" /app/share/applications/org.libreoffice.LibreOffice.writer.desktop
eac0b7
-
eac0b7
-desktop-file-edit --set-key=X-Endless-Alias --set-value=libreoffice-startcenter \
eac0b7
- --set-key=X-Flatpak-RenamedFrom --set-value='libreoffice-startcenter.desktop;' \
eac0b7
- /app/share/applications/org.libreoffice.LibreOffice.desktop
eac0b7
-for i in base calc draw impress math writer xsltfilter
eac0b7
-do
eac0b7
- desktop-file-edit --set-key=X-Endless-Alias --set-value=libreoffice-"$i" \
eac0b7
-  --set-key=X-Flatpak-RenamedFrom \
eac0b7
-  --set-value="libreoffice-$i.desktop;org.libreoffice.LibreOffice-$i.desktop;" \
eac0b7
-  /app/share/applications/org.libreoffice.LibreOffice."$i".desktop
eac0b7
-done
eac0b7
+"${SRCDIR?}"/solenv/bin/assemble-flatpak-desktop.sh "${PREFIXDIR?}"/share/applications/ \
eac0b7
+ /app/share/applications/
eac0b7
 
eac0b7
 ## icons/hicolor/*/apps/libreoffice-* ->
eac0b7
 ## icons/hicolor/*/apps/org.libreoffice.LibreOffice-*:
eac0b7
@@ -82,81 +61,10 @@ do
eac0b7
   ln -rs /app/share/runtime/locale/"${lang}"/registry/"${basename}".xcd "${i}"
eac0b7
 done
eac0b7
 
eac0b7
-## org.libreoffice.LibreOffice.appdata.xml is manually derived from the various
eac0b7
-## inst/share/appdata/libreoffice-*.appdata.xml (at least recent GNOME Software
eac0b7
-## doesn't show more than five screenshots anyway, so restrict to one each from
eac0b7
-## the five libreoffice-*.appdata.xml: Writer, Calc, Impress, Draw, Base):
eac0b7
 mkdir -p /app/share/appdata
eac0b7
-cat <<EOF >/app/share/appdata/org.libreoffice.LibreOffice.appdata.xml
eac0b7
-
eac0b7
-<component type="desktop">
eac0b7
- <id>org.libreoffice.LibreOffice.desktop</id>
eac0b7
- <metadata_license>CC0-1.0</metadata_license>
eac0b7
- <project_license>MPL-2.0</project_license>
eac0b7
- <name>LibreOffice</name>
eac0b7
- <summary>The LibreOffice productivity suite</summary>
eac0b7
- <description>
eac0b7
-  

LibreOffice is a powerful office suite. Its clean interface and

eac0b7
-  feature-rich tools help you unleash your creativity and enhance your
eac0b7
-  productivity.  LibreOffice includes several applications that make it the most
eac0b7
-  powerful Free and Open Source office suite on the market: Writer (word
eac0b7
-  processing), Calc (spreadsheets), Impress (presentations), Draw (vector
eac0b7
-  graphics and flowcharts), Base (databases), and Math (formula editing).

eac0b7
-  

LibreOffice supports opening and saving into a wide variety of formats, so

eac0b7
-  you can easily share documents with users of other popular office suites
eac0b7
-  without worrying about compatibility.

eac0b7
- </description>
eac0b7
- <url type="homepage">http://www.libreoffice.org/discover/libreoffice/</url>
eac0b7
- <url type="bugtracker">https://bugs.documentfoundation.org/</url>
eac0b7
- <url type="donation">https://donate.libreoffice.org/</url>
eac0b7
- <url type="faq">https://wiki.documentfoundation.org/Faq</url>
eac0b7
- <url type="help">http://www.libreoffice.org/get-help/documentation/</url>
eac0b7
- <url type="translate">https://wiki.documentfoundation.org/Translating_LibreOffice</url>
eac0b7
- <screenshots>
eac0b7
-  <screenshot type="default">
eac0b7
-   <image>https://hub.libreoffice.org/screenshots/writer-01.png</image>
eac0b7
-   <caption></caption>
eac0b7
-  </screenshot>
eac0b7
-  <screenshot>
eac0b7
-   <image>https://hub.libreoffice.org/screenshots/calc-02.png</image>
eac0b7
-   <caption></caption>
eac0b7
-  </screenshot>
eac0b7
-  <screenshot>
eac0b7
-   <image>https://hub.libreoffice.org/screenshots/impress-01.png</image>
eac0b7
-   <caption></caption>
eac0b7
-  </screenshot>
eac0b7
-  <screenshot>
eac0b7
-   <image>https://hub.libreoffice.org/screenshots/draw-02.png</image>
eac0b7
-   <caption></caption>
eac0b7
-  </screenshot>
eac0b7
-  <screenshot>
eac0b7
-   <image>https://hub.libreoffice.org/screenshots/base-02.png</image>
eac0b7
-   <caption></caption>
eac0b7
-  </screenshot>
eac0b7
- </screenshots>
eac0b7
- <developer_name>The Document Foundation</developer_name>
eac0b7
- <update_contact>libreoffice_at_lists.freedesktop.org</update_contact>
eac0b7
- <kudos>
eac0b7
-  <kudo>HiDpiIcon</kudo>
eac0b7
-  <kudo>HighContrast</kudo>
eac0b7
-  <kudo>ModernToolkit</kudo>
eac0b7
-  <kudo>UserDocs</kudo>
eac0b7
- </kudos>
eac0b7
- <content_rating type="oars-1.0"/>
eac0b7
- <releases>
eac0b7
-  
eac0b7
-    version="${LIBO_VERSION_MAJOR?}.${LIBO_VERSION_MINOR?}.${LIBO_VERSION_MICRO?}.${LIBO_VERSION_PATCH?}"
eac0b7
-    date="$(date +%Y-%m-%d)"/>
eac0b7
- </releases>
eac0b7
-</component>
eac0b7
-EOF
eac0b7
-
eac0b7
-# append the appdata for the different components
eac0b7
-for i in "${PREFIXDIR?}"/share/appdata/libreoffice-*.appdata.xml
eac0b7
-do
eac0b7
-  sed "1 d; s/<id>libreoffice-/<id>org.libreoffice.LibreOffice./" "$i" \
eac0b7
-    >>/app/share/appdata/org.libreoffice.LibreOffice.appdata.xml
eac0b7
-done
eac0b7
+"${SRCDIR?}"/solenv/bin/assemble-flatpak-appdata-step1.sh /app/share/appdata/ 1
eac0b7
+"${SRCDIR?}"/solenv/bin/assemble-flatpak-appdata-step2.sh "${PREFIXDIR?}"/share/appdata/ \
eac0b7
+ /app/share/appdata/
eac0b7
 
eac0b7
 ## see 
eac0b7
 ## flatpak-builtins-build-finish.c> for further places where build-finish would
eac0b7
-- 
eac0b7
2.26.2
eac0b7