Import newer scripts upstream

This commit is contained in:
Pierre Pronchery 2020-11-03 23:31:35 +01:00
parent a094eaf0e8
commit d30a9a986d
2 changed files with 39 additions and 17 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
#$Id$ #$Id$
#Copyright (c) 2016-2019 Pierre Pronchery <khorben@defora.org> #Copyright (c) 2016-2020 Pierre Pronchery <khorben@defora.org>
# #
#Redistribution and use in source and binary forms, with or without #Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met: #modification, are permitted provided that the following conditions are met:
@ -35,6 +35,7 @@ DEBUG="_debug"
FIND="find" FIND="find"
GREP="grep" GREP="grep"
LINT="lint -g" LINT="lint -g"
MKDIR="mkdir -p"
SORT="sort -n" SORT="sort -n"
TR="tr" TR="tr"
@ -43,8 +44,8 @@ TR="tr"
#clint #clint
_clint() _clint()
{ {
ret=0 res=0
subdirs="data doc src tests tools" subdirs=
$DATE $DATE
while read line; do while read line; do
@ -58,6 +59,10 @@ _clint()
;; ;;
esac esac
done < "$PROJECTCONF" done < "$PROJECTCONF"
if [ ! -n "$subdirs" ]; then
_error "Could not locate directories to analyze"
return $?
fi
for subdir in $subdirs; do for subdir in $subdirs; do
[ -d "../$subdir" ] || continue [ -d "../$subdir" ] || continue
for filename in $($FIND "../$subdir" -type f | $SORT); do for filename in $($FIND "../$subdir" -type f | $SORT); do
@ -79,13 +84,13 @@ _clint()
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "FAIL" echo "FAIL"
echo "$PROGNAME: $filename: FAIL" 1>&2 echo "$PROGNAME: $filename: FAIL" 1>&2
ret=2 res=2
else else
echo "OK" echo "OK"
fi fi
done done
done done
return $ret return $res
} }
_clint_lint() _clint_lint()
@ -117,6 +122,14 @@ _debug()
} }
#error
_error()
{
echo "$PROGNAME: $@" 1>&2
return 2
}
#usage #usage
_usage() _usage()
{ {
@ -125,14 +138,6 @@ _usage()
} }
#warning
_warning()
{
echo "$PROGNAME: $@" 1>&2
return 2
}
#main #main
clean=0 clean=0
while getopts "cO:P:" name; do while getopts "cO:P:" name; do
@ -162,9 +167,15 @@ fi
[ $clean -ne 0 ] && exit 0 [ $clean -ne 0 ] && exit 0
exec 3>&1 exec 3>&1
ret=0
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
target="$1" target="$1"
dirname="${target%/*}"
shift shift
_clint > "$target" || exit 2 if [ -n "$dirname" -a "$dirname" != "$target" ]; then
$MKDIR -- "$dirname" || ret=$?
fi
_clint > "$target" || ret=$?
done done
exit $ret

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
#$Id$ #$Id$
#Copyright (c) 2017-2019 Pierre Pronchery <khorben@defora.org> #Copyright (c) 2017-2020 Pierre Pronchery <khorben@defora.org>
# #
#Redistribution and use in source and binary forms, with or without #Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met: #modification, are permitted provided that the following conditions are met:
@ -42,6 +42,7 @@ TR="tr"
_fixme() _fixme()
{ {
res=0 res=0
subdirs=
$DATE $DATE
echo echo
@ -56,6 +57,10 @@ _fixme()
;; ;;
esac esac
done < "$PROJECTCONF" done < "$PROJECTCONF"
if [ ! -n "$subdirs" ]; then
_error "Could not locate directories to analyze"
return $?
fi
for subdir in $subdirs; do for subdir in $subdirs; do
[ -d "../$subdir" ] || continue [ -d "../$subdir" ] || continue
for filename in $($FIND "../$subdir" -type f | $SORT); do for filename in $($FIND "../$subdir" -type f | $SORT); do
@ -152,6 +157,14 @@ _debug()
} }
#error
_error()
{
echo "$PROGNAME: $@" 1>&2
return 2
}
#usage #usage
_usage() _usage()
{ {
@ -200,6 +213,4 @@ while [ $# -gt 0 ]; do
fi fi
_fixme > "$target" || ret=$? _fixme > "$target" || ret=$?
done done
#XXX ignore errors
ret=0
exit $ret exit $ret