packetary/util/parseSources.py
Sergey Kulanov f2bccfc0b3 Bump version to 7.0. Update code from upstream repo
1. Bump version to 7.0

2. Use perestroika v5 repo schema

3. Fixing pool permissions after rsync
This change corrects the permissions of the pool folder so that it can
be consumed as a repository mirror via nginx.

4. Add packages (deb, rpm) specs

Related-bug: #1478118
Related-bug: #1476561
Change-Id: Iada03ddab5b7d551f13692cb1c87a634c2f10947
2015-08-11 17:41:01 +03:00

45 lines
1.2 KiB
Python
Executable File

#!/usr/bin/python
# This script parses contents of given 'Source' files, and creates rsync
# command line to synchronize mirror
import re
import sys
# Regex to parse
regex=re.compile("^(?P<param>[a-zA-Z0-9_-]+):\s?(?P<value>.*)$")
files_regex=re.compile("(?P<md5>[a-f0-9]{32}) [0-9]+ (?P<filename>.*)")
for pkgfile in sys.argv[1:]:
if pkgfile.endswith(".gz"):
import gzip
file = gzip.open(pkgfile)
elif pkgfile.endswith(".bz2"):
import bz2
file = bz2.BZ2File(pkgfile)
else:
file = open(pkgfile)
pkg={}
cur_param=""
for line in file:
if line == "\n":
#print("----------------------------------------------------")
basedir=pkg['directory']
files=files_regex.findall(pkg['files'])
for md5, file in files:
print basedir + "/" + file
pkg={}
continue
m = regex.match(line)
if m:
cur_param = m.group("param").lower()
pkg[cur_param] = m.group("value")
elif line.startswith(" "):
# We got a multiliner continuation
pkg[cur_param] += line.lstrip()
else:
print "IMMPOSSIBIRUUUU!!!!"
sys.exit(999)