Imported the subst.sh script
This commit is contained in:
parent
c922b4fee7
commit
8cd51c477a
1
Makefile
1
Makefile
@ -37,6 +37,7 @@ dist:
|
||||
$(PACKAGE)-$(VERSION)/doc/scripts/gettext.sh \
|
||||
$(PACKAGE)-$(VERSION)/doc/scripts/gtkdoc.sh \
|
||||
$(PACKAGE)-$(VERSION)/doc/scripts/pkgconfig.sh \
|
||||
$(PACKAGE)-$(VERSION)/doc/scripts/subst.sh \
|
||||
$(PACKAGE)-$(VERSION)/doc/scripts/project.conf \
|
||||
$(PACKAGE)-$(VERSION)/src/configure.c \
|
||||
$(PACKAGE)-$(VERSION)/src/makefile.c \
|
||||
|
@ -22,6 +22,8 @@ install:
|
||||
$(INSTALL) -m 0644 -- gtkdoc.sh $(DESTDIR)$(PREFIX)/share/doc/configure/scripts/gtkdoc.sh
|
||||
$(MKDIR) $(DESTDIR)$(PREFIX)/share/doc/configure/scripts
|
||||
$(INSTALL) -m 0644 -- pkgconfig.sh $(DESTDIR)$(PREFIX)/share/doc/configure/scripts/pkgconfig.sh
|
||||
$(MKDIR) $(DESTDIR)$(PREFIX)/share/doc/configure/scripts
|
||||
$(INSTALL) -m 0644 -- subst.sh $(DESTDIR)$(PREFIX)/share/doc/configure/scripts/subst.sh
|
||||
|
||||
uninstall:
|
||||
$(RM) -- $(DESTDIR)$(PREFIX)/share/doc/configure/scripts/appbroker.sh
|
||||
@ -29,5 +31,6 @@ uninstall:
|
||||
$(RM) -- $(DESTDIR)$(PREFIX)/share/doc/configure/scripts/gettext.sh
|
||||
$(RM) -- $(DESTDIR)$(PREFIX)/share/doc/configure/scripts/gtkdoc.sh
|
||||
$(RM) -- $(DESTDIR)$(PREFIX)/share/doc/configure/scripts/pkgconfig.sh
|
||||
$(RM) -- $(DESTDIR)$(PREFIX)/share/doc/configure/scripts/subst.sh
|
||||
|
||||
.PHONY: all clean distclean install uninstall
|
||||
|
@ -1,4 +1,4 @@
|
||||
dist=Makefile,appbroker.sh,docbook.sh,gettext.sh,gtkdoc.sh,pkgconfig.sh
|
||||
dist=Makefile,appbroker.sh,docbook.sh,gettext.sh,gtkdoc.sh,pkgconfig.sh,subst.sh
|
||||
|
||||
[appbroker.sh]
|
||||
install=$(PREFIX)/share/doc/configure/scripts
|
||||
@ -14,3 +14,6 @@ install=$(PREFIX)/share/doc/configure/scripts
|
||||
|
||||
[pkgconfig.sh]
|
||||
install=$(PREFIX)/share/doc/configure/scripts
|
||||
|
||||
[subst.sh]
|
||||
install=$(PREFIX)/share/doc/configure/scripts
|
||||
|
102
doc/scripts/subst.sh
Executable file
102
doc/scripts/subst.sh
Executable file
@ -0,0 +1,102 @@
|
||||
#!/bin/sh
|
||||
#$Id$
|
||||
#Copyright (c) 2012 Pierre Pronchery <khorben@defora.org>
|
||||
#This program is free software: you can redistribute it and/or modify
|
||||
#it under the terms of the GNU General Public License as published by
|
||||
#the Free Software Foundation, version 3 of the License.
|
||||
#
|
||||
#This program is distributed in the hope that it will be useful,
|
||||
#but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
#GNU General Public License for more details.
|
||||
#
|
||||
#You should have received a copy of the GNU General Public License
|
||||
#along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
|
||||
#variables
|
||||
PREFIX="/usr/local"
|
||||
[ -f "../config.sh" ] && . "../config.sh"
|
||||
CHMOD="chmod"
|
||||
DEBUG="_debug"
|
||||
DEVNULL="/dev/null"
|
||||
INSTALL="install -m 0755"
|
||||
MKDIR="mkdir -m 0755 -p"
|
||||
RM="rm -f"
|
||||
SED="sed"
|
||||
|
||||
|
||||
#functions
|
||||
#debug
|
||||
_debug()
|
||||
{
|
||||
echo $@ 1>&2
|
||||
$@
|
||||
}
|
||||
|
||||
|
||||
#usage
|
||||
_usage()
|
||||
{
|
||||
echo "Usage: subst.sh [-i|-u][-P prefix] target" 1>&2
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
#main
|
||||
install=0
|
||||
uninstall=0
|
||||
while getopts iuP: name; do
|
||||
case $name in
|
||||
i)
|
||||
uninstall=0
|
||||
install=1
|
||||
;;
|
||||
u)
|
||||
install=0
|
||||
uninstall=1
|
||||
;;
|
||||
P)
|
||||
PREFIX="$2"
|
||||
;;
|
||||
?)
|
||||
_usage
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
if [ $# -eq 0 ]; then
|
||||
_usage
|
||||
exit $?
|
||||
fi
|
||||
|
||||
BINDIR="$PREFIX/bin"
|
||||
while [ $# -gt 0 ]; do
|
||||
target="$1"
|
||||
shift
|
||||
|
||||
#uninstall
|
||||
if [ "$uninstall" -eq 1 ]; then
|
||||
$DEBUG $RM -- "$BINDIR/$target" || exit 2
|
||||
continue
|
||||
fi
|
||||
|
||||
#install
|
||||
if [ "$install" -eq 1 ]; then
|
||||
$DEBUG $MKDIR -- "$BINDIR" || exit 2
|
||||
$DEBUG $INSTALL "$target" "$BINDIR/$target" || exit 2
|
||||
continue
|
||||
fi
|
||||
|
||||
#create
|
||||
$DEBUG $SED -e "s,@PREFIX@,$PREFIX," \
|
||||
-e "s,@VERSION@,$VERSION," "$target.in" > "$target"
|
||||
if [ $? -ne 0 ]; then
|
||||
$RM -- "$target" 2> "$DEVNULL"
|
||||
exit 2
|
||||
elif [ -x "$target.in" ]; then
|
||||
$DEBUG $CHMOD +x "$target"
|
||||
fi
|
||||
done
|
Loading…
Reference in New Issue
Block a user