File: check-consistency

package info (click to toggle)
gmobile 0.3.1-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 632 kB
  • sloc: ansic: 2,079; sh: 36; xml: 31; makefile: 10; javascript: 6
file content (102 lines) | stat: -rwxr-xr-x 2,481 bytes parent folder | download | duplicates (19)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/bin/bash
#
# Copyright (C) 2024 The Phosh developers
# SPDX-License-Identifier: GPL-3.0-or-later
# Author: Guido Günther <agx@sigxcpu.org>
#
# Check if NEWS, changelog, meson and metainfo are in sync

set -e

COLOR=
if [ -n "${TERM}" ] && [ "${TERM}" != "dumb" ]; then
  COLOR=1
fi

function log
{
    local level="${1}"
    local fd=2
    local use_color

    shift
    if [ -n "${COLOR}" ]; then
        [ "${level}" == warn ] || [ "${level}" == error ] || fd=1
        ! [ -t "${fd}" ] || use_color=1

        if [ -n "${use_color}" ]; then
            case "${level}" in
                warn)
                    tput setaf 1
                    ;;
                error)
                    tput bold; tput setaf 1
                    ;;
                info)
                    tput setaf 2
                    ;;
            esac
        fi
    fi

    echo "$@"

    [ -z "${use_color}" ] || tput sgr0
}


if [ -f debian/changelog ]; then
    log info "Fetching version from d/changelog"
    VERSION=$(dpkg-parsechangelog -SVersion)
elif [ -f meson.build ]; then
    log info "Fetching version from meson build file"
    VERSION=$(sed -n "s/.*version\s*:\s*'\([0-9].*\)'.*/\1/p" meson.build)
else
    log error "E: Don't know how to get version information"
    exit 1
fi

echo "I: Checking for '${VERSION}'"

# News
if ! head -1 NEWS | grep -E -qs "\s+${VERSION}\s*$"; then
    log error "E: Version ${VERSION} not in NEWS file"
    if [[ "${VERSION}" =~ (~|-)dev ]]; then
        log info "I: Unreleased development version, no need to check NEWS"
    else
        exit 1
    fi
else
    log info "I: Found matching news entry"
fi

# meson.build
MESON_VERSION="${VERSION/\~/.}"
if [ -f meson.build ]; then
    if ! grep -qs "version\s*:\s*'$MESON_VERSION'" meson.build; then
        log error  "E: Version ${MESON_VERSION} not in meson.build file"
        exit 1
    else
        log info "I: Found matching meson version entry"
    fi
else
    log info "I: no meson project"
fi

# appstream info
METAINFO=$(ls data/*metainfo.xml.in* 2>/dev/null || true)
if [ -z "${METAINFO}" ]; then
    log warn "W: No metainfo"
    exit 0
fi

if ! grep -qs "$MESON_VERSION\"" "${METAINFO}"; then
    log error "E: Version ${MESON_VERSION} not in metainfo ${METAINFO}"
    if [[ "${VERSION}" =~ (~|-)(alpha|beta|dev|rc) ]]; then
        log info "I: Not a stable release, no metainfo is fine"
    else
        exit 1
    fi
else
    log info "I: Found matching metainfo entry"
fi