#!/bin/sh usage () { echo Usage: `basename $0` '[-h|-u] [-r ref] [--] command...'; } ############################################################################# ## ## Copyright (C) 2016 The Qt Company Ltd. ## Contact: https://www.qt.io/licensing/ ## ## This file is part of the release tools of the Qt Toolkit. ## ## $QT_BEGIN_LICENSE:LGPL$ ## Commercial License Usage ## Licensees holding valid commercial Qt licenses may use this file in ## accordance with the commercial license agreement provided with the ## Software or, alternatively, in accordance with the terms contained in ## a written agreement between you and The Qt Company. For licensing terms ## and conditions see https://www.qt.io/terms-conditions. For further ## information use the contact form at https://www.qt.io/contact-us. ## ## GNU Lesser General Public License Usage ## Alternatively, this file may be used under the terms of the GNU Lesser ## General Public License version 3 as published by the Free Software ## Foundation and appearing in the file LICENSE.LGPL3 included in the ## packaging of this file. Please review the following information to ## ensure the GNU Lesser General Public License version 3 requirements ## will be met: https://www.gnu.org/licenses/lgpl-3.0.html. ## ## GNU General Public License Usage ## Alternatively, this file may be used under the terms of the GNU ## General Public License version 2.0 or (at your option) the GNU General ## Public license version 3 or any later version approved by the KDE Free ## Qt Foundation. The licenses are as published by the Free Software ## Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 ## included in the packaging of this file. Please review the following ## information to ensure the GNU General Public License requirements will ## be met: https://www.gnu.org/licenses/gpl-2.0.html and ## https://www.gnu.org/licenses/gpl-3.0.html. ## ## $QT_END_LICENSE$ ## ############################################################################# help () { usage # Example data: [ "$LAST" ] || LAST=v5.9.0 [ "$NEXT" ] || NEXT=5.10 [ "$TASK" ] || TASK=QTBUG-5678 ME=`basename $0` cat <&2; } die () { warn "$@"; exit 1; } banner () { echo; echo "====== $@ ======"; echo; } # Convert each .gitmodules stanza into a single line: modules () { sed -e 's/^\[submodule/\v[submodule/' <.gitmodules | tr '\n\v' '\f\n' echo } # Parse a single linearised stanza; discard if boring, else extract # its directory name: vet () { # First pass: filter out modules we don't want: echo "$@" | tr '\f' '\n' | while read name op value do [ "$op" = '=' ] || continue case "$name" in # In dev, status is replaced by initrepo; but it's only # given when true, so we can't filter on it here. status) # No BC/SC promises in preview; and we # don't care about obsolete or ignore: case "$value" in essential|addon|deprecated) ;; preview|obsolete|ignore) return ;; esac;; # repotools has qt = false qt) [ "$value" = false ] && return ;; # non-versioned modules aren't relevant to us: branch) [ "$value" = master ] && return ;; esac done # Because | while runs in a sub-shell, no variable assignment we # make there survives to be used; so we need to re-scan to extract # module paths: echo "$@" | grep -w '\(status *= *\|initrepo *= *true\)' | \ tr '\f' '\n' | grep 'path *=' | cut -d = -f 2 } # Re-echo a module if it has all required refs: checkrefs () { for ref in $REFS # Use rev-parse --verify to test whether $ref exists in this repo: do (cd "$1" && git rev-parse -q --verify "$ref^{commit}" >/dev/null 2>&1) || return done echo "$1" } # List the API-relevant modules: relevant () { # Select released Qt modules: modules | while read stanza do vet "$stanza" done | while read path # Only those with src/ and a sync.profile matter: do if [ -d "$path/src" -a -f "$path/sync.profile" ] # Filter on the desired refs (if any): then checkrefs "$path" fi done } [ -e .gitmodules ] || die "I must be run in the top-level (qt5) directory" REFS= while [ $# -gt 0 ] do case "$1" in -u|--usage) usage; exit 0;; -h|--help) help; exit 0;; -r|--require) REFS="$REFS $2"; shift 2;; --) shift; break;; -*) usage >&2; die "Unrecognised option: $1";; *) break;; esac done if [ $# -eq 0 ] then usage >&2 die "You need to supply a command to run in each module !" fi relevant | while read dir do (cd "$dir" && banner "$dir" && eval "$@") || warn "Failed ($?) in $dir: $@" done