# PDF-XChange Viewer turbo.me file
#
# Licensed under the Apache License, Version 2.0
# http://www.apache.org/licenses/LICENSE-2.0

###################################
# Set metadata
###################################

meta title = "PDF-XChange Viewer"
meta namespace = "Tracker Software"
meta name = "pdf-xchange-viewer"

###################################
# Get build dependencies
###################################

using python:3.4.1,wget

###################################
# Download installer
###################################

cmd mkdir @SYSDRIVE@\Workspace
workdir @SYSDRIVE@\Workspace
batch
 echo import sys > script.py
 echo import re >> script.py
 echo import urllib.request >> script.py
 echo src = urllib.request.urlopen('http://www.tracker-software.com/history/viewer_history.xml').read().decode('utf-8') >> script.py
 echo src = src[src.find('item'):src.find('/item')+1] >> script.py
 echo version = re.findall('title.Version\s*([\d\.]+).\/title.', src)[0] >> script.py
 echo url = re.findall('url="(.*\.exe)"', src)[0] >> script.py
 echo filename = re.findall('.*/(.*\.exe)', url)[0] >> script.py
 echo print([url, filename, version]) >> script.py
cmd python script.py
var res = last
cmd "python -c ""print(%res%[0])"""
var url = last
cmd "python -c ""print(%res%[1])"""
var filename = last
cmd "python -c ""print(%res%[2])"""
var version = last
meta tag = version
cmd "wget %url%"

###################################
# Install
###################################

cmd "%filename% /VERYSILENT /SUPPRESSMSGBOXES /NORESTART"
startup file ("@PROGRAMFILES@\Tracker Software\PDF Viewer\PDFXCview.exe")

###################################
# Clean up
###################################

workdir @SYSDRIVE@\
cmd rmdir @SYSDRIVE@\Workspace /s /q
cmd rmdir @SYSDRIVE@\wget /s /q
cmd rmdir @SYSDRIVE@\Python34 /s /q

Build file for PDF-XChange Viewer
Build file for PDF-XChange Viewer
