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

LibreOffice is a powerful office suite. Its clean interface and

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

8461bb4
+  

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

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

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

LibreOffice is a powerful office suite. Its clean interface and

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

8461bb4
-  

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

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

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