From 23d1fbdb09495289c05de62dac1d0763e613176c Mon Sep 17 00:00:00 2001 From: rudolfkoenig <> Date: Mon, 2 Aug 2010 12:47:55 +0000 Subject: [PATCH] debian/ubuntu package creation git-svn-id: https://svn.fhem.de/fhem/trunk@661 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/Makefile | 91 ++++++++++++++++++-------- fhem/contrib/DEBIAN/conffiles | 1 + fhem/contrib/DEBIAN/control | 12 ++++ fhem/contrib/DEBIAN/postinst | 13 ++++ fhem/contrib/DEBIAN/postrm | 10 +++ fhem/contrib/DEBIAN/prerm | 6 ++ fhem/contrib/executables | 27 ++++++++ fhem/contrib/fs20_holidays.sh | 2 +- fhem/contrib/init-scripts/fhem.upstart | 14 ++++ fhem/docs/fhem.html | 11 +++- fhem/fhem.pl | 12 +++- 12 files changed, 169 insertions(+), 31 deletions(-) create mode 100644 fhem/contrib/DEBIAN/conffiles create mode 100755 fhem/contrib/DEBIAN/control create mode 100644 fhem/contrib/DEBIAN/postinst create mode 100755 fhem/contrib/DEBIAN/postrm create mode 100755 fhem/contrib/DEBIAN/prerm create mode 100644 fhem/contrib/executables create mode 100644 fhem/contrib/init-scripts/fhem.upstart diff --git a/fhem/CHANGED b/fhem/CHANGED index 7151abe21..bf40f1849 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -14,6 +14,7 @@ - bugfix: make BS known to CUL to avoid lost messages if both FHZ1300 and CUL are connected, adjust matching rule - feature: Copy&Paste in SVG + - feature: Debian/Ubuntu Package creation in the Makefile - 2010-03-13 (4.9) - bugfix: changed the fhem prompt from FHZ> to fhem> diff --git a/fhem/Makefile b/fhem/Makefile index 0d83aa471..63b352a30 100644 --- a/fhem/Makefile +++ b/fhem/Makefile @@ -1,43 +1,55 @@ -BINDIR=/usr/local/bin -MODDIR=/usr/local/lib +BINDIR=/usr/bin +MODDIR=/usr/share/fhem VARDIR=/var/log/fhem +DOCDIR=/usr/share/doc/fhem +MANDIR=/usr/share/man/man1 +ETCDIR=/etc -VERS=4.9 -DATE=2010-03-14 +# Used for .deb package creation +RBINDIR=$(ROOT)$(BINDIR) +RMODDIR=$(ROOT)$(MODDIR) +RVARDIR=$(ROOT)$(VARDIR) +RDOCDIR=$(ROOT)$(DOCDIR) +RMANDIR=$(ROOT)$(MANDIR) +RETCDIR=$(ROOT)$(ETCDIR) + +VERS=4.10 +DATE=2010-08-01 +DESTDIR=fhem-$(VERS) all: @echo Nothing to do for all. @echo To install, check the Makefile, and then \'make install\' @echo or \'make install-pgm2\' to install a web frontend too. -install:install-base - -mv $(VARDIR)/fhem.cfg $(VARDIR)/fhem.cfg.`date "+%Y-%m-%d_%H:%M:%S"` - cp examples_changed/sample_fhem $(VARDIR)/fhem.cfg - @echo - @echo - @echo Start fhem with - @echo perl $(BINDIR)/fhem.pl $(VARDIR)/fhem.cfg +install:install-pgm2 install-pgm2:install-base - cp -r webfrontend/pgm2/* $(MODDIR)/FHEM - cp docs/commandref.html docs/faq.html docs/HOWTO.html $(MODDIR)/FHEM - cp docs/*.png docs/*.jpg $(MODDIR)/FHEM - -mv $(VARDIR)/fhem.cfg $(VARDIR)/fhem.cfg.`date "+%Y-%m-%d_%H:%M:%S"` - cp examples_changed/sample_pgm2 $(VARDIR)/fhem.cfg - cd examples_changed; for i in *; do cp -r $$i $(MODDIR)/FHEM/example.$$i; done - @echo - @echo - @echo Start fhem with - @echo perl $(BINDIR)/fhem.pl $(VARDIR)/fhem.cfg + cp -r webfrontend/pgm2/* $(RMODDIR)/FHEM + cp docs/commandref.html docs/faq.html docs/HOWTO.html $(RMODDIR)/FHEM + cp docs/*.png docs/*.jpg $(RMODDIR)/FHEM + cd examples_changed; for i in *; do cp -r $$i $(RMODDIR)/FHEM/example.$$i; done + cp examples_changed/sample_pgm2 $(RETCDIR)/fhem.cfg install-base: - mkdir -p $(BINDIR) $(MODDIR) $(VARDIR) - cp fhem.pl $(BINDIR) - cp -r FHEM $(MODDIR) + @echo After installation start fhem with + @echo perl $(BINDIR)/fhem.pl $(ETCDIR)/fhem.cfg + @echo + @echo + mkdir -p $(RBINDIR) $(RMODDIR) $(RVARDIR) + mkdir -p $(RDOCDIR) $(RETCDIR) $(RMANDIR) + cp fhem.pl $(RBINDIR) + cp -r FHEM $(RMODDIR) rm -rf examples_changed cp -r examples examples_changed perl -pi -e 's,modpath \.,modpath $(MODDIR),' examples_changed/[a-z]* perl -pi -e 's,([^h]) /tmp,$$1 $(VARDIR),' examples_changed/[a-z]* + -mv $(RETCDIR)/fhem.cfg $(RETCDIR)/fhem.cfg.`date "+%Y-%m-%d_%H:%M:%S"` + cp examples_changed/sample_fhem $(RETCDIR)/fhem.cfg + cp -rp contrib $(RMODDIR) + cp -rp docs/* $(RDOCDIR) + cp docs/fhem.man $(RMANDIR)/fhem.pl.1 + gzip -9 $(RMANDIR)/fhem.pl.1 dist: @echo Version is $(VERS), Date is $(DATE) @@ -45,11 +57,34 @@ dist: cp -r CHANGED FHEM HISTORY Makefile README.CVS\ TODO contrib docs examples fhem.pl webfrontend .f find .f -name CVS -print | xargs rm -rf + find .f -name example.CVS -print | xargs rm -rf find .f -name \*.orig -print | xargs rm -f find .f -name .#\* -print | xargs rm -f find .f -type f -print |\ xargs perl -pi -e 's/=VERS=/$(VERS)/g;s/=DATE=/$(DATE)/g' - mv .f fhem-$(VERS) - tar cf - fhem-$(VERS) | gzip > fhem-$(VERS).tar.gz - mv fhem-$(VERS)/docs/*.html . - rm -rf fhem-$(VERS) + mv .f $(DESTDIR) + tar cf - $(DESTDIR) | gzip > $(DESTDIR).tar.gz + mv $(DESTDIR)/docs/*.html . + rm -rf $(DESTDIR) + +deb: + echo $(PWD) + rm -rf .f + make ROOT=`pwd`/.f install + cp -r contrib/DEBIAN .f + mkdir .f/etc/init + cp contrib/init-scripts/fhem.upstart .f/etc/init/fhem.conf + find .f -name CVS -print | xargs rm -rf + find .f -name example.CVS -print | xargs rm -rf + find .f -name \*.orig -print | xargs rm -f + find .f -name .#\* -print | xargs rm -f + find .f -type f -print |\ + xargs perl -pi -e 's/=VERS=/$(VERS)/g;s/=DATE=/$(DATE)/g' + find .f -type f | xargs chmod 644 + find .f -type d | xargs chmod 755 + chmod 755 `cat contrib/executables` + gzip -9 .f/$(DOCDIR)/changelog + chown -R root:root .f + mv .f $(DESTDIR) + dpkg-deb --build $(DESTDIR) + rm -rf $(DESTDIR) diff --git a/fhem/contrib/DEBIAN/conffiles b/fhem/contrib/DEBIAN/conffiles new file mode 100644 index 000000000..220308349 --- /dev/null +++ b/fhem/contrib/DEBIAN/conffiles @@ -0,0 +1 @@ +/etc/fhem.cfg diff --git a/fhem/contrib/DEBIAN/control b/fhem/contrib/DEBIAN/control new file mode 100755 index 000000000..081a99db0 --- /dev/null +++ b/fhem/contrib/DEBIAN/control @@ -0,0 +1,12 @@ +Package: fhem +Version: =VERS= +Maintainer: Rudolf Koenig +Description: GPL'd perl server for house automation. + It is used to automate some common tasks in the household like switching lamps + / shutters / heating / etc. and to log events like temperature/humidity/power + consumption. +Section: utils +Priority: extra +Architecture: all +Homepage: http://www.fhem.de +Depends: perl-base (>= 5.6.2), libdevice-serialport-perl (>= 1.0) diff --git a/fhem/contrib/DEBIAN/postinst b/fhem/contrib/DEBIAN/postinst new file mode 100644 index 000000000..bfb984811 --- /dev/null +++ b/fhem/contrib/DEBIAN/postinst @@ -0,0 +1,13 @@ +#!/bin/sh + +# Don't know how to check presence of fhem in passwd with -e +#set -e + +grep -q fhem /etc/passwd +e=$? + +if test ! $e = 0; then + useradd --system --home /var/log/fhem --shell /bin/false fhem +fi +chown -R fhem /var/log/fhem /etc/fhem.cfg +initctl start fhem diff --git a/fhem/contrib/DEBIAN/postrm b/fhem/contrib/DEBIAN/postrm new file mode 100755 index 000000000..0cbf1c310 --- /dev/null +++ b/fhem/contrib/DEBIAN/postrm @@ -0,0 +1,10 @@ +#!/bin/sh + +set -e + +if grep -q fhem /etc/passwd; then + userdel fhem +fi +if test -f /etc/init/fhem.conf; then + rm /etc/init/fhem.conf +fi diff --git a/fhem/contrib/DEBIAN/prerm b/fhem/contrib/DEBIAN/prerm new file mode 100755 index 000000000..0facdb209 --- /dev/null +++ b/fhem/contrib/DEBIAN/prerm @@ -0,0 +1,6 @@ +#!/bin/sh + +set -e +if pgrep fhem.pl >/dev/null; then + initctl stop fhem +fi diff --git a/fhem/contrib/executables b/fhem/contrib/executables new file mode 100644 index 000000000..d0784ba8b --- /dev/null +++ b/fhem/contrib/executables @@ -0,0 +1,27 @@ +.f/usr/bin/fhem.pl +.f/usr/share/fhem/contrib/checkmsg.pl +.f/usr/share/fhem/contrib/crc.pl +.f/usr/share/fhem/contrib/dblog/fhemdb_get.pl +.f/usr/share/fhem/contrib/em1010.pl +.f/usr/share/fhem/contrib/fhem2speech/fhem-speech +.f/usr/share/fhem/contrib/fhem2speech/fhem-speech.agi +.f/usr/share/fhem/contrib/fs20_holidays.sh +.f/usr/share/fhem/contrib/garden.pl +.f/usr/share/fhem/contrib/getstate/fhem-getstate +.f/usr/share/fhem/contrib/init-scripts/fhem.1 +.f/usr/share/fhem/contrib/init-scripts/fhem.2 +.f/usr/share/fhem/contrib/km271.pl +.f/usr/share/fhem/contrib/ks300avg.pl +.f/usr/share/fhem/contrib/rolwzo_not_off.sh +.f/usr/share/fhem/contrib/rotateShiftWork/rotateShiftWork.sh +.f/usr/share/fhem/contrib/serial.pl +.f/usr/share/fhem/contrib/voip2fhem/voip2fhem +.f/usr/share/fhem/contrib/voip2fhem/voip2fhem_create_telefonlist +.f/usr/share/fhem/contrib/voip2fhem/voip2fhem_create_txt2gsm +.f/usr/share/fhem/contrib/ws2000_reader.pl +.f/usr/share/fhem/contrib/DEBIAN/postrm +.f/usr/share/fhem/contrib/DEBIAN/postinst +.f/usr/share/fhem/contrib/DEBIAN/prerm +.f/DEBIAN/postrm +.f/DEBIAN/postinst +.f/DEBIAN/prerm diff --git a/fhem/contrib/fs20_holidays.sh b/fhem/contrib/fs20_holidays.sh index c9d3dc6d1..453fc46ac 100755 --- a/fhem/contrib/fs20_holidays.sh +++ b/fhem/contrib/fs20_holidays.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # script to generate a random number of on/off events to simulate presence eg. # while on holidays. normally this script would be executed by an event like a diff --git a/fhem/contrib/init-scripts/fhem.upstart b/fhem/contrib/init-scripts/fhem.upstart new file mode 100644 index 000000000..9fb02e979 --- /dev/null +++ b/fhem/contrib/init-scripts/fhem.upstart @@ -0,0 +1,14 @@ +# FHEM Service + +description "fhem server" +author "Rudolf Koenig " + +start on (net-device-up + and local-filesystems + and runlevel [2345]) +stop on runlevel [016] + +expect fork +respawn + +exec /usr/bin/fhem.pl /etc/fhem.cfg diff --git a/fhem/docs/fhem.html b/fhem/docs/fhem.html index 666493d47..450b1d9c4 100644 --- a/fhem/docs/fhem.html +++ b/fhem/docs/fhem.html @@ -273,7 +273,16 @@

Installation