provide bootstrap.conf to handle bootstrap
authorGui Chen <gui.chen@intel.com>
Wed, 15 Aug 2012 13:33:04 +0000 (21:33 +0800)
committerGui Chen <gui.chen@intel.com>
Thu, 16 Aug 2012 10:51:05 +0000 (18:51 +0800)
Signed-off-by: Gui Chen <gui.chen@intel.com>
distfiles/bootstrap.conf [new file with mode: 0644]
mic/conf.py
setup.py

diff --git a/distfiles/bootstrap.conf b/distfiles/bootstrap.conf
new file mode 100644 (file)
index 0000000..a053ffb
--- /dev/null
@@ -0,0 +1,18 @@
+[main]
+distro_name = tizen
+rootdir = /var/tmp/mic-bootstrap
+enable = true
+
+[tizen]
+packages: setup filesystem tzdata libgcc eglibc-common eglibc ncurses-base
+    ncurses ncurses-libs bash zlib libpython python-base libstdc++ popt
+    libuuid libblkid libcom_err expat db4 nspr elfutils-libelf sqlite
+    bzip2-libs bzip2 e2fsprogs-libs libss e2fsprogs libmount libpcre
+    libfile libxml2 c-ares mtools syslinux syslinux-extlinux dosfstools
+    sed readline libattr libacl coreutils openssl gzip python util-linux
+    nss-softokn-freebl nss nss-sysinit libidn libcurl curl python-pycurl
+    xz-libs kmod libcap liblua rpm-libs rpm rpm-python satsolver-tools
+    mkdevnodes udev libudev libzypp python-zypp mic grep pwdutils lua
+    device-mapper device-mapper-libs psmisc kpartx parted which gawk
+    cpio lsof file python-xml python-urlgrabber smack-utils
+    rpm-security-plugin
index ec2da56..c7d3317 100644 (file)
@@ -42,7 +42,6 @@ class ConfigMgr(object):
                     "tmpdir": '/var/tmp/mic',
                     "cachedir": '/var/tmp/mic/cache',
                     "outdir": './mic-output',
-                    "bootstrapdir": '/var/tmp/mic/bootstrap',
 
                     "arch": None, # None means auto-detect
                     "pkgmgr": "yum",
@@ -54,14 +53,11 @@ class ConfigMgr(object):
                     "release": None,
                     "logfile": None,
                     "record_pkgs": [],
-                    "rpmver": None,
                     "pack_to": None,
                     "name_prefix": None,
                     "proxy": None,
                     "no_proxy": None,
                     "copy_kernel": False,
-
-                    "runtime": None,
                 },
                 'chroot': {
                     "saveto": None,
@@ -69,7 +65,11 @@ class ConfigMgr(object):
                 'convert': {
                     "shell": False,
                 },
-                'bootstraps': {},
+                'bootstrap': {
+                    "enable": False,
+                    "distro_name": None,
+                    "rootdir": '/var/tmp/mic-bootstrap',
+                },
                }
 
     # make the manager class as singleton
@@ -90,6 +90,10 @@ class ConfigMgr(object):
         # initial options from siteconf
         self._siteconf = siteconf
 
+        # set bootstrap from bootstrap.conf
+        bsconf = os.path.join(os.path.dirname(siteconf), 'bootstrap.conf')
+        self._parse_bootstrap(bsconf)
+
         if ksconf:
             self._ksconf = ksconf
 
@@ -155,35 +159,6 @@ class ConfigMgr(object):
 
         proxy.set_proxies(self.create['proxy'], self.create['no_proxy'])
 
-        for section in parser.sections():
-            if section.startswith('bootstrap'):
-                name = section
-                repostr = {}
-                for option in parser.options(section):
-                    if option == 'name':
-                        name = parser.get(section, 'name')
-                        continue
-
-                    val = parser.get(section, option)
-                    if '_' in option:
-                        (reponame, repoopt) = option.split('_')
-                        if repostr.has_key(reponame):
-                            repostr[reponame] += "%s:%s," % (repoopt, val)
-                        else:
-                            repostr[reponame] = "%s:%s," % (repoopt, val)
-                        continue
-
-                    if val.split(':')[0] in ('file', 'http', 'https', 'ftp'):
-                        if repostr.has_key(option):
-                            repostr[option] += "name:%s,baseurl:%s," % \
-                                                (option, val)
-                        else:
-                            repostr[option]  = "name:%s,baseurl:%s," % \
-                                                (option, val)
-                        continue
-
-                self.bootstraps[name] = repostr
-
     def _parse_kickstart(self, ksconf=None):
         if not ksconf:
             return
@@ -207,8 +182,6 @@ class ConfigMgr(object):
                                                     self.create['cachedir'])
         msger.raw(" DONE")
 
-        self.create['rpmver'] = misc.get_rpmver_in_repo(self.create['repomd'])
-
         target_archlist, archlist = misc.get_arch(self.create['repomd'])
         if self.create['arch']:
             if self.create['arch'] not in archlist:
@@ -230,4 +203,31 @@ class ConfigMgr(object):
         misc.selinux_check(self.create['arch'],
                            [p.fstype for p in ks.handler.partition.partitions])
 
+
+    def _parse_bootstrap(self, bsconf):
+        if not bsconf or not os.path.exists(bsconf):
+            self.bootstrap['enable'] = False
+            return
+
+        parser = ConfigParser.SafeConfigParser()
+        parser.read(bsconf)
+
+        for section in parser.sections():
+            if section == "main":
+                self.bootstrap.update(dict(parser.items(section)))
+            elif parser.has_option(section, 'packages'):
+                pkglist = parser.get(section, 'packages')
+                pkglist = pkglist.replace('\n', ' ')
+                self.bootstrap[section.lower()] = pkglist.split()
+                self.bootstrap['enable'] = True
+
+        # update bootstrap options
+        if self.bootstrap['enable'] not in (True, False):
+            try:
+                self.bootstrap['enable'] = parser.getboolean('main', 'enable')
+            except:
+                self.bootstrap['enable'] = False
+        if self.bootstrap['distro_name']:
+            self.bootstrap['distro_name'] = self.common['distro_name']
+
 configmgr = ConfigMgr()
index f68c1c0..83ad835 100644 (file)
--- a/setup.py
+++ b/setup.py
@@ -78,6 +78,7 @@ else:
     etc_prefix = os.path.join(prefix, 'etc')
 
 conffile = 'distfiles/mic.conf'
+bsconf = 'distfiles/bootstrap.conf'
 if os.path.isfile('%s/mic/mic.conf' % etc_prefix):
     conffile += '.new'
 
@@ -101,7 +102,7 @@ try:
           packages = PACKAGES,
           data_files = [("%s/lib/mic/plugins/imager" % prefix, IMAGER_PLUGINS),
                         ("%s/lib/mic/plugins/backend" % prefix, BACKEND_PLUGINS),
-                        ("%s/mic" % etc_prefix, [conffile])]
+                        ("%s/mic" % etc_prefix, [conffile, bsconf])]
     )
 finally:
     # remove dynamic file distfiles/mic.conf