2019-01-03 11:42:32 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
2019-10-19 18:49:58 +02:00
|
|
|
# Get list of debian packages
|
|
|
|
#
|
|
|
|
# Usage:
|
|
|
|
#
|
|
|
|
# cd cppcheck/tools
|
|
|
|
# python daca2-getpackages.py
|
|
|
|
#
|
|
|
|
|
2019-01-03 11:42:32 +01:00
|
|
|
|
|
|
|
import argparse
|
|
|
|
import logging
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
import shutil
|
|
|
|
import glob
|
|
|
|
import os
|
2019-11-03 08:05:06 +01:00
|
|
|
import re
|
2019-01-03 11:42:32 +01:00
|
|
|
import datetime
|
|
|
|
import time
|
2019-11-24 13:05:21 +01:00
|
|
|
import semver
|
2019-01-03 11:42:32 +01:00
|
|
|
|
2019-10-26 17:47:42 +02:00
|
|
|
DEBIAN = ('ftp://ftp.de.debian.org/debian/',
|
2019-01-03 11:42:32 +01:00
|
|
|
'ftp://ftp.debian.org/debian/')
|
|
|
|
|
|
|
|
def wget(filepath):
|
|
|
|
filename = filepath
|
|
|
|
if '/' in filepath:
|
|
|
|
filename = filename[filename.rfind('/') + 1:]
|
|
|
|
for d in DEBIAN:
|
|
|
|
subprocess.call(
|
|
|
|
['nice', 'wget', '--tries=10', '--timeout=300', '-O', filename, d + filepath])
|
|
|
|
if os.path.isfile(filename):
|
|
|
|
return True
|
|
|
|
print('Sleep for 10 seconds..')
|
|
|
|
time.sleep(10)
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
2019-11-24 13:05:21 +01:00
|
|
|
def latestvername(names):
|
|
|
|
if len(names) == 1:
|
|
|
|
return names[0]
|
2020-01-16 20:02:56 +01:00
|
|
|
try:
|
|
|
|
names.sort(cmp=semver.compare, key=lambda x: x[x.index('_')+1:x.index('.orig.tar')])
|
|
|
|
except ValueError:
|
|
|
|
# semver.compare() throws an exception if the version is not formatted
|
|
|
|
# like it is required by semver. For example 0.8 is not valid.
|
|
|
|
pass
|
2019-11-24 13:05:21 +01:00
|
|
|
return names[-1]
|
|
|
|
|
|
|
|
|
2019-01-03 11:42:32 +01:00
|
|
|
def getpackages():
|
|
|
|
if not wget('ls-lR.gz'):
|
2019-03-27 06:33:08 +01:00
|
|
|
sys.exit(1)
|
2019-01-03 11:42:32 +01:00
|
|
|
subprocess.call(['nice', 'gunzip', 'ls-lR.gz'])
|
2019-03-27 06:41:35 +01:00
|
|
|
if not os.path.isfile('ls-lR'):
|
|
|
|
sys.exit(1)
|
2019-01-03 11:42:32 +01:00
|
|
|
f = open('ls-lR', 'rt')
|
|
|
|
lines = f.readlines()
|
|
|
|
f.close()
|
|
|
|
subprocess.call(['rm', 'ls-lR'])
|
|
|
|
|
|
|
|
# Example content in ls-lR:
|
|
|
|
#./pool/main/0/0xffff:
|
|
|
|
#total 1452
|
|
|
|
#-rw-r--r-- 2 dak debadmin 6524 Dec 25 2016 0xffff_0.7-2.debian.tar.xz
|
|
|
|
#-rw-r--r-- 2 dak debadmin 1791 Dec 25 2016 0xffff_0.7-2.dsc
|
|
|
|
#-rw-r--r-- 2 dak debadmin 57168 Dec 25 2016 0xffff_0.7-2_amd64.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 48578 Dec 26 2016 0xffff_0.7-2_arm64.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 56730 Dec 26 2016 0xffff_0.7-2_armel.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 57296 Dec 26 2016 0xffff_0.7-2_armhf.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 60254 Dec 26 2016 0xffff_0.7-2_i386.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 53130 Dec 26 2016 0xffff_0.7-2_mips.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 52542 Dec 26 2016 0xffff_0.7-2_mips64el.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 53712 Dec 26 2016 0xffff_0.7-2_mipsel.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 51908 Dec 26 2016 0xffff_0.7-2_ppc64el.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 53548 Dec 26 2016 0xffff_0.7-2_s390x.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 65248 Dec 25 2016 0xffff_0.7.orig.tar.gz
|
|
|
|
#-rw-r--r-- 2 dak debadmin 6884 Jul 19 19:08 0xffff_0.8-1.debian.tar.xz
|
|
|
|
#-rw-r--r-- 2 dak debadmin 1807 Jul 19 19:08 0xffff_0.8-1.dsc
|
|
|
|
#-rw-r--r-- 2 dak debadmin 58908 Jul 19 19:08 0xffff_0.8-1_amd64.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 51340 Jul 19 19:58 0xffff_0.8-1_arm64.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 57612 Jul 19 20:13 0xffff_0.8-1_armel.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 58584 Jul 19 19:58 0xffff_0.8-1_armhf.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 57544 Jul 19 20:23 0xffff_0.8-1_hurd-i386.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 62048 Jul 19 23:54 0xffff_0.8-1_i386.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 55080 Jul 23 19:07 0xffff_0.8-1_kfreebsd-amd64.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 58392 Jul 23 19:07 0xffff_0.8-1_kfreebsd-i386.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 54144 Jul 19 22:28 0xffff_0.8-1_mips.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 53648 Jul 20 00:56 0xffff_0.8-1_mips64el.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 54740 Jul 19 22:58 0xffff_0.8-1_mipsel.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 57424 Jul 19 19:58 0xffff_0.8-1_ppc64el.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 53764 Jul 19 22:28 0xffff_0.8-1_s390x.deb
|
|
|
|
#-rw-r--r-- 2 dak debadmin 64504 Jul 19 19:08 0xffff_0.8.orig.tar.gz
|
|
|
|
#
|
|
|
|
|
|
|
|
path = None
|
2019-11-03 08:05:06 +01:00
|
|
|
previous_path = ''
|
2019-01-03 11:42:32 +01:00
|
|
|
archives = []
|
|
|
|
filename = None
|
2019-11-24 13:05:21 +01:00
|
|
|
filenames = []
|
2019-01-03 11:42:32 +01:00
|
|
|
for line in lines:
|
|
|
|
line = line.strip()
|
|
|
|
if len(line) < 4:
|
|
|
|
if filename:
|
2019-11-03 08:13:06 +01:00
|
|
|
res1 = re.match(r'(.*)-[0-9.]+$', path)
|
|
|
|
if res1 is None:
|
|
|
|
res1 = re.match(r'(.*)[-.][0-9.]+$', path)
|
|
|
|
res2 = re.match(r'(.*)-[0-9.]+$', previous_path)
|
|
|
|
if res2 is None:
|
|
|
|
res2 = re.match(r'(.*)[-.][0-9.]+$', previous_path)
|
2019-11-03 08:05:06 +01:00
|
|
|
if res1 is None or res2 is None or res1.group(1) != res2.group(1):
|
2019-11-24 13:05:21 +01:00
|
|
|
archives.append(path + '/' + latestvername(filenames))
|
2019-11-03 08:05:06 +01:00
|
|
|
else:
|
2019-11-24 13:05:21 +01:00
|
|
|
archives[-1] = path + '/' + latestvername(filenames)
|
2019-11-03 08:05:06 +01:00
|
|
|
if path:
|
|
|
|
previous_path = path
|
2019-01-03 11:42:32 +01:00
|
|
|
path = None
|
|
|
|
filename = None
|
2019-11-24 13:05:21 +01:00
|
|
|
filenames = []
|
2019-01-03 11:42:32 +01:00
|
|
|
elif line.startswith('./pool/main/'):
|
|
|
|
path = line[2:-1]
|
2020-01-17 12:23:07 +01:00
|
|
|
elif path and line.endswith(('.orig.tar.gz', '.orig.tar.bz2', '.orig.tar.xz')):
|
2019-01-03 11:42:32 +01:00
|
|
|
filename = line[1 + line.rfind(' '):]
|
2019-11-24 13:05:21 +01:00
|
|
|
filenames.append(filename)
|
2019-01-03 11:42:32 +01:00
|
|
|
|
|
|
|
return archives
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for p in getpackages():
|
2019-11-03 08:13:06 +01:00
|
|
|
print(DEBIAN[0] + p)
|
|
|
|
|