def main(): """ Test case to exercise the fetch method from the Repo object. """ description="Program to clone git repo using the twobit.oebuild.Repo object." parser = ArgumentParser(prog=__file__, description=description) parser.add_argument("-n", "--name", default="repo_clone_test", help="name of Repo object") parser.add_argument("-u", "--url", default="repo_clone.git", help="URL of repo") parser.add_argument("-b", "--branch", default="master", help="default branch") parser.add_argument("-r", "--revision", default="head", help="default revision") args = parser.parse_args() repo = Repo(args.name, args.url, args.branch, args.revision, None) print("twobit.oebuild.Repo test Fetch:\n{0}".format (repo)) try: repo.fetch(args.name) except Exception as e: print(e) sys.exit(1)
def layers_gen(args): """ Collect data from repos in src_dir to generate the LAYERS file. """ paths = PathSanity(args.top_dir) paths["src_dir"] = args.src_dir paths["bblayers_file"] = args.bblayers_file paths["layers_file"] = args.layers_file # create list of Repo objects repos = Repo.repos_from_state(paths["bblayers_file"], top_dir=paths._top_dir, src_dir=paths["src_dir"]) # create LAYERS file layers = LayerSerializer(repos) with open(paths["layers_file"], 'w') as layers_fd: layers.write(fd=layers_fd)
def json_gen(args): """ Parse bblayers.conf and collect data from repos in src_dir to generate a json file representing their state. """ paths = PathSanity(args.top_dir) paths["conf_dir"] = "conf" paths["bblayers_file"] = os.path.join(paths["conf_dir"], "bblayers.conf") paths["src_dir"] = args.src_dir paths["json_out"] = args.json_out # build a list of Repo objects and create a fetcher for them repos = Repo.repos_from_state(paths["bblayers_file"], top_dir=paths._top_dir, src_dir=paths["src_dir"]) fetcher = RepoFetcher(paths["src_dir"], repos=repos) # Serialize Repo objects to JSON manifest with open(paths["json_out"], 'w') as repo_json_fd: json.dump(fetcher, repo_json_fd, indent=4, cls=FetcherEncoder)