From: "Brian Dolbec" <dolsen@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/layman:master commit in: layman/config_modules/reposconf/
Date: Tue, 17 Feb 2015 05:07:35 +0000 (UTC) [thread overview]
Message-ID: <1424149568.afece9a3634defccebd86d161d21e5475f3fea3c.dolsen@gentoo> (raw)
commit: afece9a3634defccebd86d161d21e5475f3fea3c
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 17 05:02:32 2015 +0000
Commit: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
CommitDate: Tue Feb 17 05:06:08 2015 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/layman.git;a=commit;h=afece9a3
config_modules/reposconf.py: Fix bug 540012 Errors /layman.conf does not exist
app-portage/layman-2.3.0 - ReposConf: ConfigHandler.read(); Failed to read "/etc/portage/repos.conf/layman.conf.
---
layman/config_modules/reposconf/reposconf.py | 30 +++++++++++++++++++++++-----
1 file changed, 25 insertions(+), 5 deletions(-)
diff --git a/layman/config_modules/reposconf/reposconf.py b/layman/config_modules/reposconf/reposconf.py
index 8b678eb..2b12d00 100644
--- a/layman/config_modules/reposconf/reposconf.py
+++ b/layman/config_modules/reposconf/reposconf.py
@@ -46,6 +46,8 @@ class ConfigHandler:
self.overlays = overlays
self.path = config['repos_conf']
self.storage = config['storage']
+ self.repo_config = None
+ self.rebuild = False
self.read()
@@ -73,21 +75,33 @@ class ConfigHandler:
Reads the repos.conf config file from
/etc/portage/repos.conf/layman.conf
'''
+ self.repo_conf = ConfigParser.ConfigParser()
if os.path.isfile(self.path):
- self.repo_conf = ConfigParser.ConfigParser()
self._read_config(self.repo_conf)
else:
- self.output.error('ReposConf: ConfigHandler.read(); Failed to read "'\
+ self.output.warn('ReposConf: ConfigHandler.read(); Failed to read "'\
'%(path)s".\nFile not found.' % ({'path': self.path}))
+ target_dir = os.path.split(os.path.realpath(self.path))[0]
+ if not os.path.isdir(target_dir):
+ self.output.info("Creating %s" % target_dir)
+ try:
+ os.mkdir(target_dir,0o0755)
+ self.rebuild = True
+ except OSError:
+ raise
- def add(self, overlay):
+ def add(self, overlay, no_write=False):
'''
Adds overlay information to the specified config file.
@param overlay: layman.overlay.Overlay instance.
+ @param no_write: boolean default=False usedto prevent circular recursion
+ when add() is called from write()
@return boolean: reflects a successful/failed write to the config file.
'''
+ if self.repo_conf and self.repo_conf.has_section(overlay.name):
+ return
self.repo_conf.add_section(overlay.name)
self.repo_conf.set(overlay.name, 'priority', str(overlay.priority))
self.repo_conf.set(overlay.name, 'location', path((self.storage, overlay.name)))
@@ -102,7 +116,9 @@ class ConfigHandler:
else:
self.repo_conf.set(overlay.name, 'auto-sync', 'No')
- return self.write()
+ if not no_write:
+ return self.write()
+ return
def delete(self, overlay):
@@ -160,11 +176,15 @@ class ConfigHandler:
with fileopen(self.path, 'w') as laymanconf:
# If the repos.conf is empty check to see if we can write
# all the overlays to the file.
+ if self.rebuild:
+ # start over with a fresh instance
+ self.repo_conf = ConfigParser.ConfigParser()
if not self.repo_conf.sections():
for i in sorted(self.overlays):
if not i == delete:
- self.add(self.overlays[i])
+ self.add(self.overlays[i], no_write=True)
self.repo_conf.write(laymanconf)
+ self.rebuild = False
return True
except IOError as error:
self.output.error('ReposConf: ConfigHandler.write(); Failed to write "'\
next reply other threads:[~2015-02-17 5:07 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-17 5:07 Brian Dolbec [this message]
-- strict thread matches above, loose matches on Subject: below --
2015-04-20 17:12 [gentoo-commits] proj/layman:master commit in: layman/config_modules/reposconf/ Devan Franchini
2015-03-25 1:13 Devan Franchini
2015-03-25 0:44 Devan Franchini
2015-02-17 5:07 Brian Dolbec
2015-02-08 3:39 Brian Dolbec
2015-02-08 0:33 Devan Franchini
2015-02-05 2:56 Devan Franchini
2015-02-05 2:48 Devan Franchini
2015-02-04 17:58 Devan Franchini
2015-02-04 17:19 Devan Franchini
2015-02-04 17:13 Devan Franchini
2015-02-04 17:13 Devan Franchini
2015-02-03 2:43 Devan Franchini
2015-02-02 23:05 Devan Franchini
2014-12-08 4:15 Devan Franchini
2014-12-03 19:08 Devan Franchini
2014-08-28 22:01 Devan Franchini
2014-08-17 21:17 Devan Franchini
2014-08-19 1:49 ` Devan Franchini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1424149568.afece9a3634defccebd86d161d21e5475f3fea3c.dolsen@gentoo \
--to=dolsen@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox