]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tools: add checktarball-meson.sh
authorKarel Zak <kzak@redhat.com>
Thu, 13 Mar 2025 09:12:26 +0000 (10:12 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 13 Mar 2025 09:13:58 +0000 (10:13 +0100)
Simple script to check for missing meson.build files in the release tarball.

Addresses: https://github.com/util-linux/util-linux/issues/3460
Signed-off-by: Karel Zak <kzak@redhat.com>
tools/checktarball-meson.sh [new file with mode: 0755]

diff --git a/tools/checktarball-meson.sh b/tools/checktarball-meson.sh
new file mode 100755 (executable)
index 0000000..5c6d14e
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+#
+# Copyright (C) 2025 Karel Zak <kzak@redhat.com>
+#
+# 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 2 of the License, or
+# (at your option) any later version.
+#
+if [[ "$1" == "-h" || "$1" == "--help" ]]; then
+    echo "Usage: $0 TARBALL"
+    echo "Compare meson.build files in the current Git with those in the specified tarball."
+    exit 0
+fi
+
+TARBALL="$1"
+
+if [ -z "$TARBALL" ]; then
+    echo "Error: No tarball specified."
+    exit 1
+elif [ ! -f "$TARBALL" ]; then
+    echo "Error: Tarball '$TARBALL' not found."
+    exit 1
+fi
+
+TAR_DIRNAME=$(tar -tf "$TARBALL" | head -1 | cut -d'/' -f1)
+TAR_MESON_FILES=$(tar -tf "$TARBALL" | grep 'meson.build$' | sed "s|^$TAR_DIRNAME/||")
+GIT_MESON_FILES=$(git ls-files | grep 'meson.build$')
+
+MISSING_FILES=()
+for file in $GIT_MESON_FILES; do
+    if ! grep -qx "$file" <<< "$TAR_MESON_FILES"; then
+        MISSING_FILES+=("$file")
+    fi
+done
+
+if [ ${#MISSING_FILES[@]} -gt 0 ]; then
+    echo "The following meson.build files are missing in the tarball:"
+    for file in "${MISSING_FILES[@]}"; do
+        echo "$file"
+    done
+    exit 1
+fi