From 466f1fe7be8a02950942334f4541087826cc6e9f Mon Sep 17 00:00:00 2001 From: SJ Date: Fri, 11 Oct 2013 14:13:18 +0200 Subject: [PATCH] added metainfo to create deb package of piler --- Makefile.in | 2 +- debian/changelog | 5 ++++ debian/compat | 1 + debian/control | 12 +++++++++ debian/copyright | 0 debian/dirs | 4 +++ debian/postinst | 60 ++++++++++++++++++++++++++++++++++++++++++ debian/preinst | 41 +++++++++++++++++++++++++++++ debian/rules | 14 ++++++++++ util/Makefile.in | 5 +++- util/postinstall.sh.in | 5 ++-- 11 files changed, 145 insertions(+), 4 deletions(-) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/dirs create mode 100644 debian/postinst create mode 100644 debian/preinst create mode 100755 debian/rules diff --git a/Makefile.in b/Makefile.in index 4b65ca20..8f54a409 100644 --- a/Makefile.in +++ b/Makefile.in @@ -66,7 +66,7 @@ $(RECURSIVE_TARGETS): installdirs: mkinstalldirs $(srcdir)/mkinstalldirs \ - $(DESTDIR)$(bindir) $(DESTDIR)$(sbindir) $(DESTDIR)$(libdir) $(DESTDIR)$(libexecdir)/piler $(DESTDIR)$(sysconfdir) \ + $(DESTDIR)$(bindir) $(DESTDIR)$(sbindir) $(DESTDIR)$(libdir) $(DESTDIR)$(libexecdir)/piler $(DESTDIR)$(datarootdir)/piler $(DESTDIR)$(sysconfdir) \ $(DESTDIR)$(localstatedir)/piler/store \ $(DESTDIR)$(localstatedir)/piler/stat $(DESTDIR)$(localstatedir)/piler/tmp \ $(DESTDIR)$(localstatedir)/piler/sphinx diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 00000000..4bac7ad6 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +piler (0.1.25-2) UNRELEASED; urgency=low + + * Improved deb package of piler build 845. + + -- sj Wed, 11 Oct 2013 20:56:24 +0200 diff --git a/debian/compat b/debian/compat new file mode 100644 index 00000000..45a4fb75 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +8 diff --git a/debian/control b/debian/control new file mode 100644 index 00000000..352991ae --- /dev/null +++ b/debian/control @@ -0,0 +1,12 @@ +Source: piler +Maintainer: Janos SUTO +Section: misc +Priority: optional +Standards-Version: 0.1.25 +Build-Depends: debhelper (>= 8), unrtf, catdoc, tnef, poppler-utils, libwrap0, libtre5, libzip2 + +Package: piler +Architecture: amd64 +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: email archiving + piler open source email archiver diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 00000000..e69de29b diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 00000000..dd80ad93 --- /dev/null +++ b/debian/dirs @@ -0,0 +1,4 @@ +/etc/init.d +/usr/local +/usr/local/etc +/usr/local/libexec diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 00000000..54917d01 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,60 @@ +#!/bin/sh +set -e + +generate_pem_file() { + +if [ ! -f /usr/local/etc/piler.pem ]; then + echo "generating pem file . . ." + openssl req -new -newkey rsa:4096 -days 3650 -nodes -x509 -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com" -keyout /usr/local/etc/piler.pem -out 1.cert + cat 1.cert >> /usr/local/etc/piler.pem + chmod 600 /usr/local/etc/piler.pem + rm 1.cert +fi + +} + + +generate_key_file() { + +if [ ! -f /usr/local/etc/piler.key ]; then + echo "generating key file . . ." + dd if=/dev/urandom bs=56 count=1 of=/usr/local/etc/piler.key +fi + +} + + +fix_permissions() { + chown piler:piler /usr/local/bin/pilerexport /usr/local/bin/pilerpurge /usr/local/bin/pilerimport /usr/local/bin/pilerget /usr/local/bin/pileraget /usr/local/bin/reindex + chmod +s /usr/local/bin/pilerexport /usr/local/bin/pilerpurge /usr/local/bin/pilerimport /usr/local/bin/pilerget /usr/local/bin/pileraget /usr/local/bin/reindex + chgrp piler /usr/local/etc/piler.conf /usr/local/etc/piler.key + chmod 640 /usr/local/etc/piler.conf /usr/local/etc/piler.key +} + + +case "$1" in + configure) + chown piler:piler /var/run/piler /var/piler/store /var/piler/tmp + + generate_pem_file + generate_key_file + fix_permissions + + ldconfig + + ;; + + upgrade|abort-upgrade) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 0 + ;; +esac + +#DEBHELPER# + +exit 0 + + diff --git a/debian/preinst b/debian/preinst new file mode 100644 index 00000000..de2e65b9 --- /dev/null +++ b/debian/preinst @@ -0,0 +1,41 @@ +#!/bin/sh +set -e + +create_piler_user() { + id piler &>/dev/null + + if [ $? -ne 0 ]; then + groupadd piler + useradd -g piler -s /bin/sh -d /var/piler piler + usermod -L piler + fi + +} + + +save_current_config() { + BAKFILE=/usr/local/etc/piler.conf.`date +%s` + cp /usr/local/etc/piler.conf $BAKFILE +} + + +case "$1" in + install) + create_piler_user + ;; + + upgrade|abort-upgrade) + save_current_config + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 0 + ;; +esac + +#DEBHELPER# + +exit 0 + + diff --git a/debian/rules b/debian/rules new file mode 100755 index 00000000..05fd6963 --- /dev/null +++ b/debian/rules @@ -0,0 +1,14 @@ +#!/usr/bin/make -f + +%: + dh $@ + +override_dh_auto_configure: + dh_auto_configure -- --build=x86_64-linux-gnu --prefix=/usr/local --sysconfdir=/usr/local/etc --libexecdir=/usr/local/libexec --localstatedir=/var --infodir=/usr/local/share/info --with-database=mysql --enable-starttls --enable-tcpwrappers + +override_dh_auto_install: + $(MAKE) DESTDIR=$$(pwd)/debian/piler prefix=/usr/local install + +override_dh_usrlocal: + + diff --git a/util/Makefile.in b/util/Makefile.in index 3dd8a265..2d756e1d 100644 --- a/util/Makefile.in +++ b/util/Makefile.in @@ -25,7 +25,7 @@ RUNNING_GROUP = `@id_bin@ -gn $(RUNNING_USER)` INSTALL = @INSTALL@ all: - sed -e "s%BINDIR%$(bindir)%" -e "s%__SYSCONFDIR%$(sysconfdir)%" -e "s%__LOCALSTATEDIR%$(localstatedir)%" -e "s%__LIBEXECDIR%$(libexecdir)%" $(srcdir)/postinstall.sh.in > $(srcdir)/postinstall.sh + sed -e "s%BINDIR%$(bindir)%" -e "s%__SYSCONFDIR%$(sysconfdir)%" -e "s%__LOCALSTATEDIR%$(localstatedir)%" -e "s%__LIBEXECDIR%$(libexecdir)%" -e "s%__DATAROOTDIR%$(datarootdir)%" $(srcdir)/postinstall.sh.in > $(srcdir)/postinstall.sh install: @@ -38,6 +38,9 @@ install: $(INSTALL) -m 0755 $(srcdir)/purge.sh $(DESTDIR)$(libexecdir)/piler $(INSTALL) -m 0755 $(srcdir)/postinstall.sh $(DESTDIR)$(libexecdir)/piler + $(INSTALL) -m 0755 $(srcdir)/db-mysql.sql $(DESTDIR)$(datarootdir)/piler + $(INSTALL) -m 0755 $(srcdir)/db-mysql-root.sql.in $(DESTDIR)$(datarootdir)/piler + clean: rm -f postinstall.sh diff --git a/util/postinstall.sh.in b/util/postinstall.sh.in index 3368d06d..62bf3e24 100755 --- a/util/postinstall.sh.in +++ b/util/postinstall.sh.in @@ -14,6 +14,7 @@ load_default_values() { SYSCONFDIR=__SYSCONFDIR LOCALSTATEDIR=__LOCALSTATEDIR LIBEXECDIR=__LIBEXECDIR + DATAROOTDIR=__DATAROOTDIR KEYTMPFILE="piler.key" KEYFILE="$SYSCONFDIR/piler.key" @@ -331,8 +332,8 @@ execute_post_install_tasks() { echo; echo -n "Creating mysql database... "; - sed -e "s%MYSQL_HOSTNAME%$MYSQL_HOSTNAMEg%" -e "s%MYSQL_DATABASE%$MYSQL_DATABASE%g" -e "s%MYSQL_USERNAME%$MYSQL_USERNAME%g" -e "s%MYSQL_PASSWORD%$MYSQL_PASSWORD%g" util/db-mysql-root.sql.in | mysql -h $MYSQL_HOSTNAME -u root --password=$MYSQL_ROOT_PASSWORD - mysql -h $MYSQL_HOSTNAME -u $MYSQL_USERNAME --password=$MYSQL_PASSWORD $MYSQL_DATABASE < util/db-mysql.sql + sed -e "s%MYSQL_HOSTNAME%$MYSQL_HOSTNAMEg%" -e "s%MYSQL_DATABASE%$MYSQL_DATABASE%g" -e "s%MYSQL_USERNAME%$MYSQL_USERNAME%g" -e "s%MYSQL_PASSWORD%$MYSQL_PASSWORD%g" $DATAROOTDIR/piler/db-mysql-root.sql.in | mysql -h $MYSQL_HOSTNAME -u root --password=$MYSQL_ROOT_PASSWORD + mysql -h $MYSQL_HOSTNAME -u $MYSQL_USERNAME --password=$MYSQL_PASSWORD $MYSQL_DATABASE < $DATAROOTDIR/piler/db-mysql.sql echo "Done." echo -n "Overwriting sphinx configuration... ";