summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormao xiaojuan <xiaojuan.mao@samsung.com>2017-11-23 16:05:04 +0800
committermao xiaojuan <xiaojuan.mao@samsung.com>2017-11-27 14:03:50 +0800
commita844235d18bf17987b6e17dbf397622a4b26e4b9 (patch)
treea5192f7c4cf70fb32e9e0a12715e5d0f4b2aec37
parentcdfc17622a94943d667d3f608169ae690078387a (diff)
downloadmic-a844235d18bf17987b6e17dbf397622a4b26e4b9.tar.gz
mic-a844235d18bf17987b6e17dbf397622a4b26e4b9.tar.bz2
mic-a844235d18bf17987b6e17dbf397622a4b26e4b9.zip
Support local mic-bootstrap rpm package to run mic.
Change-Id: I80298991eea5a9552a497b6e4b290e7b5b94555c
-rw-r--r--mic/bootstrap.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/mic/bootstrap.py b/mic/bootstrap.py
index 5cfa8c7..2653c35 100644
--- a/mic/bootstrap.py
+++ b/mic/bootstrap.py
@@ -22,10 +22,13 @@ import tempfile
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"
@@ -87,6 +90,21 @@ class MiniBackend(object):
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()
@@ -105,7 +123,9 @@ class MiniBackend(object):
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: