Add support for update_package

master
Daniel Berteaud 6 years ago
parent 3093d2060f
commit 59e4fa1e05
  1. 2
      WAPT/control
  2. 25
      setup.py

@ -1,5 +1,5 @@
package : fws-zabbix-agent
version : 4.0.1-2
version : 4.0.1-3
architecture : all
section : base
priority : optional

@ -36,4 +36,27 @@ def install():
def uninstall():
print('Removing firewall rule')
run_notfatal('netsh advfirewall firewall del rule name="Zabbix Agent"')
run_notfatal('netsh advfirewall firewall del rule name="Zabbix Agent"')
def update_package():
import requests, re
from waptpackage import PackageEntry
print('Updating Zabbix Agent package')
page = requests.get('https://www.suiviperf.com/zabbix/',headers={'User-Agent':'Mozilla/5.0 (Windows NT 6.1; Win64; x64)'}).text
version = re.search('zabbix_agent-(\d+(\.\d+)*)_x64.msi', page).group(1)
for arch in ['86', '64']:
if not isfile('zabbix_agent-%s_x%s.msi' % (version, arch)):
filename ='zabbix_agent-%s_x%s.msi' % (version, arch)
url = 'http://www.suiviperf.com/zabbix/%s' % filename
print('Downloading %s from %s' % (filename, url))
wget(url, filename)
for old in glob.glob(r'zabbix_agent-*_x%s' % arch):
if not old == filename:
remove_file(old)
pe = PackageEntry()
control = pe.load_control_from_wapt(os.getcwd())
if Version(version) > Version(control['version'].split('-',1)[0]):
pe.version = version + '-0'
pe.save_control_to_wapt(os.getcwd())

Loading…
Cancel
Save