From 7ef2a516fc25332f99c1f4b741716259349ac18c Mon Sep 17 00:00:00 2001 From: Gui Chen Date: Wed, 15 Aug 2012 21:33:04 +0800 Subject: [PATCH] provide bootstrap.conf to handle bootstrap Signed-off-by: Gui Chen --- distfiles/bootstrap.conf | 18 ++++++++++++ mic/conf.py | 72 ++++++++++++++++++++++++------------------------ setup.py | 3 +- 3 files changed, 56 insertions(+), 37 deletions(-) create mode 100644 distfiles/bootstrap.conf diff --git a/distfiles/bootstrap.conf b/distfiles/bootstrap.conf new file mode 100644 index 0000000..a053ffb --- /dev/null +++ b/distfiles/bootstrap.conf @@ -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 diff --git a/mic/conf.py b/mic/conf.py index ec2da56..c7d3317 100644 --- a/mic/conf.py +++ b/mic/conf.py @@ -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() diff --git a/setup.py b/setup.py index f68c1c0..83ad835 100644 --- 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 -- 2.7.4