From 1a9887fe27c439662bacfeac8323ad86cd2997d9 Mon Sep 17 00:00:00 2001 From: Emiliano Vavassori Date: Thu, 17 Mar 2022 02:30:16 +0100 Subject: [PATCH] Inizio script di controllo versione. --- .gitignore | 1 + getversions.py | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 .gitignore create mode 100644 getversions.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5ceb386 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +venv diff --git a/getversions.py b/getversions.py new file mode 100644 index 0000000..be6eaf3 --- /dev/null +++ b/getversions.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python +# encoding: utf-8 + +import urllib.request +from lxml import etree +import re, sys + +archiveurl = "https://downloadarchive.documentfoundation.org/libreoffice/old/" +baseurl = "https://download.documentfoundation.org/libreoffice/" + +def getlatestrel(basever): + """Search in downloadarchive the latest version matching the baseversion indicated.""" + versionlist = etree.HTML(urllib.request.urlopen(archiveurl).read()).xpath('//td/a') + # Getting a more polished matching list + cleanlist = list(dict.fromkeys([x.strip('/') if x.startswith(basever) else None for x in versionlist])) + # Removing None entries + cleanlist.remove(None) + # Sorting, then returning the last version + return sorted(cleanlist)[-1] + +if len(sys.argv) > 1: + # A version has been specified. + version = sys.argv[1] + if '.' in version: + # Numbered version. + # Let's check it is a 4 dotted release + if not len(version.split('.')) == 4: + version = getlatestrel(version) + else: + # string version + if version == 'still': + elif version == 'fresh': + elif version == 'daily': + + +# Running for stable channel +html_stable = urllib.request.urlopen(baseurl + 'stable/').read() + +# Processing page content +stable_contents = etree.HTML(html_stable) + +# Processing first page links +stable_versions = [] +for link in stable_contents.xpath('//td/a'): + next if link.text == "Parent Directory" + + stable_versions.append(link.get('href').replace('/', '') + + # getting URL for specific versions + for arch in [ 'x86', 'x86_64' ]: + newurl = baseurl + 'stable/' + link.get('href') + 'deb/' + arch + '/' + res = etree.HTML(urllib.request.urlopen(newurl).read()).xpath("//td/a") + if len(res) == 1: + # No packages provided + next + + for link in res: + next if res.text == 'Parent Directory' + next if re.search(r'deb.tar.gz$', res.text): + # Matches a package - good. + # Checking for language packs and offline help +