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

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

LibreOffice is a powerful office suite. Its clean interface and

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

d289e2
+  

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

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

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

LibreOffice is a powerful office suite. Its clean interface and

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

d289e2
-  

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

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

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