def label(cls, label, destination): logging.info("Checking out '%(label)s'", dict(label=label)) if not os.path.isdir(destination): os.makedirs(destination) myUIDandGID = ["--myUIDandGIDcheckout"] if os.getuid() != 0 else [] run.run([ "osmosis", "checkout", destination, label, "--MD5", "--removeUnknownFiles", "--putIfMissing", "--objectStores=" + config.objectStoresOsmosisParameter()] + myUIDandGID)
def _exists(self, objectStore, label): output = run.run([ "osmosis", "listlabels", "^" + label + "$", "--objectStores=" + objectStore ]) lines = output.strip().split('\n') return len(lines) > 1 or len(lines[0]) > 0
def go(self): if len(self._requirements) == 0: logging.info("No upseto requirements to fulfill") return matching = [] for basename, hash in self._requirements: requirementLabel = requirementlabel.RequirementLabel( basename=basename, product="build", hash=hash) matching.append(requirementLabel.matching()) logging.info("Checking out '%(labels)s'", dict(labels=matching)) for label in matching: logging.info("Checking out '%(label)s'", dict(label=label)) run.run([ "osmosis", "checkout", "..", label, "--MD5", "--putIfMissing", "--objectStores=" + config.objectStoresOsmosisParameter()])
def go(self): if len(self._requirements) == 0: logging.info("No upseto requirements to fulfill") return matching = [] for basename, hash in self._requirements: requirementLabel = requirementlabel.RequirementLabel( basename=basename, product="build", hash=hash) matching.append(requirementLabel.matching()) logging.info("Checking out '%(labels)s'", dict(labels=matching)) for label in matching: logging.info("Checking out '%(label)s'", dict(label=label)) run.run([ "osmosis", "checkout", "..", label, "--MD5", "--putIfMissing", "--objectStores=" + config.objectStoresOsmosisParameter() ])
def _list(self, objectStore): output = run.run([ "osmosis", "listlabels", '^' + self._labelExpression + '$', "--objectStores", objectStore ]) if output.strip() == "": return [] return output.strip().split('\n')
def _mount(cls): output = run.run(["mount"]) result = [] for line in output.strip().split("\n"): fields = line.split(" ") assert fields[1] == "on", "'mount' output line is in wrong format" result.append(dict(type=fields[4], path=fields[2])) return result
def go(self): existing = run.run([ "osmosis", "listlabels", self._label, "--objectStores", config.LOCAL_OSMOSIS ]) if len(existing.strip()) > 0: logging.info( "label '%(label)s' already exists in local osmosis object store", dict(label=self._label)) return if not config.WITH_OFFICIAL_OBJECT_STORE: raise Exception( "No official object store in configuration to fetch out of") logging.info("fetching label '%(label)s' from official object store", dict(label=self._label)) run.run([ "osmosis", "transfer", self._label, "--objectStores", config.OFFICIAL_OSMOSIS, "--transferDestination", config.LOCAL_OSMOSIS ])
def __init__(self, product, directory): self._product = product self._directory = directory git = gitwrapper.GitWrapper(os.getcwd()) self._basename = git.originURLBasename() if config.OFFICIAL_BUILD: self._state = 'officialcandidate' elif config.CLEAN: self._state = 'cleancandidate' else: self._state = 'dirty' self._label = label.label(basename=self._basename, product=self._product, hash=git.hash(), state=self._state) if config.OFFICIAL_BUILD or config.CLEAN: run.run([ "python", "-m", "upseto.main", "checkRequirements", "--allowNoManifest", "--unsullied", "--gitClean" ])
def _hasLabel(self, objectStore): output = run.run([ "osmosis", "listlabels", '^' + self._toLabel + '$', "--objectStores", objectStore]) return len(output.split('\n')) > 1
def _approve(self, objectStore): run.run(["osmosis", "renamelabel", self._fromLabel, self._toLabel, "--objectStores", objectStore])
def _checkin(self, objectStore): run.run([ "osmosis", "checkin", self._directory, self._label, "--MD5", "--objectStores", objectStore ])
def _existing(self, objectStore): output = run.run([ "osmosis", "listlabels", self._regex(), "--objectStores=" + objectStore ]) return set(output.split("\n"))
def _exists(self, objectStore): output = run.run(["osmosis", "listlabels", "^%s$" % self._label, "--objectStores=" + objectStore]) return self._label in output
def _existing(self, objectStore): output = run.run(["osmosis", "listlabels", self._regex(), "--objectStores=" + objectStore]) return set(output.split("\n"))
localize.Localize(label=args.label).go() elif args.cmd == "fulfillrequirements": fulfillrequirements.FulfillRequirements().go() elif args.cmd == "checkrequirements": checkrequirements.CheckRequirements().go() elif args.cmd == "addrequirement": mani = manifest.Manifest.fromLocalDirOrNew() if args.basename: originURL = mani.findRequirementByBasename(args.basename)['originURL'] logging.info( "Basename '%(basename)s' matches originURL '%(originURL)s'", dict(basename=args.basename, originURL=originURL)) else: originURL = args.originURL if args.master: hash = run.run(["git", "ls-remote", originURL, "HEAD"]).strip().split("\t")[0] logging.info("Latest hash is '%(hash)s'", dict(hash=hash)) else: hash = args.hash mani.addRequirement(originURL=originURL, hash=hash) mani.save() elif args.cmd == "removerequirement": mani = manifest.Manifest.fromLocalDir() mani.delRequirementByBasename(basename=args.originURLBasename) mani.save() elif args.cmd == "printobjectstores": print config.objectStoresOsmosisParameter() elif args.cmd == "printlabel": if args.thisProject: print thisprojectlabel.ThisProjectLabel(args.product).label() else:
def _list(self, objectStore): output = run.run([ "osmosis", "listlabels", '^' + self._labelExpression + '$', "--objectStores", objectStore]) if output.strip() == "": return [] return output.strip().split('\n')
def _eraseLabel(self, objectStore, label): run.run(["osmosis", "eraselabel", label, "--objectStores", objectStore])
def _eraseLabel(self, objectStore, label): run.run( ["osmosis", "eraselabel", label, "--objectStores", objectStore])
def _exists(self, objectStore, label): output = run.run(["osmosis", "listlabels", "^" + label + "$", "--objectStores=" + objectStore]) lines = output.strip().split('\n') return len(lines) > 1 or len(lines[0]) > 0
localize.Localize( label=args.label).go() elif args.cmd == "fulfillrequirements": fulfillrequirements.FulfillRequirements().go() elif args.cmd == "checkrequirements": checkrequirements.CheckRequirements().go() elif args.cmd == "addrequirement": mani = manifest.Manifest.fromLocalDirOrNew() if args.basename: originURL = mani.findRequirementByBasename(args.basename)['originURL'] logging.info("Basename '%(basename)s' matches originURL '%(originURL)s'", dict( basename=args.basename, originURL=originURL)) else: originURL = args.originURL if args.master: hash = run.run(["git", "ls-remote", originURL, "HEAD"]).strip().split("\t")[0] logging.info("Latest hash is '%(hash)s'", dict(hash=hash)) else: hash = args.hash mani.addRequirement(originURL=originURL, hash=hash) mani.save() elif args.cmd == "removerequirement": mani = manifest.Manifest.fromLocalDir() mani.delRequirementByBasename(basename=args.originURLBasename) mani.save() elif args.cmd == "printobjectstores": print config.objectStoresOsmosisParameter() elif args.cmd == "printlabel": if args.thisProject: print thisprojectlabel.ThisProjectLabel(args.product).label() else:
changeStateCmd = subparsers.add_parser("changestate") changeStateCmd.add_argument("--basename", default=None) changeStateCmd.add_argument("--hash", default=None) changeStateCmd.add_argument("--product", required=True) changeStateCmd.add_argument("--fromState", required=True) changeStateCmd.add_argument("--toState", required=True) parser.add_argument("--configurationFile", default="/etc/solvent.conf") args = parser.parse_args() config.load(args.configurationFile) if args.cmd == "changestate": hash = args.hash if hash is None: git = gitwrapper.GitWrapper(os.getcwd()) hash = git.hash() basename = args.basename if basename is None: git = gitwrapper.GitWrapper(os.getcwd()) basename = git.originURLBasename() fromLabel = label.label(basename=basename, product=args.product, hash=hash, state=args.fromState) toLabel = label.label(basename=basename, product=args.product, hash=hash, state=args.toState) run.run([ "osmosis", "renamelabel", fromLabel, toLabel, "--objectStores=" + config.LOCAL_OSMOSIS]) if config.WITH_OFFICIAL_OBJECT_STORE: run.run([ "osmosis", "renamelabel", fromLabel, toLabel, "--objectStores=" + config.OFFICIAL_OSMOSIS]) else: raise AssertionError("No such command")