+
+
+def read_packages():
+ '''Read in the packages file from source_packages
+ '''
+ try: pf = file("source_packages")
+ except IOError:
+ print "Error: source_packages file not found"
+ exit(1)
+ def is_comment(line):
+ if re.match("^\\s*#", line): return False
+ if "#" in line: raise ValueError(
+ "Source package line contains a comment but not at beginning")
+ return True
+ return map(lambda(x): x.rstrip(),
+ filter(is_comment, pf.readlines()))
+
+
+# main program
+opt = OptionParser()
+opt.add_option('-b', '--build-place',
+ dest='build_place', help="Write resulting packages to BUILD_PLACE",
+ default=build_place)
+opt.add_option('-d', '--distribution',
+ help="Set the Debian distribution to DISTRIBUTION",
+ dest="distribution",
+ default=distribution
+ )
+opt.add_option('-s', '--sbuild-opt',
+ action='append', dest='sbuild_opts',
+ help='Specify an option to be sent to sbuild')
+opt.usage = "%prog [options] [packages]"
+(options, packages) = opt.parse_args()
+build_place = options.build_place
+distribution = options.distribution
+sbuild_opts = options.sbuild_opts
+
+if len(packages) == 0: packages = read_packages()
+