From 5c70f43906eefaa32cd560a97faf7c009dfd9cfd Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Mon, 27 Aug 2007 10:02:03 -0400 Subject: [PATCH] Move arch setup to __init__.py so that it is done if gather is not used. --- Changelog | 3 +++ pypungi/__init__.py | 13 +++++++++++++ pypungi/gather.py | 27 +++++++++++++++++---------- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/Changelog b/Changelog index c37595e3..96b1b174 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,6 @@ +* Mon Aug 27 2007 Jesse Keating +- Set up arch in __init__.py as it's needed for logging + * Sun Aug 26 2007 Jesse Keating - Add better support for %packages syntax using native pykickstart - Add a cache dir for pungi (/var/cache/pungi) and a cli option to override diff --git a/pypungi/__init__.py b/pypungi/__init__.py index 0fab6fd8..93c2a1c6 100644 --- a/pypungi/__init__.py +++ b/pypungi/__init__.py @@ -15,12 +15,25 @@ import logging import os import subprocess +import yum +import os class PungiBase(): """The base Pungi class. Set up config items and logging here""" def __init__(self, config): self.config = config + + hostarch = os.uname()[4] + if hostarch in yum.rpmUtils.arch.getArchList('athlon'): + config.set('default', 'arch', 'i386') + elif hostarch == 'ppc': + config.set('default', 'arch', 'ppc') + elif hostarch == 'sparc': + config.set('default', 'arch', 'sparc') + else: + config.set('default', 'arch', hostarch) + self.doLoggerSetup() self.workdir = os.path.join(self.config.get('default', 'destdir'), diff --git a/pypungi/gather.py b/pypungi/gather.py index 0a1fbecf..3c0f0238 100755 --- a/pypungi/gather.py +++ b/pypungi/gather.py @@ -48,20 +48,16 @@ class PungiYum(yum.YumBase): class Gather(pypungi.PungiBase): def __init__(self, config, ksparser): - # Set up arches, needed for log file name - hostarch = os.uname()[4] - if hostarch in yum.rpmUtils.arch.getArchList('athlon'): - config.set('default', 'arch', 'i386') + + arch = self.config.get('default', 'arch') + if arch == 'i386' yumarch = 'athlon' - elif hostarch == 'ppc': - config.set('default', 'arch', 'ppc') + elif arch == 'ppc': yumarch = 'ppc64' - elif hostarch == 'sparc': - config.set('default', 'arch', 'sparc') + elif arch == 'sparc': yumarch = 'sparc64v' else: - config.set('default', 'arch', hostarch) - yumarch = hostarch + yumarch = arch pypungi.PungiBase.__init__(self, config) @@ -96,6 +92,17 @@ class Gather(pypungi.PungiBase): self.ayum.cleanMetadata() # clean metadata that might be in the cache from previous runs self.ayum.cleanSqlite() # clean metadata that might be in the cache from previous runs + + arch = self.config.get('default', 'arch') + if arch == 'i386' + yumarch = 'athlon' + elif arch == 'ppc': + yumarch = 'ppc64' + elif arch == 'sparc': + yumarch = 'sparc64v' + else: + yumarch = arch + self.ayum.compatarch = yumarch arches = yum.rpmUtils.arch.getArchList(yumarch) arches.append('src') # throw source in there, filter it later