From 0b5864cbda2497a39c9d217245b93c5ab3dcc775 Mon Sep 17 00:00:00 2001
From: Legimet <legimet.calc@gmail.com>
Date: Sun, 14 Feb 2016 15:25:08 -0500
Subject: [PATCH] Download KDE patches in make-firefox helper

---
 helpers/config       |  3 ++-
 helpers/make-firefox | 12 ++++++++----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/helpers/config b/helpers/config
index ff3ba246..cf74fa61 100755
--- a/helpers/config
+++ b/helpers/config
@@ -21,6 +21,7 @@
 set -e
 export LANG=C LC_TIME=C
 PACKAGE=$(echo $0 |/bin/sed s/make-//g)
+PKGVERSION=$(dpkg-parsechangelog --show-field Version)
 
 
 export DATE=$(date +'%a, %d %b %Y %T %z')
@@ -53,7 +54,7 @@ find $3 -type f -not -iregex '.*changelog.*' -not -iregex '.*copyright.*' -execd
 }
 changelog(){
 head -n 1 debian/changelog | grep -q $UPSTREAM-security && REPO=$CODENAME-security || REPO=$CODENAME
-echo | dch -D $REPO -v $(/bin/sed -n '1s/^.*(\(.*\)).*/\1'+${REVISION}trisquel${VERSION}'/p' debian/changelog)  "$1"
+echo | dch -D $REPO -v ${PKGVERSION}+${REVISION}trisquel${VERSION} "$1"
 
 # Make sure the changelog file is identical between archs
 /bin/sed "/-- Trisquel/s/.*/ -- Trisquel GNU\/Linux developers <trisquel-devel@listas.trisquel.info>  $DATE/" -i debian/changelog
diff --git a/helpers/make-firefox b/helpers/make-firefox
index f95af40e..95b67e46 100644
--- a/helpers/make-firefox
+++ b/helpers/make-firefox
@@ -29,10 +29,14 @@ patch -p1 < $DATA/enable-js-options.patch
 cp ./browser/components/preferences/advanced-scripts.xul ./browser/components/preferences/in-content/
 
 # KDE integration patches from https://www.rosenauer.org/hg/mozilla
-# These should be taken from the hg branch corresponding to the right version
-# (or default) and placed in the DATA directory in unmodified form
-cp $DATA/mozilla-kde.patch debian/patches/
-cp $DATA/firefox-kde.patch debian/patches/abrowser-kde.patch
+# Use firefox$MAJORVERSION branch if available, otherwise use default
+MAJORVERSION=echo "$PKGVERSION" | sed 's/\([0-9]\+\).*/\1/'
+BRANCH=firefox$MAJORVERSION
+if ! wget --spider https://rosenauer.org/hg/mozilla/log/$BRANCH; then
+	BRANCH=default
+fi
+wget https://rosenauer.org/hg/mozilla/raw-file/$BRANCH/mozilla-kde.patch -O debian/patches/mozilla-kde.patch
+wget https://rosenauer.org/hg/mozilla/raw-file/$BRANCH/firefox-kde.patch -O debian/patches/abrowser-kde.patch
 
 # Add to series
 cat << EOF >> debian/patches/series
-- 
GitLab