def upgrade(packages, args) -> bool: if packages.children: deps = CraftDependencyPackage(packages) else: deps = CraftDependencyPackage(CraftPackageObject(None)) for packageName, _, _ in CraftCore.installdb.getDistinctInstalled(): p = CraftPackageObject.get(packageName) # package in the db might have been renamed and has no blueprint anymore if p: deps.children[p.path] = p.path packageList = deps.getDependencies() return __recurseCraft( [], ["-i", "--options", "virtual.ignored=True", "craft" ]) and __recurseCraft(["--update"], [x.path for x in packageList])
def createArchiveCache(packages: CraftPackageObject): from Source.ArchiveSource import ArchiveSource from Package.VirtualPackageBase import SourceComponentPackageBase packages = CraftDependencyPackage(packages).getDependencies() for p in packages: if not isinstance(p.instance, ArchiveSource): continue url = p.subinfo.target() if isinstance(url, list): url = url[0] urlInfo = urllib.parse.urlparse(url) if urlInfo.hostname in { "files.kde.org", "download.kde.org", "download.qt.io" }: CraftCore.log.info(f"Skip mirroring of {url}, host is reliable") continue if p.instance._getFileInfoFromArchiveCache(): # already cached continue if isinstance(p.instance, SourceComponentPackageBase): if not p.instance.fetch(noop=False): return False else: if not p.instance.fetch(): return False if not (p.instance.checkDigest() and p.instance.generateSrcManifest()): return False 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() 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 __getImageDirectories(self): """ return the image directories where the files are stored """ imageDirs = [] depList = CraftDependencyPackage(self.package).getDependencies(depType=DependencyType.Runtime|DependencyType.Packaging, ignoredPackages=self.ignoredPackages) for x in depList: _package = x.instance if isinstance(_package, SourceOnlyPackageBase): CraftCore.log.debug(f"Ignoring package it is source only: {x}") continue imageDirs.append((x.instance.imageDir(), x.subinfo.options.package.disableStriping)) # this loop collects the files from all image directories CraftCore.log.debug(f"__getImageDirectories: package: {x}, version: {x.version}") if self.__deployQtSdk: imageDirs.append((self.__qtSdkDir, False)) return imageDirs
def __getImageDirectories(self): """ return the image directories where the files are stored """ imageDirs = [] depList = CraftDependencyPackage(self.package).getDependencies(depType=DependencyType.Runtime, ignoredPackages=self.ignoredPackages) for x in depList: if x.isVirtualPackage(): craftDebug.log.debug(f"Ignoring package b/c it is virtual: {x}") continue _package = x.instance imageDirs.append((x.instance.imageDir(), x.subinfo.options.package.disableStriping)) # this loop collects the files from all image directories craftDebug.log.debug(f"__getImageDirectories: package: {x}, version: {x.version}") if craftSettings.getboolean("QtSDK", "Enabled", False) and self.deployQt and craftSettings.getboolean("QtSDK", "PackageQtSDK", True): imageDirs.append((os.path.join(craftSettings.get("QtSDK", "Path"), craftSettings.get("QtSDK", "Version"), craftSettings.get("QtSDK", "Compiler")), False)) return imageDirs
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
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