office-gobmx/solenv/bin/assemble-flatpak.sh
Stephan Bergmann 0a13609598 Add content_rating to AppData files
At least building on Flathub makes presence of this information a hard
requirement now (see <https://blogs.gnome.org/hughsie/2019/03/28/
new-appstream-validation-requirements/> and witness the failed
<https://flathub.org/builds/#/builders/32/builds/3597>).

The suggested way to calculate that information is via the form at
<https://hughsie.github.io/oars/generate.html>, which I filled in as follows
(the answers I selected are prefixed with "=>"):

> By answering all the questions you can generate AppStream-compatible markup
> for the upstream AppData file.
>
> If the user is able to "enable" NSFW or "adult" content, then this should be
> included in the assessment even if it is turned off by default.
>
> What type of component are you generating content for:

=> Application that can connect to the Internet

> OARS has multiple versions, and the newer versions include more questions
> involving specific cultural and religious sensitivities. What version of OARS
> metadata do you want to produce:

=> 1.0 (works with all clients)

> Advertising
>
> Defined as the activity of producing advertisements for commercial products or
> services.
>
> For example, this would include banners showing the Coca-Cola logo shown in a
> Soccer game.

=> None

> Gambling
>
> Defined as taking a risky action in the hope of a desired result.
>
> For example, this would include spinning a wheel to get in-app credits.

=> None

> In-App Purchases
>
> Defined as items or points that a user can buy for use within a virtual world
> to improve a character or enhance the playing experience.

=> None

> Online Text-only Messaging
>
> Defined as any messaging system connected to the Internet.

=> None

> Online Audio and Video Messaging
>
> Defined as any multimedia messaging system connected to the Internet.

=> None

> Contact Details
>
> Defined as sharing identifiable details with other users to allow out-of-band
> communication.

=> None

> Information Sharing
>
> Defined as sharing information with a legal entity typically used for
> advertising or for sending back diagnostic data.
>
> For example, this would include sending your purchasing history to Amazon.

=> None

> Location Sharing
>
> Defined as sharing your physical real-time location.
>
> For example, this would include uploading the GPS co-ordinates of your current
> location. NOTE: This does not include heuristic based location services, e.g.
> GeoIP and others.

=> None

> The following markup can be pasted into the existing application AppData file.
>
> <content_rating type="oars-1.0" />

Change-Id: I063484d8031892c20f88999c5a9beeae3666511c
Reviewed-on: https://gerrit.libreoffice.org/72581
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
2019-05-21 10:50:57 +02:00

165 lines
6.9 KiB
Bash
Executable file

#! /bin/bash
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# Assemble Flatpak app files and metadata under /app/, copying from the
# installation tree generated by 'make distro-pack-install' (at
# $PREFIXDIR):
set -e
cp -r "${PREFIXDIR?}"/lib/libreoffice /app/
## libreoffice-*.desktop -> org.libreoffice.LibreOffice.*.desktop:
mkdir -p /app/share/applications
for i in "${PREFIXDIR?}"/share/applications/libreoffice-*.desktop
do
sed -e 's,^Exec=libreoffice,Exec=/app/libreoffice/program/soffice,' \
-e 's/^Icon=libreoffice-/Icon=org.libreoffice.LibreOffice./' "$i" \
>/app/share/applications/org.libreoffice.LibreOffice."${i#"${PREFIXDIR?}"/share/applications/libreoffice-}"
done
mv /app/share/applications/org.libreoffice.LibreOffice.startcenter.desktop \
/app/share/applications/org.libreoffice.LibreOffice.desktop
# Flatpak .desktop exports take precedence over system ones due to
# the order of XDG_DATA_DIRS - re-associating text/plain seems a bit much
sed -i "s/text\/plain;//" /app/share/applications/org.libreoffice.LibreOffice.writer.desktop
desktop-file-edit --set-key=X-Endless-Alias --set-value=libreoffice-startcenter \
--set-key=X-Flatpak-RenamedFrom --set-value='libreoffice-startcenter.desktop;' \
/app/share/applications/org.libreoffice.LibreOffice.desktop
for i in base calc draw impress math writer xsltfilter
do
desktop-file-edit --set-key=X-Endless-Alias --set-value=libreoffice-"$i" \
--set-key=X-Flatpak-RenamedFrom \
--set-value="libreoffice-$i.desktop;org.libreoffice.LibreOffice-$i.desktop;" \
/app/share/applications/org.libreoffice.LibreOffice."$i".desktop
done
## icons/hicolor/*/apps/libreoffice-* ->
## icons/hicolor/*/apps/org.libreoffice.LibreOffice-*:
mkdir -p /app/share/icons
for i in "${PREFIXDIR?}"/share/icons/hicolor/*/apps/libreoffice-*
do
mkdir -p \
"$(dirname /app/share/icons/hicolor/"${i#"${PREFIXDIR?}"/share/icons/hicolor/}")"
cp -a "$i" \
"$(dirname /app/share/icons/hicolor/"${i#"${PREFIXDIR?}"/share/icons/hicolor/}")"/"$(basename "$i")"
cp -a "$i" \
"$(dirname /app/share/icons/hicolor/"${i#"${PREFIXDIR?}"/share/icons/hicolor/}")"/org.libreoffice.LibreOffice."${i##*/apps/libreoffice-}"
done
mkdir -p /app/share/runtime/locale
for i in $(ls /app/libreoffice/program/resource)
do
lang="${i%[_@]*}"
mkdir -p /app/share/runtime/locale/"${lang}"/resource
mv /app/libreoffice/program/resource/"${i}" /app/share/runtime/locale/"${lang}"/resource
ln -s ../../../share/runtime/locale/"${lang}"/resource/"${i}" /app/libreoffice/program/resource
done
for i in /app/libreoffice/share/registry/Langpack-*.xcd /app/libreoffice/share/registry/res/{fcfg_langpack,registry}_*.xcd
do
basename="$(basename "${i}" .xcd)"
lang="${basename#Langpack-}"
lang="${lang#fcfg_langpack_}"
lang="${lang#registry_}"
# ship the base app with at least one Langpack/fcfg_langpack
if [ "${lang}" = "en-US" ]
then
continue
fi
lang="${lang%-*}"
mkdir -p /app/share/runtime/locale/"${lang}"/registry
mv "${i}" /app/share/runtime/locale/"${lang}"/registry
ln -rs /app/share/runtime/locale/"${lang}"/registry/"${basename}".xcd "${i}"
done
## org.libreoffice.LibreOffice.appdata.xml is manually derived from the various
## inst/share/appdata/libreoffice-*.appdata.xml (at least recent GNOME Software
## doesn't show more than five screenshots anyway, so restrict to one each from
## the five libreoffice-*.appdata.xml: Writer, Calc, Impress, Draw, Base):
mkdir -p /app/share/appdata
cat <<EOF >/app/share/appdata/org.libreoffice.LibreOffice.appdata.xml
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>org.libreoffice.LibreOffice.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>MPL-2.0</project_license>
<name>LibreOffice</name>
<summary>The LibreOffice productivity suite</summary>
<description>
<p>LibreOffice is a powerful office suite. Its clean interface and
feature-rich tools help you unleash your creativity and enhance your
productivity. LibreOffice includes several applications that make it the most
powerful Free and Open Source office suite on the market: Writer (word
processing), Calc (spreadsheets), Impress (presentations), Draw (vector
graphics and flowcharts), Base (databases), and Math (formula editing).</p>
<p>LibreOffice supports opening and saving into a wide variety of formats, so
you can easily share documents with users of other popular office suites
without worrying about compatibility.</p>
</description>
<url type="homepage">http://www.libreoffice.org/discover/libreoffice/</url>
<url type="bugtracker">https://bugs.documentfoundation.org/</url>
<url type="donation">https://donate.libreoffice.org/</url>
<url type="faq">https://wiki.documentfoundation.org/Faq</url>
<url type="help">http://www.libreoffice.org/get-help/documentation/</url>
<url type="translate">https://wiki.documentfoundation.org/Translating_LibreOffice</url>
<screenshots>
<screenshot type="default">
<image>https://hub.libreoffice.org/screenshots/writer-01.png</image>
<caption><!-- Describe this screenshot in less than ~10 words --></caption>
</screenshot>
<screenshot>
<image>https://hub.libreoffice.org/screenshots/calc-02.png</image>
<caption><!-- Describe this screenshot in less than ~10 words --></caption>
</screenshot>
<screenshot>
<image>https://hub.libreoffice.org/screenshots/impress-01.png</image>
<caption><!-- Describe this screenshot in less than ~10 words --></caption>
</screenshot>
<screenshot>
<image>https://hub.libreoffice.org/screenshots/draw-02.png</image>
<caption><!-- Describe this screenshot in less than ~10 words --></caption>
</screenshot>
<screenshot>
<image>https://hub.libreoffice.org/screenshots/base-02.png</image>
<caption><!-- Describe this screenshot in less than ~10 words --></caption>
</screenshot>
</screenshots>
<developer_name>The Document Foundation</developer_name>
<update_contact>libreoffice_at_lists.freedesktop.org</update_contact>
<kudos>
<kudo>HiDpiIcon</kudo>
<kudo>HighContrast</kudo>
<kudo>ModernToolkit</kudo>
<kudo>UserDocs</kudo>
</kudos>
<content_rating type="oars-1.0"/>
<releases>
<release
version="${LIBO_VERSION_MAJOR?}.${LIBO_VERSION_MINOR?}.${LIBO_VERSION_MICRO?}.${LIBO_VERSION_PATCH?}"
date="$(date +%Y-%m-%d)"/>
</releases>
</component>
EOF
# append the appdata for the different components
for i in "${PREFIXDIR?}"/share/appdata/libreoffice-*.appdata.xml
do
sed "1 d; s/<id>libreoffice-/<id>org.libreoffice.LibreOffice./" "$i" \
>>/app/share/appdata/org.libreoffice.LibreOffice.appdata.xml
done
## see <https://github.com/flatpak/flatpak/blob/master/app/
## flatpak-builtins-build-finish.c> for further places where build-finish would
## look for data:
## cp ... /app/share/dbus-1/services/
## cp ... /app/share/gnome-shell/search-providers/