From 7f61504e369af486824cadf7b9e3d4ddfd4791d7 Mon Sep 17 00:00:00 2001 From: Gui Chen Date: Wed, 11 Jul 2012 15:59:27 +0800 Subject: [PATCH] supported tizen bootstrap included mic this function is not for normal user, but for special usage Signed-off-by: Gui Chen --- distfiles/mic.conf.in | 17 +++-------------- mic/bootstrap.py | 19 +++++++++---------- mic/creator.py | 6 +++++- mic/rt_util.py | 25 ++++++++++++++++++++++--- 4 files changed, 39 insertions(+), 28 deletions(-) diff --git a/distfiles/mic.conf.in b/distfiles/mic.conf.in index 2504590..a1d0d70 100644 --- a/distfiles/mic.conf.in +++ b/distfiles/mic.conf.in @@ -30,18 +30,7 @@ pkgmgr = zypp ; settings for chroot subcommand [bootstrap1] -; This bootstrap can be used to create image with rpm 4.8.x -name=meego-1.2.0 -1.2.0-oss=http://repo.meego.com/MeeGo/releases/1.2.0/repos/oss/ia32/packages/ -1.2.0-tools=http://download.meego.com/live/devel:/tools:/building/MeeGo_1.2.0/ -; 1.2.0-oss_proxy=http://proxy.yourcompany.com:port -; 1.2.0-tools_proxy=http://proxy.yourcompany.com:port - -[bootstrap2] -; This bootstrap can be used to create image with rpm 4.9.x -name=meego-trunk -trunk-oss=http://repo.meego.com/MeeGo/builds/trunk/latest/repos/oss/ia32/packages/ -trunk-tools=http://download.meego.com/live/devel:/tools:/building/Trunk/ -; trunk-oss_proxy=http://proxy.yourcompany.com:port -; trunk-tools_proxy=http://proxy.yourcompany.com:port +name=micbootstrap +bootstrap=http://download.tizen.org/tools/micbootstrap/ +; bootstrap_proxy=http://proxy.yourcompany.com:port diff --git a/mic/bootstrap.py b/mic/bootstrap.py index 0b28599..9d223d0 100644 --- a/mic/bootstrap.py +++ b/mic/bootstrap.py @@ -29,16 +29,10 @@ from mic.utils import proxy from mic.utils import misc from mic.utils import errors -minibase_pkgs = [ "kernel", "rpm", "setup", "filesystem", "basesystem", - "tzdata", "libgcc", "ncurses-base", "ncurses", "glibc", - "glibc-common", "ncurses-libs", "nss-softokn-freebl", - "bash", "zlib", "info", "cpio", "coreutils", "zypper" ] - -required_pkgs = [ "pam", "passwd", "meego-release", "nss", "genisoimage", - "bzip2", "gzip", "perl", "make", "file", "psmisc", "wget", - "syslinux-extlinux", "btrfs-progs", "satsolver-tools", - "isomd5sum", "mtd-utils", "mtd-utils-ubi", "libzypp", - "python-zypp", "grep", "sed", "qemu-arm-static", "mic" ] +minibase_grps = [ "tizen-bootstrap" ] +minibase_pkgs = [ ] +required_pkgs = [ "syslinux", "syslinux-extlinux", "satsolver-tools", + "libzypp", "python-zypp", "qemu-arm-static", "mic" ] def query_package_rpmdb(root='/', tag='name', pattern=None): @@ -204,6 +198,8 @@ class Bootstrap(object): rpm.addMacro("_dbpath", "/var/lib/rpm") rpm.addMacro("__file_context_path", "%{nil}") + for grp in minibase_grps: + pkg_manager.selectGroup(grp) for pkg in minibase_pkgs: pkg_manager.selectPackage(pkg) for pkg in required_pkgs: @@ -228,6 +224,9 @@ class Bootstrap(object): destdir= "%s/etc/zypp/repos.d/" % os.path.abspath(self.rootdir) shutil.rmtree(destdir, ignore_errors = True) shutil.copytree(srcdir, destdir) + # create '/tmp' in chroot + if not os.path.exists(os.path.join(os.path.abspath(self.rootdir), "tmp")): + os.makedirs(os.path.join(os.path.abspath(self.rootdir), "tmp")) msger.info("Bootstrap created.") diff --git a/mic/creator.py b/mic/creator.py index 4c980e6..9dabaf3 100644 --- a/mic/creator.py +++ b/mic/creator.py @@ -91,7 +91,8 @@ class Creator(cmdln.Cmdln): help='Path for local pkgs(rpms) to be installed') optparser.add_option('', '--runtime', type='string', dest='runtime', default=None, - help='Specify runtime mode, avaiable: bootstrap') + #help='Specify runtime mode, avaiable: bootstrap') + help=SUPPRESS_HELP) # --taring-to is alias to --pack-to optparser.add_option('', '--taring-to', type='string', dest='pack_to', default=None, @@ -200,6 +201,9 @@ class Creator(cmdln.Cmdln): if self.options.pkgmgr is not None: configmgr.create['pkgmgr'] = self.options.pkgmgr + if self.options.runtime: + configmgr.create['runtime'] = self.options.runtime + if self.options.pack_to is not None: configmgr.create['pack_to'] = self.options.pack_to diff --git a/mic/rt_util.py b/mic/rt_util.py index bde3594..deb6b9f 100644 --- a/mic/rt_util.py +++ b/mic/rt_util.py @@ -25,9 +25,13 @@ from mic import msger from mic.conf import configmgr from mic.utils import errors import mic.utils.misc as misc +from mic.utils.proxy import get_proxy_for + +BOOTSTRAP_URL="http://download.tizen.org/tools/micbootstrap" def runmic_in_runtime(runmode, opts, ksfile, argv=None): - if not runmode or "MeeGo" == linux_distribution()[0]: + dist = misc.get_distro()[0] + if not runmode or not dist or "MeeGo" == dist: return if not argv: @@ -37,7 +41,15 @@ def runmic_in_runtime(runmode, opts, ksfile, argv=None): if runmode == 'bootstrap': msger.info("Use bootstrap runtime environment") - (name, repostrs) = select_bootstrap(opts['repomd'], opts['cachedir'], opts['bootstrapdir']) + name = "micbootstrap" + try: + repostrs = configmgr.bootstraps[name] + except: + repostrs = "name:%s,baseurl:%s," (name, BOOTSTRAP_URL) + proxy = get_proxy_for(BOOTSTRAP_URL) + if proxy: + repostrs += "proxy:%s" % proxy + repolist = [] if not name: # use ks repo to create bootstrap @@ -176,7 +188,7 @@ def get_mic_libpath(): # the hard code path is prepared for bootstrap def copy_mic(bootstrap_pth, bin_pth = '/usr/bin', lib_pth='/usr/lib', \ - pylib_pth = '/usr/lib/python2.6/site-packages'): + pylib_pth = '/usr/lib/python2.7/site-packages'): # copy python lib files mic_pylib = get_mic_modpath() bs_mic_pylib = bootstrap_pth + os.path.join(pylib_pth, 'mic') @@ -208,6 +220,13 @@ def copy_mic(bootstrap_pth, bin_pth = '/usr/bin', lib_pth='/usr/lib', \ os.makedirs(os.path.dirname(bs_mic_cfgpth)) shutil.copy2(mic_cfgpth, bs_mic_cfgpth) + # remove yum backend + try: + yumpth = "/usr/lib/mic/plugins/backend/yumpkgmgr.py" + os.unlink(bootstrap_pth + yumpth) + except: + pass + def clean_files(pattern, dir): if not os.path.exists(dir): return -- 2.7.4