Mailinglist Archive: opensuse-buildservice (314 mails)

< Previous Next >
[opensuse-buildservice] script to update existing .repo files
  • From: "Dr. Peter Poeml" <poeml@xxxxxxx>
  • Date: Wed, 23 Jan 2008 01:27:57 +0100
  • Message-id: <20080123002756.GY8989@xxxxxxx>

I hacked up a script which adapts .repo files, which are stored in
/etc/yum.repos.d, for the new key URLs.

It may be useful for other package managers, too -- I don't know.

"WARNING: This bug is visible to non-employees. Please be respectful!"

SUSE LINUX Products GmbH
Research & Development

# Copyright (C) 2008 Peter Poeml / Novell Inc. All rights reserved.
# This program is free software; it may be used, copied, modified
# and distributed under the terms of the GNU General Public Licence,
# either version 2, or (at your option) any later version.

import os

repofiles = os.listdir('.')
print repofiles

for repofile in repofiles:
if not repofile.endswith('.repo'):
print 'file:', repofile
baseurl = None
gpgkey = None
changed = False

lines = [ line.rstrip('\n') for line in open(repofile).readlines() ]

for lineno, line in enumerate(lines):

if line.startswith('baseurl'):
baseurl = line.split('=')[1]
baseurl = baseurl.rstrip('/')
#print ' ', line

if line.startswith('gpgkey') and baseurl:
gpgkey = baseurl + '/' + 'repodata/repomd.xml.key'
lines[lineno] = 'gpgkey=%s' % gpgkey

print 'old:', line
print 'new:', lines[lineno]

if line != lines[lineno]:
changed = True

if changed:
repl = raw_input('Write? (y/N) ')
if repl == 'y':
f = open(repofile, 'w')

print 'unchanged'

< Previous Next >
This Thread
  • No further messages