Skip to content

Commit

Permalink
master: advance to newer verison of xrst.git/bin/dev_tools.sh.
Browse files Browse the repository at this point in the history
  • Loading branch information
bradbell committed Sep 11, 2024
1 parent 2faeed6 commit 70ba0d2
Show file tree
Hide file tree
Showing 9 changed files with 471 additions and 84 deletions.
84 changes: 62 additions & 22 deletions bin/check_copy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ set -e -u
# SPDX-FileCopyrightText: Bradley M. Bell <[email protected]>
# SPDX-FileContributor: 2023-24 Bradley M. Bell
# ----------------------------------------------------------------------------
if [ "$0" != "bin/check_copy.sh" ]
then
echo "bin/check_copy.sh: must be executed from its parent directory"
exit 1
fi
if [ "$#" != 0 ]
then
echo 'check_copy does not expect any arguments'
exit 1
fi
#
# grep, sed
source bin/grep_and_sed.sh
#
# spdx_license_id, no_copyright_list
source bin/dev_settings.sh
# ----------------------------------------------------------------------------
if [ $# != 0 ]
then
echo 'bin/check_copy.sh does not expect any arguments'
Expand All @@ -20,43 +37,60 @@ then
exit 1
fi
# ---------------------------------------------------------------------------
license='SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later'
username='bradbell'
fullname='Bradley M. Bell'
# ---------------------------------------------------------------------------
if [ -e temp.sed ]
then
rm temp.sed
fi
for name in $no_copyright_list
do
if [ -f $name ]
then
echo "^$name\$" | $sed -e 's|/|[/]|g' -e 's|.*|/&/d|' >> temp.sed
elif [ -d $name ]
then
echo "^$name/" | $sed -e 's|/|[/]|g' -e 's|.*|/&/d|' >> temp.sed
else
echo "$name in no_copyright_list is not a file or directory"
exit 1
fi
done
missing='no'
changed='no'
for file_name in $(git ls-files | sed \
-e '/\.yml$/d' \
-e '/\.png$/d' \
-e '/\.html$/d' \
-e '/\.toml$/d' \
-e '/\.xml$/d' \
-e '/^.gitignore$/d' \
-e '/^.readthedocs.yaml$/d' \
-e '/^epl-2.0.txt$/d' \
-e '/^COPYING$/d' \
-e '/^authors$/d' \
-e '/^batch_edit.sed$/d' \
-e '/^build.bat$/d' \
-e '/^bin[/]build.bat$/d' \
-e '/^cmake[/]cppad_uninstall.cmake$/d' \
)
for file_name in $(git ls-files | $sed -f temp.sed)
do
if ! grep "$license\$" $file_name > /dev/null
if ! $grep "$spdx_license_id\$" $file_name > /dev/null
then
if [ "$missing" == 'no' ]
then
echo "Cannot find line that ends with:"
echo " $license"
echo " $spdx_license_id"
echo "In the following files:"
fi
echo "$file_name"
missing='yes'
fi
done
for file_name in $(git status --porcelain | sed -e 's|^...||' )
# ---------------------------------------------------------------------------
cat << EOF > temp.sed
s|\\(SPDX-FileContributor: *[0-9]\\{4\\}\\)[-0-9]* $fullname|\\1-24 $fullname|
s|\\(SPDX-FileContributor\\): 2024-24 |\\1: 2024 |
EOF
list=''
if [ "${USER+x}" != '' ]
then
if [ "$USER" == 'bradbell' ]
then
list=$(git status --porcelain | $sed -e 's|^...||' )
fi
fi
for file_name in $list
do
if [ -e $file_name ]
then
sed \
$sed \
-e 's|\(SPDX-FileContributor\): *\([0-9]\{4\}\)[-0-9]* |\1: \2-24 |' \
-e 's|\(SPDX-FileContributor\): 2024-24 |\1: 2024 |' \
$file_name > temp.$$
Expand All @@ -69,6 +103,11 @@ do
echo 'The following file contributor dates have been updated'
fi
echo $file_name
if diff $file_name temp.$$
then
echo 'check_version.sh: program error'
exit 1
fi
changed='yes'
if [ -x $file_name ]
then
Expand All @@ -81,9 +120,10 @@ do
fi
done
#
if [ "$missing" = 'yes' ]
if [ "$missing" = 'yes' ] || [ "$changed" == 'yes' ]
then
echo 'bin/check_copy.sh: See copyright errors above'
echo 'Re-execute bin/check_copy.sh ?'
exit 1
fi
echo 'bin/check_copy.sh: OK'
Expand Down
34 changes: 28 additions & 6 deletions bin/check_invisible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,40 @@ else
echo 'usage: bin/check_invisible [all]'
exit 1
fi
#
# sed
source bin/grep_and_sed.sh
#
# invisible_and_tab_ok
source bin/dev_settings.sh
# ----------------------------------------------------------------------------
#
# sed.$$
echo '#' > sed.$$
for name in $no_copyright_list
do
if [ -f $name ]
then
echo "^$name\$" | $sed -e 's|/|[/]|g' -e 's|.*|/&/d|' >> sed.$$
elif [ -d $name ]
then
echo "^$name/" | $sed -e 's|/|[/]|g' -e 's|.*|/&/d|' >> sed.$$
else
echo "$name in no_copyright_list is not a file or directory"
exit 1
fi
done
#
# file_list
if [ "$all" == 'true' ]
then
file_list=$(git ls-files | sed \
-e '/^uw_copy_040507.html$/d' \
)
file_list=$(git ls-files | $sed -f sed.$$)
else
file_list=$(git status --porcelain | sed -e 's|^...||' \
-e '/^uw_copy_040507.html$/d' \
file_list=$(git status --porcelain | \
$sed -e '/^D/d' -e 's|^...||' | $sed -f sed.$$
)
fi
# ----------------------------------------------------------------------------
#
# sed.$$
cat << EOF > sed.$$
Expand All @@ -45,7 +67,7 @@ for file in $file_list
do
if [ -f "$file" ]
then
sed -f sed.$$ $file > copy.$$
$sed -f sed.$$ $file > copy.$$
if ! diff $file copy.$$ > diff.$$
then
echo "original (<) invisible white space removed (>)"
Expand Down
75 changes: 75 additions & 0 deletions bin/check_sort.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
#! /usr/bin/env bash
set -e -u
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <[email protected]>
# SPDX-FileContributor: 2020-24 Bradley M. Bell
# -----------------------------------------------------------------------------
if [ "$0" != "bin/check_sort.sh" ]
then
echo "bin/check_sort.sh: must be executed from its parent directory"
exit 1
fi
if [ "$#" == 0 ]
then
all='false'
elif [ "$#" == 1 ] && [ "$1" == 'all' ]
then
all='true'
else
echo 'usage: bin/check_sort [all]'
echo 'see usage message forbin/sort.sh'
exit 1
fi
#
# grep, sed
source bin/grep_and_sed.sh
# ----------------------------------------------------------------------------
# file_list
if [ "$all" == 'true' ]
then
file_list=$(git grep -l 'BEGIN_SORT_THIS_LINE_PLUS_')
else
file_list=$(git status --porcelain | $sed -e '/^D/d' -e 's|^...||')
fi
#
# ok
ok='yes'
for file_name in $file_list
do
check='yes'
if [ "$file_name" == 'bin/sort.sh' ]
then
check='no'
fi
if [ "$file_name" == 'bin/check_sort.sh' ]
then
check='no'
fi
if ! $grep BEGIN_SORT_THIS_LINE $file_name > /dev/null
then
check='no'
fi
if [ "$check" == 'yes' ]
then
if ! bin/sort.sh $file_name >& temp.$$
then
cat temp.$$
echo 'check_sort.sh: Error'
exit 1
fi
last_line=$(tail -1 temp.$$)
if [ "$last_line" == 'sort.sh: Done' ]
then
cat temp.$$
ok='no'
fi
fi
done
#
if [ "$ok" == 'no' ]
then
echo 'check_sort.sh: Some files have been sorted (run again to get OK).'
exit 1
fi
echo 'check_sort.sh: OK'
exit 0
83 changes: 57 additions & 26 deletions bin/check_tab.sh
Original file line number Diff line number Diff line change
@@ -1,43 +1,74 @@
#! /bin/bash -e
#! /usr/bin/env bash
set -e -u
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <[email protected]>
# SPDX-FileContributor: 2003-22 Bradley M. Bell
# ----------------------------------------------------------------------------
if [ "$0" != 'bin/check_tab.sh' ]
# SPDX-FileContributor: 2020-24 Bradley M. Bell
# -----------------------------------------------------------------------------
if [ "$0" != "bin/check_tab.sh" ]
then
echo "bin/check_tab.sh: must be executed from its parent directory"
exit 1
fi
echo "-------------------------------------------------------"
if [ "$#" == 0 ]
then
all='false'
elif [ "$#" == 1 ] && [ "$1" == 'all' ]
then
all='true'
else
echo 'usage: bin/check_tab [all]'
exit 1
fi
#
# sed
source bin/grep_and_sed.sh
#
# invisible_and_tab_ok
source bin/dev_settings.sh
# ----------------------------------------------------------------------------
#
# sed.$$
echo '#' > sed.$$
for name in $invisible_and_tab_ok
do
if [ -f $name ]
then
echo "^$name\$" | $sed -e 's|/|[/]|g' -e 's|.*|/&/d|' >> sed.$$
elif [ -d $name ]
then
echo "^$name/" | $sed -e 's|/|[/]|g' -e 's|.*|/&/d|' >> sed.$$
else
echo "$name in no_copyright_list is not a file or directory"
exit 1
fi
done
#
# file_list
if [ "$all" == 'true' ]
then
file_list=$(git ls-files | $sed -f sed.$$)
else
file_list=$(git status --porcelain | \
$sed -e '/^D/d' -e 's|^...||' | $sed -f sed.$$)
fi
#
# ok
ok='yes'
file_list=`git ls-files | sed \
-e '/makefile[.]am$/d' \
-e '/makefile[.]in$/d' \
-e '/^batch_edit.sed$/d' \
-e '/^coin.png$/d' \
-e '/^ar-lib$/d' \
-e '/^configure$/d' \
-e '/^compile$/d' \
-e '/^config.guess$/d' \
-e '/^config.sub$/d' \
-e '/^depcomp$/d' \
-e '/^install-sh$/d' \
-e '/^uw_copy_040507.html/d' \
`
tab=$'\t'
for file in $file_list
do
if grep $'\t' $file > /dev/null
if $grep -P '\t' $file > /dev/null
then
echo $file
echo "$file has a tab"
ok='no'
fi
done
echo "-------------------------------------------------------"
if [ "$ok" = 'no' ]
if [ "$ok" != 'yes' ]
then
echo 'bin/check_tab.sh: The files above contain tabs'
echo 'check_tab: Error'
rm sed.$$
exit 1
fi
echo 'bin/check_if.sh: OK'
# -----------------------------------------------------------------------------
rm sed.$$
echo 'check_tab.sh: OK'
exit 0
Loading

0 comments on commit 70ba0d2

Please sign in to comment.