Example #1
0
 def GetPathsAndPkgnamesByBasedir(self, basedir, osrel, arch, catrel):
   sqo_osrel, sqo_arch, sqo_catrel = self.GetSqlobjectTriad(
       osrel, arch, catrel)
   connection = m.CswFile._connection
   join = [
       sqlbuilder.INNERJOINOn(None,
         m.Pkginst,
         m.CswFile.q.pkginst==m.Pkginst.q.id),
       sqlbuilder.INNERJOINOn(None,
         m.Srv4FileStats,
         m.CswFile.q.srv4_file==m.Srv4FileStats.q.id),
       sqlbuilder.INNERJOINOn(None,
         m.Srv4FileInCatalog,
         m.Srv4FileStats.q.id==m.Srv4FileInCatalog.q.srv4file),
   ]
   where = sqlobject.AND(
       m.CswFile.q.path==basedir,
       m.Srv4FileInCatalog.q.osrel==sqo_osrel,
       m.Srv4FileInCatalog.q.arch==sqo_arch,
       m.Srv4FileInCatalog.q.catrel==sqo_catrel,
   )
   query = connection.sqlrepr(
       sqlbuilder.Select(
         [m.CswFile.q.basename, m.Pkginst.q.pkgname],
         where=where,
         join=join))
   rows = connection.queryAll(query)
   pkgs = {}
   for row in rows:
     basename, pkginst = row
     pkgs.setdefault(pkginst, []).append(basename)
   return pkgs
Example #2
0
 def GET(self):
     connection = models.CheckpkgErrorTag._connection
     rows = connection.queryAll(
         connection.sqlrepr(
             sqlbuilder.Select([models.CheckpkgErrorTag.q.tag_name],
                               distinct=True,
                               orderBy=models.CheckpkgErrorTag.q.tag_name)))
     return render.ErrorTagList(rows)
Example #3
0
  def GetPathsAndPkgnamesByBasename(self, basename, osrel, arch, catrel):
    """Retrieves pkginst names of packages that have certain files.

    Since it needs to match a specific catalog, a table join is required:
      - CswFile (basename)
      - related Srv4FileStats
      - related Srv4FileInCatalog

    Args:
      basename: u'libfoo.so.1'
      osrel: u'5.9'
      arch: 'sparc', 'x86'
      catrel: 'stable'

    Returns:
      {"/opt/csw/lib": ["CSWfoo", "CSWbar"],
       "/opt/csw/1/lib": ["CSWfoomore"]}
    """
    pkgs = {}
    sqo_osrel, sqo_arch, sqo_catrel = self.GetSqlobjectTriad(
        osrel, arch, catrel)

    connection = m.CswFile._connection
    join = [
        sqlbuilder.INNERJOINOn(None,
          m.Pkginst,
          m.CswFile.q.pkginst==m.Pkginst.q.id),
        sqlbuilder.INNERJOINOn(None,
          m.Srv4FileStats,
          m.CswFile.q.srv4_file==m.Srv4FileStats.q.id),
        sqlbuilder.INNERJOINOn(None,
          m.Srv4FileInCatalog,
          m.Srv4FileStats.q.id==m.Srv4FileInCatalog.q.srv4file),
    ]
    where = sqlobject.AND(
        m.CswFile.q.basename==basename,
        m.Srv4FileInCatalog.q.osrel==sqo_osrel,
        m.Srv4FileInCatalog.q.arch==sqo_arch,
        m.Srv4FileInCatalog.q.catrel==sqo_catrel,
    )
    query = connection.sqlrepr(
        sqlbuilder.Select(
          [m.CswFile.q.path, m.Pkginst.q.pkgname],
          where=where,
          join=join))
    rows = connection.queryAll(query)
    pkgs = {}

    for row in rows:
      file_path, pkginst = row
      pkgs.setdefault(file_path, []).append(pkginst)

    logging.debug("self.error_mgr_mock.GetPathsAndPkgnamesByBasename(%s)"
                  ".AndReturn(%s)", repr(basename), pprint.pformat(pkgs))
    return pkgs
Example #4
0
 def GET(self):
     try:
         connection = models.Srv4FileStats._connection
         rows = connection.queryAll(
             connection.sqlrepr(
                 sqlbuilder.Select(
                     [models.Srv4FileStats.q.catalogname],
                     distinct=True,
                     where=sqlobject.AND(
                         models.Srv4FileStats.q.use_to_generate_catalogs ==
                         True, models.Srv4FileStats.q.registered == True),
                     orderBy=models.Srv4FileStats.q.catalogname)))
         return render.CatalognameList(rows)
     except sqlobject.main.SQLObjectNotFound, e:
         raise web.notfound()
Example #5
0
def GetCatalogGenerationResult(sqo_osrel, sqo_arch, sqo_catrel):
  """Get rows with catalog results.

  CatalogEntry
  catalogname version pkgname basename md5_sum size deps category i_deps
  """
  join = [
      sqlbuilder.INNERJOINOn(None,
        Srv4FileInCatalog,
        Srv4FileInCatalog.q.srv4file==Srv4FileStats.q.id),
      sqlbuilder.INNERJOINOn(None,
        CatalogGenData,
        Srv4FileStats.q.md5_sum==CatalogGenData.q.md5_sum),
      sqlbuilder.INNERJOINOn(None,
        Maintainer,
        Srv4FileStats.q.maintainer==Maintainer.q.id),
  ]
  where = sqlbuilder.AND(
      Srv4FileInCatalog.q.osrel==sqo_osrel,
        Srv4FileInCatalog.q.arch==sqo_arch,
        Srv4FileInCatalog.q.catrel==sqo_catrel,
        Srv4FileStats.q.use_to_generate_catalogs==True,
  )
  select = sqlbuilder.Select(
      ['catalogname',    # 0
       'version_string', # 1
       'pkgname',        # 2
       'basename',       # 3
       'srv4_file_stats.md5_sum', # Hardcoded table name, is it portable?
       'size',           # 5
       'deps',           # 6
       'i_deps',         # 7
       'pkginfo_name',   # 8
       # The above columns are used to generate catalogs.
       # Additional columns can be added blow.
       # 'maintainer.id',  # 9
       'maintainer.email',  # 9
       'mtime',          # 10
       'created_on',     # 11
       'created_by',     # 12
       'bundle',         # 13
      ],
      where=where,
      orderBy='catalogname',
      join=join)
  query = sqlobject.sqlhub.processConnection.sqlrepr(select)
  rows = sqlobject.sqlhub.processConnection.queryAll(query)
  return rows
Example #6
0
 def GET(self):
   try:
     connection = models.Srv4FileStats._connection
     rows = connection.queryAll(connection.sqlrepr(
       sqlbuilder.Select(
         [models.Srv4FileStats.q.catalogname],
         distinct=True,
         where=sqlobject.AND(
           models.Srv4FileStats.q.use_to_generate_catalogs==True,
           models.Srv4FileStats.q.registered_level_two==True),
         orderBy=models.Srv4FileStats.q.catalogname)))
     rows_by_letter = {}
     for row in rows:
       initial = row[0][0]
       rows_by_letter.setdefault(initial, [])
       rows_by_letter[initial].append(row)
     return render.CatalognameList(rows_by_letter, sorted(rows_by_letter))
   except sqlobject.main.SQLObjectNotFound, e:
     raise web.notfound()
Example #7
0
def main():
    configuration.SetUpSqlobjectConnection()
    total_pkgs = m.Srv4FileStats.select().count()
    logging.info("There are {0} packages to inspect.".format(total_pkgs))
    res = m.Srv4FileStats.select(
        sqlbuilder.NOTEXISTS(
            sqlbuilder.Select(
                m.Srv4FileInCatalog.q.id,
                where=(sqlbuilder.Outer(
                    m.Srv4FileStats).q.id == m.Srv4FileInCatalog.q.srv4file
                       )))).orderBy('id')
    deleted_pkgs = 0
    for stats in res:
        # logging.info("Package {0} ({1}) is not in any catalogs. Removing.".format(stats.basename, stats.md5_sum))
        stats.DeleteAllDependentObjects()
        stats.destroySelf()
        deleted_pkgs += 1
        sys.stdout.write(".")
        sys.stdout.flush()
    logging.info("Deleted {0} unused packages.".format(deleted_pkgs))
Example #8
0
def GetRecentlyBuiltPackages():
  join = [
      # sqlbuilder.INNERJOINOn(None,
      #   Srv4FileInCatalog,
      #   Srv4FileInCatalog.q.srv4file==Srv4FileStats.q.id),
      # sqlbuilder.INNERJOINOn(None,
      #   CatalogGenData,
      #   Srv4FileStats.q.md5_sum==CatalogGenData.q.md5_sum),
  ]
  where = sqlbuilder.AND(
        # Srv4FileStats.q.use_to_generate_catalogs==True,
  )
  select = sqlbuilder.Select(
      [
       'srv4_file_stats.md5_sum', # Hardcoded table name, is it portable?
       'srv4_file_stats.catalogname',
       # 'version_string',
       # 'pkgname',
       # 'basename',
       # 'size',
       # 'deps',
       # 'i_deps',
       # 'pkginfo_name',
       # The above columns are used to generate catalogs.
       # Additional columns can be added blow.
       'srv4_file_stats.maintainer_id',
       'srv4_file_stats.mtime',
       # 'created_on',
       # 'created_by',
       ],
      where=where,
      orderBy='-mtime',
      join=join,
      limit=30)
  query = sqlobject.sqlhub.processConnection.sqlrepr(select)
  rows = sqlobject.sqlhub.processConnection.queryAll(query)
  return rows