From cb07627b70d3e057ddf07893222d16fabdf76de9 Mon Sep 17 00:00:00 2001 From: Kevin GUERINEAU Date: Sun, 29 Aug 2021 18:59:43 +0200 Subject: [PATCH] first commit --- linux/setup.py | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 linux/setup.py diff --git a/linux/setup.py b/linux/setup.py new file mode 100644 index 0000000..65ec9ff --- /dev/null +++ b/linux/setup.py @@ -0,0 +1,59 @@ +# -*- coding: utf-8 -*- +from setuphelpers import * + +# Usable WAPT package functions: install(), uninstall(), session_setup(), audit(), update_package() +# Declaring global variables - Warnings: 1) WAPT context is only available in package functions; 2) Global variables are not persistent between calls + +nextcloud_path=makepath('/opt','nextcloud') + +def install(): + print("Installing: %s" % control.package) + + if not isdir(nextcloud_path): + mkdirs(nextcloud_path) + + filecopyto('Nextcloud-%s-x86_64.AppImage'%control.version.split('-')[0],makepath(nextcloud_path,'Nextcloud.AppImage')) + run("chmod +x %s/Nextcloud.AppImage" % nextcloud_path) + + filecopyto('nextcloud.desktop',makepath('/usr','share','applications')) + +def uninstall(): + remove_tree(nextcloud_path) + remove_file(makepath('/usr','share','applications','nextcloud.desktop') + + +def update_package(): + + proxies = {} + if isfile(makepath(application_data(),'waptconsole','waptconsole.ini')): + proxywapt = inifile_readstring(makepath(user_local_appdata(),'waptconsole','waptconsole.ini'),'global','http_proxy') + if proxywapt : + proxies = {'http':proxywapt,'https':proxywapt} + + + for line in wgets('https://download.nextcloud.com/desktop/releases/Linux/?C=M;O=D',proxies=proxies).splitlines() : + if 'AppImage' in line: + version = line[line.find('Nextcloud-'):line.find('-x86_64.AppImage')].replace('Nextcloud-','') + break + + exes = glob.glob('*.AppImage') + for fn in exes: + if fn != 'Nextcloud-' + version + '-x86_64.AppImage': + remove_file(fn) + + if not isfile('Nextcloud-' + version + '-x86_64.AppImage'): + wget('https://download.nextcloud.com/desktop/releases/Linux/' + 'Nextcloud-' + version + '-x86_64.AppImage','Nextcloud-' + version + '-x86_64.AppImage',proxies=proxies) + else: + print('Already up to date, skipped') + + os.chdir(os.path.dirname(__file__)) + + from waptpackage import PackageEntry + pe = PackageEntry() + pe.load_control_from_wapt(os.getcwd()) + + pe.version = version + '-0' + pe.save_control_to_wapt(os.getcwd()) + +if __name__ == '__main__': + update_package()