From f7df12564a5aa5b7d144386355ede8b44b429601 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 15 Jun 2013 18:01:59 -0600 Subject: mv src/librelib src/lib/ # and split librelib into a separate package --- src/lib/Makefile | 18 +++++++++----- src/lib/librelib | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/librelib | 71 -------------------------------------------------------- 3 files changed, 83 insertions(+), 77 deletions(-) create mode 100755 src/lib/librelib delete mode 100755 src/librelib (limited to 'src') diff --git a/src/lib/Makefile b/src/lib/Makefile index 8683ee1..e0067be 100644 --- a/src/lib/Makefile +++ b/src/lib/Makefile @@ -12,7 +12,7 @@ common.sh.in: $(devtoolsdir)/lib/common.sh ; cp $< $@ build: common.sh -lib/common.sh: %: %.in %.top Makefile +common.sh: %: %.in %.top Makefile @echo "GEN $@" @{ \ cat "$*.top" && \ @@ -23,19 +23,25 @@ lib/common.sh: %: %.in %.top Makefile # Install ############################################################ -executables = $(wildcard libre*) -libraries = $(wildcard *.sh) +libexecs = $(filter-out librelib,$(wildcard libre*)) +libs = $(wildcard *.sh) # relative path to `/` from $(bindir) rootdir=$(shell sed -r 's|^/||;s|[^/]+|..|g'<<<$(bindir)) install: \ - $(addprefix $(DESTDIR)$(bindir)/,$(executables)) \ - $(addprefix $(DESTDIR)$(pkglibexecdir)/,$(executables) $(libraries)) + $(addprefix $(DESTDIR)$(bindir)/,$(libexecs) librelib) \ + $(addprefix $(DESTDIR)$(pkglibexecdir)/,$(libexecs) $(libs)) + +$(DESTDIR)$(bindir)/librelib: librelib + install -Dm755 '$<' '$@' $(DESTDIR)$(bindir)/%: % install -d '$(@D)' ln -sf '$(rootdir)$(pkglibexecdir)/$(@F)' "$@" -$(DESTDIR)$(pkglibexecdir)/%: % +$(DESTDIR)$(pkglibexecdir)/libre%: libre% install -Dm755 '$<' '$@' + +$(DESTDIR)$(pkglibexecdir)/%.sh: %.sh + install -Dm644 '$<' '$@' diff --git a/src/lib/librelib b/src/lib/librelib new file mode 100755 index 0000000..dc4969f --- /dev/null +++ b/src/lib/librelib @@ -0,0 +1,71 @@ +#!/bin/bash +# Copyright (c) 2013 by Luke Shumaker +# +# 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; either version 3 of the License, or +# (at your option) any later version. +# +# 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 . + +default_libdir=/usr/lib/libretools + +print() { + fmt=$1; shift + printf -- "$fmt\n" "$@" +} + +cmd=${0##*/} +usage() { + . libremessages + print 'Usage: . $(%s LIBRARY)' "$cmd" + print "Finds a shell library file" + echo + print "While some libraries can be sourced just by their name because" + print "they are installed in PATH (like libremessages), some are not" + print "installed there (like conf.sh), so a path must be given." + print "Hardcoding that path is the way of the dark side." + echo + print "By default, it looks for the files in '%s'," "$default_libdir" + print "but this can be changed with the environmental variable" + print "LIBRETOOLS_LIBDIR." + echo + print "Example usage:" + print ' . $(librelib conf.sh)' +} + +main() { + if [[ $# != 1 ]]; then + usage >&2 + return 2 + fi + if [[ $1 == '-h' ]]; then + usage + return 0; + fi + + if [[ -z $LIBRETOOLS_LIBDIR ]]; then + export LIBRETOOLS_LIBDIR=$default_libdir + fi + + lib=$1 + lib=${lib#libre} + lib=${lib%.sh} + + for file in ${lib} libre${lib} ${lib}.sh libre${lib}.sh; do + if [[ -f "$LIBRETOOLS_LIBDIR/$file" ]]; then + printf '%s\n' "$LIBRETOOLS_LIBDIR/$file" + return 0; + fi + done + printf 'librelib: could not find library `%s`\n' "$lib" >> /dev/stderr + return 1 +} + +main "$@" diff --git a/src/librelib b/src/librelib deleted file mode 100755 index dc4969f..0000000 --- a/src/librelib +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -# Copyright (c) 2013 by Luke Shumaker -# -# 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; either version 3 of the License, or -# (at your option) any later version. -# -# 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 . - -default_libdir=/usr/lib/libretools - -print() { - fmt=$1; shift - printf -- "$fmt\n" "$@" -} - -cmd=${0##*/} -usage() { - . libremessages - print 'Usage: . $(%s LIBRARY)' "$cmd" - print "Finds a shell library file" - echo - print "While some libraries can be sourced just by their name because" - print "they are installed in PATH (like libremessages), some are not" - print "installed there (like conf.sh), so a path must be given." - print "Hardcoding that path is the way of the dark side." - echo - print "By default, it looks for the files in '%s'," "$default_libdir" - print "but this can be changed with the environmental variable" - print "LIBRETOOLS_LIBDIR." - echo - print "Example usage:" - print ' . $(librelib conf.sh)' -} - -main() { - if [[ $# != 1 ]]; then - usage >&2 - return 2 - fi - if [[ $1 == '-h' ]]; then - usage - return 0; - fi - - if [[ -z $LIBRETOOLS_LIBDIR ]]; then - export LIBRETOOLS_LIBDIR=$default_libdir - fi - - lib=$1 - lib=${lib#libre} - lib=${lib%.sh} - - for file in ${lib} libre${lib} ${lib}.sh libre${lib}.sh; do - if [[ -f "$LIBRETOOLS_LIBDIR/$file" ]]; then - printf '%s\n' "$LIBRETOOLS_LIBDIR/$file" - return 0; - fi - done - printf 'librelib: could not find library `%s`\n' "$lib" >> /dev/stderr - return 1 -} - -main "$@" -- cgit v1.2.2