2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2024-11-22 09:49:50 +00:00

debian/ubuntu package creation

git-svn-id: https://svn.fhem.de/fhem/trunk@661 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2010-08-02 12:47:55 +00:00
parent 06169df608
commit 23d1fbdb09
12 changed files with 169 additions and 31 deletions

View File

@ -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>

View File

@ -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)

View File

@ -0,0 +1 @@
/etc/fhem.cfg

12
fhem/contrib/DEBIAN/control Executable file
View File

@ -0,0 +1,12 @@
Package: fhem
Version: =VERS=
Maintainer: Rudolf Koenig <r.koenig@koeniglich.de>
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)

View File

@ -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

10
fhem/contrib/DEBIAN/postrm Executable file
View File

@ -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

6
fhem/contrib/DEBIAN/prerm Executable file
View File

@ -0,0 +1,6 @@
#!/bin/sh
set -e
if pgrep fhem.pl >/dev/null; then
initctl stop fhem
fi

27
fhem/contrib/executables Normal file
View File

@ -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

View File

@ -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

View File

@ -0,0 +1,14 @@
# FHEM Service
description "fhem server"
author "Rudolf Koenig <r.koenig@koeniglich.de>"
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

View File

@ -273,7 +273,16 @@
<h3>Installation</h3>
<ul>
<h3>Unix</h3>
<h3>Debian/Ubuntu</h3>
<ul>
<li>Install <a href="http://www.koeniglich.de/fhem/fhem-=VERS=.deb">
this</a> package, and connect to
http://localhost:8083/fhem (or to http://localhost:8084/fhem for
smartphones)
</ul>
<h3>Unix/OSX</h3>
<ul>
<li>Make sure you have perl. Install the module Device::SerialPort with
"cpan Device::SerialPort"</li>

View File

@ -160,7 +160,7 @@ my $nextat; # Time when next timer will be triggered.
my $intAtCnt=0;
my %duplicate; # Pool of received msg for multi-fhz/cul setups
my $duplidx=0; # helper for the above pool
my $cvsid = '$Id: fhem.pl,v 1.108 2010-07-18 08:17:48 rudolfkoenig Exp $';
my $cvsid = '$Id: fhem.pl,v 1.109 2010-08-02 12:47:55 rudolfkoenig Exp $';
my $namedef =
"where <name> is either:\n" .
"- a single device name\n" .
@ -272,6 +272,16 @@ if($^O =~ m/Win/ && !$attr{global}{nofork}) {
$attr{global}{nofork}=1;
}
# If started as root, and there is a fhem user in the /etc/passwd, su to it
if($^O !~ m/Win/ && $< == 0) {
my @pw = getpwnam("fhem");
if(@pw) {
use POSIX qw(setuid);
setuid($pw[2]);
}
}
# Go to background if the logfile is a real file (not stdout)
if($attr{global}{logfile} ne "-" && !$attr{global}{nofork}) {
defined(my $pid = fork) || die "Can't fork: $!";