Allow the HOMEDIR and ETCDIR to be configurable via Makefile ENV. Add FreeBSD user creation support.
#!/usr/bin/env make -f
PREFIX=/usr/local/share
LIBDIR=$(PREFIX)/mercurial-server
DOCDIR=$(PREFIX)/doc/mercurial-server
ETCDIR=/etc/mercurial-server
NEWUSER=hg
HOMEDIR=/var/lib/mercurial-server
DOCBOOK_XSL=/usr/share/xml/docbook/stylesheet/nwalsh
INSTALL=install
build: build/html/index.html pythonbuild
setup-freebsd: installetc pythoninstall bsduseradd inituser
setup-adduser: installfiles adduser inituser
# WARNING: this is experimental
setup-useradd: installfiles useradd inituser
installetc:
$(INSTALL) -d $(DESTDIR)$(ETCDIR)
$(INSTALL) -m 644 src/init/conf/access.conf \
$(DESTDIR)$(ETCDIR)
$(INSTALL) -d $(DESTDIR)$(ETCDIR)/remote-hgrc.d
$(INSTALL) -m 644 \
src/init/conf/remote-hgrc.d/access.rc \
src/init/conf/remote-hgrc.d/logging.rc \
$(DESTDIR)$(ETCDIR)/remote-hgrc.d
$(INSTALL) -d $(DESTDIR)$(ETCDIR)/keys/root
$(INSTALL) -d $(DESTDIR)$(ETCDIR)/keys/users
installdoc: build/html/index.html
$(INSTALL) -d $(DESTDIR)$(DOCDIR)
$(INSTALL) -m 644 -t $(DESTDIR)$(DOCDIR) README
$(INSTALL) -d $(DESTDIR)$(DOCDIR)/html
$(INSTALL) -m 644 -t $(DESTDIR)$(DOCDIR)/html build/html/index.html
build/html/index.html: doc/manual.docbook
xsltproc --nonet -o $@ $(DOCBOOK_XSL)/html/docbook.xsl $^
build/pdf/manual.pdf: doc/manual.docbook
mkdir -p build/pdf
fop -xml $^ -xsl $(DOCBOOK_XSL)/fo/docbook.xsl $@
pythonbuild:
python setup.py build
dot-mercurial: src/init/dot-mercurial-server.tmpl
sed -e "s|_ETCDIR_|$(ETCDIR)|" \
src/init/dot-mercurial-server.tmpl \
> src/init/dot-mercurial-server
pythoninstall: dot-mercurial
python setup.py install \
--install-purelib=$(DESTDIR)$(LIBDIR) \
--install-platlib=$(DESTDIR)$(LIBDIR) \
--install-scripts=$(DESTDIR)$(LIBDIR) \
--install-data=$(DESTDIR)$(LIBDIR)
installfiles: installetc installdoc pythoninstall
adduser:
adduser --system --shell /bin/sh --group --disabled-password \
--home $(HOMEDIR) \
--gecos "Mercurial repositories" $(NEWUSER)
# WARNING: this is experimental
useradd:
useradd --system --shell /bin/sh \
--home $(HOMEDIR) --create-home \
--comment "Mercurial repositories" $(NEWUSER)
bsduseradd:
pw useradd $(NEWUSER) -c "Mercurial repositories" -m -s /bin/sh \
-d $(HOMEDIR)
inituser:
su $(NEWUSER) -c "$(DESTDIR)$(LIBDIR)/init/hginit $(DESTDIR)$(LIBDIR)" -