#!/usr/bin/python ## # NAME # mreg.py # # SYNOPSIS # mreg.py [package] [version] [revision] [variant] # # DESCRITPTION # builds and reads out mports registry file # # VERSION # 2.4.0 # 20061204 # # AUTHOR # marius schamschula # marius (a) physics.aamu.edu ## import commands, sys if len(sys.argv) > 1: pkg = sys.argv[1] dp = commands.getoutput('echo $DEVDIR') input = open("/usr/local/var/mports/mreg.dat", 'r') R = input.readlines() input.close() found = 0 L=[] # read out if len(sys.argv) == 1: for r in R: r = r.split() if len(r) > 0: print r[0] + " " + r[1] + " " + r[2] elif len(sys.argv) == 2: for r in R: r = r.split() if len(r) > 0 and r[0] == pkg: print r[0] + " " + r[1] + " " + r[2] # update else: vers = sys.argv[2] rev = sys.argv[3] for r in R: x = r.split() if len(x) > 0 and x[0] != pkg: L.append(r) L.append(pkg + " " + vers + " " + rev) output = open("/usr/local/var/mports/mreg.dat", 'w') for r in L: output.write(r) output.write('\n') output.close()