def test_GetFakeSrv4(self): self.dbc.InitialDataImport() importer = system_pkgmap.InstallContentsImporter() data = { "pkginfo": { "SUNWfoo": "sunwfoo - a fake Sun package", }, } importer._ImportPackages(data) fake_srv4 = importer._GetFakeSrv4("SUNWfoo", "SunOS5.9", "i386") self.assertEqual(u"68d6e9124bff1c0ce56994fae50cc9b1", fake_srv4.md5_sum)
def test_ImportFilesAddToCatalog(self): self.dbc.InitialDataImport() contents = [ { 'cksum': '21717', 'class': 'none', 'group': 'bin', 'line': ('/etc/fonts/conf.avail/70-no-bitmaps.conf ' 'f none 0444 root bin 263 21717 1210872725 ' 'SUNWfontconfig-root\n'), 'major': None, 'minor': None, 'mode': '0444', 'modtime': '1210872725', 'owner': 'root', 'path': '/etc/fonts/conf.avail/70-no-bitmaps.conf', 'pkgnames': ['SUNWfontconfig-root'], 'size': '263', 'target': None, 'type': 'f' }, ] data = { 'pkginfo': { "SUNWfontconfig-root": "sunw_fontconfig_root fake package", }, 'contents': contents, 'osrel': 'SunOS5.9', 'arch': 'i386', } importer = system_pkgmap.InstallContentsImporter() importer._ImportPackages(data) importer._ImportFiles(data) self.assertEquals(1, len(list(models.Srv4FileStats.select()))) self.assertEquals(1, len(list(models.CswFile.select()))) # There are 5 catalog releases by default. This should match # common_constants.DEFAULT_CATALOG_RELEASES self.assertEquals(len(common_constants.DEFAULT_CATALOG_RELEASES), len(list(models.Srv4FileInCatalog.select())))
def test_ImportFilesCsw(self): contents = [ { 'cksum': '21717', 'class': 'none', 'group': 'bin', 'line': ('/etc/fonts/conf.avail/70-no-bitmaps.conf ' 'f none 0444 root bin 263 21717 1210872725 ' 'CSWfontconfig-root\n'), 'major': None, 'minor': None, 'mode': '0444', 'modtime': '1210872725', 'owner': 'root', 'path': '/etc/fonts/conf.avail/70-no-bitmaps.conf', 'pkgnames': ['CSWfontconfig-root'], 'size': '263', 'target': None, 'type': 'f' }, ] data = { 'pkginfo': { "CSWfontconfig-root": "fontconfig_root system fake package", }, 'contents': contents, 'osrel': 'SunOS5.9', 'arch': 'i386', } importer = system_pkgmap.InstallContentsImporter() importer._ImportPackages(data) importer._ImportFiles(data, show_progress=False) self.assertEquals(0, len(list(models.Srv4FileStats.select()))) self.assertEquals(0, len(list(models.CswFile.select())))
def RefreshDatabase(self): # Using the same stuff pkgdb is using. logging.warning( "Refreshing the database. It may take a long time, please be patient." ) logging.warning("If you need a way to make it faster, please see:") logging.warning("http://wiki.opencsw.org/checkpkg#toc5") infile_contents = common_constants.DEFAULT_INSTALL_CONTENTS_FILE infile_pkginfo = None logging.debug("Indexing.") spi = system_pkgmap.Indexer(None, infile_contents, infile_pkginfo, None, None) data = spi.Index(show_progress=True) logging.debug("Importing to the database.") importer = system_pkgmap.InstallContentsImporter() importer.ImportData(data, show_progress=True, include_prefixes=frozenset(["CSW"]))
infile_contents = args[0] infile_pkginfo = args[1] if len(args) >= 3: outfile = args[2] if len(args) >= 4: if len(args) == 5: osrel, arch = args[3:5] else: raise UsageError("Wrong number of arguments (%s), see usage." % len(args)) spi = system_pkgmap.Indexer(outfile, infile_contents, infile_pkginfo, osrel, arch) spi.IndexAndSave() elif command == 'import-system-file': infile = args[0] importer = system_pkgmap.InstallContentsImporter() infile_fd = open(infile, "r") importer.ImportFromFile(infile_fd, show_progress=True) elif (command, subcommand) == ('pkg', 'search'): logging.debug("Searching for %s", args) sqo_osrel = m.OsRelease.selectBy(short_name=options.osrel).getOne() sqo_arch = m.Architecture.selectBy(name=options.arch).getOne() sqo_catrel = m.CatalogRelease.selectBy(name=options.catrel).getOne() if len(args) < 1: logging.fatal("Wrong number of arguments: %s", len(args)) raise SystemExit for catalogname in args: join = [ sqlbuilder.INNERJOINOn( None, m.Srv4FileInCatalog, m.Srv4FileInCatalog.q.srv4file == m.Srv4FileStats.q.id),
def testSanitizeInstallContentsPkgnameInstallError(self): importer = system_pkgmap.InstallContentsImporter() self.assertEquals( "CSWmozilla", importer.SanitizeInstallContentsPkgname("!CSWmozilla"))
def testSanitizeInstallContentsPkgnameJ5linkAi(self): importer = system_pkgmap.InstallContentsImporter() self.assertEquals( "SUNWjai", importer.SanitizeInstallContentsPkgname("SUNWjai:j5link"))
def testSanitizeInstallContentsPkgnameJ3link(self): importer = system_pkgmap.InstallContentsImporter() self.assertEquals( "SUNWjhrt", importer.SanitizeInstallContentsPkgname("SUNWjhrt:j3link"))
def testSanitizeInstallContentsPkgnameTilde(self): importer = system_pkgmap.InstallContentsImporter() self.assertEquals("BOstdenv", importer.SanitizeInstallContentsPkgname("~BOstdenv"))