Permalink
Browse files

Cleanup dependencies support.

  • Loading branch information...
roddhjav committed Feb 27, 2018
1 parent ea673ff commit 0871eddcaecb896cbae72c74ac8ac8ac4cf6e4a8
Showing with 7 additions and 9 deletions.
  1. +1 −1 Makefile
  2. +6 −8 import.bash
View
@@ -20,7 +20,7 @@ install:
@install -v -d "$(DESTDIR)$(MANDIR)/man1"
@install -v -d "$(DESTDIR)$(SYSTEM_EXTENSION_DIR)/"
@install -v -d "$(DESTDIR)$(EXTENSION_LIB)/"
@trap 'rm -f src/.$(PROG).bash' EXIT; sed "s|/usr/lib/password-store/import|$(EXTENSION_LIB)|" $(PROG).bash > .$(PROG).bash && \
@trap 'rm -f .import.bash' EXIT; sed "s|/usr/lib|$(LIBDIR)|" "$(PROG).bash" > ".$(PROG).bash" && \
install -v -m 0755 ".$(PROG).bash" "$(DESTDIR)$(SYSTEM_EXTENSION_DIR)/$(PROG).bash"
@install -v -m 0755 "lib/$(PROG).py" "$(DESTDIR)$(EXTENSION_LIB)/$(PROG).py"
@install -v -m 0644 "pass-$(PROG).1" "$(DESTDIR)$(MANDIR)/man1/pass-$(PROG).1"
View
@@ -16,13 +16,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
readonly LIBDIR="${PASSWORD_STORE_LIBDIR:-/usr/lib/password-store/import}"
readonly Bold='\e[1m' Bred='\e[1;31m' reset='\e[0m'
_error() { echo -e " ${Bred}[x]${reset} ${Bold}Error:${reset} ${*}" >&2; }
_die() { _error "${@}" && exit 1; }
readonly CMD="import"
readonly LIBDIR="${PASSWORD_STORE_LIBDIR:-/usr/lib/password-store/$CMD}"
_ensure_dependencies() {
command -v "python3" &>/dev/null || _die "$PROGRAM $COMMAND requires python3"
[[ -f "${LIBDIR}/import.py" ]] || _die "$PROGRAM $COMMAND requires ${LIBDIR}/import.py"
command -v "python3" &>/dev/null || die "$PROGRAM $COMMAND requires python3"
[[ -f "${LIBDIR}/${CMD}.py" ]] || die "$PROGRAM $COMMAND requires ${LIBDIR}/$CMD.py"
}
cmd_import() {
@@ -33,10 +31,10 @@ cmd_import() {
export PASSWORD_STORE_ENABLE_EXTENSIONS PASSWORD_STORE_SIGNING_KEY
export GNUPGHOME LIBDIR PYTHONIOENCODING="UTF-8" PASSWORD_STORE_BIN="$0"
if [[ -t 0 ]]; then
python3 "${LIBDIR}/import.py" "$@"
python3 "${LIBDIR}/${CMD}.py" "$@"
ret=$?
else
cat | python3 "${LIBDIR}/import.py" "$@"
cat | python3 "${LIBDIR}/${CMD}.py" "$@"
ret=$?
fi
return $ret

0 comments on commit 0871edd

Please sign in to comment.