Daiki Ueno <[email protected]> writes: > The modules are listed by a script that does: > - for each file listed by: git show --oneline --name-only 705f4efc > - deduce the containing modules, based on "Files:" > - deduce the modules which depend on the containing modules, based > on "Depends-on:" > > It's tempting to automate those steps. Is it okay to add some scripts > for that to Gnulib?
So here it is. As noted in the comment, it's often too slow. Comments would be appreciated. Regards, -- Daiki Ueno
>From 64fcd6dcccf5ee1a639e9171092c078a1b2b975a Mon Sep 17 00:00:00 2001 From: Daiki Ueno <[email protected]> Date: Fri, 19 Jun 2015 17:53:35 +0900 Subject: [PATCH] maint: add a script to list libunistring modules * libunistring-modules: New script. --- ChangeLog | 5 ++ libunistring-modules | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100755 libunistring-modules diff --git a/ChangeLog b/ChangeLog index 66df3da..385ab23 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2015-06-19 Daiki Ueno <[email protected]> + maint: add a script to list libunistring modules + * libunistring-modules: New script. + +2015-06-19 Daiki Ueno <[email protected]> + libunistring: bump minimum version to 0.9.6 * all modules depending on updated Unicode data: Regenerate. The modules are listed by a script that does: diff --git a/libunistring-modules b/libunistring-modules new file mode 100755 index 0000000..8b6f0b3 --- /dev/null +++ b/libunistring-modules @@ -0,0 +1,147 @@ +#!/bin/sh +# +# Copyright (C) 2015 Free Software Foundation, Inc. +# +# 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, see <http://www.gnu.org/licenses/>. +# + +# List modules copied into libunistring. If a git commit is +# specified, it identifies modules affected by the commit (it's +# often too slow). + +# Usage: libunistring-modules [COMMIT] + +progname=$0 + +# func_tmpdir +# creates a temporary directory. +# Input: +# - progname name of this program +# Sets variable +# - tmp pathname of freshly created temporary directory +func_tmpdir () +{ + # Use the environment variable TMPDIR, falling back to /tmp. This allows + # users to specify a different temporary directory, for example, if their + # /tmp is filled up or too small. + : ${TMPDIR=/tmp} + { + # Use the mktemp program if available. If not available, hide the error + # message. + tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" + } || + { + # Use a simple mkdir command. It is guaranteed to fail if the directory + # already exists. $RANDOM is bash specific and expands to empty in shells + # other than bash, ksh and zsh. Its use does not increase security; + # rather, it minimizes the probability of failure in a very cluttered /tmp + # directory. + tmp=$TMPDIR/gl$$-$RANDOM + (umask 077 && mkdir "$tmp") + } || + { + echo "$progname: cannot create a temporary directory in $TMPDIR" >&2 + func_exit 1 + } +} + +# func_exit STATUS +# exits with a given status. +# This function needs to be used, rather than 'exit', when a 'trap' handler is +# in effect that refers to $?. +func_exit () +{ + (exit $1); exit $1 +} + +PREFIXES=' +unicase +uniconv +unictype +unigbrk +unilbrk +uniname +uninorm +unistdio +unistr +uniwbrk +uniwidth +' + +# If no commit is specified, list all modules and exit. +if test $# -eq 0; then + echo unitypes + for prefix in $PREFIXES; do + ./gnulib-tool --list | grep "^$prefix/" + done + func_exit 0 +fi + +func_tmpdir +trap 'exit_status=$? + if test "$signal" != 0; then + echo "caught signal $signal" >&2 + fi + rm -rf "$tmp" + exit $exit_status' 0 +for signal in 1 2 3 13 15; do + trap '{ signal='$signal'; func_exit 1; }' $signal +done + +COMMIT="$1" + +# List all modules included in libunistring. +modules=unitypes +for prefix in $PREFIXES; do + add=`./gnulib-tool --list | grep "^$prefix/"` + modules="$modules $add" +done + +# List the containing modules. +files=`git show --oneline --name-only "$COMMIT" | tail -n+2` +for file in $files; do + (cd modules && grep -l "^$file\$" $modules) +done | sort | uniq > "$tmp/modules" + +# Loop until the dependent module list does not change. +found= +while test -z "$found"; do + for module in $modules; do + dependencies=`./gnulib-tool --extract-dependencies $module` + for dependency in $dependencies; do + if grep "^$dependency\$" "$tmp/modules" > /dev/null 2>&1; then + echo $module + fi + done + done | cat "$tmp/modules" - | sort | uniq > "$tmp/modules.tmp" + if cmp "$tmp/modules" "$tmp/modules.tmp" > /dev/null 2>&1; then + found=yes + fi + mv "$tmp/modules.tmp" "$tmp/modules" +done + +cat "$tmp/modules" + +rm -rf "$tmp" + +# Undo the effect of the previous 'trap' command. Some shellology: +# We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to +# execute the command "-". "trap '' ..." is fine only for signal 0 (= normal +# exit); for the others we need to call 'exit' explicitly. The value of $? is +# 128 + signal number and is set before the trap-registered command is run. +trap '' 0 +trap 'func_exit $?' 1 2 3 13 15 + +exit 0 -- 2.4.2
