summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2013-05-26 22:11:51 -0400
committerLuke Shumaker <LukeShu@sbcglobal.net>2013-05-26 22:11:51 -0400
commitca6db7290cacee0d3b5ba836e6acea76ea314e50 (patch)
tree7cf3e4eda33335fdcc245d41e75a3b1602485266
parentb159a370e2b1458c8c3817bdf3cabe2a630732e3 (diff)
redo the library system; avoid hard-coded paths
* install all library files to $(libexecdir)/libretools, instead of - $(bindir) - $(datadir)/libretools - $(datadir)/devtools * symlink the executable library files into $(bindir) * add the tool `librelib` * instead of ". /path/to/lib.sh", use ". $(librelib lib.sh)" * mark all libraries with shebangs of what options they support * move blacklist.sh to libreblacklist
-rw-r--r--common.mk9
-rwxr-xr-xsrc/chroot-tools/librechroot4
-rwxr-xr-xsrc/chroot-tools/libremakepkg11
-rw-r--r--src/devtools/Makefile24
-rw-r--r--src/lib/Makefile10
-rw-r--r--src/lib/conf.sh1
-rwxr-xr-xsrc/lib/libreblacklist (renamed from src/lib/blacklist.sh)3
-rwxr-xr-xsrc/lib/libremessages (renamed from src/libremessages)3
-rwxr-xr-xsrc/librefetch/librefetch2
-rwxr-xr-xsrc/librelib60
-rw-r--r--src/libretools.conf4
-rwxr-xr-xsrc/pkgbuild-check-nonfree2
12 files changed, 109 insertions, 24 deletions
diff --git a/common.mk b/common.mk
index 8727640..ef96ee6 100644
--- a/common.mk
+++ b/common.mk
@@ -4,13 +4,16 @@ DESTDIR=
#prefix=/usr/local
prefix=/usr
exec_prefix=$(prefix)
-datarootdir=$(prefix)/share
-
bindir=$(exec_prefix)/bin
sbindir=$(exec_prefix)/sbin
+#libexecdir=$(exec_prefix)/libexec
+libexecdir=$(exec_prefix)/lib
+
+datarootdir=$(prefix)/share
+datadir=$(datarootdir)
#sysconfdir=$(prefix)/etc
sysconfdir=/etc
-datadir=$(datarootdir)
+
docdir=$(datarootdir)/doc
################################################################################
diff --git a/src/chroot-tools/librechroot b/src/chroot-tools/librechroot
index 5027938..5afce05 100755
--- a/src/chroot-tools/librechroot
+++ b/src/chroot-tools/librechroot
@@ -20,11 +20,11 @@
# You should have received a copy of the GNU General Public License
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
-. /usr/share/libretools/conf.sh
+. $(librelib conf.sh)
load_conf_libretools_chroot
. libremessages
-. /usr/share/devtools/makechrootpkg.sh
+. $(librelib makechrootpkg)
# Because the makechrootpkg.sh library functions don't work with -euE
normshell() (
diff --git a/src/chroot-tools/libremakepkg b/src/chroot-tools/libremakepkg
index cdd2f39..f1b3916 100755
--- a/src/chroot-tools/libremakepkg
+++ b/src/chroot-tools/libremakepkg
@@ -20,10 +20,11 @@
# You should have received a copy of the GNU General Public License
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
-. /usr/share/libretools/conf.sh
+. $(librelib conf.sh)
load_conf_libretools_chroot
. libremessages
+makechrootpkg=$(librelib makechrootpkg)
shopt -s nullglob
umask 0022
@@ -74,7 +75,7 @@ EOF
# Usage: add_to_local_repo $copydir $pkgfiles...
add_to_local_repo() (
set +euE
- . /usr/share/devtools/makechrootpkg.sh
+ . $makechrootpkg
chroot_add_to_local_repo "$@"
)
@@ -84,7 +85,7 @@ add_to_local_repo() (
# - $SRCDEST is set
chroot_copy_in() (
set +euE
- . /usr/share/devtools/makechrootpkg.sh
+ . $makechrootpkg
chroot_copy_in "$@"
)
@@ -94,7 +95,7 @@ chroot_copy_in() (
# - $PKGDEST is set
chroot_copy_out() (
set +euE
- . /usr/share/devtools/makechrootpkg.sh
+ . $makechrootpkg
chroot_copy_out_pkgs "$@"
chroot_copy_out_logs "$@"
chroot_copy_out_srcs "$@"
@@ -103,7 +104,7 @@ chroot_copy_out() (
# Usage: chroot_let_nobody_use_pacman $copydir
chroot_let_nobody_use_pacman() (
set +euE
- . /usr/share/devtools/makechrootpkg.sh
+ . $makechrootpkg
chroot_let_nobody_use_pacman "$@"
)
diff --git a/src/devtools/Makefile b/src/devtools/Makefile
index e357675..18f1518 100644
--- a/src/devtools/Makefile
+++ b/src/devtools/Makefile
@@ -4,13 +4,21 @@ DESTDIR=
#prefix=/usr/local
prefix=/usr
exec_prefix=$(prefix)
-datarootdir=$(prefix)/share
-
bindir=$(exec_prefix)/bin
sbindir=$(exec_prefix)/sbin
+#libexecdir=$(exec_prefix)/libexec
+libexecdir=$(exec_prefix)/lib
+
+datarootdir=$(prefix)/share
datadir=$(datarootdir)
+#sysconfdir=$(prefix)/etc
+sysconfdir=/etc
+
+docdir=$(datarootdir)/doc
+
+################################################################################
-pkgdatadir=$(datadir)/devtools
+pkglibexecdir=$(libexecdir)/libretools
devtoolsdir=../../../devtools-par
@@ -47,7 +55,7 @@ build: \
lib/common.sh \
lib/makechrootpkg.sh
-edit = sed -e 's|m4_include(lib/\(.*\))|. @pkgdatadir@/\1|' -e "s|@pkgdatadir[@]|$(pkgdatadir)|g"
+edit = sed -e 's|m4_include(lib/\(.*\))|. $$(librelib \1)|'
indent = emacs --batch $1 \
--eval '(setq sh-basic-offset 8)' \
@@ -62,6 +70,8 @@ indent = emacs --batch $1 \
lib/common.sh: %: %.in Makefile
@echo "GEN $@"
@{ \
+ echo '#!/bin/bash -euE' && \
+ echo '#!/bin/bash' && \
echo 'if [[ -z $${_INCLUDE_COMMON_SH:-} ]]; then' && \
echo '_INCLUDE_COMMON_SH=true' && \
cat "$<" && \
@@ -86,8 +96,8 @@ install: \
$(DESTDIR)$(bindir)/find-libprovides \
$(DESTDIR)$(bindir)/finddeps \
$(DESTDIR)$(bindir)/lddd \
- $(DESTDIR)$(pkgdatadir)/common.sh \
- $(DESTDIR)$(pkgdatadir)/makechrootpkg.sh
+ $(DESTDIR)$(pkglibexecdir)/common.sh \
+ $(DESTDIR)$(pkglibexecdir)/makechrootpkg.sh
$(DESTDIR)$(sbindir)/%: %
install -Dm755 $< $@
@@ -95,7 +105,7 @@ $(DESTDIR)$(sbindir)/%: %
$(DESTDIR)$(bindir)/%: %
install -Dm755 $< $@
-$(DESTDIR)$(pkgdatadir)/%: lib/%
+$(DESTDIR)$(pkglibexecdir)/%: lib/%
install -Dm644 $< $@
$(DESTDIR)$(bindir)/find-libprovides:
diff --git a/src/lib/Makefile b/src/lib/Makefile
index 0c69ba3..e1068c1 100644
--- a/src/lib/Makefile
+++ b/src/lib/Makefile
@@ -1,2 +1,10 @@
-libre_datadir=$(datadir)/libretools
+libre_execdir=$(bindir)
+libre_datadir=$(libexecdir)/libretools
include ../../common.mk
+
+rootdir=$(shell sed -r 's|^/||;s|[^/]+|..|g'<<<$(bindir))
+
+$(DESTDIR)$(libre_execdir)/%: %
+ install -Dm755 '$<' '$(DESTDIR)$(libre_datadir)/$(@F)'
+ install -d '$(@D)'
+ ln -sf '$(rootdir)$(libre_datadir)/$(@F)' "$@"
diff --git a/src/lib/conf.sh b/src/lib/conf.sh
index 73dfca4..8e8610e 100644
--- a/src/lib/conf.sh
+++ b/src/lib/conf.sh
@@ -1,3 +1,4 @@
+#!/bin/bash -euE
#!/bin/bash
# Copyright (c) 2012-2013 by Luke Shumaker <lukeshu@sbcglobal.net>
#
diff --git a/src/lib/blacklist.sh b/src/lib/libreblacklist
index 664b5f3..2f73a06 100755
--- a/src/lib/blacklist.sh
+++ b/src/lib/libreblacklist
@@ -1,4 +1,5 @@
#!/bin/bash -euE
+#!/bin/bash
# Copyright (c) 2013 by Luke Shumaker <lukeshu@sbcglobal.net>
#
# This program is free software; you can redistribute it and/or modify
@@ -15,7 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# make sure XDG_CACHE_HOME is set
-. /usr/share/libretools/conf.sh
+. $(librelib conf.sh)
# Usage: blacklist-normalize <$file
# Normalizes the syntax of the blacklist on stdin.
diff --git a/src/libremessages b/src/lib/libremessages
index 726daa5..c9b6b83 100755
--- a/src/libremessages
+++ b/src/lib/libremessages
@@ -1,4 +1,5 @@
#!/bin/bash -euE
+#!/bin/bash
# Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
# Copyright (c) 2006-2010 Pacman Development Team <pacman-dev@archlinux.org>
# Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
@@ -26,7 +27,7 @@
# Inherit most functions from devtools #
################################################################################
-. /usr/share/devtools/common.sh
+. $(librelib common.sh)
################################################################################
# gettext initialization #
diff --git a/src/librefetch/librefetch b/src/librefetch/librefetch
index 1d4dd5c..f73beca 100755
--- a/src/librefetch/librefetch
+++ b/src/librefetch/librefetch
@@ -18,7 +18,7 @@
# You should have received a copy of the GNU General Public License
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
-. /usr/share/libretools/conf.sh
+. $(librelib conf.sh)
. libremessages
declare -r tempdir="$(mktemp -d --tmpdir ${0##*/}.XXXXXXXXXXX)"
diff --git a/src/librelib b/src/librelib
new file mode 100755
index 0000000..22811db
--- /dev/null
+++ b/src/librelib
@@ -0,0 +1,60 @@
+#!/bin/bash
+# Copyright (c) 2013 by Luke Shumaker <lukeshu@sbcglobal.net>
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+default_libdir=/usr/lib/libretools
+
+cmd=${0##*/}
+usage() {
+ 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 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 [[ -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
+ return 1
+}
+
+main "$@"
diff --git a/src/libretools.conf b/src/libretools.conf
index 3477761..df0471e 100644
--- a/src/libretools.conf
+++ b/src/libretools.conf
@@ -88,11 +88,11 @@ TORUPATH=/var/lib/libretools/toru
################################################################################
if [[ -z ${INCLUDE_CONF_SH:-} ]]; then
- . /usr/share/libretools/conf.sh
+ . $(librelib conf.sh)
if [[ -e "$XDG_CONFIG_HOME/libretools/libretools.conf" ]]; then
. "$XDG_CONFIG_HOME/libretools/libretools.conf"
fi
check_conf_libretools || exit $?
- . /usr/bin/libremessages
+ . libremessages
fi
diff --git a/src/pkgbuild-check-nonfree b/src/pkgbuild-check-nonfree
index e20e1a3..c37b0bf 100755
--- a/src/pkgbuild-check-nonfree
+++ b/src/pkgbuild-check-nonfree
@@ -20,7 +20,7 @@
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
. libremessages
-. /usr/share/libretools/blacklist.sh
+. libreblacklist
# Unset any PKGBUILD variables inherited from the environment
# I took these from makepkg 4.1.1-1