Exemple #1
0
 def _getOSVersionAndRelease():
     ts = transaction.initReadOnlyTransaction()
     for h in ts.dbMatch('Providename', "oraclelinux-release"):
         SYSRELVER = 'system-release(releasever)'
         version = sstr(h['version'])
         release = sstr(h['release'])
         if SYSRELVER in h['providename']:
             provides = dict(zip(h['providename'], h['provideversion']))
             release = '%s-%s' % (version, release)
             version = provides[SYSRELVER]
         osVersionRelease = (sstr(h['name']), version, release)
         return osVersionRelease
     else:
         for h in ts.dbMatch('Providename', "redhat-release"):
             SYSRELVER = 'system-release(releasever)'
             version = sstr(h['version'])
             release = sstr(h['release'])
             if SYSRELVER in h['providename']:
                 provides = dict(zip(h['providename'], h['provideversion']))
                 release = '%s-%s' % (version, release)
                 version = provides[SYSRELVER]
             osVersionRelease = (sstr(h['name']), version, release)
             return osVersionRelease
         else:
             for h in ts.dbMatch('Providename', "distribution-release"):
                 osVersionRelease = (sstr(h['name']), sstr(h['version']), sstr(h['release']))
                 # zypper requires a exclusive lock on the rpmdb. So we need
                 # to close it here.
                 ts.ts.closeDB()
                 return osVersionRelease
             else:
                 raise up2dateErrors.RpmError(
                     "Could not determine what version of Red Hat Linux you "\
                     "are running.\nIf you get this error, try running \n\n"\
                     "\t\trpm --rebuilddb\n\n")
Exemple #2
0
 def _getOSVersionAndRelease():
     ts = transaction.initReadOnlyTransaction()
     for h in ts.dbMatch('Providename', "redhat-release"):
         SYSRELVER = 'system-release(releasever)'
         version = sstr(h['version'])
         release = sstr(h['release'])
         if SYSRELVER in h['providename']:
             provides = dict(zip(h['providename'], h['provideversion']))
             release = '%s-%s' % (version, release)
             version = provides[SYSRELVER]
         osVersionRelease = (sstr(h['name']), version, release)
         return osVersionRelease
     else:
         for h in ts.dbMatch('Providename', "distribution-release"):
             osVersionRelease = (sstr(h['name']), sstr(h['version']),
                                 sstr(h['release']))
             # zypper requires a exclusive lock on the rpmdb. So we need
             # to close it here.
             ts.ts.closeDB()
             return osVersionRelease
         else:
             raise up2dateErrors.RpmError(
                 "Could not determine what version of Red Hat Linux you "\
                 "are running.\nIf you get this error, try running \n\n"\
                 "\t\trpm --rebuilddb\n\n")
Exemple #3
0
 def _getOSVersionAndRelease():
     ts = transaction.initReadOnlyTransaction()
     for h in ts.dbMatch("Providename", "redhat-release"):
         SYSRELVER = "system-release(releasever)"
         version = h["version"]
         release = h["release"]
         if SYSRELVER in h["providename"]:
             provides = dict(zip(h["providename"], h["provideversion"]))
             release = "%s-%s" % (version, release)
             version = provides[SYSRELVER]
         osVersionRelease = (h["name"], version, release)
         return osVersionRelease
     else:
         for h in ts.dbMatch("Providename", "distribution-release"):
             osVersionRelease = (h["name"], h["version"], h["release"])
             # zypper requires a exclusive lock on the rpmdb. So we need
             # to close it here.
             ts.ts.closeDB()
             return osVersionRelease
         else:
             raise up2dateErrors.RpmError(
                 "Could not determine what version of Red Hat Linux you "
                 "are running.\nIf you get this error, try running \n\n"
                 "\t\trpm --rebuilddb\n\n"
             )
Exemple #4
0
def getInstalledPackageList(msgCallback=None,
                            progressCallback=None,
                            getArch=None,
                            getInfo=None):
    """ Return list of packages. Package is hash with keys name, epoch,
        version, release and optionaly arch and cookie
    """
    pkg_list = []

    if msgCallback != None:
        msgCallback(_("Getting list of packages installed on the system"))

    _ts = transaction.initReadOnlyTransaction()
    count = 0
    total = 0

    for h in _ts.dbMatch():
        if h == None:
            break
        count = count + 1

    total = count

    count = 0
    for h in _ts.dbMatch():
        if h == None:
            break
        package = {
            'name': sstr(h['name']),
            'epoch': h['epoch'],
            'version': sstr(h['version']),
            'release': sstr(h['release']),
            'installtime': h['installtime']
        }
        if package['epoch'] == None:
            package['epoch'] = ""
        else:  # convert it to string
            package['epoch'] = "%s" % package['epoch']
        if getArch:
            package['arch'] = h['arch']
            # the arch on gpg-pubkeys is "None"...
            if package['arch']:
                package['arch'] = sstr(package['arch'])
                pkg_list.append(package)
        elif getInfo:
            if h['arch']:
                package['arch'] = sstr(h['arch'])
            if h['cookie']:
                package['cookie'] = sstr(h['cookie'])
            pkg_list.append(package)
        else:
            pkg_list.append(package)

        if progressCallback != None:
            progressCallback(count, total)
        count = count + 1

    pkg_list.sort(
        key=lambda x: (x['name'], x['epoch'], x['version'], x['release']))
    return pkg_list
Exemple #5
0
    def _getOSVersionAndRelease():
        osVersionRelease = None
        ts = transaction.initReadOnlyTransaction()
        for h in ts.dbMatch('Providename', "oraclelinux-release"):
            SYSRELVER = 'system-release(releasever)'
            version = sstr(h['version'])
            release = sstr(h['release'])
            if SYSRELVER in (sstr(provide) for provide in h['providename']):
                provides = dict((sstr(n), sstr(v))
                                for n,v in zip(h['providename'], h['provideversion']))
                release = '%s-%s' % (version, release)
                version = provides[SYSRELVER]
            osVersionRelease = (sstr(h['name']), version, release)
            return osVersionRelease
        else:
            for h in ts.dbMatch('Providename', "redhat-release"):
                SYSRELVER = 'system-release(releasever)'
                version = sstr(h['version'])
                release = sstr(h['release'])
                if SYSRELVER in (sstr(provide) for provide in h['providename']):
                    provides = dict((sstr(n), sstr(v))
                                    for n,v in zip(h['providename'], h['provideversion']))
                    release = '%s-%s' % (version, release)
                    version = provides[SYSRELVER]
                osVersionRelease = (sstr(h['name']), version, release)
                return osVersionRelease
            else:
                # new SUSE always has a baseproduct link which point to the
                # product file of the first installed product (the OS)
                # all rpms containing a product must provide "product()"
                # search now for the package providing the base product
                baseproduct = '/etc/products.d/baseproduct'
                if os.path.exists(baseproduct):
                    bp = os.path.abspath(os.path.join(os.path.dirname(baseproduct), os.readlink(baseproduct)))
                    for h in ts.dbMatch('Providename', "product()"):
                        if bstr(bp) in h['filenames']:
                            osVersionRelease = (sstr(h['name']), sstr(h['version']), sstr(h['release']))
                            # zypper requires a exclusive lock on the rpmdb. So we need
                            # to close it here.
                            ts.ts.closeDB()
                            return osVersionRelease
                else:
                    # for older SUSE versions we need to search for distribution-release
                    # package which also has /etc/SuSE-release file
                    for h in ts.dbMatch('Providename', "distribution-release"):
                        osVersionRelease = (sstr(h['name']), sstr(h['version']), sstr(h['release']))
                        if bstr('/etc/SuSE-release') in h['filenames']:
                            # zypper requires a exclusive lock on the rpmdb. So we need
                            # to close it here.
                            ts.ts.closeDB()
                            return osVersionRelease

                log = up2dateLog.initLog()
                log.log_me("Error: Could not determine what version of Linux you are running. "\
                           "Check if the product is installed correctly. Aborting.")
                raise up2dateErrors.RpmError(
                    "Could not determine what version of Linux you "\
                    "are running.\nIf you get this error, try running \n\n"\
                    "\t\trpm --rebuilddb\n\n")
Exemple #6
0
def getInstalledPackageList(msgCallback = None, progressCallback = None,
                            getArch=None, getInfo = None):
    """ Return list of packages. Package is hash with keys name, epoch,
        version, release and optionaly arch and cookie
    """
    pkg_list = []

    if msgCallback != None:
        msgCallback(_("Getting list of packages installed on the system"))

    _ts = transaction.initReadOnlyTransaction()
    count = 0
    total = 0

    for h in _ts.dbMatch():
        if h == None:
            break
        count = count + 1

    total = count

    count = 0
    for h in _ts.dbMatch():
        if h == None:
            break
        package = {
            'name': sstr(h['name']),
            'epoch': h['epoch'],
            'version': sstr(h['version']),
            'release': sstr(h['release']),
            'installtime': h['installtime']
        }
        if package['epoch'] == None:
            package['epoch'] = ""
        else: # convert it to string
            package['epoch'] = "%s" % package['epoch']
        if getArch:
            package['arch'] = h['arch']
            # the arch on gpg-pubkeys is "None"...
            if package['arch']:
                package['arch'] = sstr(package['arch'])
                pkg_list.append(package)
        elif getInfo:
            if h['arch']:
                package['arch'] = sstr(h['arch'])
            if h['cookie']:
                package['cookie'] = sstr(h['cookie'])
            pkg_list.append(package)
        else:
            pkg_list.append(package)

        if progressCallback != None:
            progressCallback(count, total)
        count = count + 1

    pkg_list.sort(key=lambda x:(x['name'], x['epoch'], x['version'], x['release']))
    return pkg_list
Exemple #7
0
    def _getOSVersionAndRelease():
        osVersionRelease = None
        ts = transaction.initReadOnlyTransaction()
        for h in ts.dbMatch('Providename', "oraclelinux-release"):
            SYSRELVER = 'system-release(releasever)'
            version = sstr(h['version'])
            release = sstr(h['release'])
            if SYSRELVER in h['providename']:
                provides = dict(zip(h['providename'], h['provideversion']))
                release = '%s-%s' % (version, release)
                version = provides[SYSRELVER]
            osVersionRelease = (sstr(h['name']), version, release)
            return osVersionRelease
        else:
            for h in ts.dbMatch('Providename', "redhat-release"):
                SYSRELVER = 'system-release(releasever)'
                version = sstr(h['version'])
                release = sstr(h['release'])
                if SYSRELVER in h['providename']:
                    provides = dict(zip(h['providename'], h['provideversion']))
                    release = '%s-%s' % (version, release)
                    version = provides[SYSRELVER]
                osVersionRelease = (sstr(h['name']), version, release)
                return osVersionRelease
            else:
                # new SUSE always has a baseproduct link which point to the
                # product file of the first installed product (the OS)
                # all rpms containing a product must provide "product()"
                # search now for the package providing the base product
                baseproduct = '/etc/products.d/baseproduct'
                if os.path.exists(baseproduct):
                    bp = os.path.abspath(os.path.join(os.path.dirname(baseproduct), os.readlink(baseproduct)))
                    for h in ts.dbMatch('Providename', "product()"):
                        if bstr(bp) in h['filenames']:
                            osVersionRelease = (sstr(h['name']), sstr(h['version']), sstr(h['release']))
                            # zypper requires a exclusive lock on the rpmdb. So we need
                            # to close it here.
                            ts.ts.closeDB()
                            return osVersionRelease
                else:
                    # for older SUSE versions we need to search for distribution-release
                    # package which also has /etc/SuSE-release file
                    for h in ts.dbMatch('Providename', "distribution-release"):
                        osVersionRelease = (sstr(h['name']), sstr(h['version']), sstr(h['release']))
                        if bstr('/etc/SuSE-release') in h['filenames']:
                            # zypper requires a exclusive lock on the rpmdb. So we need
                            # to close it here.
                            ts.ts.closeDB()
                            return osVersionRelease

                raise up2dateErrors.RpmError(
                    "Could not determine what version of Linux you "\
                    "are running.\nIf you get this error, try running \n\n"\
                    "\t\trpm --rebuilddb\n\n")
Exemple #8
0
    def __getHeader(self, path):
        fd = os.open(path, os.R_OK)
        ts = transaction.initReadOnlyTransaction()

        try:
            hdr = ts.hdrFromFdno(fd)
        except:
            os.close(fd)
            return None
        os.close(fd)
        return hdr
Exemple #9
0
 def __getHeader(self, path):
     fd = os.open(path, os.R_OK)
     ts = transaction.initReadOnlyTransaction()
     
     try:
         hdr = ts.hdrFromFdno(fd)
     except:
         os.close(fd)
         return None
     os.close(fd)
     return hdr
Exemple #10
0
def installedHeaderByKeyword(**kwargs):
    """ just cause this is such a potentially useful looking method... """
    _ts = transaction.initReadOnlyTransaction()
    mi = _ts.dbMatch()
    for keyword in kwargs.keys():
        mi.pattern(keyword, rpm.RPMMIRE_GLOB, kwargs[keyword])
        # we really shouldnt be getting multiples here, but what the heck
    headerList = []
    for h in mi:
        headerList.append(h)

    return headerList
Exemple #11
0
def installedHeaderByKeyword(**kwargs):
    """ just cause this is such a potentially useful looking method... """
    _ts = transaction.initReadOnlyTransaction()
    mi = _ts.dbMatch()
    for keyword in kwargs.keys():
        mi.pattern(keyword, rpm.RPMMIRE_GLOB, kwargs[keyword])
        # we really shouldnt be getting multiples here, but what the heck
    headerList = []
    for h in mi:
        headerList.append(h)

    return headerList
Exemple #12
0
def getInstalledPackageList(msgCallback=None,
                            progressCallback=None,
                            getArch=None,
                            getInfo=None):
    """ Return list of packages. Package is hash with keys name, epoch,
        version, release and optionaly arch and cookie
    """
    pkg_list = []

    if msgCallback != None:
        msgCallback(_("Getting list of packages installed on the system"))

    _ts = transaction.initReadOnlyTransaction()
    count = 0
    total = 0

    dbmatch = _ts.dbMatch()
    for h in dbmatch:
        if h == None:
            break
        count = count + 1

    total = count

    count = 0
    dbmatch = _ts.dbMatch()
    for h in dbmatch:
        if h == None:
            break
        if not (is_utf8(sstr(h['name'])) and is_utf8(sstr(h['version']))
                and is_utf8(sstr(h['release']))):
            log = up2dateLog.initLog()
            log.log_me(
                "Package with invalid character set found. Skipping: '%s-%s-%s'"
                % (h['name'].decode('UTF-8', errors='replace'),
                   h['version'].decode('UTF-8', errors='replace'),
                   h['release'].decode('UTF-8', errors='replace')))
            continue
        package = {
            'name': sstr(h['name']),
            'epoch': h['epoch'],
            'version': sstr(h['version']),
            'release': sstr(h['release']),
            'installtime': h['installtime']
        }
        if package['epoch'] == None:
            package['epoch'] = ""
        else:  # convert it to string
            package['epoch'] = "%s" % package['epoch']
        if getArch:
            package['arch'] = h['arch']
            # the arch on gpg-pubkeys is "None"...
            if package['arch']:
                package['arch'] = sstr(package['arch'])
                pkg_list.append(package)
        elif getInfo:
            if h['arch']:
                package['arch'] = sstr(h['arch'])
            if h['cookie']:
                package['cookie'] = sstr(h['cookie'])
            pkg_list.append(package)
        else:
            pkg_list.append(package)

        if progressCallback != None:
            progressCallback(count, total)
        count = count + 1
    dbmatch = None
    _ts.ts.closeDB()
    pkg_list.sort(
        key=lambda x: (x['name'], x['epoch'], x['version'], x['release']))
    return pkg_list
Exemple #13
0
def getInstalledPackageList(msgCallback = None, progressCallback = None,
                            getArch=None, getInfo = None):
    """ Return list of packages. Package is hash with keys name, epoch,
        version, release and optionaly arch and cookie
    """
    pkg_list = []

    if msgCallback != None:
        msgCallback(_("Getting list of packages installed on the system"))

    _ts = transaction.initReadOnlyTransaction()
    count = 0
    total = 0

    dbmatch = _ts.dbMatch()
    for h in dbmatch:
        if h == None:
            break
        count = count + 1

    total = count

    count = 0
    dbmatch = _ts.dbMatch()
    for h in dbmatch:
        if h == None:
            break
        if not (is_utf8(sstr(h['name'])) and is_utf8(sstr(h['version']))
                and is_utf8(sstr(h['release']))):
            log = up2dateLog.initLog()
            log.log_me("Package with invalid character set found. Skipping: '%s-%s-%s'" %
                    (h['name'].decode('UTF-8', errors='replace'),
                     h['version'].decode('UTF-8', errors='replace'),
                     h['release'].decode('UTF-8', errors='replace')))
            continue
        package = {
            'name': sstr(h['name']),
            'epoch': h['epoch'],
            'version': sstr(h['version']),
            'release': sstr(h['release']),
            'installtime': h['installtime']
        }
        if package['epoch'] == None:
            package['epoch'] = ""
        else: # convert it to string
            package['epoch'] = "%s" % package['epoch']
        if getArch:
            package['arch'] = h['arch']
            # the arch on gpg-pubkeys is "None"...
            if package['arch']:
                package['arch'] = sstr(package['arch'])
                pkg_list.append(package)
        elif getInfo:
            if h['arch']:
                package['arch'] = sstr(h['arch'])
            if h['cookie']:
                package['cookie'] = sstr(h['cookie'])
            pkg_list.append(package)
        else:
            pkg_list.append(package)

        if progressCallback != None:
            progressCallback(count, total)
        count = count + 1
    dbmatch = None
    _ts.ts.closeDB()
    pkg_list.sort(key=lambda x:(x['name'], x['epoch'], x['version'], x['release']))
    return pkg_list