Import the newer scripts from DeforaOS configure

This commit is contained in:
Pierre Pronchery 2020-11-19 02:48:39 +01:00
parent 95d45851b5
commit dca219b7b6
5 changed files with 132 additions and 52 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh
#$Id$
#Copyright (c) 2011-2019 Pierre Pronchery <khorben@defora.org>
#Copyright (c) 2011-2020 Pierre Pronchery <khorben@defora.org>
#
#Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met:
@ -27,14 +27,15 @@
#variables
CONFIGSH="${0%/pkgconfig.sh}/../config.sh"
PREFIX="/usr/local"
DEBUG="_debug"
DEVNULL="/dev/null"
PROGNAME="pkgconfig.sh"
#executables
DEBUG="_debug"
INSTALL="install -m 0644"
MKDIR="mkdir -m 0755 -p"
RM="rm -f"
SED="sed"
[ -f "$CONFIGSH" ] && . "$CONFIGSH"

View File

@ -1,6 +1,6 @@
#!/bin/sh
#$Id$
#Copyright (c) 2012-2017 Pierre Pronchery <khorben@defora.org>
#Copyright (c) 2012-2020 Pierre Pronchery <khorben@defora.org>
#
#Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met:
@ -25,8 +25,8 @@
#variables
CONFIGSH="${0%/docbook.sh}/../config.sh"
PREFIX="/usr/local"
[ -f "../config.sh" ] && . "../config.sh"
PROGNAME="docbook.sh"
#executables
DEBUG="_debug"
@ -37,6 +37,8 @@ RM="rm -f"
XMLLINT="xmllint"
XSLTPROC="xsltproc --nonet --xinclude"
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#functions
#debug

View File

@ -25,6 +25,7 @@
#variables
CONFIGSH="${0%/gtkdoc.sh}/../config.sh"
PREFIX="/usr/local"
PROGNAME="gtkdoc.sh"
#executables
@ -41,7 +42,7 @@ RM="rm -f"
RMDIR="rmdir"
TOUCH="touch"
[ -f "../config.sh" ] && . "../config.sh"
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#functions

View File

@ -1,6 +1,6 @@
#!/bin/sh
#$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
#modification, are permitted provided that the following conditions are met:
@ -25,23 +25,30 @@
#variables
CONFIGSH="${0%/fixme.sh}/../config.sh"
PROGNAME="fixme.sh"
PROJECTCONF="../project.conf"
REGEXP_ERROR="FIXME"
REGEXP_WARNING="\\(TODO\|XXX\\)"
#executables
DATE="date"
DEBUG="_debug"
FIND="find"
GREP="grep"
HEAD="head"
MKDIR="mkdir -p"
SORT="sort -n"
TR="tr"
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#functions
#fixme
_fixme()
{
res=0
subdirs=
$DATE
echo
@ -56,27 +63,14 @@ _fixme()
;;
esac
done < "$PROJECTCONF"
if [ ! -n "$subdirs" ]; then
_error "Could not locate directories to analyze"
return $?
fi
for subdir in $subdirs; do
[ -d "../$subdir" ] || continue
for filename in $($FIND "../$subdir" -type f | $SORT); do
callback=
ext=${filename##*/}
ext=${ext%.in}
ext=${ext##*.}
case "$ext" in
asm|S)
callback="_fixme_asm"
;;
c|cc|cpp|cxx|h|js)
callback="_fixme_c"
;;
conf|sh)
callback="_fixme_sh"
;;
htm|html|xml)
callback="_fixme_xml"
;;
esac
callback=$(_fixme_callback "$filename")
[ -n "$callback" ] || continue
($callback "$filename") 2>&1
if [ $? -ne 0 ]; then
@ -88,54 +82,114 @@ _fixme()
return $res
}
_fixme_asm()
_fixme_callback()
{
filename="$1"
ext=${filename##*/}
ext=${ext%.in}
ext=${ext##*.}
callback=
case "$ext" in
asm|S)
echo "_fixme_callback_asm"
return 0
;;
c|cc|cpp|cxx|h|js|v)
echo "_fixme_callback_c"
return 0
;;
conf|sh)
echo "_fixme_callback_sh"
return 0
;;
py)
echo "_fixme_callback_python"
return 0
;;
htm|html|xml|xsl)
echo "_fixme_callback_xml"
return 0
;;
esac
case $($HEAD -n 1 "$filename") in
"#!/bin/sh"*|"#! /bin/sh"*|\
"#!/usr/bin/env bash"*|"#! /usr/bin/env bash"*)
echo "_fixme_callback_sh"
return 0
;;
"#!/usr/bin/env python"*|"#! /usr/bin/env python"*)
echo "_fixme_callback_python"
return 0
;;
"<html"*|"<?xml"*)
echo "_fixme_callback_xml"
return 0
;;
esac
return 2
}
_fixme_callback_asm()
{
res=0
filename="$1"
#warnings
$GREP -nH '/\*.*\(TODO\|XXX\)' "$filename"
$GREP -nH "/\\*.*$REGEXP_WARNING" "$filename"
#failures
$GREP -nH '/\*.*FIXME' "$filename" && res=2
$GREP -nH "/\\*.*$REGEXP_ERROR" "$filename" && res=2
return $res
}
_fixme_c()
_fixme_callback_c()
{
res=0
filename="$1"
#warnings
$GREP -nH '/\(/\|\*\).*\(TODO\|XXX\)' "$filename"
$GREP -nH "/\\(/\\|\\*\\).*$REGEXP_WARNING" "$filename"
#failures
$GREP -nH '/\(/\|\*\).*FIXME' "$filename" && res=2
$GREP -nH "/\\(/\\|\\*\\).*$REGEXP_ERROR" "$filename" && res=2
return $res
}
_fixme_sh()
_fixme_callback_python()
{
res=0
filename="$1"
#XXX avoid matching the regexp
comment="#"
#warnings
$GREP -nH "$comment.*\\(TODO\\|XXX\\)" "$filename"
$GREP -nH "$comment.*$REGEXP_WARNING" "$filename"
#failures
$GREP -nH "$comment.*FIXME" "$filename" && res=2
$GREP -nH "$comment.*$REGEXP_ERROR" "$filename" && res=2
return $res
}
_fixme_xml()
_fixme_callback_sh()
{
res=0
filename="$1"
comment="#"
#warnings
$GREP -nH "$comment.*$REGEXP_WARNING" "$filename"
#failures
$GREP -nH "$comment.*$REGEXP_ERROR" "$filename" && res=2
return $res
}
_fixme_callback_xml()
{
res=0
filename="$1"
#XXX limited to a single line
#warnings
$GREP -nH '<!--.*\(TODO\|XXX\)' "$filename"
$GREP -nH "<!--.*$REGEXP_WARNING" "$filename"
#failures
$GREP -nH '<!--.*FIXME' "$filename" && res=2
$GREP -nH "<!--.*$REGEXP_ERROR" "$filename" && res=2
return $res
}
@ -152,6 +206,14 @@ _debug()
}
#error
_error()
{
echo "$PROGNAME: $@" 1>&2
return 2
}
#usage
_usage()
{

View File

@ -1,6 +1,6 @@
#!/bin/sh
#$Id$
#Copyright (c) 2014-2017 Pierre Pronchery <khorben@defora.org>
#Copyright (c) 2014-2020 Pierre Pronchery <khorben@defora.org>
#
#Redistribution and use in source and binary forms, with or without
#modification, are permitted provided that the following conditions are met:
@ -25,23 +25,27 @@
#variables
CONFIGSH="${0%/shlint.sh}/../config.sh"
PROGNAME="shlint.sh"
PROJECTCONF="../project.conf"
#executables
DATE="date"
DEBUG="_debug"
FIND="find"
MKDIR="mkdir -p"
SHLINT="sh -n"
SORT="sort -n"
TR="tr"
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#functions
#shlint
_shlint()
{
ret=0
subdirs="data doc src tests tools"
res=0
subdirs=
$DATE
echo
@ -56,6 +60,10 @@ _shlint()
;;
esac
done < "$PROJECTCONF"
if [ ! -n "$subdirs" ]; then
_error "Could not locate directories to analyze"
return $?
fi
for subdir in $subdirs; do
[ -d "../$subdir" ] || continue
for filename in $($FIND "../$subdir" -type f -a -name '*.sh' | $SORT); do
@ -64,11 +72,11 @@ _shlint()
echo "$filename:"
else
echo "$PROGNAME: $filename: FAIL" 1>&2
ret=2
res=2
fi
done
done
return $ret
return $res
}
_shlint_file()
@ -88,7 +96,7 @@ _shlint_file()
esac
done < "$filename"
if [ $warn -ne 0 ]; then
_warning "$filename: return instead of exit in the global scope"
_error "$filename: return instead of exit in the global scope"
fi
return 0
}
@ -106,6 +114,14 @@ _debug()
}
#error
_error()
{
echo "$PROGNAME: $@" 1>&2
return 2
}
#usage
_usage()
{
@ -114,14 +130,6 @@ _usage()
}
#warning
_warning()
{
echo "$PROGNAME: $@" 1>&2
return 2
}
#main
clean=0
while getopts "cO:P:" name; do
@ -151,9 +159,15 @@ fi
[ $clean -ne 0 ] && exit 0
exec 3>&1
ret=0
while [ $# -gt 0 ]; do
target="$1"
dirname="${target%/*}"
shift
_shlint > "$target" || exit 2
if [ -n "$dirname" -a "$dirname" != "$target" ]; then
$MKDIR -- "$dirname" || ret=$?
fi
_shlint > "$target" || ret=$?
done
exit $ret