mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-26 18:06:13 +01:00
if only .netrc is found, automatically create a ready-to-go .oscrc
This commit is contained in:
parent
e19ded6f70
commit
11845654ac
32
osc/build.py
32
osc/build.py
@ -14,6 +14,7 @@ import cElementTree as ET
|
||||
from tempfile import NamedTemporaryFile
|
||||
from osc.fetch import *
|
||||
|
||||
APISRV = 'api.opensuse.org'
|
||||
|
||||
DEFAULTS = { 'packagecachedir': '/var/tmp/osbuild-packagecache',
|
||||
'su-wrapper': 'su -c',
|
||||
@ -177,11 +178,42 @@ def get_build_conf():
|
||||
|
||||
conffile = os.path.expanduser('~/.oscrc')
|
||||
if not os.path.exists(conffile):
|
||||
import netrc
|
||||
|
||||
try:
|
||||
info = netrc.netrc()
|
||||
username, account, password = info.authenticators(APISRV)
|
||||
|
||||
except (IOError, TypeError, netrc.NetrcParseError):
|
||||
print >>sys.stderr, 'Error:'
|
||||
print >>sys.stderr, 'You need to create ~/.oscrc.'
|
||||
print >>sys.stderr, 'Running the osc command will do this for you.'
|
||||
sys.exit(1)
|
||||
|
||||
cf = open(conffile, 'w')
|
||||
os.chmod(conffile, 0600)
|
||||
print 'creating', conffile
|
||||
cf.write("""
|
||||
|
||||
[general]
|
||||
|
||||
# Downloaded packages are cached here. Must be writable by you.
|
||||
#packagecachedir: /var/tmp/osbuild-packagecache
|
||||
|
||||
# Wrapper to call build as root (sudo, su -, ...)
|
||||
#su-wrapper: su -c
|
||||
|
||||
# rootdir to setup the chroot environment
|
||||
#build-root: /var/tmp/build-root
|
||||
|
||||
|
||||
[%s]
|
||||
user: %s
|
||||
pass: %s
|
||||
""" % (APISRV, username, password))
|
||||
cf.close()
|
||||
|
||||
|
||||
config = ConfigParser.ConfigParser(DEFAULTS)
|
||||
config.read(conffile)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user