diff options
author | Zhang Qiang <qiang.z.zhang@intel.com> | 2012-02-03 11:17:06 +0800 |
---|---|---|
committer | Zhang Qiang <qiang.z.zhang@intel.com> | 2012-02-03 11:17:06 +0800 |
commit | 99de796d9ab8944adea2bcf6c4f1ca5d53f4a7cf (patch) | |
tree | 4d1503ebfc5780d7dfbf47c510736f528f24cb6b /plugins | |
parent | 121b13cce3a302d586b8945fa311dc6afd55b3f3 (diff) | |
download | mic-99de796d9ab8944adea2bcf6c4f1ca5d53f4a7cf.tar.gz mic-99de796d9ab8944adea2bcf6c4f1ca5d53f4a7cf.tar.bz2 mic-99de796d9ab8944adea2bcf6c4f1ca5d53f4a7cf.zip |
check free space of cache filesystem for downloading.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/backend/yumpkgmgr.py | 8 | ||||
-rw-r--r-- | plugins/backend/zypppkgmgr.py | 8 |
2 files changed, 12 insertions, 4 deletions
diff --git a/plugins/backend/yumpkgmgr.py b/plugins/backend/yumpkgmgr.py index 3cd01f9..1c112a5 100644 --- a/plugins/backend/yumpkgmgr.py +++ b/plugins/backend/yumpkgmgr.py @@ -24,6 +24,7 @@ import yum from mic import msger from mic.kickstart import ksparser from mic.utils import rpmmisc +from mic.utils import misc from mic.utils.errors import CreatorError from mic.imager.baseimager import BaseImageCreator @@ -294,6 +295,9 @@ class Yum(BackendPlugin, yum.YumBase): else: download_total_size -= int(po.packagesize) cached_count +=1 + cache_avail_size = misc.get_filesystem_avail(self.cachedir) + if cache_avail_size < download_total_size: + raise CreatorError("No enough space used for downloading.") # record the total size of installed pkgs pkgs_total_size = 0L @@ -304,8 +308,8 @@ class Yum(BackendPlugin, yum.YumBase): pkgs_total_size += int(x.size) # check needed size before actually download and install - if checksize and pkgs_total_size + download_total_size > checksize: - raise CreatorError("No enough space used for downloading and installing") + if checksize and pkgs_total_size > checksize: + raise CreatorError("No enough space used for installing, please resize partition size in ks file") msger.info("%d packages to be installed, %d packages gotten from cache, %d packages to be downloaded" % (total_count, cached_count, total_count - cached_count)) try: diff --git a/plugins/backend/zypppkgmgr.py b/plugins/backend/zypppkgmgr.py index bcaccf0..a967b91 100644 --- a/plugins/backend/zypppkgmgr.py +++ b/plugins/backend/zypppkgmgr.py @@ -29,6 +29,7 @@ if not hasattr(zypp, 'PoolQuery') or not hasattr(zypp.RepoManager, 'loadSolvFile from mic import msger from mic.kickstart import ksparser from mic.utils import rpmmisc +from mic.utils import misc from mic.utils.proxy import get_proxy_for from mic.utils.errors import CreatorError from mic.imager.baseimager import BaseImageCreator @@ -366,12 +367,15 @@ class Zypp(BackendPlugin): else: download_total_size -= int(po.downloadSize()) cached_count += 1 + cache_avail_size = misc.get_filesystem_avail(self.cachedir) + if cache_avail_size < download_total_size: + raise CreatorError("No enough space used for downloading.") # record the total size of installed pkgs install_total_size = sum(map(lambda x: int(x.installSize()), dlpkgs)) # check needed size before actually download and install - if checksize and download_total_size + install_total_size > checksize: - raise CreatorError("No enough space used for downloading and installing") + if checksize and install_total_size > checksize: + raise CreatorError("No enough space used for installing, please resize partition size in ks file") download_count = total_count - cached_count msger.info("%d packages to be installed, %d packages gotten from cache, %d packages to be downloaded" % (total_count, cached_count, download_count)) |