From ba082c3de88c82659a8dd0e5fa093fd2a8d13251 Mon Sep 17 00:00:00 2001 From: Jan-Pascal van Best Date: Thu, 11 Feb 2016 20:25:43 +0100 Subject: [PATCH] Initial Debianisation --- .gitignore | 3 ++ debian/README.source | 1 + debian/apache.conf | 8 ++++ debian/changelog | 5 +++ debian/compat | 1 + debian/config | 10 +++++ debian/control | 18 ++++++++ debian/copyright | 35 ++++++++++++++++ debian/dbsettings.py.template | 13 ++++++ debian/gbp.conf | 4 ++ debian/patches/patch-settings | 79 +++++++++++++++++++++++++++++++++++ debian/patches/series | 1 + debian/postinst | 36 ++++++++++++++++ debian/postrm | 25 +++++++++++ debian/prerm | 10 +++++ debian/rules | 24 +++++++++++ debian/settings.ini.example | 17 ++++++++ debian/settings.py.template | 32 ++++++++++++++ debian/source/format | 1 + debian/tweet-django.dirs | 3 ++ debian/tweet-django.links | 3 ++ 21 files changed, 329 insertions(+) create mode 100644 debian/README.source create mode 100644 debian/apache.conf create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/config create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/dbsettings.py.template create mode 100644 debian/gbp.conf create mode 100644 debian/patches/patch-settings create mode 100644 debian/patches/series create mode 100644 debian/postinst create mode 100644 debian/postrm create mode 100644 debian/prerm create mode 100755 debian/rules create mode 100644 debian/settings.ini.example create mode 100644 debian/settings.py.template create mode 100644 debian/source/format create mode 100644 debian/tweet-django.dirs create mode 100644 debian/tweet-django.links diff --git a/.gitignore b/.gitignore index 8cf8bb1..7a179ba 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ __pycache__ *.pyc *.log +tweet_django/local.ini +tweet_django/prod.ini +.pc diff --git a/debian/README.source b/debian/README.source new file mode 100644 index 0000000..582e526 --- /dev/null +++ b/debian/README.source @@ -0,0 +1 @@ +This package uses quilt as a patch management system, see /usr/share/doc/quilt/README.source. diff --git a/debian/apache.conf b/debian/apache.conf new file mode 100644 index 0000000..0fb16ba --- /dev/null +++ b/debian/apache.conf @@ -0,0 +1,8 @@ +WSGIScriptAlias / /usr/share/tweet-django/tweet_django +WSGIPythonPath /usr/share/tweet-django + + + +Require all granted + + diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..4379157 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +tweet-django (1.0-1) unstable; urgency=medium + + * Initial release. (Closes: #XXXXXX) + + -- Jan-Pascal van Best Thu, 11 Feb 2016 21:39:09 +0100 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/config b/debian/config new file mode 100644 index 0000000..8247d89 --- /dev/null +++ b/debian/config @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e +#set -x + +. /usr/share/debconf/confmodule +if [ -f /usr/share/dbconfig-common/dpkg/config.mysql ]; then + . /usr/share/dbconfig-common/dpkg/config.mysql + dbc_go tweet-django $@ +fi diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..17d6473 --- /dev/null +++ b/debian/control @@ -0,0 +1,18 @@ +Source: tweet-django +Section: net +Priority: optional +Maintainer: Jan-Pascal van Best +Build-Depends: debhelper (>= 9), python3, dh-python, dh-systemd (>= 1.3), quilt +Standards-Version: 3.9.6 +Vcs-Git: git://anonscm.debian.org/collab-maint/tweet-django.git +Vcs-Browser: http://anonscm.debian.org/cgit/collab-maint/tweet-django.git +Homepage: https://github.com/tweet-django/tweet-django + +Package: tweet-django +Architecture: all +Depends: lsb-base (>= 3.1-13), ${python3:Depends}, ${misc:Depends}, + libapache2-mod-wsgi-py3, dbconfig-common, ucf (>=0.28) +Recommends: mysql-client +Suggests: mysql-server +Description: Utility to help sys admins thwart SSH crackers + tweet-django is a program that blah blah blah diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..1800360 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,35 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: tweet-django +Upstream-Contact: Jan-Pascal van Best +Source: http://www.vanbest.org/gitweb/tweet_django + +Files: * +Copyright: 2016, Jan-Pascal van Best +License: GPL-3+ + +Files: debian/* +Copyright: 2016, Jan-Pascal van Best +License: GPL-3+ + +License: GPL-3+ + 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 3 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 package; if not, see + or write to the Free + Software Foundation, Inc., 51 Franklin St, Fifth Floor, + Boston, MA 02110-1301 USA + . + On Debian systems, the full text of the GNU General Public + License version 3 can be found in the file + `/usr/share/common-licenses/GPL-3'. diff --git a/debian/dbsettings.py.template b/debian/dbsettings.py.template new file mode 100644 index 0000000..8ee0e4a --- /dev/null +++ b/debian/dbsettings.py.template @@ -0,0 +1,13 @@ +# Database configuration +# Managed by dbconfig-common +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends._DBC_DBTYPE_', + 'HOST': '_DBC_DBSERVER_', + 'NAME': '_DBC_DBNAME_', + 'USER': '_DBC_DBUSER_', + 'PASSWORD': '_DBC_DBPASS_', + 'OPTIONS': {'charset': 'utf8mb4'}, + } +} + diff --git a/debian/gbp.conf b/debian/gbp.conf new file mode 100644 index 0000000..164cf43 --- /dev/null +++ b/debian/gbp.conf @@ -0,0 +1,4 @@ +[DEFAULT] +debian-branch=master +upstream-branch=upstream +upstream-tag=v%(version)s diff --git a/debian/patches/patch-settings b/debian/patches/patch-settings new file mode 100644 index 0000000..23045d2 --- /dev/null +++ b/debian/patches/patch-settings @@ -0,0 +1,79 @@ +--- a/tweet_django/settings.py ++++ b/tweet_django/settings.py +@@ -20,11 +20,8 @@ + # Quick-start development settings - unsuitable for production + # See https://docs.djangoproject.com/en/1.9/howto/deployment/checklist/ + +-# SECURITY WARNING: keep the secret key used in production secret! +-SECRET_KEY = 'gho@vr!guh#ylqdi4(voavn+*lzyvm&91xnz9c-x6yol5ye%s=' +- + # SECURITY WARNING: don't run with debug turned on in production! +-DEBUG = True ++DEBUG = False + + ALLOWED_HOSTS = [] + +@@ -57,7 +54,7 @@ + TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', +- 'DIRS': [], ++ 'DIRS': ['/usr/share/tweet-django/templates'], + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': [ +@@ -111,34 +108,6 @@ + + STATIC_URL = '/static/' + +-# Application specific settings +- +-TWEET_BASEPATH = 'results' +- +- +-config = ConfigParser() +-config.read(os.path.join(BASE_DIR, 'tweet_django', 'local.ini')) +- +-DATABASES = { +- 'default': { +- 'ENGINE': config.get('database', 'ENGINE'), +- 'NAME': config.get('database', 'NAME'), +- 'USER': config.get('database', 'USER'), +- 'PASSWORD': config.get('database', 'PASSWORD'), +- 'HOST': config.get('database', 'HOST'), +- 'OPTIONS': {'charset': 'utf8mb4'}, +- } +-} +- +-TWEET_BASEPATH = config.get('paths', 'TWEET_BASEPATH') +- +-TWEET_OAUTH_CONSUMER_KEY = config.get('twitter', 'TWEET_OAUTH_CONSUMER_KEY') +-TWEET_OAUTH_CONSUMER_SECRET = config.get('twitter', 'TWEET_OAUTH_CONSUMER_SECRET') +-TWEET_OAUTH_ACCESS_TOKEN = config.get('twitter', 'TWEET_OAUTH_ACCESS_TOKEN') +-TWEET_OAUTH_ACCESS_TOKEN_SECRET = config.get('twitter', 'TWEET_OAUTH_ACCESS_TOKEN_SECRET') +- +-TWEET_MAPQUEST_API_KEY = config.get('geo', 'TWEET_MAPQUEST_API_KEY') +- + # Logging + + LOGGING = { +@@ -151,7 +120,7 @@ + 'file': { + 'level': 'DEBUG', + 'class': 'logging.FileHandler', +- 'filename': 'django_debug.log', ++ 'filename': '/var/log/tweet-django/debug.log', + }, + }, + 'loggers': { +@@ -167,3 +136,10 @@ + }, + }, + } ++ ++# Database settings, provided by dbconfig_common ++if os.path.exists("/etc/tweet-django/dbsettings.py"): ++ exec(open("/etc/tweet-django/dbsettings.py").read()) ++ ++if os.path.exists("/etc/tweet-django/settings.py"): ++ exec(open("/etc/tweet-django/settings.py").read()) diff --git a/debian/patches/series b/debian/patches/series new file mode 100644 index 0000000..4722455 --- /dev/null +++ b/debian/patches/series @@ -0,0 +1 @@ +patch-settings diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..91d537c --- /dev/null +++ b/debian/postinst @@ -0,0 +1,36 @@ +#!/bin/sh + +set -e +#set -x + +. /usr/share/debconf/confmodule +. /usr/share/dbconfig-common/dpkg/postinst.mysql +dbc_sql_substitutions=1 +dbc_generate_include=template:/etc/tweet-django/dbsettings.py +dbc_generate_include_args=-otemplate_infile=/usr/share/tweet-django/debian/dbsettings.py.template +dbc_generate_include_owner=root:www-data +dbc_generate_include_perms=0640 +dbc_go tweet-django $@ + +if [ "$1" = configure ] ; then + random_key=$( env LANG=C LC_ALL=C tr -dc "[:alnum:]" < /dev/urandom | dd bs=1 count=63 2> /dev/null ) + tempfile=`tempfile` + sed -e "s/__SECRET_KEY__/$random_key/" < /usr/share/tweet-django/debian/settings.py.template > $tempfile + chown root:www-data $tempfile + chmod 0640 $tempfile + ucf --debconf-ok $tempfile /etc/tweet-django/settings.py + ucfr tweet-django /etc/tweet-django/settings.py + rm -f $tempfile + + if ! dpkg-statoverride --list /var/log/tweet-django >/dev/null; then + chown -R www-data:www-data /var/log/tweet-django + fi + if ! dpkg-statoverride --list /var/lib/tweet-django >/dev/null; then + chown -R www-data:www-data /var/lib/tweet-django + fi + + /usr/share/tweet-django/manage.py migrate + +fi + +#DEBHELPER# diff --git a/debian/postrm b/debian/postrm new file mode 100644 index 0000000..20814eb --- /dev/null +++ b/debian/postrm @@ -0,0 +1,25 @@ +#!/bin/sh + +set -e +#set -x + +if [ -f /usr/share/debconf/confmodule ]; then + . /usr/share/debconf/confmodule +fi +if [ -f /usr/share/dbconfig-common/dpkg/postrm.mysql ]; then + . /usr/share/dbconfig-common/dpkg/postrm.mysql + dbc_go tweet-django $@ +fi + + +if [ "$1" = "purge" ]; then + for conffile in dbsettings.py settings.py; do + rm -f /etc/tweet-django/$conffile + if which ucf >/dev/null 2>&1; then + ucf --debconf-ok --purge /etc/tweet-django/$conffile + ucfr --purge tweet-django /etc/tweet-django/$conffile + fi + done +fi + +#DEBHELPER# diff --git a/debian/prerm b/debian/prerm new file mode 100644 index 0000000..8e6eb08 --- /dev/null +++ b/debian/prerm @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e +#set -x + +. /usr/share/debconf/confmodule +. /usr/share/dbconfig-common/dpkg/prerm.mysql +dbc_go tweet-django $@ + +#DEBHELPER# diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..d5a87a1 --- /dev/null +++ b/debian/rules @@ -0,0 +1,24 @@ +#!/usr/bin/make -f +# -*- makefile -*- + +DESTDIR := debian/tweet-django + +%: + dh $@ --with python3,systemd + +override_dh_auto_install: + install -m 0755 -D manage.py --target-directory=$(DESTDIR)/usr/share/tweet-django/ + install -m 0755 -D runstream.py --target-directory=$(DESTDIR)/usr/share/tweet-django/ + install -m 0640 -D tweet/*.py --target-directory=$(DESTDIR)/usr/share/tweet-django/tweet/ + install -m 0640 -D tweet/migrations/*.py --target-directory=$(DESTDIR)/usr/share/tweet-django/tweet/migrations + install -m 0640 -D tweet/templates/tweet/* --target-directory=$(DESTDIR)/usr/share/tweet-django/templates/tweet/ + install -m 0640 -D tweet/static/tweet/favicon.ico --target-directory=$(DESTDIR)/usr/share/tweet-django/static/tweet/ + #install -m 0640 -D tweet/static/tweet/javascript/* --target-directory=$(DESTDIR)/usr/share/tweet-django/static/tweet/javascript/ + cp -r tweet/static/tweet/stylesheets --target-directory=$(DESTDIR)/usr/share/tweet-django/static/tweet/ + install -m 0640 -D tweet_django/*.py --target-directory=$(DESTDIR)/usr/share/tweet-django/tweet_django/ + install -m 0640 -D debian/dbsettings.py.template --target-directory=$(DESTDIR)/usr/share/tweet-django/debian/ + install -m 0640 -D debian/settings.py.template --target-directory=$(DESTDIR)/usr/share/tweet-django/debian/ + #install -m 0640 -o root -g www-data debian/settings.ini.example $(DESTDIR)/etc/tweet-django/settings.ini + install -m 0755 -d $(DESTDIR)/var/lib/tweet-django + install -m 0755 -d $(DESTDIR)/var/log/tweet-django + diff --git a/debian/settings.ini.example b/debian/settings.ini.example new file mode 100644 index 0000000..c16e3f7 --- /dev/null +++ b/debian/settings.ini.example @@ -0,0 +1,17 @@ +# Database +[misc] +SECRET_KEY = + +[paths] +TWEET_BASEPATH = /var/lib/tweet-django +STATIC_ROOT = /usr/share/tweet-django/static +STATIC_URL = /static/ + +[twitter] +TWEET_OAUTH_CONSUMER_KEY = +TWEET_OAUTH_CONSUMER_SECRET = +TWEET_OAUTH_ACCESS_TOKEN = +TWEET_OAUTH_ACCESS_TOKEN_SECRET = + +[geo] +TWEET_MAPQUEST_API_KEY = diff --git a/debian/settings.py.template b/debian/settings.py.template new file mode 100644 index 0000000..b514a7b --- /dev/null +++ b/debian/settings.py.template @@ -0,0 +1,32 @@ +DEBUG = False + +# Fill in the host names your web server uses +ALLOWED_HOSTS = ["127.0.0.1"] + +# Internationalization +# https://docs.djangoproject.com/en/1.9/topics/i18n/ + +LANGUAGE_CODE = 'en-us' +TIME_ZONE = 'Europe/Amsterdam' +USE_I18N = True +USE_L10N = True +USE_TZ = True + + +# Static files (CSS, JavaScript, Images) +# https://docs.djangoproject.com/en/1.9/howto/static-files/ + +STATIC_URL = '/static/' + +SECRET_KEY = '__SECRET_KEY__' + +TWEET_BASEPATH = '/var/lib/tweet-django' +STATIC_ROOT = '/usr/share/tweet-django/static' +STATIC_URL = '/static/' + +TWEET_OAUTH_CONSUMER_KEY = '' +TWEET_OAUTH_CONSUMER_SECRET = '' +TWEET_OAUTH_ACCESS_TOKEN = '' +TWEET_OAUTH_ACCESS_TOKEN_SECRET = '' + +TWEET_MAPQUEST_API_KEY = '' diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/tweet-django.dirs b/debian/tweet-django.dirs new file mode 100644 index 0000000..40af13d --- /dev/null +++ b/debian/tweet-django.dirs @@ -0,0 +1,3 @@ +usr/share/tweet-django/static/tweet/javascript +usr/share/tweet-django/static/tweet/stylesheets +/etc/tweet-django diff --git a/debian/tweet-django.links b/debian/tweet-django.links new file mode 100644 index 0000000..905ecc0 --- /dev/null +++ b/debian/tweet-django.links @@ -0,0 +1,3 @@ +usr/share/javascript/bootstrap/js/bootstrap.min.js usr/share/tweet-django/static/tweet/javascript/bootstrap.min.js +usr/share/javascript/jquery/jquery.min.js usr/share/tweet-django/static/tweet/javascript/jquery.min.js +usr/share/javascript/jquery-ui/jquery-ui.min.js usr/share/tweet-django/static/tweet/javascript/jquery-ui.min.js -- 2.39.5