Example #1
0
def get_arch_name():
	target_os = canonicalize_os(uname[0])
	target_machine = canonicalize_machine(uname[4])
	if target_os == 'Darwin' and target_machine == 'i386':
		# this system detection shell script comes from config.guess (20090918):
		CC = os.getenv("CC_FOR_BUILD") or os.getenv("CC") or os.getenv("HOST_CC") or "cc"
		process = subprocess.Popen("(echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | " +
		                           "(CCOPTS= %s -E - 2>/dev/null) | " % CC +
		                           "grep IS_64BIT_ARCH >/dev/null", stdout=subprocess.PIPE, shell=True)
		output, error = process.communicate()
		retcode = process.poll()
		if retcode == 0:
			target_machine='x86_64'
	if target_machine in ('i585', 'i686'):
		target_machine = 'i486'	# (sensible default)
	return target_os + '-' + target_machine
Example #2
0
def get_arch_name():
	target_os = canonicalize_os(uname[0])
	target_machine = canonicalize_machine(uname[4])
	if target_os == 'Darwin' and target_machine == 'i386':
		# this system detection shell script comes from config.guess (20090918):
		CC = os.getenv("CC_FOR_BUILD") or os.getenv("CC") or os.getenv("HOST_CC") or "cc"
		process = subprocess.Popen("(echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | " +
		                           "(CCOPTS= %s -E - 2>/dev/null) | " % CC +
		                           "grep IS_64BIT_ARCH >/dev/null", stdout=subprocess.PIPE, shell=True)
		output, error = process.communicate()
		retcode = process.poll()
		if retcode == 0:
			target_machine='x86_64'
	if target_machine in ('i585', 'i686'):
		target_machine = 'i486'	# (sensible default)
	return target_os + '-' + target_machine
Example #3
0
    def get_package_info(self, package, factory):
        # Add installed versions...
        _version_start_reqexp = '-[0-9]'

        if package.count('/') != 1: return

        category, leafname = package.split('/')
        category_dir = os.path.join(self._pkgdir, category)
        match_prefix = leafname + '-'

        if not os.path.isdir(category_dir): return

        for filename in os.listdir(category_dir):
            if filename.startswith(match_prefix) and filename[len(
                    match_prefix)].isdigit():
                with open(os.path.join(category_dir, filename, 'PF'),
                          'rt') as stream:
                    name = stream.readline().strip()

                match = re.search(_version_start_reqexp, name)
                if match is None:
                    logger.warn(
                        _('Cannot parse version from Gentoo package named "%(name)s"'
                          ), {'name': name})
                    continue
                else:
                    version = try_cleanup_distro_version(name[match.start() +
                                                              1:])

                if category == 'app-emulation' and name.startswith('emul-'):
                    __, __, machine, __ = name.split('-', 3)
                else:
                    with open(os.path.join(category_dir, filename, 'CHOST'),
                              'rt') as stream:
                        machine, __ = stream.readline().split('-', 1)
                machine = arch.canonicalize_machine(machine)

                impl = factory('package:gentoo:%s:%s:%s' % \
                  (package, version, machine))
                impl.version = model.parse_version(version)
                impl.machine = machine

        # Add any uninstalled candidates found by PackageKit
        self.packagekit.get_candidates(package, factory, 'package:gentoo')
Example #4
0
	def get_package_info(self, package, factory):
		# Add installed versions...
		"""@type package: str"""
		_version_start_reqexp = '-[0-9]'

		if package.count('/') != 1: return

		category, leafname = package.split('/')
		category_dir = os.path.join(self._pkgdir, category)
		match_prefix = leafname + '-'

		if not os.path.isdir(category_dir): return

		for filename in os.listdir(category_dir):
			if filename.startswith(match_prefix) and filename[len(match_prefix)].isdigit():
				with open(os.path.join(category_dir, filename, 'PF'), 'rt') as stream:
					name = stream.readline().strip()

				match = re.search(_version_start_reqexp, name)
				if match is None:
					logger.warning(_('Cannot parse version from Gentoo package named "%(name)s"'), {'name': name})
					continue
				else:
					version = try_cleanup_distro_version(name[match.start() + 1:])

				if category == 'app-emulation' and name.startswith('emul-'):
					__, __, machine, __ = name.split('-', 3)
				else:
					with open(os.path.join(category_dir, filename, 'CHOST'), 'rt') as stream:
						machine, __ = stream.readline().split('-', 1)
				machine = arch.canonicalize_machine(machine)

				impl = factory('package:gentoo:%s:%s:%s' % \
						(package, version, machine))
				impl.version = model.parse_version(version)
				impl.machine = machine

		# Add any uninstalled candidates found by PackageKit
		self.packagekit.get_candidates(package, factory, 'package:gentoo')
Example #5
0
_canonical_machine = {
	'all' : '*',
	'any' : '*',
	'noarch' : '*',
	'(none)' : '*',
	'x86_64': 'x86_64',
	'amd64': 'x86_64',
	'i386': 'i386',
	'i486': 'i486',
	'i586': 'i586',
	'i686': 'i686',
	'ppc64': 'ppc64',
	'ppc': 'ppc',
}

host_machine = arch.canonicalize_machine(platform.uname()[4])
def canonical_machine(package_machine):
	machine = _canonical_machine.get(package_machine.lower(), None)
	if machine is None:
		# Safe default if we can't understand the arch
		return host_machine.lower()
	return machine

class DebianDistribution(Distribution):
	"""A dpkg-based distribution."""

	name = 'Debian'

	cache_leaf = 'dpkg-status.cache'

	def __init__(self, dpkg_status):
Example #6
0
_canonical_machine = {
    'all': '*',
    'any': '*',
    'noarch': '*',
    '(none)': '*',
    'x86_64': 'x86_64',
    'amd64': 'x86_64',
    'i386': 'i386',
    'i486': 'i486',
    'i586': 'i586',
    'i686': 'i686',
    'ppc64': 'ppc64',
    'ppc': 'ppc',
}

host_machine = arch.canonicalize_machine(platform.uname()[4])


def canonical_machine(package_machine):
    machine = _canonical_machine.get(package_machine, None)
    if machine is None:
        # Safe default if we can't understand the arch
        return host_machine
    return machine


class DebianDistribution(Distribution):
    """A dpkg-based distribution."""

    cache_leaf = 'dpkg-status.cache'