From f737fa7b13cfbae18ad132e43ca50adae797587e Mon Sep 17 00:00:00 2001
From: Hugo Lefeuvre <hugo.lefeuvre@savoirfairelinux.com>
Date: Tue, 7 Aug 2018 16:20:20 -0400
Subject: [PATCH] packaging: fix issues with oci on Linux Mint

ring-all automatically registers

dl.ring.cx/ring-nightly/{id}_{version_id}

(id and version_id from os-release) as a trusted source. This is
perfectly fine as long as the package is installed on an officially
supported system, but if the package is installed on an unsupported
system (e.g. Linux Mint) the installed source will be wrong even if
even if the package is expected to work.

This patch addresses this issue by adding if else if else statements
handling all possible cases. This is not as pretty as before but it
makes sure we handle all cases properly.

Change-Id: I25167e013c56b212f7d59275419921cd0732de17
Gitlab: #490
---
 packaging/rules/debian/ring-all.postinst | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/packaging/rules/debian/ring-all.postinst b/packaging/rules/debian/ring-all.postinst
index bef66013..b3e3d5da 100755
--- a/packaging/rules/debian/ring-all.postinst
+++ b/packaging/rules/debian/ring-all.postinst
@@ -93,10 +93,27 @@ CAN_ADD_DEB_SOURCE=true
 # the case then we simply don't want to provide automatic updates
 if [ -f /etc/os-release ]; then
     . /etc/os-release
+
     # Set-up Ring PPA end tag
-    ENDTAG="${ID}_${VERSION_ID}"
+    if [ "$OS" = "debian" ] && [ "$VER" = "9" ]; then
+        ENDTAG="${ID}_${VERSION_ID}"
+    elif [ "$OS" = "ubuntu" ] && [ "$VER" = "16.04" ]; then
+        ENDTAG="${ID}_${VERSION_ID}"
+    elif [ "$OS" = "ubuntu" ] && [ "$VER" = "17.04" ]; then
+        ENDTAG="${ID}_${VERSION_ID}"
+    elif [ "$OS" = "ubuntu" ] && [ "$VER" = "17.10" ]; then
+        ENDTAG="${ID}_${VERSION_ID}"
+    elif [ "$OS" = "ubuntu" ] && [ "$VER" = "18.04" ]; then
+        ENDTAG="${ID}_${VERSION_ID}"
+    elif [ "$OS" = "linuxmint" ] && [ "$UBUNTU_CODENAME" = "xenial" ]; then
+        ENDTAG="ubuntu_16.04"
+    elif [ "$OS" = "linuxmint" ] && [ "$UBUNTU_CODENAME" = "bionic" ]; then
+        ENDTAG="ubuntu_18.04"
+    else
+        # Distribution is not supported. Don't provide automatic updates.
+        CAN_ADD_DEB_SOURCE=false
+    fi
 else
-    # Distribution is not supported. Don't provide automatic updates.
     CAN_ADD_DEB_SOURCE=false
 fi
 
-- 
GitLab