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

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

LibreOffice is a powerful office suite. Its clean interface and

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

9317df
+  

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

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

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

LibreOffice is a powerful office suite. Its clean interface and

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

9317df
-  

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

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

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