control: reassign -1 src:firefox-esr 45.7.0esr-4
control: severity -1 important
control: tags -1 + patch


Reassigning to the version I actually use.  Raising severity, but that's
the maintainer's decision.  This should be fixed for all released
firefox packages.

Attached is a patch that removes (backups) iceweasel desktop files in
$HOME, and references the system wide firefox[-esr].desktop file in
mimeapps.list.  If iceweasel was previously set as the default
application, it will be changed to either firefox or firefox-esr now,
depending on which package is installed and does the migration.  That
sounds good to me, but I'm not really familiar with the 2 flavors of
firefox in debian.

This patch does not exactly what I previously suggested, please find the
rationale in the patch comments.

Please note that I only tested a static version of this patch, but not
the @browser@ substitution in firefox.in.

If you find any errors/issues with this patch, please tell me, since a
similar version will also be used for thunderbird.

Greets
jre
diff --git a/debian/firefox.in b/debian/firefox.in
index 66aaa5870cd..03d4a362afc 100644
--- a/debian/firefox.in
+++ b/debian/firefox.in
@@ -1,5 +1,48 @@
 #!/bin/sh
 
+# Fix old mimeapps.list files referencing iceweasel.
+# The latter location (in ~/.local) is deprecated, but still commonly used.
+# Note: mimeapps.list files configure default applications for MIME types.
+for MIMEAPPS_LIST in ${HOME}/.config/mimeapps.list ${HOME}/.local/share/applications/mimeapps.list; do
+    # Check if file exists and has an old iceweasel entry
+    if [ -e "${MIMEAPPS_LIST}" ] && \
+          grep -iq "\(userapp-\)*iceweasel\(-.*\)*\.desktop" "${MIMEAPPS_LIST}"; then
+        echo "Fixing broken '${MIMEAPPS_LIST}'."
+        MIMEAPPS_LIST_COPY="${MIMEAPPS_LIST}.copy_by_firefox_starter"
+        # Fix mimeapps.list and create backup suffixed ".copy_by_firefox_starter"
+        # (requires GNU sed 3.02 or ssed to make the search case-insensitive
+        # with the option "I").
+        sed -i.copy_by_firefox_starter "s|\(userapp-\)*iceweasel\(-.*\)*\.desktop|@browser@.desktop|gI" "${MIMEAPPS_LIST}"
+        if [ "$(echo $?)" != 0  ]; then
+            echo "The configuration file for default applications for some MIME types"
+            echo "'${MIMEAPPS_LIST}' couldn't be fixed."
+            echo "Please check for potential problems like low disk space or wrong access rights!"
+            logger -i -p warning -s "$0: [desktop migration] Couldn't fix '${MIMEAPPS_LIST}'!"
+            exit 1
+        fi
+    fi
+    echo "A copy of the configuration file for default applications for some MIME types"
+    echo "was saved into '${MIMEAPPS_LIST_COPY}'."
+done
+
+# Remove old iceweasel desktop files in $(HOME)/.local/share/applications/.
+# They are superseded by /usr/share/applications/firefox[-esr].desktop.  The old
+# ones in $(HOME)/.local/share/applications/ don't receive updates and might
+# have missing/outdated fields.
+# They are named 'userapp-Iceweasel-RYY0FY.desktop' (or similar) or
+# 'iceweasel.desktop'.  Usually there should be only one of them at most.
+# Note: .desktop files and their reverse cache mimeinfo.cache provide
+# information about available applications.
+for ICEWEASEL_DESKTOP in $(find ${HOME}/.local/share/applications/ -iname "*iceweasel*.desktop"); do
+    ICEWEASEL_DESKTOP_COPY=${ICEWEASEL_DESKTOP}.copy_by_firefox_starter
+    mv ${ICEWEASEL_DESKTOP} ${ICEWEASEL_DESKTOP_COPY}
+    # Update the mimeinfo cache.  This is not critical because non-existing
+    # .desktop files are ignored by the system anyway.
+    if [ -x "$(which update-desktop-database)" ]; then
+        update-desktop-database ${HOME}/.local/share/applications/
+    fi
+done
+
 FIREFOX="$(which firefox)"
 [ -x "$FIREFOX.real" ] && exec "$FIREFOX.real" "$@"
 

Reply via email to