diff options
author | B Stack <bgstack15@gmail.com> | 2020-12-10 08:03:55 -0500 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2020-12-10 08:03:55 -0500 |
commit | be4896c2999422682f440cc821cd6a36d39123f2 (patch) | |
tree | 8f6386e80014d470fc646eca97be728fcab3b268 | |
parent | add check-for-short_url and fix init user check (diff) | |
download | hex-zero-be4896c2999422682f440cc821cd6a36d39123f2.tar.gz hex-zero-be4896c2999422682f440cc821cd6a36d39123f2.tar.bz2 hex-zero-be4896c2999422682f440cc821cd6a36d39123f2.zip |
add initial Makefile for install, uninstall
-rw-r--r-- | config/Makefile | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/config/Makefile b/config/Makefile new file mode 100644 index 0000000..76b69d3 --- /dev/null +++ b/config/Makefile @@ -0,0 +1,116 @@ +# File: Makefile for hex-zero +# Location: hex-zero source package +# Author: bgstack15 +# Startdate: 2020-12-09 +# Title: Makefile for hex-zero source package +# Purpose: To use traditional Unix make utility +# History: +# Usage: +# Reference: +# bgscripts Makefile +# Improve: +# add man page? +# Document: +# Dependencies: +# build-devuan: + +APPNAME = hex-zero +APPVERSION = 0.0.1 +SRCDIR = $(CURDIR)/..# because Makefile is in config/ inside this repo +prefix = /usr +SYSCONFDIR = $(DESTDIR)/etc +DEFAULTDIR = $(DESTDIR)/etc/sysconfig# for debian use '$(DESTDIR)/etc/default' +LIBEXECDIR = $(DESTDIR)$(prefix)/libexec +SHAREDIR = $(DESTDIR)$(prefix)/share +DOCDIR = $(SHAREDIR)/doc/$(APPNAME) +APPDIR = $(DESTDIR)/var/www/$(APPNAME) +MANDIR = $(SHAREDIR)/man +SYSVDIR = $(SYSCONFDIR)/init.d +SYSDDIR = $(DESTDIR)$(prefix)/lib/systemd/system +LOGDIR = $(DESTDIR)/var/log/hex-zero +APACHEDIR = $(SYSCONFDIR)/httpd/conf.d# for debian use '$(SYSCONFDIR)/apache2/sites-available' + +# variables for deplist +DEPTYPE = dep +SEPARATOR = , + +awkbin :=$(shell which awk) +chmodbin :=$(shell which chmod) +cpbin :=$(shell which cp) +echobin :=$(shell which echo) +falsebin :=$(shell which false) +findbin :=$(shell which find) +grepbin :=$(shell which grep) +gzipbin :=$(shell which gzip) +installbin :=$(shell which install) +rmbin :=$(shell which rm) +rmdirbin :=$(shell which rmdir) +sedbin :=$(shell which sed) +sortbin :=$(shell which sort) +truebin :=$(shell which true) +uniqbin :=$(shell which uniq) +xargsbin :=$(shell which xargs) + +with_apache ?= YES +with_nsfw ?= NO +with_init ?= YES +with_systemd ?= NO + +install: install_files + +.PHONY: clean install install_files uninstall list deplist deplist_opts + +list: + @$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | ${awkbin} -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | ${sortbin} | ${grepbin} -E -v -e '^[^[:alnum:]]' -e '^$@$$' + +deplist: + @# deplist 2020-04-18 input must be comma separated + @# DEPTYPE( dep , rec , sug ) for depends, recommends, or suggests + @if test -z "${DISTRO}" ; then ${echobin} "Please run \`make deplist\` with DISTRO= one of: `make deplist_opts 2>&1 1>/dev/null | ${xargsbin}`. Aborted." 1>&2 ; exit 1 ; fi + @if ! ${echobin} "${DEPTYPE}" | grep -qE "^(dep|rec|sug)$$" ; then ${echobin} "Please run \`make deplist\` with DEPTYPE= one of: dep, rec, sug. Undefined will use \`dep\`. Aborted." 1>&2 ; exit 1; fi + @${grepbin} -h --exclude-dir='doc' -riIE "\<${DEPTYPE}-" ${SRCDIR} | ${awkbin} -v "domain=${DISTRO}" -v "deptype=${DEPTYPE}" 'tolower($$2) ~ deptype"-"domain {$$1="";$$2="";print}' | tr ',' '\n' | ${sortbin} | ${uniqbin} | ${sedbin} -r -e 's/^\s*//' -e "s/\s*\$$/${SEPARATOR}/" | ${xargsbin} + +deplist_opts: + @# deplist_opts 2020-04-18 find all available dependency domains + @${grepbin} -h -o -riIE '\<(dep|rec|sug)-[^\ :]+:' ${SRCDIR} | ${sedbin} -r -e 's/(dep|rec|sug)-//;' -e 's/:$$//;' | ${sortbin} | ${uniqbin} 1>&2 + +install_files: + ${installbin} -m0755 -d ${LOGDIR} ${APPDIR} ${APPDIR}/up ${DOCDIR} ${DEFAULTDIR} + ${installbin} -m0644 -t ${APPDIR} ${SRCDIR}/front.html.in + ${installbin} -m0644 ${SRCDIR}/config/${APPNAME}.conf.example ${APPDIR}/${APPNAME}.conf + ${installbin} -m0755 -t ${APPDIR} ${SRCDIR}/${APPNAME}.py ${SRCDIR}/${APPNAME}.wsgi + ${installbin} -m0644 -t ${DOCDIR} ${SRCDIR}/README* + ${installbin} -m0644 ${SRCDIR}/config/${APPNAME}.etc.default ${DEFAULTDIR}/${APPNAME} +ifeq ($(with_apache),YES) + ${installbin} -m0755 -d ${APACHEDIR} + ${installbin} -m0644 ${SRCDIR}/config/${APPNAME}.conf.apache ${APACHEDIR}/${APPNAME}.conf +endif +ifeq ($(with_nsfw),YES) + ${installbin} -m0755 -t ${APPDIR} ${SRCDIR}/nsfw_detect.py + ${installbin} -m0755 -d ${APPDIR}/nsfw_model + ${installbin} -m0644 -t ${APPDIR}/nsfw_model ${SRCDIR}/nsfw_model/* +endif +ifeq ($(with_init),YES) + ${installbin} -m0755 -d ${SYSVDIR} + ${installbin} -m0755 ${SRCDIR}/config/${APPNAME}.init ${SYSVDIR}/${APPNAME} +endif +ifeq ($(with_systemd),YES) + ${installbin} -m0755 -d ${SYSDDIR} + ${installbin} -m0644 ${SRCDIR}/config/0x0.service -t ${SYSDDIR} +endif + +uninstall: + @${echobin} SRCDIR=${SRCDIR} + ${rmbin} -f ${APPDIR}/${APPNAME}.conf ${APPDIR}/${APPNAME}.py ${APPDIR}/${APPNAME}.wsgi \ + ${APPDIR}/front.html.in ${DOCDIR}/* ${DEFAULTDIR}/${APPNAME} || : + ${rmbin} -f ${APACHEDIR}/${APPNAME}.conf || : + ${rmbin} -f ${APPDIR}/nsfw_model/* ${APPDIR}/nsfw_detect.py || : + ${rmbin} -f ${SYSVDIR}/${APPNAME} || : + ${rmbin} -f ${SYSDDIR}/0x0.service || : + + # remove all installed directories that are now blank. + ${rmdirbin} ${APPDIR}/up ${DEFAULTDIR} ${SYSVDIR} ${APPDIR} \ + ${APACHEDIR} ${SYSDDIR} ${DOCDIR} ${LOGDIR} 2>/dev/null || : + +clean: + @${echobin} "target $@ not implemented yet! Gotta say unh." && ${falsebin} |