Move dbconfig stuff from rules script to postinst and postrm scripts

This commit is contained in:
Emmanuel Papin 2014-12-12 15:06:51 +01:00
parent aa31c9b292
commit cd0b85aaa6
3 changed files with 28 additions and 25 deletions

View File

@ -89,24 +89,6 @@ override_dh_install:
# behavior.
#
dh_link usr/lib/cgi-bin usr/share/zoneminder/cgi-bin
#
# Install sql file for dbconfig (first installation)
install -m 644 db/zm_create.sql \
debian/zoneminder/usr/share/dbconfig-common/data/zoneminder/install/mysql
#
# Remove unneeded sql requests
# dbconfig will create the underlying database
sed -i "/^ *CREATE DATABASE /d" \
debian/zoneminder/usr/share/dbconfig-common/data/zoneminder/install/mysql
sed -i "/^ *USE /d" \
debian/zoneminder/usr/share/dbconfig-common/data/zoneminder/install/mysql
#
# Symlink sql update files for dbconfig
for sqlfile in db/zm_update-*.sql; do \
lnk=`echo $$sqlfile | sed "s/^db\/zm_update-\(.*\)\.sql/\1/"`; \
dh_link usr/share/zoneminder/$$sqlfile \
usr/share/dbconfig-common/data/zoneminder/upgrade/mysql/$$lnk; \
done || true
override_dh_fixperms:
dh_fixperms

View File

@ -60,6 +60,28 @@ fi
# Do this when the package is installed, upgraded or reconfigured
if [ "$1" = "configure" ] || [ "$1" = "reconfigure" ]; then
# Install sql database create file for dbconfig
# (needed at first package installation)
if [ ! -f /usr/share/dbconfig-common/data/zoneminder/install/mysql ]; then
install -m 644 /usr/share/zoneminder/db/zm_create.sql \
/usr/share/dbconfig-common/data/zoneminder/install/mysql
# Remove unneeded sql requests
# dbconfig will create the underlying database
sed -i "/^ *CREATE DATABASE /d" \
/usr/share/dbconfig-common/data/zoneminder/install/mysql
sed -i "/^ *USE /d" \
/usr/share/dbconfig-common/data/zoneminder/install/mysql
fi
# Symlink sql update files for dbconfig (needed when upgrading the package)
for sqlfile in /usr/share/zoneminder/db/zm_update-*.sql; do
lnk=`echo $sqlfile | sed "s/^\/usr\/share\/zoneminder\/db\/zm_update-\(.*\)\.sql/\1/"`
if [ ! -L /usr/share/dbconfig-common/data/zoneminder/upgrade/mysql/$lnk ]; then
ln -sf $sqlfile \
/usr/share/dbconfig-common/data/zoneminder/upgrade/mysql/$lnk
fi
done || true
# Create the underlying database and populate it
# dbconfig will take care of applying any updates which are newer than the
# previously installed version

View File

@ -31,12 +31,8 @@ fi
if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
# Deconfigure the web server
# Catch error because zoneminder/webserver does not exist if the user has
# skipped the use of debconf
db_get zoneminder/webserver || true
webservers="$RET"
for webserver in $webservers; do
db_get zoneminder/webserver
for webserver in $RET; do
webserver=${webserver%,}
# Currently we only support apache2
if [ "$webserver" = "apache2" ] ; then
@ -44,12 +40,15 @@ if [ "$1" = "remove" ] || [ "$1" = "purge" ]; then
fi
done
# Remove dbconfig stuff added in postinst script
rm -rf /usr/share/dbconfig-common/data/zoneminder
# No need to manually remove the zm database, dbconfig take care of this
fi
if [ "$1" = "purge" ]; then
# Delete a potential remaining file not managed by debhelper
# Delete a potential remaining file used in postinst script
rm -f /etc/zm/zm.conf.postinst.bak
# Ask the user if we have to remove the cache directory even if not empty