Exemplo n.º 1
0
            pkg_hash[pkg_key] = pkg_info

        if self.options.nullorg:
            # to satisfy xmlrpc from None values.
            orgid = "null"
        else:
            orgid = ""

        info = {"packages": pkg_hash, "channels": self.channels, "org_id": orgid, "force": self.options.force or 0}
        # rpc call to get checksum info for all the packages to be uploaded
        if not self.options.source:
            if self.new_sat_test():
                # computing checksum and other info is expensive process and session
                # could have expired.Make sure its re-authenticated.
                self.authenticate()
                if uploadLib.exists_getPackageChecksumBySession(self.server):
                    checksum_data = uploadLib.getPackageChecksumBySession(
                        self.server, self.session.getSessionString(), info
                    )
                else:
                    # old server only md5 capable
                    checksum_data = uploadLib.getPackageMD5sumBySession(
                        self.server, self.session.getSessionString(), info
                    )
            else:
                # even older server without session authentication
                checksum_data = uploadLib.getPackageMD5sum(self.server, self.username, self.password, info)
        else:
            if self.new_sat_test():
                # computing checksum and other info is expensive process and session
                # could have expired.Make sure its re-authenticated.
Exemplo n.º 2
0
    def check_package_exists(self):
        self.warn(
            2,
            "Computing checksum and package info. This may take some time ...")
        pkg_hash = {}
        digest_hash = {}

        for pkg in self.files:
            pkg_info = {}
            pkg_key = (pkg.strip()).split('/')[-1]

            if not os.access(pkg, os.R_OK):
                if not self.options.tolerant:
                    self.die(-1, "Could not read file %s" % pkg)
                self.warn(-1, "Could not read file %s" % pkg)
                continue
            try:
                a_pkg = package_from_filename(pkg)
                a_pkg.read_header()
                a_pkg.payload_checksum()
            except InvalidPackageError:
                if not self.options.tolerant:
                    self.die(
                        -1,
                        "ERROR: %s: This file doesn't appear to be a package" %
                        pkg)
                self.warn(
                    2, "ERROR: %s: This file doesn't appear to be a package" %
                    pkg)
                continue
            except IOError:
                if not self.options.tolerant:
                    self.die(
                        -1,
                        "ERROR: %s: No such file or directory available" % pkg)
                self.warn(
                    2, "ERROR: %s: No such file or directory available" % pkg)
                continue

            digest_hash[pkg_key] = (a_pkg.checksum_type, a_pkg.checksum)
            a_pkg.input_stream.close()

            for tag in ('name', 'version', 'release', 'epoch', 'arch'):
                val = a_pkg.header[tag]
                if val is None:
                    val = ''
                pkg_info[tag] = val
            #b195903:the arch for srpms should be obtained by is_source check
            #instead of checking arch in header
            if a_pkg.header.is_source:
                if not self.options.source:
                    self.die(
                        -1,
                        "ERROR: Trying to Push src rpm, Please re-try with --source."
                    )
                if RPMTAG_NOSOURCE in a_pkg.header.keys():
                    pkg_info['arch'] = 'nosrc'
                else:
                    pkg_info['arch'] = 'src'
            pkg_info['checksum_type'] = a_pkg.checksum_type
            pkg_info['checksum'] = a_pkg.checksum
            pkg_hash[pkg_key] = pkg_info

        if self.options.nullorg:
            #to satisfy xmlrpc from None values.
            orgid = 'null'
        else:
            orgid = ''

        info = {
            'packages': pkg_hash,
            'channels': self.channels,
            'org_id': orgid,
            'force': self.options.force or 0
        }
        # rpc call to get checksum info for all the packages to be uploaded
        if not self.options.source:
            # computing checksum and other info is expensive process and session
            # could have expired.Make sure its re-authenticated.
            self.authenticate()
            if uploadLib.exists_getPackageChecksumBySession(self.server):
                checksum_data = uploadLib.getPackageChecksumBySession(
                    self.server, self.session.getSessionString(), info)
            else:
                # old server only md5 capable
                checksum_data = uploadLib.getPackageMD5sumBySession(
                    self.server, self.session.getSessionString(), info)
        else:
            # computing checksum and other info is expensive process and session
            # could have expired.Make sure its re-authenticated.
            self.authenticate()
            if uploadLib.exists_getPackageChecksumBySession(self.server):
                checksum_data = uploadLib.getSourcePackageChecksumBySession(
                    self.server, self.session.getSessionString(), info)
            else:
                # old server only md5 capable
                checksum_data = uploadLib.getSourcePackageMD5sumBySession(
                    self.server, self.session.getSessionString(), info)

        return (checksum_data, pkg_hash, digest_hash)
Exemplo n.º 3
0
    def check_package_exists(self):
        self.warn(2, "Computing checksum and package info. This may take some time ...")
        pkg_hash = {}
        digest_hash = {}

        for pkg in self.files:
            pkg_info = {}
            pkg_key = (pkg.strip()).split('/')[-1]

            if not os.access(pkg, os.R_OK):
                if not self.options.tolerant:
                    self.die(-1, "Could not read file %s" % pkg)
                self.warn(-1, "Could not read file %s" % pkg)
                continue
            try:
                a_pkg = package_from_filename(pkg)
                a_pkg.read_header()
                a_pkg.payload_checksum()
            except InvalidPackageError:
                if not self.options.tolerant:
                    self.die(-1, "ERROR: %s: This file doesn't appear to be a package" % pkg)
                self.warn(2, "ERROR: %s: This file doesn't appear to be a package" % pkg)
                continue
            except IOError:
                if not self.options.tolerant:
                    self.die(-1, "ERROR: %s: No such file or directory available" % pkg)
                self.warn(2, "ERROR: %s: No such file or directory available" % pkg)
                continue

            digest_hash[pkg_key] =  (a_pkg.checksum_type, a_pkg.checksum)
            a_pkg.input_stream.close()

            for tag in ('name', 'version', 'release', 'epoch', 'arch'):
                val = a_pkg.header[tag]
                if val is None:
                    val = ''
                pkg_info[tag] = val
            #b195903:the arch for srpms should be obtained by is_source check
            #instead of checking arch in header
            if a_pkg.header.is_source:
                if not self.options.source:
                    self.die(-1, "ERROR: Trying to Push src rpm, Please re-try with --source.")
                if RPMTAG_NOSOURCE in a_pkg.header.keys():
                    pkg_info['arch'] = 'nosrc'
                else:
                    pkg_info['arch'] = 'src'
            pkg_info['checksum_type'] = a_pkg.checksum_type
            pkg_info['checksum'] = a_pkg.checksum
            pkg_hash[pkg_key] = pkg_info

        if self.options.nullorg:
            #to satisfy xmlrpc from None values.
            orgid = 'null'
        else:
            orgid = ''

        info = {
            'packages' : pkg_hash,
            'channels' : self.channels,
            'org_id'   : orgid,
	    'force'    : self.options.force or 0
            }
        # rpc call to get checksum info for all the packages to be uploaded
        if not self.options.source:
            # computing checksum and other info is expensive process and session
            # could have expired.Make sure its re-authenticated.
            self.authenticate()
            if uploadLib.exists_getPackageChecksumBySession(self.server):
                checksum_data = uploadLib.getPackageChecksumBySession(self.server,
                                                self.session.getSessionString(), info)
            else:
                # old server only md5 capable
                checksum_data = uploadLib.getPackageMD5sumBySession(self.server,
                                                self.session.getSessionString(), info)
        else:
            # computing checksum and other info is expensive process and session
            # could have expired.Make sure its re-authenticated.
            self.authenticate()
            if uploadLib.exists_getPackageChecksumBySession(self.server):
                checksum_data = uploadLib.getSourcePackageChecksumBySession(self.server,
                                                self.session.getSessionString(), info)
            else:
                # old server only md5 capable
                checksum_data = uploadLib.getSourcePackageMD5sumBySession(self.server,
                                                self.session.getSessionString(), info)

        return (checksum_data, pkg_hash, digest_hash)