mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-28 10:46:15 +01:00
Merge branch 'config_replace_issue_313' of https://github.com/lethliel/osc
Store a newly created config file in $XDG_CONFIG_HOME/osc/. For backward compatibility, ~/.oscrc is used, if present. Fixes: #313 ("oscrc should be stored in $XDG_CONFIG_HOME on linux")
This commit is contained in:
commit
cb376a1a34
@ -491,7 +491,7 @@ def check_trusted_projects(apiurl, projects):
|
||||
print("Note that malicious packages can compromise the build result or even your system.")
|
||||
r = raw_input(trustprompt % { 'project': prj })
|
||||
if r == '1':
|
||||
print("adding '%s' to ~/.oscrc: ['%s']['trusted_prj']" % (prj, apiurl))
|
||||
print("adding '%s' to oscrc: ['%s']['trusted_prj']" % (prj, apiurl))
|
||||
trusted.append(prj)
|
||||
elif r != '2':
|
||||
print("Well, good good bye then :-)")
|
||||
|
@ -5631,7 +5631,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
|
||||
The arguments REPOSITORY and ARCH are optional. They can be taken from
|
||||
the first two columns of the 'osc repos' output. If not specified,
|
||||
REPOSITORY defaults to the 'build_repositoy' config entry in your '.oscrc'
|
||||
REPOSITORY defaults to the 'build_repositoy' config entry in your 'oscrc'
|
||||
and ARCH defaults to your host architecture.
|
||||
|
||||
usage:
|
||||
@ -6014,7 +6014,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
@cmdln.option('--nochecks', '--no-checks', action='store_true',
|
||||
help='Do not run build checks on the resulting packages.')
|
||||
@cmdln.option('--no-verify', '--noverify', action='store_true',
|
||||
help='Skip signature verification (via pgp keys) of packages used for build. (Global config in .oscrc: no_verify)')
|
||||
help='Skip signature verification (via pgp keys) of packages used for build. (Global config in oscrc: no_verify)')
|
||||
@cmdln.option('--noservice', '--no-service', action='store_true',
|
||||
help='Skip run of local source services as specified in _service file.')
|
||||
@cmdln.option('-p', '--prefer-pkgs', metavar='DIR', action='append',
|
||||
@ -6099,8 +6099,8 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
Debian dsc file.
|
||||
|
||||
The command honours packagecachedir, build-root and build-uid
|
||||
settings in .oscrc, if present. You may want to set su-wrapper = 'sudo'
|
||||
in .oscrc, and configure sudo with option NOPASSWD for /usr/bin/build.
|
||||
settings in oscrc, if present. You may want to set su-wrapper = 'sudo'
|
||||
in oscrc, and configure sudo with option NOPASSWD for /usr/bin/build.
|
||||
|
||||
If neither --clean nor --noinit is given, build will reuse an existing
|
||||
build-root again, removing unneeded packages and add missing ones. This
|
||||
@ -8073,7 +8073,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
apiurl = self.get_api_url()
|
||||
if len(usernames) < 1:
|
||||
if 'user' not in conf.config['api_host_options'][apiurl]:
|
||||
raise oscerr.WrongArgs('your .oscrc does not have your user name.')
|
||||
raise oscerr.WrongArgs('your oscrc does not have your user name.')
|
||||
usernames = (conf.config['api_host_options'][apiurl]['user'],)
|
||||
for name in usernames:
|
||||
user = get_user_data(apiurl, name, 'login', 'realname', 'email')
|
||||
@ -8593,7 +8593,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
||||
be in the cwd or in path.
|
||||
|
||||
The email address used in .changes file is read from BuildService
|
||||
instance, or should be defined in ~/.oscrc
|
||||
instance, or should be defined in oscrc
|
||||
[https://api.opensuse.org/]
|
||||
user = login
|
||||
pass = password
|
||||
|
33
osc/conf.py
33
osc/conf.py
@ -7,12 +7,12 @@ from __future__ import print_function
|
||||
|
||||
"""Read osc configuration and store it in a dictionary
|
||||
|
||||
This module reads and parses ~/.oscrc. The resulting configuration is stored
|
||||
This module reads and parses oscrc. The resulting configuration is stored
|
||||
for later usage in a dictionary named 'config'.
|
||||
The .oscrc is kept mode 0600, so that it is not publically readable.
|
||||
The oscrc is kept mode 0600, so that it is not publically readable.
|
||||
This gives no real security for storing passwords.
|
||||
If in doubt, use your favourite keyring.
|
||||
Password is stored on ~/.oscrc as bz2 compressed and base64 encoded, so that is fairly
|
||||
Password is stored on ~/.config/osc/oscrc as bz2 compressed and base64 encoded, so that is fairly
|
||||
large and not to be recognized or remembered easily by an occasional spectator.
|
||||
|
||||
If information is missing, it asks the user questions.
|
||||
@ -638,7 +638,9 @@ def get_configParser(conffile=None, force_read=False):
|
||||
ConfigParser object is stored in a method attribute and this attribute
|
||||
is returned unless you pass force_read=True.
|
||||
"""
|
||||
conffile = conffile or os.environ.get('OSC_CONFIG', '~/.oscrc')
|
||||
if not conffile:
|
||||
conffile = identify_conf()
|
||||
|
||||
conffile = os.path.expanduser(conffile)
|
||||
if 'conffile' not in get_configParser.__dict__:
|
||||
get_configParser.conffile = conffile
|
||||
@ -654,6 +656,8 @@ def write_config(fname, cp):
|
||||
if os.path.exists(fname) and not os.path.isfile(fname):
|
||||
# only write to a regular file
|
||||
return
|
||||
if not os.path.exists(os.path.dirname(fname)):
|
||||
os.makedirs(os.path.dirname(fname), mode=0o700)
|
||||
with open(fname + '.new', 'w') as f:
|
||||
cp.write(f, comments=True)
|
||||
try:
|
||||
@ -818,14 +822,17 @@ def get_config(override_conffile=None,
|
||||
"""do the actual work (see module documentation)"""
|
||||
global config
|
||||
|
||||
conffile = override_conffile or os.environ.get('OSC_CONFIG', '~/.oscrc')
|
||||
conffile = os.path.expanduser(conffile)
|
||||
if not override_conffile:
|
||||
conffile = identify_conf()
|
||||
else:
|
||||
conffile = override_conffile
|
||||
|
||||
conffile = os.path.expanduser(conffile)
|
||||
if not os.path.exists(conffile):
|
||||
raise oscerr.NoConfigfile(conffile, \
|
||||
account_not_configured_text % conffile)
|
||||
|
||||
# okay, we made sure that .oscrc exists
|
||||
# okay, we made sure that oscrc exists
|
||||
|
||||
# make sure it is not world readable, it may contain a password.
|
||||
os.chmod(conffile, 0o600)
|
||||
@ -997,7 +1004,7 @@ def get_config(override_conffile=None,
|
||||
scheme = config.get('scheme', 'https')
|
||||
config['apiurl'] = urljoin(scheme, apisrv)
|
||||
if 'apisrc' in config or 'scheme' in config:
|
||||
print('Warning: Use of the \'scheme\' or \'apisrv\' in ~/.oscrc is deprecated!\n' \
|
||||
print('Warning: Use of the \'scheme\' or \'apisrv\' in oscrc is deprecated!\n' \
|
||||
'Warning: See README for migration details.', file=sys.stderr)
|
||||
if 'build_platform' in config:
|
||||
print('Warning: Use of \'build_platform\' config option is deprecated! (use \'build_repository\' instead)', file=sys.stderr)
|
||||
@ -1037,5 +1044,15 @@ def get_config(override_conffile=None,
|
||||
# finally, initialize urllib2 for to use the credentials for Basic Authentication
|
||||
init_basicauth(config, os.stat(conffile).st_mtime)
|
||||
|
||||
def identify_conf():
|
||||
# needed for compat reasons(users may have their oscrc still in ~
|
||||
if 'OSC_CONFIG' in os.environ:
|
||||
return os.environ.get('OSC_CONFIG')
|
||||
if os.path.exists(os.path.expanduser('~/.oscrc')):
|
||||
conffile = '~/.oscrc'
|
||||
else:
|
||||
conffile = os.environ.get('XDG_CONFIG_HOME', '~/.config') + '/osc/oscrc'
|
||||
|
||||
return conffile
|
||||
|
||||
# vim: sw=4 et
|
||||
|
Loading…
Reference in New Issue
Block a user