cdist-web/Makefile

80 lines
3.3 KiB
Makefile
Raw Normal View History

2019-04-23 18:55:23 +00:00
WEBSITE_SRC_DIR=src
WEBSITE_MAN_PAGE="$(WEBSITE_SRC_DIR)/cdist-manual.rst"
WEBSITE_HTML_DIST_DIR=dist/html
WEBSITE_ARCHIVE=cdist-www.tar.gz
WEBSITE_REMOTE_HOST=staticweb.ungleich.ch
WEBSITE_REMOTE_DIR=/home/services/www/nico/www.cdi.st/www/
2019-05-05 15:06:02 +00:00
WEBSITE_MANUALS_DIR="$(WEBSITE_SRC_DIR)/extra/manual"
2019-04-23 18:55:23 +00:00
CDIST_DIR=../cdist
CDIST_DOCS_DIR="$(CDIST_DIR)/docs"
CDIST_HELPER="$(CDIST_DIR)/bin/build-helper"
CDIST_CHANGELOG_VERSION=$(shell $(CDIST_HELPER) changelog-version)
2019-04-23 18:55:23 +00:00
CDIST_CHANGELOG_FILE="$(CDIST_DOCS_DIR)/changelog"
CDIST_DOCS_HTML_DIST_DIR="$(CDIST_DOCS_DIR)/dist/html"
CDIST_MAKE_VERSION=make -C "$(CDIST_DIR)" version
CDIST_MAKE_HTML=make -C "$(CDIST_DIR)" html
CDIST_CLEAN_HTML=make -C "$(CDIST_DOCS_DIR)/src" clean
2019-04-25 10:01:42 +00:00
SPHINXH=make -C $(WEBSITE_SRC_DIR) html
SPHINXC=make -C $(WEBSITE_SRC_DIR) clean
2019-04-23 18:55:23 +00:00
.PHONY: help
help:
@echo "Please use \`make <target>' where <target> is one of"
2019-04-25 10:01:42 +00:00
@echo " build only build static web"
@echo " publish only publish built web"
@echo " release update web with latest cdist release and build static web"
@echo " release-publish do release and then publish"
@echo " release-no-latest update web without latest cdist release and build static web"
@echo " release-publish-no-latest do release-no-latest and then publish"
@echo " clean clean generated files"
2019-04-23 18:55:23 +00:00
################################################################################
# Website
#
# Make cdist html manual.
# Generate rst changelog.
# Create target version manual directory.
# Copy target version manual directory to website.
# Add latest manual page.
# Update latest manual link.
2019-04-25 10:01:42 +00:00
release-prepare:
2019-04-23 18:55:23 +00:00
$(CDIST_MAKE_VERSION)
$(CDIST_MAKE_HTML)
@awk '/^[0-9a-z.]+: [0-9-]+$$/ { print; for(i = 0; i < length; ++i) { printf "~"; }; printf "\n"; next; } { print; }' "$(CDIST_CHANGELOG_FILE)" > "$(WEBSITE_SRC_DIR)/cdist-changelog.rst"
@mkdir -p "$(WEBSITE_MANUALS_DIR)/$(CDIST_CHANGELOG_VERSION)/"
@rsync -a "$(CDIST_DOCS_HTML_DIST_DIR)/" "$(WEBSITE_MANUALS_DIR)/$(CDIST_CHANGELOG_VERSION)/"
2019-04-25 10:01:42 +00:00
release-prepare-latest: release-prepare
2019-05-05 15:06:02 +00:00
@grep '$(CDIST_CHANGELOG_VERSION)' "$(WEBSITE_MAN_PAGE)" || awk 'BEGIN { print_new = 0; } /All versions/ { print; print_new = 1; next; } print_new == 1 { print; print "* `$(CDIST_CHANGELOG_VERSION) <manual/$(CDIST_CHANGELOG_VERSION)>`_"; print_new = 0; next; } { print; }' "$(WEBSITE_MAN_PAGE)" > "$(WEBSITE_MAN_PAGE)-new" && mv "$(WEBSITE_MAN_PAGE)-new" "$(WEBSITE_MAN_PAGE)" || exit 0
2019-04-23 18:55:23 +00:00
# Build website.
2019-04-25 10:01:42 +00:00
build:
$(SPHINXH)
2019-05-05 15:06:02 +00:00
@cd "$(WEBSITE_HTML_DIST_DIR)/manual" && rm -f latest && ln -s "$(CDIST_CHANGELOG_VERSION)" latest
2019-04-23 18:55:23 +00:00
2019-04-25 10:01:42 +00:00
release: release-prepare-latest build
2019-04-23 18:55:23 +00:00
2019-04-25 10:01:42 +00:00
release-no-latest: release-prepare build
publish:
2019-04-23 18:55:23 +00:00
@cd "$(WEBSITE_HTML_DIST_DIR)" \
&& tar -c -z -f "../$(WEBSITE_ARCHIVE)" . \
&& scp "../$(WEBSITE_ARCHIVE)" "$(WEBSITE_REMOTE_HOST):$(WEBSITE_REMOTE_DIR)" \
&& rm -f "../$(WEBSITE_ARCHIVE)"
@ssh "$(WEBSITE_REMOTE_HOST)" "cd $(WEBSITE_REMOTE_DIR) && tar -x -f $(WEBSITE_ARCHIVE) && rm -f $(WEBSITE_ARCHIVE)"
2019-05-02 17:34:46 +00:00
# Publish static website.
# Update latest symlink.
2019-04-25 10:01:42 +00:00
release-publish: release publish
2019-05-05 15:06:02 +00:00
@ssh "$(WEBSITE_REMOTE_HOST)" "cd '$(WEBSITE_REMOTE_DIR)/manual' && rm -f latest && ln -s '$(CDIST_CHANGELOG_VERSION)' latest"
2019-04-23 18:55:23 +00:00
2019-04-25 10:01:42 +00:00
release-publish-no-latest: release-no-latest publish
2019-04-23 18:55:23 +00:00
clean:
$(CDIST_CLEAN_HTML)
2019-04-25 10:01:42 +00:00
$(SPHINXC)