import shutil
import subprocess
import rpm
+import glob
+
from mic import msger
from mic.utils import errors, proxy, misc
from mic.utils.rpmmisc import readRpmHeader, RPMInstallCallback
from mic.chroot import cleanup_mounts, setup_chrootenv, cleanup_chrootenv
+from mic.conf import configmgr
PATH_BOOTSTRAP = "/usr/sbin:/usr/bin:/sbin:/bin"
if not pkg in self.dlpkgs:
self.dlpkgs.append(pkg)
+ def _get_local_packages(self, pkg):
+ """Return local mic-bootstrap rpm path."""
+ cropts = configmgr.create
+ if cropts['local_pkgs_path']:
+ if os.path.isdir(cropts['local_pkgs_path']):
+ pkglist = glob.glob(
+ os.path.join(cropts['local_pkgs_path'], pkg + '*.rpm'))
+ if len(pkglist) > 1:
+ raise errors.BootstrapError("Many %s packages in folder, put only one %s package in it." % (pkg, pkg))
+ elif len(pkglist) == 1:
+ return ''.join(pkglist)
+ elif os.path.splitext(cropts['local_pkgs_path'])[-1] == '.rpm':
+ if cropts['local_pkgs_path'].index(pkg) > -1:
+ return cropts['local_pkgs_path']
+ return None
def runInstall(self):
# FIXME: check space
self.downloadPkgs()
def downloadPkgs(self):
nonexist = []
for pkg in self.dlpkgs:
- localpth = misc.get_package(pkg, self.repomd, self.arch)
+ localpth = self._get_local_packages(pkg)
+ if localpth is None:
+ localpth = misc.get_package(pkg, self.repomd, self.arch)
if localpth:
self.localpkgs[pkg] = localpth
elif pkg in self.optionals: