From c3779b77b7d5dd4184791e75dc680fb22e97c225 Mon Sep 17 00:00:00 2001 From: Diego Giovane Pasqualin <dpasqualin@c3sl.ufpr.br> Date: Wed, 2 Jul 2014 16:32:21 -0300 Subject: [PATCH] le-proinfodata: Fix session-setup-script option on lightdm Signed-off-by: Diego Giovane Pasqualin <dpasqualin@c3sl.ufpr.br> --- le-proinfodata/package/DEBIAN/control | 2 +- le-proinfodata/package/DEBIAN/postinst | 38 ++++++++++++++++++-------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/le-proinfodata/package/DEBIAN/control b/le-proinfodata/package/DEBIAN/control index c0379199..244fb2ee 100644 --- a/le-proinfodata/package/DEBIAN/control +++ b/le-proinfodata/package/DEBIAN/control @@ -1,5 +1,5 @@ Package: le-proinfodata -Version: 1.2.40 +Version: 1.2.42 Maintainer: <proinfodata@c3sl.ufpr.br> Architecture: i386 Section: main diff --git a/le-proinfodata/package/DEBIAN/postinst b/le-proinfodata/package/DEBIAN/postinst index b939f36c..a626daa0 100755 --- a/le-proinfodata/package/DEBIAN/postinst +++ b/le-proinfodata/package/DEBIAN/postinst @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (C) 2004-2010 Centro de Computacao Cientifica e Software Livre +# Copyright (C) 2004-2014 Centro de Computacao Cientifica e Software Livre # Departamento de Informatica - Universidade Federal do Parana - C3SL/UFPR # # This file is part of proinfodata @@ -26,6 +26,28 @@ BACKUP_DIR="/opt/seed_mec_backup" LBFILE="/etc/le-proinfodata/le.zone.bz2" MULTISEAT_DIR="/etc/userful/scripts/PostLogin" +# Set option on lightdm.conf. If the option $1 already exists, make sure it +# has the value $2. If it doesn't exist, add it. +function setLightdmOption() { + local option=$1 + local value=$2 + if ! grep -q "$option" /etc/lightdm/lightdm.conf; then + sed -i "/\[SeatDefaults\]/ a ${option}=${value}" \ + /etc/lightdm/lightdm.conf + else + sed -i "/${option}/ s#=.*#=${value}#" \ + /etc/lightdm/lightdm.conf + fi +} + +# Check whether file $1 was already diverted. +# Return true if it was and false otherwise. +function alreadyDiverted() { + file="$1" + dpkg-divert --listpackage $file | grep -q le-proinfodata + return $? +} + # Descompressing the local base [[ -f $LBFILE ]] && bunzip2 -f $LBFILE @@ -54,15 +76,9 @@ fi # Set lightdm to open the le-proinfodata configuration script when user # session starts if [[ ! -d $MULTISEAT_DIR ]]; then - if ! grep -q "session.*exec_dialog.sh" "/etc/lightdm/lightdm.conf"; then - sed -i '/\[SeatDefaults\]/ a\session-setup-script=/usr/local/bin/exec_dialog.sh' \ - /etc/lightdm/lightdm.conf - fi -else - sed -i '\,session-setup-script=/usr/local/bin/exec_dialog.sh,d' \ - /etc/lightdm/lightdm.conf + setLightdmOption "session-setup-script" "/usr/local/bin/exec_dialog.sh" fi - + # We will no longer need this files, but as the postrm would only remove the # diverts when this package were removed, we have to do it here DIVERTS=" @@ -70,9 +86,7 @@ DIVERTS=" /etc/init/tty1.conf \ " for file in $DIVERTS; do - # Why the heck dpkg-divert doesn't return 'false' if the pattern doesn't - # match on the --list option? - if [ -n "$(dpkg-divert --list $file)" ]; then + if alreadyDiverted $file; then dpkg-divert --package le-proinfodata --remove --rename \ --divert ${file}{.real,} fi -- GitLab