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

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

LibreOffice is a powerful office suite. Its clean interface and

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

2654e0
+  

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

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

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

LibreOffice is a powerful office suite. Its clean interface and

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

2654e0
-  

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

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

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