def download_rpm_sources(spec, args): """ Generate rules to download sources """ print "# spec.source_urls: " + ",".join(spec.source_urls()) print "# spec.source_paths: " + ",".join(spec.source_paths()) for (url, path) in zip(spec.source_urls(), spec.source_paths()): source = urlparse.urlparse(url) print "# source.scheme: " + source.scheme print "# url: " + url # Source comes from a remote HTTP server if source.scheme in ["http", "https"]: print "%s: %s" % (path, spec.specpath()) print "\t@echo [DOWNLOADER] $@" print "\t@planex-downloader %s %s" % (url, path) # Source comes from a local file or directory if source.scheme == "file": print "%s: %s $(shell find %s)" % (path, spec.specpath(), source.path) # Assume that the directory name is already what's expected by the # spec file, and prefix it with the version number in the tarball print "\t@echo [GIT] $@" dirname = "%s-%s" % (os.path.basename(source.path), spec.version()) print "\t@git --git-dir=%s/.git " "archive --prefix %s/ -o $@ HEAD" % (source.path, dirname) if source.scheme in ["git", "hg"]: print "%s: %s" % (path, spec.specpath()) cmds = sources.source(url, args).archive_commands() print "\t@echo [ARCHIVER] $@" for cmd in cmds: print "\t@%s" % (" ".join(cmd))
def main(): """ Entry point """ config = parse_args_or_exit() logging.basicConfig(format='%(message)s', level=logging.ERROR if config.quiet else logging.DEBUG) specs_path = os.path.join(config.config_dir, config.specs_path, "*.spec.in") templates = [planex.spec.Spec(path) for path in glob.glob(specs_path)] if config.print_only: for template in templates: print template.source_urls() sys.exit(0) if config.dry_run: executor = executors.PrintExecutor(sys.stdout) else: executor = executors.RealExecutor() for template in templates: srcs = [sources.source(url, config) for url in template.source_urls()] commands_list = [src.clone_commands() for src in srcs] logging.info(commands_list) results_list = [[executor.run(command) for command in commands] for commands in commands_list] for results in results_list: for result in results: if result.return_code != 0: logging.warning("FAILED: %s", commands) if result.stdout: logging.warning("STDOUT: %s", result.stdout) if result.stderr: logging.warning("STDERR: %s", result.stderr)