Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Install data files from the Makefile #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,44 @@
PREFIX ?= /usr
DESTDIR ?= /
LIBDIR ?= $(PREFIX)/lib
SHAREDIR = $(PREFIX)/share
MANDIR ?= $(SHAREDIR)/man
PYTHON ?= yes

EXTENSION_DIR ?= $(LIBDIR)/password-store/extensions

BASHCOMPDIR ?= $(SHAREDIR)/bash-completion/completions
ZSHCOMPDIR ?= $(SHAREDIR)/zsh/site-functions

all:
@python3 setup.py build
@echo "pass-audit was built successfully. You can now install it with \"make install\""

install:
@python3 setup.py install --root="$(DESTDIR)" --optimize=1 --skip-build
base_install:
@install -vd "$(DESTDIR)$(EXTENSION_DIR)/" "$(DESTDIR)$(MANDIR)/man1" \
"$(DESTDIR)$(BASHCOMPDIR)" "$(DESTDIR)$(ZSHCOMPDIR)"
@install -vm 0755 audit.bash "$(DESTDIR)$(EXTENSION_DIR)/audit.bash"
@install -vm 0644 share/man/man1/pass-audit.1 "$(DESTDIR)$(MANDIR)/man1/"
@install -vm 0644 share/bash-completion/completions/pass-audit "$(DESTDIR)$(BASHCOMPDIR)/"
@install -vm 0644 share/zsh/site-functions/_pass-audit "$(DESTDIR)$(ZSHCOMPDIR)/"

install: base_install
@[ "$(PYTHON)" = "yes" ] || exit 0; python3 setup.py install --root="$(DESTDIR)" --optimize=1 --skip-build
@echo "pass-audit is installed successfully"

local:
@python3 setup.py install --user --optimize=1
uninstall:
@rm -vrf \
"$(DESTDIR)$(EXTENSION_DIR)/audit.bash" \
"$(DESTDIR)$(MANDIR)/man1/pass-audit.1" \
"$(DESTDIR)$(ZSHCOMPDIR)/_pass-audit" \
"$(DESTDIR)$(BASHCOMPDIR)/pass-audit"

XDG_DATA_HOME ?= $(HOME)/.local/share
PASSWORD_STORE_EXTENSIONS_DIR ?= $(HOME)/.password-store/.extensions
local: EXTENSION_DIR = $(PASSWORD_STORE_EXTENSIONS_DIR)
local: SHAREDIR = $(XDG_DATA_HOME)
local: base_install
@[ "$(PYTHON)" = "yes" ] || exit 0; python3 setup.py install --user --optimize=1
@echo "pass-audit is locally installed successfully."
@echo "Remember to set PASSWORD_STORE_ENABLE_EXTENSIONS to 'true' for the extension to be enabled."

Expand Down
35 changes: 1 addition & 34 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,6 @@
# pass audit - Password Store Extension (https://www.passwordstore.org/)
# Copyright (C) 2017-2022 Alexandre PUJOL <[email protected]>.

import os
import sys
from pathlib import Path

from setuptools import setup

share = Path(sys.prefix, 'share')
base = '/usr'
if os.uname().sysname == 'Darwin':
base = '/usr/local'
lib = Path(base, 'lib', 'password-store', 'extensions')

if '--user' in sys.argv:
if 'PASSWORD_STORE_EXTENSIONS_DIR' in os.environ:
lib = Path(os.environ['PASSWORD_STORE_EXTENSIONS_DIR'])
else:
lib = Path.home() / '.password-store' / '.extensions'
if 'XDG_DATA_HOME' in os.environ:
share = Path(os.environ['XDG_DATA_HOME'])
else:
share = Path.home() / '.local' / 'share'

setup(
data_files=[
(str(share / 'man' / 'man1'), [
'share/man/man1/pass-audit.1'
]),
(str(share / 'bash-completion' / 'completions'), [
'share/bash-completion/completions/pass-audit'
]),
(str(share / 'zsh' / 'site-functions'), [
'share/zsh/site-functions/_pass-audit'
]),
(str(lib), ["audit.bash"]),
],
)
setup()