From 1b585c2baf5f7b87a04c19b59373d5a2a0a06a79 Mon Sep 17 00:00:00 2001 From: Damian Minkov Date: Tue, 13 Jul 2010 15:18:43 +0000 Subject: [PATCH] Update debian packages. When deb packet is installed for the first time it automatically ads the key and the repositories. --- resources/install/debian/postinst | 118 ++++++++++++++++++++++++++++++ resources/install/debian/postrm | 45 ++++++++++++ 2 files changed, 163 insertions(+) create mode 100644 resources/install/debian/postinst create mode 100644 resources/install/debian/postrm diff --git a/resources/install/debian/postinst b/resources/install/debian/postinst new file mode 100644 index 000000000..8a75c2fe4 --- /dev/null +++ b/resources/install/debian/postinst @@ -0,0 +1,118 @@ +#!/bin/sh +# +# SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. +# +# Distributable under LGPL license. +# See terms of license at gnu.org. +# + +# sources.list setting for SIP Communicator updates. +REPOCONFIG="deb http://download.sip-communicator.org/deb unstable/" + +SOURCES_PREAMBLE="### THIS FILE IS AUTOMATICALLY CONFIGURED ### +# You may comment out this entry, but any other modifications may be lost.\n" + +APT_CONFIG="`which apt-config 2> /dev/null`" + +# Install the repository signing key +install_key() { + APT_KEY="`which apt-key 2> /dev/null`" + if [ -x "$APT_KEY" ]; then + "$APT_KEY" add - >/dev/null 2>&1 </dev/null) + + # Don't do anything if the file is there, since that probably means + # we have already installed it + if [ -r "$SOURCELIST" ]; then + if [ ! "$REPOMATCH" ]; then + # At this point wrong configuration is active. In that case, + # just abandon the mess and recreate the file + # with the correct configuration. + printf "$SOURCES_PREAMBLE" > "$SOURCELIST" + printf "$REPOCONFIG\n" >> "$SOURCELIST" + + if [ $? -eq 0 ]; then + return 0 + fi + return 2 + fi + fi + + if [ -d "$APT_SOURCESDIR" ]; then + printf "$SOURCES_PREAMBLE" > "$SOURCELIST" + printf "$REPOCONFIG\n" >> "$SOURCELIST" + if [ $? -eq 0 ]; then + return 0 + fi + fi + return 2 +} + +## MAIN ## +install_key +create_sources_lists diff --git a/resources/install/debian/postrm b/resources/install/debian/postrm new file mode 100644 index 000000000..3410a272d --- /dev/null +++ b/resources/install/debian/postrm @@ -0,0 +1,45 @@ +#!/bin/sh +# +# SIP Communicator, the OpenSource Java VoIP and Instant Messaging client. +# +# Distributable under LGPL license. +# See terms of license at gnu.org. +# + +# sources.list setting for SIP Communicator updates. +REPOCONFIG="deb http://download.sip-communicator.org/deb unstable/" + +APT_CONFIG="`which apt-config 2> /dev/null`" + +# Parse apt configuration and return requested variable value. +apt_config_val() { + APTVAR="$1" + if [ -x "$APT_CONFIG" ]; then + "$APT_CONFIG" dump | sed -e "/^$APTVAR /"'!d' -e "s/^$APTVAR \"\(.*\)\".*/\1/" + fi +} + +# Set variables for the locations of the apt sources lists. +find_apt_sources() { + APTDIR=$(apt_config_val Dir) + APTETC=$(apt_config_val 'Dir::Etc') + APT_SOURCES="$APTDIR$APTETC$(apt_config_val 'Dir::Etc::sourcelist')" + APT_SOURCESDIR="$APTDIR$APTETC$(apt_config_val 'Dir::Etc::sourceparts')" +} + +# Remove our custom sources list file. +# Returns: +# 0 - successfully removed, or not configured +# !0 - failed to remove +clean_sources_lists() { + if [ ! "$REPOCONFIG" ]; then + return 0 + fi + + find_apt_sources + + rm -f "$APT_SOURCESDIR/sip-communicator.list" +} + +# Remove any SIP Communicator repository added by the package. +clean_sources_lists