#!/usr/bin/python import getpass import re import sys import os import shlex import subprocess import pexpect # the input for this is the repo/main/binary-amd64 file in the source repository file = open(sys.argv[1]) filetext = file.read() destrepo = sys.argv[2] # match each package in the repo (note: Source is an optional line, we ignore it when it is there) pattern = re.compile(r"Package: (.*?)\n(?:Source: .*?\n)*Version: (.*?)\nArchitecture: (.*?)\n", re.MULTILINE | re.DOTALL) packageErrors = 0 count = 0 pw = getpass.getpass("cert passphrase:") for match in pattern.finditer(filetext): count += 1 f1 = "incoming/" + match.group(1) + "_" + match.group(2) + "_amd64.changes" # print "removing " + match.group(1) + " from " + destrepo # child = pexpect.spawn("reprepro remove " + destrepo + " " + match.group(1)) # child.expect('Please enter passphrase:') # child.sendline(pw) # continue if os.path.isfile(f1): try: child = pexpect.spawn("reprepro --ignore=wrongdistribution -Vb . include " + destrepo + " " + f1) child.expect('Please enter passphrase:') child.sendline(pw) except pexpect.EOF as e: print "problem : " + str(e) else: f2 = "incoming/" + match.group(1) + "_" + match.group(2) + "_amd64.deb" if os.path.isfile(f2): try: child = pexpect.spawn("reprepro --ignore=wrongdistribution -Vb . includedeb " + destrepo + " " + f2) child.expect('Please enter passphrase:') child.sendline(pw) except pexpect.EOF as e: print "problem" print "problem : " + str(e) else: f3 = "incoming/" + match.group(1) + "_" + match.group(2) + "_all.deb" if os.path.isfile(f3): try: child = pexpect.spawn("reprepro --ignore=wrongdistribution -Vb . includedeb " + destrepo + " " + f3) child.expect('Please enter passphrase:') child.sendline(pw) except pexpect.EOF as e: print "problem" print "problem : " + str(e) else: print "!!!! not found " + f2 packageErrors += 1 # print " Arch: " + match.group(3) print "total package count:" + str(count) print "total package errors:" + str(packageErrors) #args: ['/usr/bin/reprepro', '--ignore=wrongdistribution', '-Vb', '.', 'includedeb', 'diego', 'incoming/hubzero-twm-config_1.1.3-1_amd64.deb']