Skip to content

Commit

Permalink
fix constant name length
Browse files Browse the repository at this point in the history
  • Loading branch information
aminzai committed May 26, 2011
1 parent 583368d commit 6bc0801
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 36 deletions.
57 changes: 33 additions & 24 deletions lazyscripts/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,42 @@

### DISTRIBUTION
# Debian base
DISTRIBUTION_DEBIAN = 'debian'
DISTRIBUTION_UBUNTU = 'ubuntu'
DISTRIBUTION_LINUXMINT = 'linuxmint'
DIST_DEBIAN = 'debian'
DIST_UBUNTU = 'ubuntu'
DIST_LINUXMINT = 'linuxmint'

DISTRIBUTION_DEB_BASE = \
(DISTRIBUTION_DEBIAN,
DISTRIBUTION_UBUNTU,
DISTRIBUTION_LINUXMINT)
DIST_DEB_BASE = \
(DIST_DEBIAN,
DIST_UBUNTU,
DIST_LINUXMINT)


# RPM Base
DISTRIBUTION_REDHAT = 'redhat'
DISTRIBUTION_CENTOS = 'centos'
DISTRIBUTION_FEDORA = 'fedora'

DISTRIBUTION_SUSE = 'suse'
DISTRIBUTION_OPENSUSE = 'opensuse'
DISTRIBUTION_MANDRIVA = 'mandriva'

DISTRIBUTION_RPM_BASE = \
(DISTRIBUTION_REDHAT,
DISTRIBUTION_CENTOS,
DISTRIBUTION_FEDORA,
DISTRIBUTION_SUSE,
DISTRIBUTION_OPENSUSE,
DISTRIBUTION_MANDRIVA)
DIST_REDHAT = 'redhat'
DIST_CENTOS = 'centos'
DIST_FEDORA = 'fedora'

DIST_SUSE = 'suse'
DIST_OPENSUSE = 'opensuse'
DIST_MANDRIVA = 'mandriva'

DIST_RPM_BASE = \
(DIST_REDHAT,
DIST_CENTOS,
DIST_FEDORA,
DIST_SUSE,
DIST_OPENSUSE,
DIST_MANDRIVA)

# BSD Base
DIST_MACOSX = 'macosx'

### Architecture
ARCHITECTURE_I386 = 'i386'
ARCHITECTURE_AMD64 = 'amd64'
ARCH_I386 = 'i386'
ARCH_AMD64 = 'amd64'

### System
SYSTEM_LINUX = 'Linux'
SYSTEM_MAC = 'Darwin'
# not ready
#SYSTEM_BSD = ''
22 changes: 10 additions & 12 deletions lazyscripts/distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,9 @@ def pkgsrc_name(self):
@return str
"""
#if self.name in ('ubuntu', 'debian', 'linuxmint'):
if self.name in DISTRIBUTION_DEB_BASE:
if self.name in DIST_DEB_BASE:
extend = 'list'
#elif self.name in ('fedora', 'redhat', 'centos','opensuse','suse','mandriva'):
elif self.name in DISTRIBUTION_RPM_BASE:
elif self.name in DIST_RPM_BASE:
extend = 'sh'
return "lzs_%s_%s_%s.%s" % (platform.machine(),
self.name,
Expand Down Expand Up @@ -96,32 +94,32 @@ def _reduce_name(self):
raise DistrobutionNotFound()
elif self.name == 'susE':
if commands.getoutput('cat /etc/SuSE-release | grep "openSUSE"'):
self.name = DISTRIBUTION_OPENSUSE
elif self.name == DISTRIBUTION_REDHAT:
self.name = DIST_OPENSUSE
elif self.name == DIST_REDHAT:
if commands.getoutput('cat /etc/redhat-release | grep "Red Hat"'):
self.name = DISTRIBUTION_REDHAT
self.name = DIST_REDHAT
if commands.getoutput('cat /etc/redhat-release | grep "CentOS"'):
self.name = DISTRIBUTION_CENTOS
self.name = DIST_CENTOS
elif self.name in ('mandrake', 'mandriva linux'):
if os.path.exists('/etc/mandriva-release') and \
commands.getoutput('cat /etc/mandriva-release | grep "Mandriva"'):
self.name = DISTRIBUTION_MANDRIVA
self.name = DIST_MANDRIVA
#}}}

#{{{def _reduce_version(self):
def _reduce_version(self):
if self.name == 'opensolaris' and not self.version:
self.version = commands.getoutput('cat /etc/release | grep "OpenSolaris" | cut -d " " -f 27')
elif self.name == DISTRIBUTION_DEBIAN:
elif self.name == DIST_DEBIAN:
self.version = self.version.split('.')[0]
#}}}

def _reduce_architecture(self):
arch = platform.architecture()[0]
if arch == '32bit':
self.architecture = ARCHITECTURE_I386
self.architecture = ARCH_I386
elif arch == '64bit':
self.architecture = ARCHITECTURE_AMD64
self.architecture = ARCH_AMD64
else:
self.architecture = None

Expand Down

0 comments on commit 6bc0801

Please sign in to comment.