From ad4f71fffa3de2f8ee262ef76f0e926068459d1d Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Fri, 21 Dec 2018 13:27:16 +0100 Subject: [bug] snap post install: add support to python2 Some old systems doesn't have python3 installed by default. Let's keep support for both python3 and python2 in our post installation script. `subprocess.run` doesn't exist on python2. - Resolves: #53 --- snap/hooks/install | 9 +++++---- snap/pre/pack_installers | 7 ++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/snap/hooks/install b/snap/hooks/install index e51cdb5..fa05c6c 100755 --- a/snap/hooks/install +++ b/snap/hooks/install @@ -1,9 +1,9 @@ -#!/usr/bin/env python3 +#!/usr/bin/env python # DO NOT MODIFY MANUALLY # This helper installs the polkit policy file # for the RiseupVPN snap. # It is generated automatically -# by the script at "pkg/riseupvpn/pack_installers" +# by the script at "snap/pre/pack_installers" import subprocess from base64 import decodestring as decode @@ -14,9 +14,10 @@ with open('/usr/share/polkit-1/actions/se.leap.bitmask.riseupvpn.policy', 'w') a for line in lines: polkit.write(line.decode() + "\n") -release = subprocess.run(['cat', '/etc/os-release'], stdout=subprocess.PIPE).stdout +with open('/etc/os-release') as f: + release = f.read() # this is a workaround for the fact that debian does not place snap desktop entries in a system+wide path. -if b'ID=debian' in release: +if 'ID=debian' in release: cmd = 'ln -s /snap/riseup-vpn/current/snap/gui/riseup-vpn.desktop /usr/share/applications/' subprocess.run(cmd.split(' ')) subprocess.run(['update-desktop-database']) diff --git a/snap/pre/pack_installers b/snap/pre/pack_installers index c11bca8..a893574 100755 --- a/snap/pre/pack_installers +++ b/snap/pre/pack_installers @@ -27,7 +27,7 @@ with open(os.path.join(HELPDIR, POLKIT_FILE)) as polkit: b64_polkit = encode(polkit.read().encode()) with open(INSTALL, 'w') as install: - install.write('#!/usr/bin/env python3\n') + install.write('#!/usr/bin/env python\n') install.write('# DO NOT MODIFY MANUALLY\n') install.write('# This helper installs the polkit policy file\n') install.write('# for the RiseupVPN snap.\n') @@ -43,9 +43,10 @@ with open('/usr/share/polkit-1/actions/{polkit_file}', 'w') as polkit: for line in lines: polkit.write(line.decode() + "\\n") -release = subprocess.run(['cat', '/etc/os-release'], stdout=subprocess.PIPE).stdout +with open('/etc/os-release') as f: + release = f.read() # this is a workaround for the fact that debian does not place snap desktop entries in a system+wide path. -if b'ID=debian' in release: +if 'ID=debian' in release: cmd = 'ln -s /snap/{app_name}/current/snap/gui/{app_name}.desktop /usr/share/applications/' subprocess.run(cmd.split(' ')) subprocess.run(['update-desktop-database']) -- cgit v1.2.3