Repo Management Helper Script

So we’re finally on to building Fedora 15 for ARMv5 on F13 builders and since we’re managing a repo manually, I needed a script to do the following:

  • Move all failed build packages back to the source folder to be rebuilt again
  • Move all completed build packages not in the destination to that directory
  • Move any build packages in the destination that are not built back to the source folder

Here is the following script which helps us achieve this:

fixs.py

import os
import re
import subprocess

z = '/var/export/f15v5.0'
os.system("mkdir \"%s/fixs/\" 2> /dev/null" % (z))

r = subprocess.Popen(["find", "%s/repo" % (z), "-type", "f"], stdout=subprocess.PIPE).communicate()[0]
s = r.split("\n")

f = subprocess.Popen(["ls", "%s/dest" % (z)], stdout=subprocess.PIPE).communicate()[0]
g = f.split("\n")

for i in g:
	i = i.strip()
	n = re.sub("\.src\.rpm$", "", i)
	m = [0, 0]
	for j in s:
		j = j.strip()
		k = re.sub("[^0-9A-Za-z]", ".", n)
		if (re.match("^.*%s.*$" % (k), j)):
			m[0] = 1
		if (re.match("^.*%s\.src\.rpm$" % (k), j)):
			m[1] = 1
	c = ("mv \"%s/dest/%s\" \"%s/fixs/\"" % (z, i, z))
	if ((m[0] == 1) and (m[1] == 0)):
		print(c)
		os.system(c)
	if ((m[0] == 0) and (m[1] == 0)):
		print(c)
		os.system(c)

Leave a comment