diff options
author | mmoss@chromium.org <mmoss@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 03:41:47 +0000 |
---|---|---|
committer | mmoss@chromium.org <mmoss@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-27 03:41:47 +0000 |
commit | de412917b254482842408c79b01f2962c5888ee2 (patch) | |
tree | cf46d850fed53c6c882d2ad00a51d90e83a6538f /chrome/installer | |
parent | 56e71b7c8d857ed8c05336c370fe4cf95d10f973 (diff) | |
download | chromium_src-de412917b254482842408c79b01f2962c5888ee2.zip chromium_src-de412917b254482842408c79b01f2962c5888ee2.tar.gz chromium_src-de412917b254482842408c79b01f2962c5888ee2.tar.bz2 |
Automatically remove repository configurations on Linux package uninstall.
Review URL: http://codereview.chromium.org/53122
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@12633 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer')
-rw-r--r-- | chrome/installer/linux/common/apt.include | 53 | ||||
-rwxr-xr-x | chrome/installer/linux/debian/prerm | 7 |
2 files changed, 55 insertions, 5 deletions
diff --git a/chrome/installer/linux/common/apt.include b/chrome/installer/linux/common/apt.include index d071733..d0c0ba1 100644 --- a/chrome/installer/linux/common/apt.include +++ b/chrome/installer/linux/common/apt.include @@ -54,16 +54,21 @@ KEYDATA 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')" +} + # Add the Google repository to the apt sources. # Returns: # 0 - no update necessary # 1 - sources were updated # 2 - error update_sources_lists() { - 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')" + find_apt_sources if [ -d "$APT_SOURCESDIR" ]; then # Nothing to do if it's already there. @@ -91,9 +96,47 @@ update_sources_lists() { fi if [ -w "$APT_SOURCES" ]; then - printf "$REPOCONFIG\n" >> "$APT_SOURCES" + printf "$REPOCONFIG #@@PACKAGE@@\n" >> "$APT_SOURCES" return 1 fi return 2 } + +# Remove a repository from the apt sources. +# Returns: +# 0 - successfully removed, or not configured +# 1 - failed to remove +clean_sources_lists() { + find_apt_sources + + if [ -d "$APT_SOURCESDIR" ]; then + # Check if our package.list has this repo configured. + SOURCELIST=$(grep -H "$REPOCONFIG" "$APT_SOURCESDIR/@@PACKAGE@@.list" \ + 2>/dev/null | cut -d ':' -f 1) + if [ -n "$SOURCELIST" ]; then + sed -i -e "\,$REPOCONFIG,d" "$SOURCELIST" + if [ $? -ne 0 ]; then + return 1 + fi + # Delete file if empty (all comments or whitespace) + LINECOUNT=$(sed -e '/^[[:space:]]*\(#.*\|$\)/d' "$SOURCELIST" | wc -l) + if [ "$LINECOUNT" = "0" ]; then + rm -f "$SOURCELIST" + fi + fi + fi + + # Also check if it was added to the global sources.list + SOURCELIST=$(grep -H "$REPOCONFIG" "$APT_SOURCES" 2>/dev/null \ + | cut -d ':' -f 1) + if [ -n "$SOURCELIST" ]; then + # Remove repo line(s) marked with our package comment + sed -i -e "\,$REPOCONFIG #@@PACKAGE@@,d" "$SOURCELIST" + if [ $? -ne 0 ]; then + return 1 + fi + fi + + return 0 +} diff --git a/chrome/installer/linux/debian/prerm b/chrome/installer/linux/debian/prerm index 1cbef42..676fe15 100755 --- a/chrome/installer/linux/debian/prerm +++ b/chrome/installer/linux/debian/prerm @@ -16,3 +16,10 @@ fi if [ -x "$UPDATE_MENUS" ]; then update-menus fi + +# Remove any Google repository added by the package. +@@include@@../common/apt.include + +if [ -x "$APT_GET" ]; then + clean_sources_lists +fi |