From 213a1ffca123ab7bf30ba3af57fff3c5e99f54ea Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 23 Jun 2014 20:58:18 -0400 Subject: clean up the build system --- .gitignore | 7 ++- Makefile | 59 +++++++++++++++--------- parabolaweb-changepassword.real.in | 51 +++++++++++++++++++++ parabolaweb-changepassword.sh | 51 --------------------- parabolaweb-fcgi | 23 ---------- parabolaweb-fcgi.in | 23 ++++++++++ parabolaweb-reporead-inotify | 24 ---------- parabolaweb-reporead-inotify.in | 24 ++++++++++ parabolaweb-update | 93 -------------------------------------- parabolaweb-update.in | 93 ++++++++++++++++++++++++++++++++++++++ 10 files changed, 233 insertions(+), 215 deletions(-) create mode 100644 parabolaweb-changepassword.real.in delete mode 100755 parabolaweb-changepassword.sh delete mode 100755 parabolaweb-fcgi create mode 100644 parabolaweb-fcgi.in delete mode 100755 parabolaweb-reporead-inotify create mode 100644 parabolaweb-reporead-inotify.in delete mode 100755 parabolaweb-update create mode 100644 parabolaweb-update.in diff --git a/.gitignore b/.gitignore index 52f4d7c..21b81d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ depends.txt -*.service -parabolaweb-changepassword + +parabolaweb* +!parabolaweb*.in +!parabolaweb*.c +!parabolaweb.conf diff --git a/Makefile b/Makefile index 4abd3a5..d4e4bf0 100644 --- a/Makefile +++ b/Makefile @@ -1,44 +1,59 @@ -prefix = /usr +DESTDIR = + +#prefix = /usr/local +prefix = /usr exec_prefix = $(prefix) -sbindir = $(exec_prefix)/sbin -libexecdir = $(exec_prefix)/lib -systemddir = $(prefix)/lib/systemd/system -confdir = /etc/conf.d +bindir = $(exec_prefix)/bin +#sbindir = $(exec_prefix)/sbin +sbindir = $(bindir) +#libexecdir = $(exec_prefix)/libexec +libexecdir = $(exec_prefix)/lib +#sysconfdir = $(prefix)/etc +sysconfdir = /etc/conf.d +systemddir = $(prefix)/lib/systemd/system pkglibexecdir = $(libexecdir)/parabolaweb-utils +pkgconffile = $(sysconfdir)/parabolaweb CFLAGS += -std=c99 -Wall -Wextra -Werror -Wno-unused-parameter CPPFLAGS += -DSCRIPT_LOCATION='"$(pkglibexecdir)/parabolaweb-changepassword.real"' -all: depends.txt parabolaweb-changepassword - -install: \ +targets = \ $(DESTDIR)$(sbindir)/parabolaweb-changepassword \ $(DESTDIR)$(sbindir)/parabolaweb-fcgi \ $(DESTDIR)$(sbindir)/parabolaweb-reporead-inotify \ $(DESTDIR)$(sbindir)/parabolaweb-update \ - $(DESTDIR)$(confdir)/parabolaweb \ $(DESTDIR)$(pkglibexecdir)/parabolaweb-changepassword.real \ $(DESTDIR)$(systemddir)/parabolaweb.service \ $(DESTDIR)$(systemddir)/parabolaweb-reporead-inotify.service -depends.txt: list-depends depends_static.txt - bash $< > $@ +all: depends.txt $(notdir $(targets)) parabolaweb.conf -%.service: %.service.in - sed 's|@sbindir@|$(sbindir)|' < $< > $@ +install: $(targets) $(sysconffile) -$(DESTDIR)$(sbindir)/%: % - install -Dm755 $< $@ +# Pattern rules -$(DESTDIR)$(sbindir)/parabolaweb-changepassword: parabolaweb-changepassword - install -Dm6755 $< $@ +%: %.in + sed -e 's|@sbindir@|$(sbindir)|' -e 's|@pkgconffile@|$(pkgconffile)|' < $< > $@ + +$(DESTDIR)$(sbindir)/%: % + $(INSTALL) -Dm755 $< $@ -$(DESTDIR)$(pkglibexecdir)/parabolaweb-changepassword.real: parabolaweb-changepassword.sh - install -Dm755 $< $@ +$(DESTDIR)$(pkglibexecdir)/%: % + $(INSTALL) -Dm755 $< $@ $(DESTDIR)$(systemddir)/%.service: %.service - install -Dm644 $< $@ + $(INSTALL) -Dm644 $< $@ + +# Specific rules + +depends.txt: list-depends depends_static.txt + $< > $@ + +$(DESTDIR)$(sbindir)/parabolaweb-changepassword: parabolaweb-changepassword + $(INSTALL) -Dm6755 $< $@ + +$(DESTDIR)(pkgconffile): parabolaweb.conf + $(INSTALL) -Dm644 $< $@ -$(DESTDIR)$(confdir)/%: %.conf - install -Dm644 $< $@ +.DELETE_ON_ERROR: diff --git a/parabolaweb-changepassword.real.in b/parabolaweb-changepassword.real.in new file mode 100644 index 0000000..942ec66 --- /dev/null +++ b/parabolaweb-changepassword.real.in @@ -0,0 +1,51 @@ +#!/bin/bash -e + +# Copyright (c) 2014 Luke Shumaker +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +export PATH + +usage() { + printf 'Usage: %s [USERNAME]\n' "${0##*/}" + printf 'A username may only be specified if run as root or WEBUSER.\n' +} + +main() { + . @pkgconffile@ + + [[ -e "${WEBDIR}/manage.py" ]] + [[ -n "${WEBUSER}" ]] + + RUSER=${SUDO_USER:-${SUID_USER:-$USER}} + EUSER=${USER} + + if [[ $EUSER == root ]] || [[ $EUSER == "$WEBUSER" ]]; then + if [[ $# -gt 1 ]]; then + usage >&2 + return 1 + fi + username=${1:-$RUSER} + else + if [[ $# -gt 0 ]]; then + usage >&2 + return 1 + fi + username=$RUSER + fi + + sudo -u "${WEBUSER}" python2 "${WEBDIR}/manage.py" changepassword "${username}" +} + +main "$@" diff --git a/parabolaweb-changepassword.sh b/parabolaweb-changepassword.sh deleted file mode 100755 index 04627c8..0000000 --- a/parabolaweb-changepassword.sh +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/bash -e - -# Copyright (c) 2014 Luke Shumaker -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -export PATH - -usage() { - printf 'Usage: %s [USERNAME]\n' "${0##*/}" - printf 'A username may only be specified if run as root or WEBUSER.\n' -} - -main() { - . /etc/conf.d/parabolaweb - - [[ -e "${WEBDIR}/manage.py" ]] - [[ -n "${WEBUSER}" ]] - - RUSER=${SUDO_USER:-${SUID_USER:-$USER}} - EUSER=${USER} - - if [[ $EUSER == root ]] || [[ $EUSER == "$WEBUSER" ]]; then - if [[ $# -gt 1 ]]; then - usage >&2 - return 1 - fi - username=${1:-$RUSER} - else - if [[ $# -gt 0 ]]; then - usage >&2 - return 1 - fi - username=$RUSER - fi - - sudo -u "${WEBUSER}" python2 "${WEBDIR}/manage.py" changepassword "${username}" -} - -main "$@" diff --git a/parabolaweb-fcgi b/parabolaweb-fcgi deleted file mode 100755 index 431c371..0000000 --- a/parabolaweb-fcgi +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/bash -e - -# Copyright (c) 2012-2013 Luke Shumaker -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. /etc/conf.d/parabolaweb - -[[ -e "${WEBDIR}/manage.py" ]] - -sudo -u "${WEBUSER:-$USER}" python2 \ - "${WEBDIR}/manage.py" runfcgi "${FCGIARGS[@]}" --settings=settings "$@" diff --git a/parabolaweb-fcgi.in b/parabolaweb-fcgi.in new file mode 100644 index 0000000..2c8b5bf --- /dev/null +++ b/parabolaweb-fcgi.in @@ -0,0 +1,23 @@ +#!/bin/bash -e + +# Copyright (c) 2012-2013 Luke Shumaker +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. @pkgconffile@ + +[[ -e "${WEBDIR}/manage.py" ]] + +sudo -u "${WEBUSER:-$USER}" python2 \ + "${WEBDIR}/manage.py" runfcgi "${FCGIARGS[@]}" --settings=settings "$@" diff --git a/parabolaweb-reporead-inotify b/parabolaweb-reporead-inotify deleted file mode 100755 index 4e11146..0000000 --- a/parabolaweb-reporead-inotify +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -e - -# Copyright (c) 2012-2013 Luke Shumaker -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. /etc/conf.d/parabolaweb - -[[ -e "${WEBDIR}/manage.py" ]] -[[ $# -eq 0 ]] - -sudo -u "${WEBUSER:-$USER}" python2 "${WEBDIR}/manage.py" reporead_inotify \ - "${INOTIFYARGS[@]}" diff --git a/parabolaweb-reporead-inotify.in b/parabolaweb-reporead-inotify.in new file mode 100644 index 0000000..66934ea --- /dev/null +++ b/parabolaweb-reporead-inotify.in @@ -0,0 +1,24 @@ +#!/bin/bash -e + +# Copyright (c) 2012-2013 Luke Shumaker +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. @pkgconffile@ + +[[ -e "${WEBDIR}/manage.py" ]] +[[ $# -eq 0 ]] + +sudo -u "${WEBUSER:-$USER}" python2 "${WEBDIR}/manage.py" reporead_inotify \ + "${INOTIFYARGS[@]}" diff --git a/parabolaweb-update b/parabolaweb-update deleted file mode 100755 index d5bcd18..0000000 --- a/parabolaweb-update +++ /dev/null @@ -1,93 +0,0 @@ -#!/bin/bash -e - -# Copyright (c) 2012-2013 Luke Shumaker -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -. /etc/conf.d/parabolaweb -. libremessages - -clean() { - cd "$WEBDIR" - msg "Purging old .pyc files..." - find . -name '*.pyc' -delete - if $RUNMAKE; then - msg "Purging old GNU Make generated files..." - make clean - fi -} - -configure() { - cd "$WEBDIR" - msg "Checking configuration..." - if [[ ! -f local_settings.py ]]; then - msg2 "Configuration file missing, opening editor..." - cp local_settings.py.example local_settings.tmp.$$.py - if "$EDITOR" local_settings.tmp.$$.py; then - mv local_settings.tmp.$$.py local_settings.py - else - rm local_settings.tmp.$$.py - msg "Failed to configure, exiting" - exit 1 - fi - msg2 "Creating database..." - ./manage.py syncdb - else - msg2 "Current configuration checks out" - fi -} - -update-database() { - cd "$WEBDIR" - msg "Updating database..." - msg2 "Running migrations..." - ./manage.py migrate - if [[ -f devel/management/commands/update_types_permissions.py ]]; then - msg2 "Updating permissions..." - ./manage.py update_types_permissions - fi - msg2 "Loading fixtures..." - local file - for file in */fixtures/*.json; do - ./manage.py loaddata "$file" || true - done -} - -update-filesystem() { - cd "$WEBDIR" - msg "Updating filesystem..." - if $RUNMAKE; then - msg2 "Re-creating GNU Make generated files..." - make - fi - msg2 "Collecting static files..." - echo yes | ./manage.py collectstatic -l -} - -main() { - if [[ -z "$EDITOR" ]]; then - error 'Please set the $EDITOR variable' - exit 1 - fi - - if [[ -d "$WEBDIR" ]]; then - clean - fi - gitget checkout "$GITURL" "$WEBDIR" - configure - update-database - update-filesystem -} - -main "$@" diff --git a/parabolaweb-update.in b/parabolaweb-update.in new file mode 100644 index 0000000..6a2ad02 --- /dev/null +++ b/parabolaweb-update.in @@ -0,0 +1,93 @@ +#!/bin/bash -e + +# Copyright (c) 2012-2013 Luke Shumaker +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. @pkgconffile@ +. libremessages + +clean() { + cd "$WEBDIR" + msg "Purging old .pyc files..." + find . -name '*.pyc' -delete + if $RUNMAKE; then + msg "Purging old GNU Make generated files..." + make clean + fi +} + +configure() { + cd "$WEBDIR" + msg "Checking configuration..." + if [[ ! -f local_settings.py ]]; then + msg2 "Configuration file missing, opening editor..." + cp local_settings.py.example local_settings.tmp.$$.py + if "$EDITOR" local_settings.tmp.$$.py; then + mv local_settings.tmp.$$.py local_settings.py + else + rm local_settings.tmp.$$.py + msg "Failed to configure, exiting" + exit 1 + fi + msg2 "Creating database..." + ./manage.py syncdb + else + msg2 "Current configuration checks out" + fi +} + +update-database() { + cd "$WEBDIR" + msg "Updating database..." + msg2 "Running migrations..." + ./manage.py migrate + if [[ -f devel/management/commands/update_types_permissions.py ]]; then + msg2 "Updating permissions..." + ./manage.py update_types_permissions + fi + msg2 "Loading fixtures..." + local file + for file in */fixtures/*.json; do + ./manage.py loaddata "$file" || true + done +} + +update-filesystem() { + cd "$WEBDIR" + msg "Updating filesystem..." + if $RUNMAKE; then + msg2 "Re-creating GNU Make generated files..." + make + fi + msg2 "Collecting static files..." + echo yes | ./manage.py collectstatic -l +} + +main() { + if [[ -z "$EDITOR" ]]; then + error 'Please set the $EDITOR variable' + exit 1 + fi + + if [[ -d "$WEBDIR" ]]; then + clean + fi + gitget checkout "$GITURL" "$WEBDIR" + configure + update-database + update-filesystem +} + +main "$@" -- cgit v1.2.3