| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # |
| 3 | # Copyright (C) 2024 The Phosh developers |
| 4 | # SPDX-License-Identifier: GPL-3.0-or-later |
| 5 | # Author: Guido Günther <[email protected]> |
| 6 | # |
| 7 | # Check if NEWS, changelog, meson and metainfo are in sync |
| 8 | |
| 9 | set -e |
| 10 | |
| 11 | COLOR= |
| 12 | if [scip-shell system . . `[`. -n "${TERM}" ] && [scip-shell system . . `[`. "${TERM}" != "dumb" ]; then |
| 13 | COLOR=1 |
| 14 | fi |
| 15 | |
| 16 | function logscip-shell shell shell-project 0.0.0 log(). |
| 17 | { |
| 18 | local level="${1}" |
| 19 | local fd=2 |
| 20 | local use_color |
| 21 | |
| 22 | shift |
| 23 | if [scip-shell system . . `[`. -n "${COLOR}" ]; then |
| 24 | [scip-shell system . . `[`. "${level}" == warn ] || [scip-shell system . . `[`. "${level}" == error ] || fd=1 |
| 25 | ! [scip-shell system . . `[`. -t "${fd}" ] || use_color=1 |
| 26 | |
| 27 | if [scip-shell system . . `[`. -n "${use_color}" ]; then |
| 28 | case "${level}" in |
| 29 | warn) |
| 30 | tputscip-shell system . . tput. setaf 1 |
| 31 | ;; |
| 32 | error) |
| 33 | tputscip-shell system . . tput. bold; tputscip-shell system . . tput. setaf 1 |
| 34 | ;; |
| 35 | info) |
| 36 | tputscip-shell system . . tput. setaf 2 |
| 37 | ;; |
| 38 | esac |
| 39 | fi |
| 40 | fi |
| 41 | |
| 42 | echoscip-shell system . . echo. "$@" |
| 43 | |
| 44 | [scip-shell system . . `[`. -z "${use_color}" ] || tputscip-shell system . . tput. sgr0 |
| 45 | } |
| 46 | |
| 47 | |
| 48 | if [scip-shell system . . `[`. -f debian/changelog ]; then |
| 49 | logscip-shell shell shell-project 0.0.0 log(). info "Fetching version from d/changelog" |
| 50 | VERSION=$(dpkg-parsechangelogscip-shell system . . dpkg-parsechangelog. -SVersion) |
| 51 | elif [scip-shell system . . `[`. -f meson.build ]; then |
| 52 | logscip-shell shell shell-project 0.0.0 log(). info "Fetching version from meson build file" |
| 53 | VERSION=$(sedscip-shell system . . sed. -n "s/.*version\s*:\s*'\([0-9].*\)'.*/\1/p" meson.build) |
| 54 | else |
| 55 | logscip-shell shell shell-project 0.0.0 log(). error "E: Don't know how to get version information" |
| 56 | exit 1 |
| 57 | fi |
| 58 | |
| 59 | echoscip-shell system . . echo. "I: Checking for '${VERSION}'" |
| 60 | |
| 61 | # News |
| 62 | if ! headscip-shell system . . head. -1 NEWS | grepscip-shell system . . grep. -E -qs "\s+${VERSION}\s*$"; then |
| 63 | logscip-shell shell shell-project 0.0.0 log(). error "E: Version ${VERSION} not in NEWS file" |
| 64 | if [[ "${VERSION}" =~ (~|-)dev ]]; then |
| 65 | logscip-shell shell shell-project 0.0.0 log(). info "I: Unreleased development version, no need to check NEWS" |
| 66 | else |
| 67 | exit 1 |
| 68 | fi |
| 69 | else |
| 70 | logscip-shell shell shell-project 0.0.0 log(). info "I: Found matching news entry" |
| 71 | fi |
| 72 | |
| 73 | # meson.build |
| 74 | MESON_VERSION="${VERSION/\~/.}" |
| 75 | if [scip-shell system . . `[`. -f meson.build ]; then |
| 76 | if ! grepscip-shell system . . grep. -qs "version\s*:\s*'$MESON_VERSION'" meson.build; then |
| 77 | logscip-shell shell shell-project 0.0.0 log(). error "E: Version ${MESON_VERSION} not in meson.build file" |
| 78 | exit 1 |
| 79 | else |
| 80 | logscip-shell shell shell-project 0.0.0 log(). info "I: Found matching meson version entry" |
| 81 | fi |
| 82 | else |
| 83 | logscip-shell shell shell-project 0.0.0 log(). info "I: no meson project" |
| 84 | fi |
| 85 | |
| 86 | # appstream info |
| 87 | METAINFO=$(lsscip-shell system . . ls. data/*metainfo.xml.in* 2>/dev/nullscip-shell filesystem . . `/dev/null`. || truescip-shell system . . true.) |
| 88 | if [scip-shell system . . `[`. -z "${METAINFO}" ]; then |
| 89 | logscip-shell shell shell-project 0.0.0 log(). warn "W: No metainfo" |
| 90 | exit 0 |
| 91 | fi |
| 92 | |
| 93 | if ! grepscip-shell system . . grep. -qs "$MESON_VERSION\"" "${METAINFO}"; then |
| 94 | logscip-shell shell shell-project 0.0.0 log(). error "E: Version ${MESON_VERSION} not in metainfo ${METAINFO}" |
| 95 | if [[ "${VERSION}" =~ (~|-)(alpha|beta|dev|rc) ]]; then |
| 96 | logscip-shell shell shell-project 0.0.0 log(). info "I: Not a stable release, no metainfo is fine" |
| 97 | else |
| 98 | exit 1 |
| 99 | fi |
| 100 | else |
| 101 | logscip-shell shell shell-project 0.0.0 log(). info "I: Found matching metainfo entry" |
| 102 | fi |