From 3af0b56c48d798fc9502f89d67a499f1ff7e494b Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 16 Jun 2023 10:25:32 +0200 Subject: [PATCH 1/2] build: Check for NEWS and appdata updates for new releases At least 4 different bugs were filed against the Flathub version of evince because Flatpak prominently shows the appdata version in the UI, making users think that there was a bug in the packaging, or that the package had not been updated. Avoid this problem in the future by failing the build if the NEWS or appdata files aren't updated on release. --- check-news.sh | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++ meson.build | 17 +++++++++++ 2 files changed, 99 insertions(+) create mode 100755 check-news.sh diff --git a/check-news.sh b/check-news.sh new file mode 100755 index 000000000..e7e8fa6bb --- /dev/null +++ b/check-news.sh @@ -0,0 +1,82 @@ +#!/bin/sh + +# Copyright (C) 2019 Red Hat, Inc. +# Author: Bastien Nocera +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + + +# Add to your top-level meson.build to check for an updated NEWS file +# when doing a "dist" release, similarly to automake's check-news: +# https://www.gnu.org/software/automake/manual/html_node/List-of-Automake-options.html +# +# Checks NEWS for the version number: +# meson.add_dist_script( +# find_program('check-news.sh').path(), +# '@0@'.format(meson.project_version()) +# ) +# +# Checks NEWS and data/foo.appdata.xml for the version number: +# meson.add_dist_script( +# find_program('check-news.sh').path(), +# '@0@'.format(meson.project_version()), +# 'NEWS', +# 'data/foo.appdata.xml' +# ) + +usage() +{ + echo "$0 VERSION [FILES...]" + exit 1 +} + +check_version() +{ + VERSION=$1 + # Look in the first 15 lines for NEWS files, but look + # everywhere for other types of files + if [ "$2" = "NEWS" ]; then + DATA=`sed 15q $SRC_ROOT/"$2"` + else + DATA=`cat $SRC_ROOT/"$2"` + fi + case "$DATA" in + *"$VERSION"*) + : + ;; + *) + echo "$2 not updated; not releasing" 1>&2; + exit 1 + ;; + esac +} + +SRC_ROOT=${MESON_DIST_ROOT:-"./"} + +if [ $# -lt 1 ] ; then usage ; fi + +VERSION=$1 +shift + +if [ $# -eq 0 ] ; then + check_version $VERSION 'NEWS' + exit 0 +fi + +for i in $@ ; do + check_version $VERSION "$i" +done + +exit 0 diff --git a/meson.build b/meson.build index b1990a872..de2217d7e 100644 --- a/meson.build +++ b/meson.build @@ -525,6 +525,23 @@ gnome.post_install( update_desktop_database: true, ) +is_stable = (ev_minor_version != 'alpha' and + ev_minor_version != 'beta' and + ev_minor_version != 'rc') +if is_stable + meson.add_dist_script( + find_program('check-news.sh').full_path(), + '@0@'.format(meson.project_version()), + 'NEWS', + 'org.gnome.Evince.appdata.xml.in' + ) +else + meson.add_dist_script( + find_program('check-news.sh').full_path(), + '@0@'.format(meson.project_version()), + 'NEWS', + ) +endif summary({'Platform...................': ev_platform, 'Debug mode.................': ev_debug, -- GitLab From 82cdd057367b80fc515c78febc23b5fbb46df11a Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Sun, 18 Jun 2023 11:57:24 +0200 Subject: [PATCH 2/2] build: Add support for validating appdata versions This will avoid old dates from being mentioned in the appdata file, as happened in evince. This requires a version of appstream-util with the get-latest-version command: https://github.com/hughsie/appstream-glib/pull/468 See https://gitlab.gnome.org/GNOME/evince/-/issues/1950 --- check-news.sh | 25 +++++++++++++++++++++++++ meson.build | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/check-news.sh b/check-news.sh index e7e8fa6bb..24a2ea10b 100755 --- a/check-news.sh +++ b/check-news.sh @@ -63,6 +63,23 @@ check_version() esac } +has_verify_latest_version() +{ + appstream-util 2>&1 | grep -q get-latest-version + return $? +} + +verify_latest_version() +{ + VERSION=$1 + FILE=$SRC_ROOT/"$2" + LATEST_VERSION=`appstream-util get-latest-version "$FILE" | tr -d '\d'` + if [ "$LATEST_VERSION" != "$VERSION" ] ; then + echo "Expected latest version $VERSION in $FILE, got $LATEST_VERSION" + exit 1 + fi +} + SRC_ROOT=${MESON_DIST_ROOT:-"./"} if [ $# -lt 1 ] ; then usage ; fi @@ -76,6 +93,14 @@ if [ $# -eq 0 ] ; then fi for i in $@ ; do + case "$i" in + *"metainfo"*) + if has_verify_latest_version ; then + verify_latest_version $VERSION "$i" + fi + ;; + esac + check_version $VERSION "$i" done diff --git a/meson.build b/meson.build index de2217d7e..c0ab3d224 100644 --- a/meson.build +++ b/meson.build @@ -533,7 +533,7 @@ if is_stable find_program('check-news.sh').full_path(), '@0@'.format(meson.project_version()), 'NEWS', - 'org.gnome.Evince.appdata.xml.in' + 'org.gnome.Evince.metainfo.xml.in' ) else meson.add_dist_script( -- GitLab