def run(package: [CraftPackageObject], action: str, args) -> bool: if package.isIgnored(): CraftCore.log.info( f"Skipping package because it has been ignored: {package}") return True directTargets = package.children.values() if action == "get": return invoke(args.get, directTargets) elif action in ["all", "install-deps"]: # work on the dependencies depPackage = CraftDependencyPackage(package) depList = depPackage.getDependencies() packages = [] for item in depList: if (args.ignoreInstalled and item in directTargets) or packageIsOutdated(item): packages.append(item) CraftCore.log.debug(f"dependency: {item}") if not packages: CraftCore.log.debug("<none>") if action == "install-deps": # we don't intend to build the package itself for x in directTargets: packages.remove(x) CraftTitleUpdater.usePackageProgressTitle(packages) while packages: info = packages[0] # in case we only want to see which packages are still to be build, simply return the package name if args.probe: CraftCore.log.warning(f"pretending {info}: {info.version}") else: if CraftCore.settings.getboolean("ContinuousIntegration", "Enabled", False): CraftCore.debug.debug_line() CraftCore.log.info(f"Status: {CraftTitleUpdater.instance}") if action in ["install-deps"]: action = "all" if not handlePackage(info, action, directTargets=directTargets): CraftCore.log.error( f"fatal error: package {info} {action} failed") return False packages.pop(0) else: for info in directTargets: if not handlePackage(info, action, directTargets=directTargets): return False CraftCore.debug.new_line() return True
def run(package: [CraftPackageObject], action: str, args) -> bool: if package.isIgnored(): CraftCore.log.info( f"Skipping package because it has been ignored: {package}") return True directTargets = package.children.values() CraftCore.state.directTargets = directTargets if action == "get": return invoke(args.get, directTargets) elif action == "install-to-desktop": return installToDektop(directTargets) elif action == "create-download-cache": return createArchiveCache(package) elif action == "print-files": return printFiles(directTargets) elif args.resolve_deps or action in ["all", "install-deps", "update"]: # work on the dependencies depPackage = CraftDependencyPackage(package) if args.resolve_deps: if not args.resolve_deps.capitalize( ) in DependencyType.__members__: CraftCore.log.error( f"Invalid dependency type {args.resolve_deps}, valid types are {DependencyType.__members__}" ) return False depType = DependencyType.__getattr__( args.resolve_deps.capitalize()) elif action == "install-deps": depType = DependencyType.Both else: depType = DependencyType.All depList = depPackage.getDependencies(depType=depType) for p in directTargets: # print if a direct target is disabled # do it after the dependencies are initialised if p.isIgnored(): if not p.categoryInfo.isActive: CraftCore.log.warning( f"Ignoring: {p} as it is not supported on your platform/compiler" ) packages = [] if not args.resolve_deps: for item in depList: if not item.name: continue # are we a real package if ((item in directTargets and (args.ignoreInstalled or (action == "update" and item.subinfo.hasSvnTarget()))) or packageIsOutdated(item)): packages.append(item) CraftCore.log.debug(f"dependency: {item}") elif item in directTargets: CraftCore.debug.step( f"{item} is up to date, nothing to do") else: packages = depList if not packages: CraftCore.log.debug("<none>") if action == "install-deps": # we don't intend to build the package itself for x in directTargets: packages.remove(x) CraftTitleUpdater.usePackageProgressTitle(packages) while packages: info = packages[0] # in case we only want to see which packages are still to be build, simply return the package name if args.probe: CraftCore.log.warning(f"pretending {info}: {info.version}") else: if CraftCore.settings.getboolean("ContinuousIntegration", "Enabled", False): CraftCore.debug.debug_line() CraftCore.log.info(f"Status: {CraftTitleUpdater.instance}") else: CraftTitleUpdater.instance.updateTitle() if action in ["install-deps"]: action = "all" elif action == "update" and not info.isLatestVersionInstalled: action = "all" if not handlePackage(info, action, directTargets=directTargets): CraftCore.log.error( f"fatal error: package {info} {action} failed") return False packages.pop(0) else: for info in directTargets: if not handlePackage(info, action, directTargets=directTargets): return False CraftCore.debug.new_line() return True
def run(package, action, args, directTargets): if package.isIgnored(): craftDebug.log.info( f"Skipping package because it has been ignored: {package}") return True if action == "get": key = args.get.replace("()", "") isMethode = args.get.endswith("()") for p in directTargets: instance = p.instance if hasattr(instance, key.replace("()", "")): attr = getattr(instance, key) if isMethode: value = attr() else: value = attr craftDebug.log.debug(value) print(value) return True else: craftDebug.log.debug(f"{p} has no member {key}") print(f"{p} has no member {key}", file=sys.stderr) return False elif action not in ["all", "install-deps"]: for info in package.children.values(): # not all commands should be executed on the deps if we are a virtual packages # if a buildAction is given, then do not try to build dependencies # and do the action although the package might already be installed. # This is still a bit problematic since packageName might not be a valid # package # for list files, we also want to handle fetching & packaging per package if not handlePackage( info, action, args.doContinue, directTargets=directTargets): return False else: depPackage = CraftDependencyPackage(package) depList = depPackage.getDependencies() packages = [] for item in depList: if (args.ignoreInstalled and item in directTargets) or packageIsOutdated(item): packages.append(item) craftDebug.log.debug(f"dependency: {item}") if not packages: craftDebug.log.debug("<none>") if action == "install-deps": # we don't intend to build the package itself for x in directTargets: packages.remove(x) CraftTitleUpdater.usePackageProgressTitle(packages) while packages: info = packages[0] # in case we only want to see which packages are still to be build, simply return the package name if args.probe: craftDebug.log.warning(f"pretending {info}: {info.version}") else: if action in ["install-deps"]: action = "all" if not handlePackage( info, action, args.doContinue, directTargets=directTargets): craftDebug.log.error( f"fatal error: package {info} {action} failed") return False packages.pop(0) craftDebug.new_line() return True
if child.isCategory(): package.children.update(child.children) else: if tempArgs.target: craftSettings.set("BlueprintVersions", child.path, args.target) package.children[child.name] = child if not run(package, action, tempArgs, package.children.values()): return False return True if __name__ == '__main__': success = False with CraftTimer.Timer("Craft", 0) as timer: CraftTitleUpdater.instance = CraftTitleUpdater() CraftTitleUpdater.instance.start( f"({CraftStandardDirs.craftRoot()}) craft " + " ".join(sys.argv[1:]), timer) try: success = main() except KeyboardInterrupt: pass except BlueprintException as e: craftDebug.log.error(e, exc_info=e.exception or e) except Exception as e: craftDebug.log.error(e, exc_info=e) finally: CraftTitleUpdater.instance.stop() if not success: exit(1)
def run(package: [CraftPackageObject], action: str, args) -> bool: if package.isIgnored(): CraftCore.log.info( f"Skipping package because it has been ignored: {package}") return True directTargets = package.children.values() CraftCore.state.directTargets = directTargets if action == "get": return invoke(args.get, directTargets) if action == "install-to-desktop": return installToDektop(directTargets) elif args.resolve_deps or action in ["all", "install-deps"]: # work on the dependencies depPackage = CraftDependencyPackage(package) if args.resolve_deps: if not args.resolve_deps.capitalize( ) in DependencyType.__members__: CraftCore.log.error( f"Invalid dependency type {args.resolve_deps}, valid types are {DependencyType.__members__}" ) return False depType = DependencyType.__getattr__( args.resolve_deps.capitalize()) print(depType) elif action == "install-deps": depType = DependencyType.Both else: depType = DependencyType.All depList = depPackage.getDependencies(depType=depType) packages = [] if not args.resolve_deps: for item in depList: if (args.ignoreInstalled and item in directTargets) or packageIsOutdated(item): packages.append(item) CraftCore.log.debug(f"dependency: {item}") elif item in directTargets: CraftCore.debug.step( f"{item} is up to date, nothing to do") else: packages = depList if not packages: CraftCore.log.debug("<none>") if action == "install-deps": # we don't intend to build the package itself for x in directTargets: packages.remove(x) CraftTitleUpdater.usePackageProgressTitle(packages) while packages: info = packages[0] # in case we only want to see which packages are still to be build, simply return the package name if args.probe: CraftCore.log.warning(f"pretending {info}: {info.version}") else: if CraftCore.settings.getboolean("ContinuousIntegration", "Enabled", False): CraftCore.debug.debug_line() CraftCore.log.info(f"Status: {CraftTitleUpdater.instance}") if action in ["install-deps"]: action = "all" if not handlePackage(info, action, directTargets=directTargets): CraftCore.log.error( f"fatal error: package {info} {action} failed") return False packages.pop(0) else: for info in directTargets: if not handlePackage(info, action, directTargets=directTargets): return False CraftCore.debug.new_line() return True