def buildInstalledPkgRepoSack(self): sack = PackageSack() ainstRoot = AinstRoot(self._installRoot) if not ainstRoot.isValidAinstRoot(): Log.cout(Log.DEBUG, '%s is invalid ainst root' % self._installRoot) return None reader = AinstRootReader(ainstRoot) installPkgMetas = reader.getInstallPkgMetas() if installPkgMetas is None: Log.cout(Log.DEBUG, 'Get install meta of %s failed' % self._installRoot) return None for pkgVer, rpmPath in installPkgMetas: pkg = LocalRpmPackage(rpmPath) if pkg.init(): sack.addPackageObject(pkg) return sack
def buildInstalledPkgRepoSack(self): sack = PackageSack() ainstRoot = AinstRoot(self._installRoot) if not ainstRoot.isValidAinstRoot(): Log.cout(Log.DEBUG, '%s is invalid ainst root' % self._installRoot) return None reader = AinstRootReader(ainstRoot) installPkgMetas = reader.getInstallPkgMetas() if installPkgMetas is None: Log.cout(Log.DEBUG, 'Get install meta of %s failed' % self._installRoot) return None for pkgVer, rpmPath in installPkgMetas: pkg = LocalRpmPackage(rpmPath) if pkg.init(): sack.addPackageObject(pkg) return sack
def buildInstalledPkgSack(self): sack = PackageSack() ainstRoot = AinstRoot(self._installRoot) if not ainstRoot.isValidAinstRoot(): Log.cout(Log.DEBUG, '%s is invalid ainst root' % self._installRoot) return None reader = AinstRootReader(ainstRoot) installPkgMetas = reader.getInstallPkgMetas() if installPkgMetas is None: Log.cout(Log.DEBUG, 'Get install meta of %s failed' % self._installRoot) return None for pkgVer, rpmPath in installPkgMetas: header = rpmutils.readRpmHeader(rpmPath) if header: repo = FakeRepository(self._installRoot, True) pkg = AinstRpmPackage(header, repo) sack.addPackageObject(pkg) return sack
def buildInstalledPkgSack(self): sack = PackageSack() ainstRoot = AinstRoot(self._installRoot) if not ainstRoot.isValidAinstRoot(): Log.cout(Log.DEBUG, '%s is invalid ainst root' % self._installRoot) return None reader = AinstRootReader(ainstRoot) installPkgMetas = reader.getInstallPkgMetas() if installPkgMetas is None: Log.cout(Log.DEBUG, 'Get install meta of %s failed' % self._installRoot) return None for pkgVer, rpmPath in installPkgMetas: header = rpmutils.readRpmHeader(rpmPath) if header: repo = FakeRepository(self._installRoot, True) pkg = AinstRpmPackage(header, repo) sack.addPackageObject(pkg) return sack
def buildActivePkgSack(self): sack = PackageSack() ainstRoot = AinstRoot(self._installRoot) if not ainstRoot.isValidAinstRoot(): Log.cout(Log.DEBUG, '%s is invalid ainst root' % self._installRoot) return None reader = AinstRootReader(ainstRoot) activePkgMetas = reader.getActivePkgMetas() if activePkgMetas is None: Log.cout(Log.DEBUG, 'Get active meta of %s failed' % self._installRoot) return None for pkgName, rpmPath, aicfPath in activePkgMetas: aicfInfo = None if file_util.isFile(aicfPath): aicfInfo = AicfParser().parse(aicfPath) header = rpmutils.readRpmHeader(rpmPath) if header: repo = FakeRepository(self._installRoot, True) pkg = AinstRpmPackage(header, repo, aicfInfo) sack.addPackageObject(pkg) return sack
def buildActivePkgSack(self): sack = PackageSack() ainstRoot = AinstRoot(self._installRoot) if not ainstRoot.isValidAinstRoot(): Log.cout(Log.DEBUG, '%s is invalid ainst root' % self._installRoot) return None reader = AinstRootReader(ainstRoot) activePkgMetas = reader.getActivePkgMetas() if activePkgMetas is None: Log.cout(Log.DEBUG, 'Get active meta of %s failed' % self._installRoot) return None for pkgName, rpmPath, aicfPath in activePkgMetas: aicfInfo = None if file_util.isFile(aicfPath): aicfInfo = AicfParser().parse(aicfPath) header = rpmutils.readRpmHeader(rpmPath) if header: repo = FakeRepository(self._installRoot, True) pkg = AinstRpmPackage(header, repo, aicfInfo) sack.addPackageObject(pkg) return sack
def getAinstOperator(ainstConf, installRoot=None, installRootType=InstallRootType.MUST_INSTALLROOT): if not ainstConf: Log.cout(Log.ERROR, "Ainst config is None") return None if installRootType == InstallRootType.NO_INSTALLROOT: return AinstOperator(ainstConf) if installRootType == InstallRootType.MUST_INSTALLROOT and not installRoot: Log.cout(Log.ERROR, "Install root is invalid") return None if installRoot == '/': return RootAinstOperator(ainstConf, installRoot) ainstRoot = AinstRoot(installRoot) return LocalAinstOperator(ainstConf, installRoot, ainstRoot)
return False self._tmpSettingPath = tmpPath return True def _recoverSettings(self): if not self._tmpSettingPath: return True if not file_util.isFile(self._tmpSettingPath) or\ not file_util.move(self._tmpSettingPath, self._settingPath): return False return True if __name__ == '__main__': installRoot = '/home/xiaoming.zhang/xx/' ainstRoot = AinstRoot(installRoot) ainstRoot.init() rpmPath = '/home/xiaoming.zhang/aicf/aggregator/build/release64/bin_rpm/RPMS/x86_64/aggregator-9.9.1-rc_1.x86_64.rpm' from package_object import PackageObject class TestPkg(PackageObject): def __init__(self): PackageObject.__init__(self) def installed(self): return True def active(self): return True def getLocation(self): return rpmPath package = TestPkg() package.name = 'aggregator' package.version = '9.9.1'