Import the newer scripts from DeforaOS configure

This commit is contained in:
Pierre Pronchery 2020-11-19 03:16:51 +01:00
parent d8aa309f69
commit d800f9611a
5 changed files with 149 additions and 60 deletions

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
#$Id$ #$Id$
#Copyright (c) 2012-2015 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 #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:
@ -25,8 +25,8 @@
#variables #variables
CONFIGSH="${0%/docbook.sh}/../config.sh"
PREFIX="/usr/local" PREFIX="/usr/local"
[ -f "../config.sh" ] && . "../config.sh"
PROGNAME="docbook.sh" PROGNAME="docbook.sh"
#executables #executables
DEBUG="_debug" DEBUG="_debug"
@ -37,6 +37,8 @@ RM="rm -f"
XMLLINT="xmllint" XMLLINT="xmllint"
XSLTPROC="xsltproc --nonet --xinclude" XSLTPROC="xsltproc --nonet --xinclude"
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#functions #functions
#debug #debug
@ -114,7 +116,7 @@ _usage()
clean=0 clean=0
install=0 install=0
uninstall=0 uninstall=0
while getopts "ciuP:" name; do while getopts "ciO:uP:" name; do
case "$name" in case "$name" in
c) c)
clean=1 clean=1
@ -123,6 +125,9 @@ while getopts "ciuP:" name; do
uninstall=0 uninstall=0
install=1 install=1
;; ;;
O)
export "${OPTARG%%=*}"="${OPTARG#*=}"
;;
u) u)
install=0 install=0
uninstall=1 uninstall=1
@ -137,7 +142,7 @@ while getopts "ciuP:" name; do
esac esac
done done
shift $((OPTIND - 1)) shift $((OPTIND - 1))
if [ $# -eq 0 ]; then if [ $# -lt 1 ]; then
_usage _usage
exit $? exit $?
fi fi
@ -167,7 +172,7 @@ while [ $# -gt 0 ]; do
xpath="string(/refentry/refmeta/manvolnum)" xpath="string(/refentry/refmeta/manvolnum)"
section=$($XMLLINT --xpath "$xpath" "$source") section=$($XMLLINT --xpath "$xpath" "$source")
if [ $? -eq 0 -a -n "$section" ]; then if [ $? -eq 0 -a -n "$section" ]; then
instdir="$DATADIR/man/html$section" instdir="$MANDIR/html$section"
fi fi
;; ;;
pdf) pdf)

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
#$Id$ #$Id$
#Copyright (c) 2010-2015 Pierre Pronchery <khorben@defora.org> #Copyright (c) 2010-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:
@ -25,8 +25,8 @@
#variables #variables
CONFIGSH="${0%/gettext.sh}/../config.sh"
PREFIX="/usr/local" PREFIX="/usr/local"
[ -f "../config.sh" ] && . "../config.sh"
LOCALEDIR="$PREFIX/share/locale" LOCALEDIR="$PREFIX/share/locale"
POTFILES="POTFILES" POTFILES="POTFILES"
PROGNAME="gettext.sh" PROGNAME="gettext.sh"
@ -40,6 +40,8 @@ MSGMERGE="msgmerge"
RM="rm -f" RM="rm -f"
XGETTEXT="xgettext --force-po" XGETTEXT="xgettext --force-po"
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#functions #functions
#debug #debug
@ -112,7 +114,7 @@ _gettext_pot()
clean=0 clean=0
install=0 install=0
uninstall=0 uninstall=0
while getopts "ciuP:" name; do while getopts "ciO:uP:" name; do
case "$name" in case "$name" in
c) c)
clean=1 clean=1
@ -121,6 +123,9 @@ while getopts "ciuP:" name; do
uninstall=0 uninstall=0
install=1 install=1
;; ;;
O)
export "${OPTARG%%=*}"="${OPTARG#*=}"
;;
u) u)
install=0 install=0
uninstall=1 uninstall=1
@ -135,7 +140,7 @@ while getopts "ciuP:" name; do
esac esac
done done
shift $(($OPTIND - 1)) shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then if [ $# -lt 1 ]; then
_usage _usage
exit $? exit $?
fi fi

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:
@ -25,6 +25,7 @@
#variables #variables
CONFIGSH="${0%/clint.sh}/../config.sh"
CFLAGS= CFLAGS=
CPPFLAGS= CPPFLAGS=
PROGNAME="clint.sh" PROGNAME="clint.sh"
@ -35,16 +36,19 @@ 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"
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#functions #functions
#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 +62,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 +87,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 +125,14 @@ _debug()
} }
#error
_error()
{
echo "$PROGNAME: $@" 1>&2
return 2
}
#usage #usage
_usage() _usage()
{ {
@ -125,14 +141,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 +170,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:
@ -25,23 +25,30 @@
#variables #variables
CONFIGSH="${0%/fixme.sh}/../config.sh"
PROGNAME="fixme.sh" PROGNAME="fixme.sh"
PROJECTCONF="../project.conf" PROJECTCONF="../project.conf"
REGEXP_ERROR="FIXME"
REGEXP_WARNING="\\(TODO\|XXX\\)"
#executables #executables
DATE="date" DATE="date"
DEBUG="_debug" DEBUG="_debug"
FIND="find" FIND="find"
GREP="grep" GREP="grep"
HEAD="head"
MKDIR="mkdir -p" MKDIR="mkdir -p"
SORT="sort -n" SORT="sort -n"
TR="tr" TR="tr"
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#functions #functions
#fixme #fixme
_fixme() _fixme()
{ {
res=0 res=0
subdirs=
$DATE $DATE
echo echo
@ -56,27 +63,14 @@ _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
callback= callback=$(_fixme_callback "$filename")
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
[ -n "$callback" ] || continue [ -n "$callback" ] || continue
($callback "$filename") 2>&1 ($callback "$filename") 2>&1
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
@ -88,54 +82,114 @@ _fixme()
return $res 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 res=0
filename="$1" filename="$1"
#warnings #warnings
$GREP -nH '/\*.*\(TODO\|XXX\)' "$filename" $GREP -nH "/\\*.*$REGEXP_WARNING" "$filename"
#failures #failures
$GREP -nH '/\*.*FIXME' "$filename" && res=2 $GREP -nH "/\\*.*$REGEXP_ERROR" "$filename" && res=2
return $res return $res
} }
_fixme_c() _fixme_callback_c()
{ {
res=0 res=0
filename="$1" filename="$1"
#warnings #warnings
$GREP -nH '/\(/\|\*\).*\(TODO\|XXX\)' "$filename" $GREP -nH "/\\(/\\|\\*\\).*$REGEXP_WARNING" "$filename"
#failures #failures
$GREP -nH '/\(/\|\*\).*FIXME' "$filename" && res=2 $GREP -nH "/\\(/\\|\\*\\).*$REGEXP_ERROR" "$filename" && res=2
return $res return $res
} }
_fixme_sh() _fixme_callback_python()
{ {
res=0 res=0
filename="$1" filename="$1"
#XXX avoid matching the regexp
comment="#" comment="#"
#warnings #warnings
$GREP -nH "$comment.*\\(TODO\\|XXX\\)" "$filename" $GREP -nH "$comment.*$REGEXP_WARNING" "$filename"
#failures #failures
$GREP -nH "$comment.*FIXME" "$filename" && res=2 $GREP -nH "$comment.*$REGEXP_ERROR" "$filename" && res=2
return $res 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 res=0
filename="$1" filename="$1"
#XXX limited to a single line #XXX limited to a single line
#warnings #warnings
$GREP -nH '<!--.*\(TODO\|XXX\)' "$filename" $GREP -nH "<!--.*$REGEXP_WARNING" "$filename"
#failures #failures
$GREP -nH '<!--.*FIXME' "$filename" && res=2 $GREP -nH "<!--.*$REGEXP_ERROR" "$filename" && res=2
return $res return $res
} }
@ -152,6 +206,14 @@ _debug()
} }
#error
_error()
{
echo "$PROGNAME: $@" 1>&2
return 2
}
#usage #usage
_usage() _usage()
{ {

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
#$Id$ #$Id$
#Copyright (c) 2012-2016 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 #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:
@ -36,7 +36,6 @@ LIBEXECDIR=
MANDIR= MANDIR=
PROGNAME="subst.sh" PROGNAME="subst.sh"
SYSCONFDIR= SYSCONFDIR=
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#executables #executables
CHMOD="chmod" CHMOD="chmod"
DATE="date" DATE="date"
@ -47,6 +46,8 @@ MKDIR="mkdir -m 0755 -p"
RM="rm -f" RM="rm -f"
SED="sed" SED="sed"
[ -f "$CONFIGSH" ] && . "$CONFIGSH"
#functions #functions
#subst #subst
@ -70,7 +71,7 @@ _subst()
LDSO="/libexec/ld-elf.so.1" LDSO="/libexec/ld-elf.so.1"
;; ;;
Linux) Linux)
LDSO="/lib/ld-linux-$(uname -p).so.2" LDSO="/lib/ld-linux-$(uname -m | tr _ -).so.2"
;; ;;
*) *)
LDSO="/libexec/ld.elf_so" LDSO="/libexec/ld.elf_so"
@ -112,6 +113,8 @@ _subst()
#create #create
source="${target#$OBJDIR}" source="${target#$OBJDIR}"
source="${source}.in" source="${source}.in"
([ -z "$OBJDIR" ] || $DEBUG $MKDIR -- "${target%/*}") \
|| return 2
$DEBUG $SED -e "s;@PACKAGE@;$PACKAGE;g" \ $DEBUG $SED -e "s;@PACKAGE@;$PACKAGE;g" \
-e "s;@VERSION@;$VERSION;g" \ -e "s;@VERSION@;$VERSION;g" \
-e "s;@PREFIX@;$PREFIX;g" \ -e "s;@PREFIX@;$PREFIX;g" \
@ -123,8 +126,8 @@ _subst()
-e "s;@LIBDIR@;$LIBDIR;g" \ -e "s;@LIBDIR@;$LIBDIR;g" \
-e "s;@LIBEXECDIR@;$LIBEXECDIR;g" \ -e "s;@LIBEXECDIR@;$LIBEXECDIR;g" \
-e "s;@MANDIR@;$MANDIR;g" \ -e "s;@MANDIR@;$MANDIR;g" \
-e "s;@SYSCONFDIR@;$SYSCONFDIR;g" \
-e "s;@PWD@;$PWD;g" \ -e "s;@PWD@;$PWD;g" \
-e "s;@SYSCONFDIR@;$SYSCONFDIR;g" \
-- "$source" > "$target" -- "$source" > "$target"
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
$RM -- "$target" 2> "$DEVNULL" $RM -- "$target" 2> "$DEVNULL"
@ -190,7 +193,7 @@ while getopts "ciuO:P:" name; do
esac esac
done done
shift $(($OPTIND - 1)) shift $(($OPTIND - 1))
if [ $# -eq 0 ]; then if [ $# -lt 1 ]; then
_usage _usage
exit $? exit $?
fi fi