From 52cfb8eb2971837ac7eda8fe854186f9fd45f310 Mon Sep 17 00:00:00 2001
From: Ruben Rodriguez <ruben@trisquel.info>
Date: Mon, 12 Feb 2018 21:31:26 -0500
Subject: [PATCH] Changes to prevent the update system from automatically
 connect to the repos without the user's permission

---
 .../prevent-autoconnection.patch              | 53 +++++++++++++++++++
 .../update-manager/trisquel-versions.patch    |  2 +-
 helpers/make-unattended-upgrades              |  7 ++-
 helpers/make-update-manager                   | 30 +++++++++--
 helpers/make-update-notifier                  |  7 ++-
 5 files changed, 89 insertions(+), 10 deletions(-)
 create mode 100644 helpers/DATA/update-manager/prevent-autoconnection.patch

diff --git a/helpers/DATA/update-manager/prevent-autoconnection.patch b/helpers/DATA/update-manager/prevent-autoconnection.patch
new file mode 100644
index 00000000..9484ccd4
--- /dev/null
+++ b/helpers/DATA/update-manager/prevent-autoconnection.patch
@@ -0,0 +1,53 @@
+diff -ru source.orig/UpdateManager/Dialogs.py source/UpdateManager/Dialogs.py
+--- source.orig/UpdateManager/Dialogs.py	2018-02-12 20:44:33.321329066 -0500
++++ source/UpdateManager/Dialogs.py	2018-02-12 20:45:28.141249480 -0500
+@@ -161,7 +162,20 @@
+         self.add_settings_button()
+         self.focus_button = self.add_button(Gtk.STOCK_OK,
+                                             self.window_main.close)
++class ShouldUpdateDialog(InternalDialog):
++    def __init__(self, window_main):
+ 
++        InternalDialog.__init__(self, window_main)
++        self.set_header(_("Include latest updates from the Internet?"))
++        self.set_desc(_('''To prevent unwanted connections to the Internet
++Trisquel will not automatically check for updates
++unless you say so in the Settings panel.'''))
++        self.add_settings_button()
++        self.add_button(_("Check for Updates"),self.check)
++        self.add_button(_("Ask Me Later"), self.window_main.close)
++
++    def check(self):
++        self.window_main.check_update()
+ 
+ class DistUpgradeDialog(InternalDialog):
+     def __init__(self, window_main, meta_release):
+diff -ru source.orig/UpdateManager/UpdateManager.py source/UpdateManager/UpdateManager.py
+--- source.orig/UpdateManager/UpdateManager.py	2018-02-12 20:44:33.317329071 -0500
++++ source/UpdateManager/UpdateManager.py	2018-02-12 20:45:28.133249491 -0500
+@@ -50,6 +50,7 @@
+                       ErrorDialog,
+                       NeedRestartDialog,
+                       NoUpdatesDialog,
++                      ShouldUpdateDialog,
+                       StoppedUpdatesDialog,
+                       PartialUpgradeDialog,
+                       UnsupportedDialog,
+@@ -205,6 +206,17 @@
+             self.start_available()
+ 
+     def start_update(self):
++        if apt_pkg.config.find_i("APT::Periodic::Update-Package-Lists") == 0:
++            self._start_pane(ShouldUpdateDialog(self))
++            return
++        if self.options.no_update:
++            self.start_available()
++            return
++
++        update_backend = get_backend(self, InstallBackend.ACTION_UPDATE)
++        self._start_pane(update_backend)
++
++    def check_update(self):
+         if self.options.no_update:
+             self.start_available()
+             return
diff --git a/helpers/DATA/update-manager/trisquel-versions.patch b/helpers/DATA/update-manager/trisquel-versions.patch
index 2e5883b7..f83138ff 100644
--- a/helpers/DATA/update-manager/trisquel-versions.patch
+++ b/helpers/DATA/update-manager/trisquel-versions.patch
@@ -20,7 +20,7 @@
  def get_ubuntu_flavor_name(cache=None):
      """ try to guess the flavor name based on the running desktop """
      pkg = get_ubuntu_flavor_package(cache=cache)
--    lookup = {'ubuntustudio-desktop': 'Trisquel Studio'}
+-    lookup = {'ubuntustudio-desktop': 'Ubuntu Studio'}
 +    lookup = {'trisquel-mini': 'Trisquel Mini', 'trisquel-sugar': 'Trisquel Sugar' }
      if pkg in lookup:
          return lookup[pkg]
diff --git a/helpers/make-unattended-upgrades b/helpers/make-unattended-upgrades
index d6f73989..4bb8c281 100644
--- a/helpers/make-unattended-upgrades
+++ b/helpers/make-unattended-upgrades
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-#    Copyright (C) 2008-2010  Rubén Rodríguez <ruben@trisquel.info>
+#    Copyright (C) 2008-2018  Ruben Rodriguez <ruben@trisquel.info>
 #
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
@@ -17,13 +17,16 @@
 #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 #
 
-VERSION=1
+VERSION=2
 COMPONENT=main
 
 . ./config
 
 cp data/50unattended-upgrades.Ubuntu data/50unattended-upgrades.Trisquel
 
+# Prevent automated connections
+sed '/Update-Package-Lists/s/1/0/' -i data/20auto-upgrades
+
 changelog "Compiled for Trisquel"
 
 compile
diff --git a/helpers/make-update-manager b/helpers/make-update-manager
index d87b7b53..f7c63da3 100644
--- a/helpers/make-update-manager
+++ b/helpers/make-update-manager
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-#    Copyright (C) 2008-2014  Rubén Rodríguez <ruben@trisquel.info>
+#    Copyright (C) 2008-2018  Ruben Rodriguez <ruben@trisquel.info>
 #
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
@@ -17,22 +17,42 @@
 #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 #
 
-VERSION=7
+VERSION=8
 
 . ./config
 
+#Closes #12545
+patch -p0 < $DATA/trisquel-versions.patch
+
 cp $DATA/index.docbook help/C/index.docbook
 
+# Prevent automated connections
+patch -p1 < $DATA/prevent-autoconnection.patch
+cat << EOF >> po/es.po
+
+msgid ""
+"To prevent unwanted connections to the Internet\n"
+"Trisquel will not automatically check for updates\n"
+"unless you say so in the Settings panel."
+msgstr ""
+"Para prevenir conexiones inesperadas a Internet\n"
+"Trisquel no descargará actualizaciones automáticamente\n"
+"salvo que lo indiques en el panel de Configuración."
+EOF
+
+replace internet Internet .
 replace Ubuntu Trisquel .
 replace "Trisquel-Gettext" "Ubuntu-Gettext" .
 
+replace ubuntu-desktop trisquel .
+replace kubuntu-desktop triskel .
+replace xubuntu-desktop trisquel-mini .
+replace edubuntu-desktop toast .
+
 sed '/%s base/ s/name.*/name = "Trisquel base"/' -i ./UpdateManager/Core/UpdateList.py
 sed 's_http://changelogs.ubuntu.com/changelogs/pool/_http://packages.trisquel.info/changelogs/pool/_' -i UpdateManager/Core/MyCache.py
 sed '/len(changelog) == 0/,/"later."/d' -i UpdateManager/Core/MyCache.py
 
-#Closes #12545
-patch -p0 < $DATA/trisquel-versions.patch
-
 changelog "Compiled for Trisquel"
 
 compile
diff --git a/helpers/make-update-notifier b/helpers/make-update-notifier
index ed1a8617..65346e26 100644
--- a/helpers/make-update-notifier
+++ b/helpers/make-update-notifier
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-#    Copyright (C) 2012 Ruben Rodriguez <ruben@trisquel.info>
+#    Copyright (C) 2012-2018 Ruben Rodriguez <ruben@trisquel.info>
 #
 #    This program is free software; you can redistribute it and/or modify
 #    it under the terms of the GNU General Public License as published by
@@ -17,7 +17,7 @@
 #    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 #
 
-VERSION=1
+VERSION=2
 COMPONENT=main
 
 . ./config
@@ -25,6 +25,9 @@ COMPONENT=main
 rm debian/update-notifier-hp-firmware.conf
 sed '/hp-firmware/d' -i debian/update-notifier.install
 
+# Prevent automated connections
+sed '/Update-Package-Lists/s/1/0/' -i debian/10periodic
+
 changelog "Disabled hp-firmware handling"
 
 compile
-- 
GitLab