New way to run configuration scripts
This commit is contained in:
parent
3766fd7357
commit
d90d6302b7
|
@ -10,10 +10,10 @@ INSTALL = install
|
|||
all: $(TARGETS)
|
||||
|
||||
XMLEditor.pot: POTFILES
|
||||
./gettext.sh "XMLEditor.pot"
|
||||
./gettext.sh -P "$(PREFIX)" -- "XMLEditor.pot"
|
||||
|
||||
fr.mo: XMLEditor.pot fr.po
|
||||
./gettext.sh "fr.mo"
|
||||
./gettext.sh -P "$(PREFIX)" -- "fr.mo"
|
||||
|
||||
clean:
|
||||
$(RM) -- $(XMLEditor.pot_OBJS) $(fr.mo_OBJS)
|
||||
|
@ -22,9 +22,9 @@ distclean: clean
|
|||
$(RM) -- $(TARGETS)
|
||||
|
||||
install: all
|
||||
./gettext.sh -p "$(DESTDIR)$(PREFIX)" install "fr.mo"
|
||||
./gettext.sh -P "$(DESTDIR)$(PREFIX)" -i -- "fr.mo"
|
||||
|
||||
uninstall:
|
||||
./gettext.sh -p "$(DESTDIR)$(PREFIX)" uninstall "fr.mo"
|
||||
./gettext.sh -P "$(DESTDIR)$(PREFIX)" -u -- "fr.mo"
|
||||
|
||||
.PHONY: all clean distclean install uninstall
|
||||
|
|
|
@ -18,16 +18,6 @@ XGETTEXT="xgettext --force-po"
|
|||
|
||||
|
||||
#functions
|
||||
#usage
|
||||
_usage()
|
||||
{
|
||||
echo "Usage: ./gettext.sh <target>" 1>&2
|
||||
echo " ./gettext.sh -p <prefix> install <target>" 1>&2
|
||||
echo " ./gettext.sh -p <prefix> uninstall <target>" 1>&2
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
#debug
|
||||
_debug()
|
||||
{
|
||||
|
@ -36,6 +26,14 @@ _debug()
|
|||
}
|
||||
|
||||
|
||||
#usage
|
||||
_usage()
|
||||
{
|
||||
echo "Usage: gettext.sh [-i|-u][-P prefix] <target>" 1>&2
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
#gettext_mo
|
||||
_gettext_mo()
|
||||
{
|
||||
|
@ -63,38 +61,65 @@ _gettext_pot()
|
|||
|
||||
|
||||
#main
|
||||
if [ $# -eq 4 -a "$1" = "-p" ]; then
|
||||
PREFIX="$2"
|
||||
LOCALEDIR="$PREFIX/share/locale"
|
||||
lang="${4%%.mo}"
|
||||
|
||||
if [ "$3" = "install" ]; then
|
||||
$DEBUG $MKDIR "$LOCALEDIR/$lang/LC_MESSAGES" || exit 2
|
||||
$DEBUG $INSTALL "$4" \
|
||||
"$LOCALEDIR/$lang/LC_MESSAGES/$PACKAGE.mo" \
|
||||
|| exit 2
|
||||
exit 0
|
||||
elif [ "$3" = "uninstall" ]; then
|
||||
$DEBUG $RM "$LOCALEDIR/$lang/LC_MESSAGES/$PACKAGE.mo" \
|
||||
|| exit 2
|
||||
exit 0
|
||||
else
|
||||
echo "gettext.sh: $3: Unknown operation" 1>&2
|
||||
fi
|
||||
fi
|
||||
if [ $# -ne 1 ]; then
|
||||
args=`getopt iuP: $*`
|
||||
if [ $? -ne 0 ]; then
|
||||
_usage
|
||||
exit $?
|
||||
fi
|
||||
case "$1" in
|
||||
set -- $args
|
||||
install=0
|
||||
uninstall=0
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
-i)
|
||||
install=1
|
||||
;;
|
||||
-u)
|
||||
uninstall=1
|
||||
;;
|
||||
-P)
|
||||
PREFIX="$2"
|
||||
shift
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
LOCALEDIR="$PREFIX/share/locale"
|
||||
while [ $# -gt 0 ]; do
|
||||
target="$1"
|
||||
lang="${target%%.mo}"
|
||||
shift
|
||||
|
||||
#uninstall
|
||||
if [ "$uninstall" -eq 1 ]; then
|
||||
$DEBUG $RM "$LOCALEDIR/$lang/LC_MESSAGES/$PACKAGE.mo" \
|
||||
|| exit 2
|
||||
continue
|
||||
fi
|
||||
|
||||
#create
|
||||
case "$target" in
|
||||
*.mo)
|
||||
_gettext_mo "$PACKAGE" "${1%%.mo}" || exit 2
|
||||
_gettext_mo "$PACKAGE" "$lang" || exit 2
|
||||
;;
|
||||
*.pot)
|
||||
_gettext_pot "${1%%.pot}" || exit 2
|
||||
_gettext_pot "${target%%.pot}" || exit 2
|
||||
;;
|
||||
*)
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
exit 0
|
||||
esac
|
||||
|
||||
#install
|
||||
if [ "$install" -eq 1 ]; then
|
||||
$DEBUG $MKDIR "$LOCALEDIR/$lang/LC_MESSAGES" || exit 2
|
||||
$DEBUG $INSTALL "$target" \
|
||||
"$LOCALEDIR/$lang/LC_MESSAGES/$PACKAGE.mo" \
|
||||
|| exit 2
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue
Block a user