2006-04-20 16:26:50 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
2006-10-12 15:22:56 +02:00
|
|
|
# Copyright (C) 2006 Peter Poeml / Novell Inc. All rights reserved.
|
2006-04-20 16:26:50 +02:00
|
|
|
# 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.
|
|
|
|
|
2006-10-12 15:30:33 +02:00
|
|
|
__version__ = '0.9'
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
import urllib2
|
2006-06-30 01:34:06 +02:00
|
|
|
from urllib import pathname2url, quote_plus
|
2006-04-20 16:26:50 +02:00
|
|
|
from urlparse import urlunsplit
|
2006-05-02 10:17:45 +02:00
|
|
|
from cStringIO import StringIO
|
2006-05-30 12:07:16 +02:00
|
|
|
import shutil
|
2006-10-10 16:04:34 +02:00
|
|
|
import conf
|
2007-03-13 00:17:34 +01:00
|
|
|
try:
|
|
|
|
from xml.etree import cElementTree as ET
|
|
|
|
except ImportError:
|
|
|
|
import cElementTree as ET
|
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
BUFSIZE = 1024*1024
|
|
|
|
store = '.osc'
|
2006-10-10 16:04:34 +02:00
|
|
|
exclude_stuff = [store, '.svn', 'CVS', '.git', '.gitignore', '.pc', '*~', '.*.swp']
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
2006-05-23 17:27:43 +02:00
|
|
|
new_project_templ = """\
|
2006-05-23 18:16:14 +02:00
|
|
|
<project name="%s">
|
2006-06-23 12:35:20 +02:00
|
|
|
|
2006-05-23 17:27:43 +02:00
|
|
|
<title>Short title of NewProject</title>
|
2006-06-23 12:35:20 +02:00
|
|
|
|
2006-05-23 17:27:43 +02:00
|
|
|
<description>This project aims at providing some foo and bar.
|
|
|
|
|
|
|
|
It also does some weird stuff.
|
|
|
|
</description>
|
2006-06-23 12:35:20 +02:00
|
|
|
|
2006-05-23 17:27:43 +02:00
|
|
|
<person role="maintainer" userid="%s" />
|
2006-06-23 12:35:20 +02:00
|
|
|
|
|
|
|
<!-- remove this comment to enable one or more build targets
|
|
|
|
|
|
|
|
<repository name="SUSE_Linux_Factory">
|
|
|
|
<path project="SUSE:Factory" repository="standard" />
|
|
|
|
<arch>x86_64</arch>
|
|
|
|
<arch>i586</arch>
|
|
|
|
</repository>
|
|
|
|
<repository name="SUSE_Linux_10.1">
|
|
|
|
<path project="SUSE:SL-10.1" repository="standard" />
|
|
|
|
<arch>x86_64</arch>
|
|
|
|
<arch>i586</arch>
|
|
|
|
</repository>
|
|
|
|
<repository name="SUSE_Linux_10.0">
|
|
|
|
<path project="SUSE:SL-10.0" repository="standard" />
|
|
|
|
<arch>x86_64</arch>
|
|
|
|
<arch>i586</arch>
|
|
|
|
</repository>
|
|
|
|
<repository name="SUSE_Linux_9.3">
|
|
|
|
<path project="SUSE:SL-9.3" repository="standard" />
|
|
|
|
<arch>x86_64</arch>
|
|
|
|
<arch>i586</arch>
|
|
|
|
</repository>
|
|
|
|
<repository name="Fedora_Core_5">
|
|
|
|
<path project="Fedora:Core5" repository="standard" />
|
|
|
|
<arch>i586</arch>
|
|
|
|
</repository>
|
|
|
|
<repository name="SUSE_SLES-9">
|
|
|
|
<path project="SUSE:SLES-9" repository="standard" />
|
|
|
|
<arch>x86_64</arch>
|
|
|
|
<arch>i586</arch>
|
2006-12-12 02:59:44 +01:00
|
|
|
</repository>
|
2006-06-23 12:35:20 +02:00
|
|
|
-->
|
|
|
|
|
2006-05-23 17:27:43 +02:00
|
|
|
</project>
|
|
|
|
"""
|
|
|
|
|
|
|
|
new_package_templ = """\
|
|
|
|
<package name="%s">
|
2006-06-23 12:35:20 +02:00
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
<title>Title of New Package</title>
|
2006-06-23 12:35:20 +02:00
|
|
|
|
2006-06-22 13:26:01 +02:00
|
|
|
<description>LONG DESCRIPTION
|
|
|
|
GOES
|
2006-06-23 12:35:20 +02:00
|
|
|
HERE
|
|
|
|
</description>
|
|
|
|
|
2006-05-23 17:27:43 +02:00
|
|
|
<person role="maintainer" userid="%s"/>
|
2006-06-23 12:35:20 +02:00
|
|
|
|
|
|
|
|
|
|
|
<!--
|
|
|
|
use on of the examples below to disable building of this package
|
|
|
|
on a certain architecture, in a certain repository,
|
|
|
|
or a combination thereof:
|
|
|
|
|
|
|
|
<disable arch="x86_64"/>
|
2006-12-12 02:59:44 +01:00
|
|
|
<disable repository="SUSE_SLE-10"/>
|
|
|
|
<disable repository="SUSE_SLE-10" arch="x86_64"/>
|
2006-06-23 12:35:20 +02:00
|
|
|
|
|
|
|
-->
|
|
|
|
|
2006-05-23 17:27:43 +02:00
|
|
|
</package>
|
|
|
|
"""
|
|
|
|
|
2006-10-12 15:22:56 +02:00
|
|
|
new_user_template = """\
|
|
|
|
<person>
|
|
|
|
<login>%(user)s</login>
|
|
|
|
<email>PUT_EMAIL_ADDRESS_HERE</email>
|
|
|
|
<realname>PUT_REAL_NAME_HERE</realname>
|
|
|
|
<source_backend>
|
|
|
|
<host></host>
|
|
|
|
<port></port>
|
|
|
|
</source_backend>
|
|
|
|
<rpm_backend>
|
|
|
|
<host></host>
|
|
|
|
<port></port>
|
|
|
|
</rpm_backend>
|
|
|
|
<watchlist>
|
|
|
|
<project name="home:%(user)s"/>
|
|
|
|
</watchlist>
|
|
|
|
</person>
|
|
|
|
"""
|
2006-05-23 17:27:43 +02:00
|
|
|
|
2006-09-25 17:11:03 +02:00
|
|
|
buildstatus_symbols = {'succeeded': '.',
|
|
|
|
'disabled': ' ',
|
|
|
|
'expansion error': 'E',
|
|
|
|
'failed': 'F',
|
|
|
|
'broken': 'B',
|
|
|
|
'blocked': 'b',
|
|
|
|
'building': '%',
|
|
|
|
'scheduled': 's',
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
class File:
|
|
|
|
"""represent a file, including its metadata"""
|
|
|
|
def __init__(self, name, md5, size, mtime):
|
|
|
|
self.name = name
|
|
|
|
self.md5 = md5
|
|
|
|
self.size = size
|
|
|
|
self.mtime = mtime
|
|
|
|
def __str__(self):
|
|
|
|
return self.name
|
|
|
|
|
|
|
|
|
2006-05-22 12:50:37 +02:00
|
|
|
class Project:
|
|
|
|
"""represent a project directory, holding packages"""
|
|
|
|
def __init__(self, dir):
|
|
|
|
self.dir = dir
|
2006-06-06 12:50:40 +02:00
|
|
|
self.absdir = os.path.abspath(dir)
|
2006-05-22 12:50:37 +02:00
|
|
|
|
|
|
|
self.name = store_read_project(self.dir)
|
|
|
|
|
|
|
|
self.pacs_available = meta_get_packagelist(self.name)
|
|
|
|
|
2006-06-26 17:11:22 +02:00
|
|
|
self.pacs_have = [ i for i in os.listdir(self.dir) if i in self.pacs_available ]
|
2006-05-22 12:50:37 +02:00
|
|
|
|
2006-06-26 17:11:22 +02:00
|
|
|
self.pacs_missing = [ i for i in self.pacs_available if i not in self.pacs_have ]
|
2006-05-22 12:50:37 +02:00
|
|
|
|
|
|
|
def checkout_missing_pacs(self):
|
|
|
|
for pac in self.pacs_missing:
|
|
|
|
print 'checking out new package %s' % pac
|
|
|
|
olddir = os.getcwd()
|
|
|
|
os.chdir(os.pardir)
|
|
|
|
checkout_package(self.name, pac)
|
|
|
|
os.chdir(olddir)
|
|
|
|
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
r = []
|
|
|
|
r.append('*****************************************************')
|
|
|
|
r.append('Project %s (dir=%s, absdir=%s)' % (self.name, self.dir, self.absdir))
|
|
|
|
r.append('have pacs:\n%s' % ', '.join(self.pacs_have))
|
|
|
|
r.append('missing pacs:\n%s' % ', '.join(self.pacs_missing))
|
|
|
|
r.append('*****************************************************')
|
|
|
|
return '\n'.join(r)
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
class Package:
|
|
|
|
"""represent a package (its directory) and read/keep/write its metadata"""
|
|
|
|
def __init__(self, workingdir):
|
2006-09-29 16:34:18 +02:00
|
|
|
import fnmatch
|
2006-05-19 22:13:29 +02:00
|
|
|
self.dir = workingdir
|
2006-06-06 12:50:40 +02:00
|
|
|
self.absdir = os.path.abspath(self.dir)
|
2006-05-19 22:13:29 +02:00
|
|
|
self.storedir = os.path.join(self.dir, store)
|
|
|
|
|
|
|
|
check_store_version(self.dir)
|
|
|
|
|
|
|
|
self.prjname = store_read_project(self.dir)
|
|
|
|
self.name = store_read_package(self.dir)
|
|
|
|
|
|
|
|
files_tree = read_filemeta(self.dir)
|
|
|
|
files_tree_root = files_tree.getroot()
|
|
|
|
|
|
|
|
self.rev = files_tree_root.get('rev')
|
|
|
|
|
|
|
|
self.filenamelist = []
|
|
|
|
self.filelist = []
|
|
|
|
for node in files_tree_root.findall('entry'):
|
2006-05-22 16:12:06 +02:00
|
|
|
try:
|
2006-05-23 10:43:04 +02:00
|
|
|
f = File(node.get('name'),
|
|
|
|
node.get('md5'),
|
|
|
|
int(node.get('size')),
|
|
|
|
int(node.get('mtime')))
|
2006-05-22 16:12:06 +02:00
|
|
|
except:
|
2006-05-23 10:43:04 +02:00
|
|
|
# okay, a very old version of _files, which didn't contain any metadata yet...
|
|
|
|
f = File(node.get('name'), '', 0, 0)
|
2006-05-19 22:13:29 +02:00
|
|
|
self.filelist.append(f)
|
|
|
|
self.filenamelist.append(f.name)
|
|
|
|
|
|
|
|
self.to_be_deleted = read_tobedeleted(self.dir)
|
2006-05-22 16:12:06 +02:00
|
|
|
self.in_conflict = read_inconflict(self.dir)
|
2006-05-19 22:13:29 +02:00
|
|
|
|
|
|
|
self.todo = []
|
|
|
|
self.todo_send = []
|
|
|
|
self.todo_delete = []
|
|
|
|
|
2006-09-29 16:34:18 +02:00
|
|
|
# gather unversioned files, but ignore some stuff
|
|
|
|
self.excluded = [ i for i in os.listdir(self.dir)
|
|
|
|
for j in exclude_stuff
|
|
|
|
if fnmatch.fnmatch(i, j) ]
|
2006-06-26 17:11:22 +02:00
|
|
|
self.filenamelist_unvers = [ i for i in os.listdir(self.dir)
|
2006-09-29 16:34:18 +02:00
|
|
|
if i not in self.excluded
|
2006-06-26 17:11:22 +02:00
|
|
|
if i not in self.filenamelist ]
|
2006-05-19 22:13:29 +02:00
|
|
|
|
|
|
|
def addfile(self, n):
|
|
|
|
st = os.stat(os.path.join(self.dir, n))
|
2006-06-16 14:19:02 +02:00
|
|
|
f = File(n, None, st.st_size, st.st_mtime)
|
2006-05-19 22:13:29 +02:00
|
|
|
self.filelist.append(f)
|
|
|
|
self.filenamelist.append(n)
|
|
|
|
self.filenamelist_unvers.remove(n)
|
2006-05-30 12:07:16 +02:00
|
|
|
shutil.copy2(os.path.join(self.dir, n), os.path.join(self.storedir, n))
|
2006-05-19 22:13:29 +02:00
|
|
|
|
2006-05-30 12:07:16 +02:00
|
|
|
def delete_localfile(self, n):
|
|
|
|
try: os.unlink(os.path.join(self.dir, n))
|
|
|
|
except: pass
|
|
|
|
try: os.unlink(os.path.join(self.storedir, n))
|
|
|
|
except: pass
|
2006-05-19 22:13:29 +02:00
|
|
|
|
|
|
|
def put_on_deletelist(self, n):
|
|
|
|
if n not in self.to_be_deleted:
|
|
|
|
self.to_be_deleted.append(n)
|
|
|
|
|
2006-05-22 16:12:06 +02:00
|
|
|
def put_on_conflictlist(self, n):
|
|
|
|
if n not in self.in_conflict:
|
|
|
|
self.in_conflict.append(n)
|
|
|
|
|
|
|
|
def clear_from_conflictlist(self, n):
|
|
|
|
"""delete an entry from the file, and remove the file if it would be empty"""
|
|
|
|
if n in self.in_conflict:
|
|
|
|
|
|
|
|
filename = os.path.join(self.dir, n)
|
|
|
|
storefilename = os.path.join(self.storedir, n)
|
|
|
|
myfilename = os.path.join(self.dir, n + '.mine')
|
|
|
|
upfilename = os.path.join(self.dir, n + '.r' + self.rev)
|
|
|
|
|
2006-06-08 12:30:29 +02:00
|
|
|
try:
|
|
|
|
os.unlink(myfilename)
|
|
|
|
# the working copy may be updated, so the .r* ending may be obsolete...
|
|
|
|
# then we don't care
|
|
|
|
os.unlink(upfilename)
|
|
|
|
except:
|
|
|
|
pass
|
2006-05-22 16:12:06 +02:00
|
|
|
|
|
|
|
self.in_conflict.remove(n)
|
|
|
|
|
2006-05-23 15:59:29 +02:00
|
|
|
self.write_conflictlist()
|
2006-05-22 16:12:06 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
def write_deletelist(self):
|
2006-05-22 16:12:06 +02:00
|
|
|
if len(self.to_be_deleted) == 0:
|
2006-05-22 19:51:44 +02:00
|
|
|
try:
|
|
|
|
os.unlink(os.path.join(self.storedir, '_to_be_deleted'))
|
|
|
|
except:
|
|
|
|
pass
|
2006-05-22 16:12:06 +02:00
|
|
|
else:
|
|
|
|
fname = os.path.join(self.storedir, '_to_be_deleted')
|
|
|
|
f = open(fname, 'w')
|
|
|
|
f.write('\n'.join(self.to_be_deleted))
|
|
|
|
f.write('\n')
|
|
|
|
f.close()
|
|
|
|
|
2006-05-30 12:07:16 +02:00
|
|
|
def delete_source_file(self, n):
|
|
|
|
import othermethods
|
|
|
|
|
2006-06-30 01:34:06 +02:00
|
|
|
u = makeurl(['source', self.prjname, self.name, pathname2url(n)])
|
2006-10-10 16:04:34 +02:00
|
|
|
othermethods.delfile(u, n, conf.config['user'], conf.config['pass'])
|
2006-05-30 12:07:16 +02:00
|
|
|
|
|
|
|
self.delete_localfile(n)
|
|
|
|
|
|
|
|
def put_source_file(self, n):
|
|
|
|
import othermethods
|
|
|
|
|
2006-06-06 12:50:40 +02:00
|
|
|
# escaping '+' in the URL path (note: not in the URL query string) is
|
|
|
|
# only a workaround for ruby on rails, which swallows it otherwise
|
2006-06-30 01:34:06 +02:00
|
|
|
u = makeurl(['source', self.prjname, self.name, pathname2url(n)])
|
2006-10-12 15:22:56 +02:00
|
|
|
if conf.config['do_commits'] == '1':
|
|
|
|
u += '?rev=upload'
|
2006-10-10 16:04:34 +02:00
|
|
|
othermethods.putfile(u, conf.config['user'], conf.config['pass'], file = os.path.join(self.dir, n))
|
2006-05-30 12:07:16 +02:00
|
|
|
|
|
|
|
shutil.copy2(os.path.join(self.dir, n), os.path.join(self.storedir, n))
|
|
|
|
|
2006-10-12 15:22:56 +02:00
|
|
|
def commit(self, msg=''):
|
|
|
|
import othermethods
|
|
|
|
|
|
|
|
u = makeurl(['source', self.prjname, self.name])
|
|
|
|
u += '?cmd=commit&rev=upload'
|
|
|
|
u += '&user=%s' % conf.config['user']
|
|
|
|
u += '&comment=%s' % quote_plus(msg)
|
|
|
|
#print u
|
|
|
|
f = urlopen(u, data='')
|
|
|
|
#print f.read()
|
2006-10-10 16:04:34 +02:00
|
|
|
|
2006-05-22 16:12:06 +02:00
|
|
|
def write_conflictlist(self):
|
|
|
|
if len(self.in_conflict) == 0:
|
|
|
|
os.unlink(os.path.join(self.storedir, '_in_conflict'))
|
|
|
|
else:
|
|
|
|
fname = os.path.join(self.storedir, '_in_conflict')
|
|
|
|
f = open(fname, 'w')
|
|
|
|
f.write('\n'.join(self.in_conflict))
|
|
|
|
f.write('\n')
|
|
|
|
f.close()
|
2006-05-19 22:13:29 +02:00
|
|
|
|
|
|
|
def updatefile(self, n):
|
|
|
|
filename = os.path.join(self.dir, n)
|
|
|
|
storefilename = os.path.join(self.storedir, n)
|
2006-05-22 10:16:31 +02:00
|
|
|
mtime = self.findfilebyname(n).mtime
|
2006-05-19 22:13:29 +02:00
|
|
|
|
|
|
|
get_source_file(self.prjname, self.name, n, targetfilename=filename)
|
|
|
|
os.utime(filename, (-1, mtime))
|
|
|
|
|
2006-05-30 12:07:16 +02:00
|
|
|
shutil.copy2(filename, storefilename)
|
2006-05-19 22:13:29 +02:00
|
|
|
|
2006-05-22 16:12:06 +02:00
|
|
|
def mergefile(self, n):
|
|
|
|
filename = os.path.join(self.dir, n)
|
|
|
|
storefilename = os.path.join(self.storedir, n)
|
|
|
|
myfilename = os.path.join(self.dir, n + '.mine')
|
|
|
|
upfilename = os.path.join(self.dir, n + '.r' + self.rev)
|
|
|
|
os.rename(filename, myfilename)
|
|
|
|
|
2006-06-22 14:54:58 +02:00
|
|
|
mtime = self.findfilebyname(n).mtime
|
2006-05-22 16:12:06 +02:00
|
|
|
get_source_file(self.prjname, self.name, n, targetfilename=upfilename)
|
2006-06-22 14:54:58 +02:00
|
|
|
os.utime(upfilename, (-1, mtime))
|
|
|
|
|
|
|
|
if binary_file(myfilename) or binary_file(upfilename):
|
|
|
|
# don't try merging
|
|
|
|
shutil.copy2(upfilename, filename)
|
|
|
|
shutil.copy2(upfilename, storefilename)
|
|
|
|
self.in_conflict.append(n)
|
|
|
|
self.write_conflictlist()
|
|
|
|
return 'C'
|
2006-05-22 16:12:06 +02:00
|
|
|
else:
|
2006-06-22 14:54:58 +02:00
|
|
|
# try merging
|
2007-01-23 07:55:43 +01:00
|
|
|
# diff3 OPTIONS... MINE OLDER YOURS
|
|
|
|
merge_cmd = 'diff3 -m -E %s %s %s > %s' % (myfilename, storefilename, upfilename, filename)
|
|
|
|
# we would rather use the subprocess module, but it is not availablebefore 2.4
|
|
|
|
ret = os.system(merge_cmd) / 256
|
|
|
|
|
|
|
|
# "An exit status of 0 means `diff3' was successful, 1 means some
|
|
|
|
# conflicts were found, and 2 means trouble."
|
2006-06-22 14:54:58 +02:00
|
|
|
if ret == 0:
|
|
|
|
# merge was successful... clean up
|
2007-01-23 07:55:43 +01:00
|
|
|
shutil.copy2(upfilename, storefilename)
|
|
|
|
os.unlink(upfilename)
|
2006-06-22 14:54:58 +02:00
|
|
|
os.unlink(myfilename)
|
|
|
|
return 'G'
|
2007-01-23 07:55:43 +01:00
|
|
|
elif ret == 1:
|
2006-06-22 14:54:58 +02:00
|
|
|
# unsuccessful merge
|
2007-01-23 07:55:43 +01:00
|
|
|
shutil.copy2(upfilename, storefilename)
|
2006-06-22 14:54:58 +02:00
|
|
|
self.in_conflict.append(n)
|
|
|
|
self.write_conflictlist()
|
|
|
|
return 'C'
|
2007-01-23 07:55:43 +01:00
|
|
|
else:
|
|
|
|
print >>sys.stderr, '\ndiff3 got in trouble... exit code:', ret
|
|
|
|
print >>sys.stderr, 'the command line was:'
|
|
|
|
print >>sys.stderr, merge_cmd
|
|
|
|
sys.exit(1)
|
2006-05-22 16:12:06 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
def update_filesmeta(self):
|
|
|
|
meta = ''.join(show_files_meta(self.prjname, self.name))
|
|
|
|
f = open(os.path.join(self.storedir, '_files'), 'w')
|
|
|
|
f.write(meta)
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
def update_pacmeta(self):
|
|
|
|
meta = ''.join(show_package_meta(self.prjname, self.name))
|
|
|
|
f = open(os.path.join(self.storedir, '_meta'), 'w')
|
|
|
|
f.write(meta)
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
def findfilebyname(self, n):
|
|
|
|
for i in self.filelist:
|
|
|
|
if i.name == n:
|
|
|
|
return i
|
|
|
|
|
|
|
|
def status(self, n):
|
|
|
|
"""
|
|
|
|
status can be:
|
|
|
|
|
|
|
|
file storefile file present STATUS
|
|
|
|
exists exists in _files
|
|
|
|
|
|
|
|
x x - 'A'
|
2006-05-22 16:12:06 +02:00
|
|
|
x x x ' ' if digest differs: 'M'
|
|
|
|
and if in conflicts file: 'C'
|
2006-05-19 22:13:29 +02:00
|
|
|
x - - '?'
|
|
|
|
x - x 'D' and listed in _to_be_deleted
|
|
|
|
- x x '!'
|
|
|
|
- x - 'D' (when file in working copy is already deleted)
|
|
|
|
- - x 'F' (new in repo, but not yet in working copy)
|
|
|
|
- - - NOT DEFINED
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
known_by_meta = False
|
|
|
|
exists = False
|
|
|
|
exists_in_store = False
|
|
|
|
if n in self.filenamelist:
|
|
|
|
known_by_meta = True
|
|
|
|
if os.path.exists(os.path.join(self.dir, n)):
|
|
|
|
exists = True
|
|
|
|
if os.path.exists(os.path.join(self.storedir, n)):
|
|
|
|
exists_in_store = True
|
|
|
|
|
|
|
|
|
|
|
|
if exists and not exists_in_store and known_by_meta:
|
|
|
|
state = 'D'
|
|
|
|
elif n in self.to_be_deleted:
|
|
|
|
state = 'D'
|
2006-05-22 16:12:06 +02:00
|
|
|
elif n in self.in_conflict:
|
|
|
|
state = 'C'
|
2006-05-19 22:13:29 +02:00
|
|
|
elif exists and exists_in_store and known_by_meta:
|
|
|
|
#print self.findfilebyname(n)
|
|
|
|
if dgst(os.path.join(self.dir, n)) != self.findfilebyname(n).md5:
|
|
|
|
state = 'M'
|
|
|
|
else:
|
|
|
|
state = ' '
|
|
|
|
elif exists and not exists_in_store and not known_by_meta:
|
|
|
|
state = '?'
|
|
|
|
elif exists and exists_in_store and not known_by_meta:
|
|
|
|
state = 'A'
|
|
|
|
elif not exists and exists_in_store and known_by_meta:
|
|
|
|
state = '!'
|
|
|
|
elif not exists and not exists_in_store and known_by_meta:
|
|
|
|
state = 'F'
|
|
|
|
elif not exists and exists_in_store and not known_by_meta:
|
|
|
|
state = 'D'
|
|
|
|
elif not exists and not exists_in_store and not known_by_meta:
|
|
|
|
print '%s: not exists and not exists_in_store and not nown_by_meta' % n
|
|
|
|
print 'this code path should never be reached!'
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
return state
|
|
|
|
|
|
|
|
|
|
|
|
def merge(self, otherpac):
|
|
|
|
self.todo += otherpac.todo
|
|
|
|
|
|
|
|
def __str__(self):
|
|
|
|
r = """
|
|
|
|
name: %s
|
|
|
|
prjname: %s
|
|
|
|
workingdir: %s
|
|
|
|
localfilelist: %s
|
|
|
|
rev: %s
|
|
|
|
'todo' files: %s
|
|
|
|
""" % (self.name,
|
|
|
|
self.prjname,
|
|
|
|
self.dir,
|
|
|
|
'\n '.join(self.filenamelist),
|
|
|
|
self.rev,
|
|
|
|
self.todo)
|
|
|
|
|
|
|
|
return r
|
|
|
|
|
|
|
|
|
2006-05-31 14:13:26 +02:00
|
|
|
def read_meta_from_spec(self):
|
|
|
|
specfile = os.path.join(self.dir, self.name + '.spec')
|
|
|
|
name, summary, descr = read_meta_from_spec(specfile)
|
|
|
|
|
|
|
|
if name != self.name:
|
|
|
|
print 'name from spec does not match name of package... this is probably a problem'
|
|
|
|
sys.exit(1)
|
|
|
|
self.summary = summary
|
|
|
|
self.descr = descr
|
|
|
|
|
|
|
|
|
2006-08-07 12:08:54 +02:00
|
|
|
def update_pac_meta(self, template=new_package_templ):
|
2006-05-31 14:13:26 +02:00
|
|
|
import othermethods
|
|
|
|
import tempfile
|
|
|
|
|
2006-07-14 18:37:34 +02:00
|
|
|
(fd, filename) = tempfile.mkstemp(prefix = 'osc_editmeta.', suffix = '.xml', dir = '/tmp')
|
2006-05-31 14:13:26 +02:00
|
|
|
|
|
|
|
try:
|
2006-07-20 16:23:10 +02:00
|
|
|
u = makeurl(['source', self.prjname, self.name, '_meta'])
|
|
|
|
m = urllib2.urlopen(u).readlines()
|
2006-05-31 14:13:26 +02:00
|
|
|
except urllib2.HTTPError, e:
|
|
|
|
if e.code == 404:
|
|
|
|
print 'package does not exist yet... creating it'
|
2006-10-10 16:04:34 +02:00
|
|
|
m = template % (pac, conf.config['user'])
|
2006-05-31 14:13:26 +02:00
|
|
|
else:
|
|
|
|
print 'error getting package meta for project \'%s\' package \'%s\':' % (prj, pac)
|
|
|
|
print e
|
|
|
|
sys.exit(1)
|
|
|
|
|
2006-07-14 18:37:34 +02:00
|
|
|
f = os.fdopen(fd, 'w')
|
2006-05-31 14:13:26 +02:00
|
|
|
f.write(''.join(m))
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
tree = ET.parse(filename)
|
|
|
|
tree.find('title').text = self.summary
|
|
|
|
tree.find('description').text = ''.join(self.descr)
|
|
|
|
tree.write(filename)
|
|
|
|
|
|
|
|
# FIXME: escape stuff for xml
|
|
|
|
print '*' * 36, 'old', '*' * 36
|
|
|
|
print ''.join(m)
|
|
|
|
print '*' * 36, 'new', '*' * 36
|
|
|
|
tree.write(sys.stdout)
|
|
|
|
print '*' * 72
|
|
|
|
|
|
|
|
# FIXME: for testing...
|
|
|
|
# open the new description in $EDITOR instead?
|
|
|
|
repl = raw_input('Write? (y/N) ')
|
|
|
|
if repl == 'y':
|
|
|
|
print 'Sending meta data...',
|
|
|
|
u = makeurl(['source', self.prjname, self.name, '_meta'])
|
2006-10-10 16:04:34 +02:00
|
|
|
othermethods.putfile(u, conf.config['user'], conf.config['pass'], file=filename)
|
2006-05-31 14:13:26 +02:00
|
|
|
print 'Done.'
|
|
|
|
else:
|
|
|
|
print 'discarding', filename
|
|
|
|
|
|
|
|
os.unlink(filename)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-05-22 12:50:37 +02:00
|
|
|
def is_project_dir(d):
|
|
|
|
if os.path.exists(os.path.join(d, store, '_project')) and not \
|
|
|
|
os.path.exists(os.path.join(d, store, '_package')):
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
|
2006-09-29 15:15:41 +02:00
|
|
|
def is_package_dir(d):
|
|
|
|
if os.path.exists(os.path.join(d, store, '_project')) and \
|
|
|
|
os.path.exists(os.path.join(d, store, '_package')):
|
|
|
|
return True
|
|
|
|
else:
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
def findpacs(files):
|
|
|
|
pacs = []
|
|
|
|
for f in files:
|
|
|
|
p = filedir_to_pac(f)
|
|
|
|
known = None
|
|
|
|
for i in pacs:
|
|
|
|
if i.name == p.name:
|
|
|
|
known = i
|
|
|
|
break
|
|
|
|
if known:
|
|
|
|
i.merge(p)
|
|
|
|
else:
|
|
|
|
pacs.append(p)
|
|
|
|
return pacs
|
|
|
|
|
|
|
|
|
|
|
|
def read_filemeta(dir):
|
|
|
|
return ET.parse(os.path.join(dir, store, '_files'))
|
|
|
|
|
|
|
|
|
|
|
|
def read_tobedeleted(dir):
|
|
|
|
r = []
|
|
|
|
fname = os.path.join(dir, store, '_to_be_deleted')
|
|
|
|
|
|
|
|
if os.path.exists(fname):
|
2006-06-26 17:11:22 +02:00
|
|
|
r = [ line.strip() for line in open(fname) ]
|
2006-05-19 22:13:29 +02:00
|
|
|
|
|
|
|
return r
|
|
|
|
|
|
|
|
|
2006-05-22 16:12:06 +02:00
|
|
|
def read_inconflict(dir):
|
|
|
|
r = []
|
|
|
|
fname = os.path.join(dir, store, '_in_conflict')
|
|
|
|
|
|
|
|
if os.path.exists(fname):
|
2006-06-26 17:11:22 +02:00
|
|
|
r = [ line.strip() for line in open(fname) ]
|
2006-05-22 16:12:06 +02:00
|
|
|
|
|
|
|
return r
|
|
|
|
|
|
|
|
|
2006-05-23 15:48:58 +02:00
|
|
|
def parseargs(list_of_args):
|
|
|
|
if list_of_args:
|
|
|
|
return list_of_args
|
2006-05-11 09:27:50 +02:00
|
|
|
else:
|
2006-05-23 15:48:58 +02:00
|
|
|
return [ os.curdir ]
|
2006-05-11 09:27:50 +02:00
|
|
|
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
def filedir_to_pac(f):
|
|
|
|
|
|
|
|
if os.path.isdir(f):
|
|
|
|
wd = f
|
|
|
|
p = Package(wd)
|
|
|
|
|
|
|
|
elif os.path.isfile(f):
|
|
|
|
wd = os.path.dirname(f)
|
|
|
|
if wd == '':
|
|
|
|
wd = os.curdir
|
|
|
|
p = Package(wd)
|
|
|
|
p.todo = [ os.path.basename(f) ]
|
|
|
|
|
|
|
|
else:
|
|
|
|
wd = os.path.dirname(f)
|
|
|
|
if wd == '':
|
|
|
|
wd = os.curdir
|
|
|
|
p = Package(wd)
|
|
|
|
p.todo = [ os.path.basename(f) ]
|
|
|
|
|
|
|
|
|
|
|
|
#else:
|
|
|
|
# print
|
|
|
|
# print 'error: %s is neither a valid file or directory' % f
|
|
|
|
# sys.exit(1)
|
|
|
|
|
|
|
|
return p
|
|
|
|
|
|
|
|
|
|
|
|
def statfrmt(statusletter, filename):
|
|
|
|
return '%s %s' % (statusletter, filename)
|
|
|
|
|
|
|
|
|
2006-09-29 15:15:41 +02:00
|
|
|
def pathjoin(a, *p):
|
|
|
|
"""Join two or more pathname components, inserting '/' as needed. Cut leading ./"""
|
|
|
|
path = os.path.join(a, *p)
|
|
|
|
if path.startswith('./'):
|
|
|
|
path = path[2:]
|
|
|
|
return path
|
|
|
|
|
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
def makeurl(l):
|
|
|
|
"""given a list of path compoments, construct a complete URL"""
|
2006-10-10 16:04:34 +02:00
|
|
|
return urlunsplit((conf.config['scheme'], conf.config['apisrv'], '/'.join(l), '', ''))
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
2006-09-15 13:47:34 +02:00
|
|
|
def urlopen(url, data=None):
|
2006-07-12 16:14:50 +02:00
|
|
|
"""wrapper around urllib2.urlopen for error handling"""
|
|
|
|
|
|
|
|
try:
|
2006-09-15 13:47:34 +02:00
|
|
|
# adding data to the request makes it a POST
|
|
|
|
fd = urllib2.urlopen(url, data=data)
|
2006-07-12 16:14:50 +02:00
|
|
|
|
|
|
|
except urllib2.HTTPError, e:
|
|
|
|
print >>sys.stderr, 'Error: can\'t get \'%s\'' % url
|
|
|
|
print >>sys.stderr, e
|
2006-09-18 18:53:55 +02:00
|
|
|
if e.code == 500:
|
|
|
|
print >>sys.stderr, '\nDebugging output follows.\nurl:\n%s\nresponse:\n%s' % (url, e.read())
|
2006-07-12 16:14:50 +02:00
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
return fd
|
|
|
|
|
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
def init_package_dir(project, package, dir):
|
|
|
|
if not os.path.isdir(store):
|
|
|
|
os.mkdir(store)
|
|
|
|
os.chdir(store)
|
|
|
|
f = open('_project', 'w')
|
|
|
|
f.write(project + '\n')
|
|
|
|
f.close
|
|
|
|
f = open('_package', 'w')
|
|
|
|
f.write(package + '\n')
|
|
|
|
f.close
|
|
|
|
|
2006-04-28 17:37:25 +02:00
|
|
|
f = open('_files', 'w')
|
|
|
|
f.write(''.join(show_files_meta(project, package)))
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
f = open('_osclib_version', 'w')
|
|
|
|
f.write(__version__ + '\n')
|
2006-04-20 16:26:50 +02:00
|
|
|
f.close()
|
|
|
|
|
2006-05-22 10:16:31 +02:00
|
|
|
os.chdir(os.pardir)
|
2006-04-20 16:26:50 +02:00
|
|
|
return
|
|
|
|
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
def check_store_version(dir):
|
|
|
|
versionfile = os.path.join(dir, store, '_osclib_version')
|
2006-04-28 17:37:25 +02:00
|
|
|
try:
|
2006-05-19 22:13:29 +02:00
|
|
|
v = open(versionfile).read().strip()
|
2006-04-28 17:37:25 +02:00
|
|
|
except:
|
|
|
|
v = ''
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
if v == '':
|
|
|
|
print 'error: "%s" is not an osc working copy' % dir
|
|
|
|
sys.exit(1)
|
|
|
|
|
2006-04-28 17:37:25 +02:00
|
|
|
if v != __version__:
|
2006-10-12 15:30:33 +02:00
|
|
|
if v in ['0.2', '0.3', '0.4', '0.5', '0.6', '0.7', '0.8']:
|
2006-05-22 16:23:13 +02:00
|
|
|
# version is fine, no migration needed
|
2006-05-19 22:13:29 +02:00
|
|
|
f = open(versionfile, 'w')
|
|
|
|
f.write(__version__ + '\n')
|
|
|
|
f.close()
|
|
|
|
return
|
2006-04-28 17:37:25 +02:00
|
|
|
print
|
2006-05-19 22:13:29 +02:00
|
|
|
print 'the osc metadata of your working copy "%s"' % dir
|
2006-04-28 17:37:25 +02:00
|
|
|
print 'has the wrong version (%s), should be %s' % (v, __version__)
|
|
|
|
print 'please do a fresh checkout'
|
|
|
|
print
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
def meta_get_packagelist(prj):
|
|
|
|
|
2006-08-07 12:08:54 +02:00
|
|
|
u = makeurl(['source', prj])
|
2006-10-10 16:04:34 +02:00
|
|
|
f = urlopen(u)
|
|
|
|
root = ET.parse(f).getroot()
|
2006-08-07 12:08:54 +02:00
|
|
|
return [ node.get('name') for node in root.findall('entry') ]
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
def meta_get_filelist(prj, package):
|
|
|
|
|
2006-04-28 17:37:25 +02:00
|
|
|
u = makeurl(['source', prj, package])
|
2006-10-10 16:04:34 +02:00
|
|
|
f = urlopen(u)
|
2006-06-26 17:11:22 +02:00
|
|
|
root = ET.parse(f).getroot()
|
|
|
|
return [ node.get('name') for node in root ]
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
2006-10-10 16:04:34 +02:00
|
|
|
def meta_get_project_list():
|
2006-04-20 16:26:50 +02:00
|
|
|
u = makeurl(['source'])
|
2006-10-10 16:04:34 +02:00
|
|
|
f = urlopen(u)
|
|
|
|
root = ET.parse(f).getroot()
|
2006-06-26 17:11:22 +02:00
|
|
|
return sorted([ node.get('name') for node in root ])
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
def show_project_meta(prj):
|
2006-10-10 16:04:34 +02:00
|
|
|
url = makeurl(['source', prj, '_meta'])
|
|
|
|
f = urlopen(url)
|
2006-04-20 16:26:50 +02:00
|
|
|
return f.readlines()
|
|
|
|
|
|
|
|
|
|
|
|
def show_package_meta(prj, pac):
|
2006-07-05 14:09:09 +02:00
|
|
|
try:
|
2006-09-15 15:24:41 +02:00
|
|
|
url = makeurl(['source', prj, pac, '_meta'])
|
|
|
|
f = urllib2.urlopen(url)
|
2006-07-05 14:09:09 +02:00
|
|
|
except urllib2.HTTPError, e:
|
|
|
|
print >>sys.stderr, 'error getting meta for project \'%s\' package \'%s\'' % (prj, pac)
|
|
|
|
print >>sys.stderr, e
|
2006-09-15 15:24:41 +02:00
|
|
|
if e.code == 500:
|
|
|
|
print >>sys.stderr, '\nDebugging output follows.\nurl:\n%s\nresponse:\n%s' % (url, e.read())
|
2006-07-05 14:09:09 +02:00
|
|
|
sys.exit(1)
|
2006-04-20 16:26:50 +02:00
|
|
|
return f.readlines()
|
|
|
|
|
2007-01-12 04:52:13 +01:00
|
|
|
class metafile:
|
|
|
|
"""metafile that can be manipulated and is stored back after manipulation."""
|
|
|
|
def __init__(self, prj, pac, template=new_package_templ, change_is_required=True):
|
|
|
|
import othermethods
|
|
|
|
import tempfile
|
2006-05-19 22:13:29 +02:00
|
|
|
|
2007-01-12 04:52:13 +01:00
|
|
|
self.change_is_required = change_is_required
|
2006-05-23 17:27:43 +02:00
|
|
|
|
2007-01-12 04:52:13 +01:00
|
|
|
(fd, self.filename) = tempfile.mkstemp(prefix = 'osc_editmeta.', suffix = '.xml', dir = '/tmp')
|
2006-05-23 17:27:43 +02:00
|
|
|
|
2007-01-12 04:52:13 +01:00
|
|
|
|
|
|
|
if pac:
|
|
|
|
# package meta
|
|
|
|
self.url = makeurl(['source', prj, pac, '_meta'])
|
|
|
|
try:
|
|
|
|
m = urllib2.urlopen(self.url).readlines()
|
|
|
|
except urllib2.HTTPError, e:
|
|
|
|
if e.code == 404:
|
|
|
|
m = template % (pac, conf.config['user'])
|
|
|
|
else:
|
|
|
|
print 'error getting package meta for project \'%s\' package \'%s\':' % (prj, pac)
|
|
|
|
print e
|
|
|
|
sys.exit(1)
|
2006-05-23 17:27:43 +02:00
|
|
|
|
2007-01-12 04:52:13 +01:00
|
|
|
else:
|
|
|
|
# project meta
|
|
|
|
self.url = makeurl(['source', prj, '_meta'])
|
|
|
|
try:
|
|
|
|
m = urllib2.urlopen(self.url).readlines()
|
|
|
|
# when testing this offline:
|
|
|
|
#except urllib2.URLError, e:
|
|
|
|
# m = new_project_templ % (prj, conf.config['user'])
|
|
|
|
except urllib2.HTTPError, e:
|
|
|
|
if e.code == 404:
|
|
|
|
m = new_project_templ % (prj, conf.config['user'])
|
|
|
|
else:
|
|
|
|
print 'error getting package meta for project \'%s\':' % prj
|
|
|
|
print e
|
|
|
|
sys.exit(1)
|
2006-05-23 17:27:43 +02:00
|
|
|
|
2007-01-12 04:52:13 +01:00
|
|
|
f = os.fdopen(fd, 'w')
|
|
|
|
f.write(''.join(m))
|
|
|
|
f.close()
|
2006-05-23 17:27:43 +02:00
|
|
|
|
2007-01-12 04:52:13 +01:00
|
|
|
self.timestamp = os.path.getmtime(self.filename)
|
2006-05-23 17:27:43 +02:00
|
|
|
|
2007-01-12 04:52:13 +01:00
|
|
|
def sync(self):
|
|
|
|
import othermethods
|
|
|
|
if self.change_is_required == True and os.path.getmtime(self.filename) == self.timestamp:
|
|
|
|
print 'File unchanged. Not saving.'
|
|
|
|
os.unlink(self.filename)
|
2006-05-23 17:27:43 +02:00
|
|
|
|
2007-01-12 04:52:13 +01:00
|
|
|
else:
|
|
|
|
print 'Sending meta data...',
|
|
|
|
othermethods.putfile(self.url, conf.config['user'], conf.config['pass'], file=self.filename)
|
|
|
|
os.unlink(self.filename)
|
|
|
|
print 'Done.'
|
|
|
|
|
|
|
|
def edit_meta(prj, pac, template=new_package_templ, change_is_required=True):
|
|
|
|
f=metafile(prj, pac, template, change_is_required)
|
2006-05-23 17:27:43 +02:00
|
|
|
|
2007-01-12 04:52:13 +01:00
|
|
|
editor = os.getenv('EDITOR', default='vim')
|
|
|
|
os.system('%s %s' % (editor, f.filename))
|
2006-05-23 17:27:43 +02:00
|
|
|
|
2007-01-12 04:52:13 +01:00
|
|
|
if change_is_required == True:
|
|
|
|
f.sync()
|
2006-05-23 17:27:43 +02:00
|
|
|
|
2006-10-12 15:22:56 +02:00
|
|
|
def edit_user_meta(user, change_is_required=True):
|
|
|
|
import othermethods
|
|
|
|
import tempfile
|
|
|
|
|
|
|
|
u = makeurl(['person', quote_plus(user)])
|
|
|
|
|
|
|
|
try:
|
|
|
|
m = urllib2.urlopen(u).readlines()
|
|
|
|
except urllib2.HTTPError, e:
|
|
|
|
if e.code == 404:
|
|
|
|
m = new_user_template % { 'user': user }
|
|
|
|
else:
|
|
|
|
print 'error getting metadata for user \'%s\':' % user
|
|
|
|
print e
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
(fd, filename) = tempfile.mkstemp(prefix = 'osc_edituser.', suffix = '.xml', dir = '/tmp')
|
|
|
|
f = os.fdopen(fd, 'w')
|
|
|
|
f.write(''.join(m))
|
|
|
|
f.close()
|
|
|
|
timestamp = os.path.getmtime(filename)
|
|
|
|
|
|
|
|
editor = os.getenv('EDITOR', default='vim')
|
|
|
|
os.system('%s %s' % (editor, filename))
|
|
|
|
|
|
|
|
if change_is_required == True and os.path.getmtime(filename) == timestamp:
|
|
|
|
print 'File unchanged. Not saving.'
|
|
|
|
os.unlink(filename)
|
|
|
|
|
|
|
|
else:
|
|
|
|
print 'Sending meta data...',
|
|
|
|
othermethods.putfile(u, conf.config['user'], conf.config['pass'], file=filename)
|
|
|
|
os.unlink(filename)
|
|
|
|
print 'Done.'
|
|
|
|
|
|
|
|
|
2006-04-28 17:37:25 +02:00
|
|
|
def show_files_meta(prj, pac):
|
2006-07-12 16:14:50 +02:00
|
|
|
f = urlopen(makeurl(['source', prj, pac]))
|
2006-04-28 17:37:25 +02:00
|
|
|
return f.readlines()
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
|
2006-06-06 12:50:40 +02:00
|
|
|
def show_upstream_rev(prj, pac):
|
|
|
|
m = show_files_meta(prj, pac)
|
|
|
|
return ET.parse(StringIO(''.join(m))).getroot().get('rev')
|
|
|
|
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
def read_meta_from_spec(specfile):
|
|
|
|
"""read Name, Summary and %description from spec file"""
|
|
|
|
|
|
|
|
if not os.path.isfile(specfile):
|
|
|
|
print 'file \'%s\' is not a readable file' % specfile
|
|
|
|
return None
|
|
|
|
|
2006-06-26 17:11:22 +02:00
|
|
|
lines = open(specfile).readlines()
|
|
|
|
|
|
|
|
for line in lines:
|
2006-05-19 22:13:29 +02:00
|
|
|
if line.startswith('Name:'):
|
|
|
|
name = line.split(':')[1].strip()
|
2006-06-26 17:11:22 +02:00
|
|
|
break
|
|
|
|
|
|
|
|
for line in lines:
|
2006-05-19 22:13:29 +02:00
|
|
|
if line.startswith('Summary:'):
|
|
|
|
summary = line.split(':')[1].strip()
|
|
|
|
break
|
2006-06-26 17:11:22 +02:00
|
|
|
|
|
|
|
descr = []
|
|
|
|
start = lines.index('%description\n') + 1
|
|
|
|
for line in lines[start:]:
|
|
|
|
if line.startswith('%'):
|
|
|
|
break
|
|
|
|
descr.append(line)
|
2006-05-19 22:13:29 +02:00
|
|
|
|
|
|
|
return name, summary, descr
|
|
|
|
|
|
|
|
|
2006-10-12 15:22:56 +02:00
|
|
|
def get_user_meta(user):
|
2006-06-30 01:34:06 +02:00
|
|
|
u = makeurl(['person', quote_plus(user)])
|
2006-05-22 16:57:11 +02:00
|
|
|
try:
|
|
|
|
f = urllib2.urlopen(u)
|
|
|
|
return ''.join(f.readlines())
|
|
|
|
except urllib2.HTTPError:
|
|
|
|
print 'user \'%s\' not found' % user
|
|
|
|
return None
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
def get_source_file(prj, package, filename, targetfilename=None):
|
2006-06-30 01:34:06 +02:00
|
|
|
u = makeurl(['source', prj, package, pathname2url(filename)])
|
2006-07-12 16:14:50 +02:00
|
|
|
f = urlopen(u)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
o = open(targetfilename or filename, 'w')
|
2006-04-20 16:26:50 +02:00
|
|
|
while 1:
|
|
|
|
buf = f.read(BUFSIZE)
|
|
|
|
if not buf: break
|
|
|
|
o.write(buf)
|
|
|
|
o.close()
|
|
|
|
|
|
|
|
|
|
|
|
def dgst(file):
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
#if not os.path.exists(file):
|
|
|
|
#return None
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
import md5
|
|
|
|
s = md5.new()
|
2006-04-20 16:26:50 +02:00
|
|
|
f = open(file, 'r')
|
|
|
|
while 1:
|
|
|
|
buf = f.read(BUFSIZE)
|
|
|
|
if not buf: break
|
|
|
|
s.update(buf)
|
2006-05-19 22:13:29 +02:00
|
|
|
return s.hexdigest()
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
2006-06-08 12:30:29 +02:00
|
|
|
def binary(s):
|
|
|
|
"""return true if a string is binary data using diff's heuristic"""
|
|
|
|
if s and '\0' in s[:4096]:
|
|
|
|
return True
|
|
|
|
return False
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
2006-06-22 14:54:58 +02:00
|
|
|
def binary_file(fn):
|
|
|
|
"""read 4096 bytes from a file named fn, and call binary() on the data"""
|
|
|
|
return binary(open(fn, 'r').read(4096))
|
|
|
|
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
def get_source_file_diff(dir, filename, rev):
|
|
|
|
import difflib
|
|
|
|
|
2006-05-19 22:28:04 +02:00
|
|
|
file1 = os.path.join(dir, store, filename) # stored original
|
|
|
|
file2 = os.path.join(dir, filename) # working copy
|
2006-05-19 22:13:29 +02:00
|
|
|
|
|
|
|
f1 = open(file1, 'r')
|
2006-06-08 12:30:29 +02:00
|
|
|
s1 = f1.read()
|
2006-06-22 14:54:58 +02:00
|
|
|
f1.close()
|
|
|
|
|
|
|
|
f2 = open(file2, 'r')
|
2006-06-08 12:30:29 +02:00
|
|
|
s2 = f2.read()
|
2006-06-22 14:54:58 +02:00
|
|
|
f2.close()
|
2006-06-08 12:30:29 +02:00
|
|
|
|
|
|
|
if binary(s1) or binary (s2):
|
|
|
|
d = ['Binary file %s has changed\n' % filename]
|
|
|
|
|
|
|
|
else:
|
|
|
|
d = difflib.unified_diff(\
|
|
|
|
s1.splitlines(1), \
|
|
|
|
s2.splitlines(1), \
|
|
|
|
fromfile = '%s (revision %s)' % (filename, rev), \
|
|
|
|
tofile = '%s (working copy)' % filename)
|
2006-05-19 22:13:29 +02:00
|
|
|
|
|
|
|
return ''.join(d)
|
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
def make_dir(project, package):
|
|
|
|
#print "creating directory '%s'" % project
|
|
|
|
if not os.path.exists(project):
|
2006-05-22 10:16:31 +02:00
|
|
|
print statfrmt('A', project)
|
2006-04-20 16:26:50 +02:00
|
|
|
os.mkdir(project)
|
|
|
|
os.mkdir(os.path.join(project, store))
|
|
|
|
|
2006-05-19 22:13:29 +02:00
|
|
|
f = open(os.path.join(project, store, '_project'), 'w')
|
|
|
|
f.write(project + '\n')
|
|
|
|
f.close()
|
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
#print "creating directory '%s/%s'" % (project, package)
|
|
|
|
if not os.path.exists(os.path.join(project, package)):
|
2006-05-22 10:16:31 +02:00
|
|
|
print statfrmt('A', '%s/%s' % (project, package))
|
2006-04-20 16:26:50 +02:00
|
|
|
os.mkdir(os.path.join(project, package))
|
|
|
|
os.mkdir(os.path.join(project, package, store))
|
|
|
|
|
|
|
|
return(os.path.join(project, package))
|
|
|
|
|
|
|
|
|
|
|
|
def checkout_package(project, package):
|
|
|
|
olddir = os.getcwd()
|
|
|
|
|
|
|
|
os.chdir(make_dir(project, package))
|
|
|
|
init_package_dir(project, package, store)
|
2006-05-22 10:16:31 +02:00
|
|
|
p = Package(os.curdir)
|
|
|
|
|
|
|
|
for filename in p.filenamelist:
|
|
|
|
p.updatefile(filename)
|
|
|
|
print 'A ', os.path.join(project, package, filename)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
os.chdir(olddir)
|
|
|
|
|
|
|
|
|
2006-08-07 12:08:54 +02:00
|
|
|
def link_pac(src_project, src_package, dst_project, dst_package):
|
|
|
|
"""
|
|
|
|
create a linked package
|
|
|
|
- "src" is the original package
|
|
|
|
- "dst" is the "link" package that we are creating here
|
|
|
|
"""
|
|
|
|
|
|
|
|
import othermethods
|
|
|
|
import tempfile
|
|
|
|
|
|
|
|
|
|
|
|
src_meta = show_package_meta(src_project, src_package)
|
|
|
|
|
|
|
|
# replace package name and username
|
|
|
|
# using a string buffer
|
|
|
|
# and create the package
|
|
|
|
tree = ET.parse(StringIO(''.join(src_meta)))
|
|
|
|
root = tree.getroot()
|
|
|
|
root.set('name', '%s')
|
|
|
|
tree.find('person').set('userid', '%s')
|
|
|
|
buf = StringIO()
|
|
|
|
tree.write(buf)
|
|
|
|
src_meta = buf.getvalue()
|
|
|
|
|
|
|
|
|
|
|
|
edit_meta(dst_project, dst_package, template=src_meta, change_is_required=False)
|
|
|
|
|
|
|
|
# create the _link file
|
|
|
|
# but first, make sure not to overwrite an existing one
|
|
|
|
if '_link' in meta_get_filelist(dst_project, dst_package):
|
|
|
|
print
|
|
|
|
print '_link file already exists...! Aborting'
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
print 'Creating _link...',
|
|
|
|
link_template = """\
|
|
|
|
<link project="%s" package="%s">
|
|
|
|
<patches>
|
|
|
|
<!-- <apply name="patch" /> -->
|
|
|
|
<!-- <topadd>%%define build_with_feature_x 1</topadd> -->
|
|
|
|
</patches>
|
|
|
|
</link>
|
|
|
|
""" % (src_project, src_package)
|
|
|
|
|
|
|
|
u = makeurl(['source', dst_project, dst_package, '_link'])
|
2006-10-10 16:04:34 +02:00
|
|
|
othermethods.putfile(u, conf.config['user'], conf.config['pass'], strbuf = link_template)
|
2006-08-07 12:08:54 +02:00
|
|
|
print 'Done.'
|
|
|
|
|
|
|
|
|
2006-09-21 16:33:24 +02:00
|
|
|
def copy_pac(src_project, src_package, dst_project, dst_package):
|
|
|
|
"""
|
|
|
|
create a copy of a package
|
|
|
|
"""
|
|
|
|
|
|
|
|
import othermethods
|
|
|
|
import tempfile
|
|
|
|
|
|
|
|
src_meta = show_package_meta(src_project, src_package)
|
|
|
|
|
|
|
|
# replace project and package name
|
|
|
|
# using a string buffer
|
|
|
|
# and create the package
|
|
|
|
tree = ET.parse(StringIO(''.join(src_meta)))
|
|
|
|
root = tree.getroot()
|
|
|
|
root.set('name', dst_package)
|
|
|
|
root.set('project', dst_project)
|
|
|
|
buf = StringIO()
|
|
|
|
tree.write(buf)
|
|
|
|
src_meta = buf.getvalue()
|
|
|
|
|
|
|
|
print 'Sending meta data...'
|
|
|
|
u = makeurl(['source', dst_project, dst_package, '_meta'])
|
2006-10-10 16:04:34 +02:00
|
|
|
othermethods.putfile(u, conf.config['user'], conf.config['pass'], strbuf=src_meta)
|
2006-09-21 16:33:24 +02:00
|
|
|
|
|
|
|
# copy one file after the other
|
|
|
|
print 'Copying files...'
|
|
|
|
tmpdir = tempfile.mkdtemp(prefix='osc_copypac', dir = '/tmp')
|
|
|
|
os.chdir(tmpdir)
|
|
|
|
for n in meta_get_filelist(src_project, src_package):
|
|
|
|
print ' ', n
|
|
|
|
get_source_file(src_project, src_package, n, targetfilename=n)
|
|
|
|
u = makeurl(['source', dst_project, dst_package, pathname2url(n)])
|
2006-10-10 16:04:34 +02:00
|
|
|
othermethods.putfile(u, conf.config['user'], conf.config['pass'], file = n)
|
2006-09-21 16:33:24 +02:00
|
|
|
os.unlink(n)
|
|
|
|
print 'Done.'
|
|
|
|
os.rmdir(tmpdir)
|
|
|
|
|
|
|
|
|
2006-08-11 12:37:29 +02:00
|
|
|
def delete_package(prj, pac):
|
|
|
|
import othermethods
|
|
|
|
|
|
|
|
u = makeurl(['source', prj, pac])
|
2006-10-12 15:22:56 +02:00
|
|
|
othermethods.delfile(u, pac, conf.config['user'], conf.config['pass'])
|
2006-08-11 12:37:29 +02:00
|
|
|
|
|
|
|
|
2006-09-25 17:11:03 +02:00
|
|
|
def delete_project(prj):
|
|
|
|
import othermethods
|
|
|
|
|
|
|
|
u = makeurl(['source', prj])
|
2006-10-12 15:22:56 +02:00
|
|
|
othermethods.delfile(u, prj, conf.config['user'], conf.config['pass'])
|
2006-09-25 17:11:03 +02:00
|
|
|
|
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
def get_platforms():
|
2006-07-12 16:14:50 +02:00
|
|
|
f = urlopen(makeurl(['platform']))
|
2006-05-02 10:17:45 +02:00
|
|
|
tree = ET.parse(f)
|
2006-06-26 17:11:22 +02:00
|
|
|
r = [ node.get('name') for node in tree.getroot() ]
|
2006-05-02 10:17:45 +02:00
|
|
|
r.sort()
|
2006-04-20 16:26:50 +02:00
|
|
|
return r
|
|
|
|
|
2006-05-02 10:17:45 +02:00
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
def get_platforms_of_project(prj):
|
|
|
|
f = show_project_meta(prj)
|
2006-05-02 10:17:45 +02:00
|
|
|
tree = ET.parse(StringIO(''.join(f)))
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-06-26 17:11:22 +02:00
|
|
|
r = [ node.get('name') for node in tree.findall('repository')]
|
2006-04-20 16:26:50 +02:00
|
|
|
return r
|
|
|
|
|
2006-05-02 10:17:45 +02:00
|
|
|
|
2006-07-05 12:25:31 +02:00
|
|
|
def get_repos_of_project(prj):
|
|
|
|
f = show_project_meta(prj)
|
|
|
|
tree = ET.parse(StringIO(''.join(f)))
|
|
|
|
|
|
|
|
repo_line_templ = '%-15s %-10s'
|
|
|
|
r = []
|
|
|
|
for node in tree.findall('repository'):
|
|
|
|
for node2 in node.findall('arch'):
|
|
|
|
r.append(repo_line_templ % (node.get('name'), node2.text))
|
|
|
|
return r
|
|
|
|
|
|
|
|
|
2007-03-13 00:21:34 +01:00
|
|
|
def show_results_meta(prj, package):
|
2007-03-13 01:17:28 +01:00
|
|
|
u = makeurl(['build', prj, '_result?package=%s' % package])
|
2006-07-12 16:14:50 +02:00
|
|
|
f = urlopen(u)
|
2006-04-20 16:26:50 +02:00
|
|
|
return f.readlines()
|
|
|
|
|
2006-05-02 10:17:45 +02:00
|
|
|
|
2006-09-25 17:11:03 +02:00
|
|
|
def show_prj_results_meta(prj):
|
2007-03-13 01:17:28 +01:00
|
|
|
u = makeurl(['build', prj, '_result'])
|
2006-09-25 17:11:03 +02:00
|
|
|
f = urlopen(u)
|
|
|
|
return f.readlines()
|
|
|
|
|
|
|
|
|
2007-03-13 00:21:34 +01:00
|
|
|
def get_results(prj, package):
|
2006-04-29 22:44:09 +02:00
|
|
|
r = []
|
2006-05-11 09:27:50 +02:00
|
|
|
result_line_templ = '%(rep)-15s %(arch)-10s %(status)s'
|
2006-04-29 22:44:09 +02:00
|
|
|
|
2007-03-13 00:21:34 +01:00
|
|
|
f = show_results_meta(prj, package)
|
2006-05-02 10:17:45 +02:00
|
|
|
tree = ET.parse(StringIO(''.join(f)))
|
|
|
|
root = tree.getroot()
|
|
|
|
|
2007-03-13 00:21:34 +01:00
|
|
|
for node in root.findall('result'):
|
|
|
|
rmap = {}
|
|
|
|
rmap['prj'] = prj
|
|
|
|
rmap['pac'] = package
|
|
|
|
rmap['rep'] = node.get('repository')
|
2006-05-02 10:17:45 +02:00
|
|
|
rmap['arch'] = node.get('arch')
|
|
|
|
|
|
|
|
statusnode = node.find('status')
|
|
|
|
rmap['status'] = statusnode.get('code')
|
|
|
|
|
2006-06-01 11:05:47 +02:00
|
|
|
if rmap['status'] in ['expansion error', 'broken']:
|
2007-03-13 00:21:34 +01:00
|
|
|
rmap['status'] += ': ' + statusnode.find('details').text
|
2006-05-02 10:17:45 +02:00
|
|
|
|
|
|
|
if rmap['status'] == 'failed':
|
2006-10-10 16:04:34 +02:00
|
|
|
rmap['status'] += ': %s://%s' % (conf.config['scheme'], conf.config['apisrv']) + \
|
2006-05-11 09:27:50 +02:00
|
|
|
'/result/%(prj)s/%(rep)s/%(pac)s/%(arch)s/log' % rmap
|
2006-04-29 22:44:09 +02:00
|
|
|
|
|
|
|
r.append(result_line_templ % rmap)
|
|
|
|
return r
|
|
|
|
|
2006-09-25 17:11:03 +02:00
|
|
|
def get_prj_results(prj):
|
|
|
|
#print '----------------------------------------'
|
|
|
|
|
|
|
|
r = []
|
|
|
|
#result_line_templ = '%(prj)-15s %(pac)-15s %(rep)-15s %(arch)-10s %(status)s'
|
|
|
|
result_line_templ = '%(rep)-15s %(arch)-10s %(status)s'
|
|
|
|
|
|
|
|
f = show_prj_results_meta(prj)
|
|
|
|
tree = ET.parse(StringIO(''.join(f)))
|
|
|
|
root = tree.getroot()
|
|
|
|
|
|
|
|
pacs = []
|
2007-03-13 01:17:28 +01:00
|
|
|
for node in root.find('result'):
|
|
|
|
pacs.append(node.get('package'))
|
2006-09-25 17:11:03 +02:00
|
|
|
|
2006-09-29 11:55:27 +02:00
|
|
|
|
|
|
|
max_pacs = 40
|
|
|
|
for startpac in range(0, len(pacs), max_pacs):
|
|
|
|
offset = 0
|
|
|
|
for pac in pacs[startpac:startpac+max_pacs]:
|
|
|
|
r.append(' |' * offset + ' ' + pac)
|
|
|
|
offset += 1
|
|
|
|
|
|
|
|
target = {}
|
2007-03-13 01:17:28 +01:00
|
|
|
for node in root.findall('result'):
|
2006-09-29 11:55:27 +02:00
|
|
|
target['repo'] = node.get('repository')
|
|
|
|
target['arch'] = node.get('arch')
|
|
|
|
|
|
|
|
status = {}
|
2007-03-13 01:17:28 +01:00
|
|
|
for pacnode in node.findall('status'):
|
2006-09-29 11:55:27 +02:00
|
|
|
try:
|
2007-03-13 01:17:28 +01:00
|
|
|
status[pacnode.get('package')] = buildstatus_symbols[pacnode.get('code')]
|
2006-09-29 11:55:27 +02:00
|
|
|
except:
|
2007-03-13 01:17:28 +01:00
|
|
|
print 'osc: warn: unknown status \'%s\'...' % pacnode.get('code')
|
2006-09-29 11:55:27 +02:00
|
|
|
print 'please edit osc/core.py, and extend the buildstatus_symbols dictionary.'
|
2007-03-13 01:17:28 +01:00
|
|
|
status[pacnode.get('package')] = '?'
|
2006-09-29 11:55:27 +02:00
|
|
|
|
|
|
|
line = []
|
2006-09-25 17:11:03 +02:00
|
|
|
line.append(' ')
|
2006-09-29 11:55:27 +02:00
|
|
|
for pac in pacs[startpac:startpac+max_pacs]:
|
|
|
|
line.append(status[pac])
|
|
|
|
line.append(' ')
|
|
|
|
line.append(' %s %s' % (target['repo'], target['arch']))
|
|
|
|
line = ''.join(line)
|
|
|
|
|
|
|
|
r.append(line)
|
2006-09-25 17:11:03 +02:00
|
|
|
|
2006-09-29 11:55:27 +02:00
|
|
|
r.append('')
|
2006-09-25 17:11:03 +02:00
|
|
|
|
|
|
|
r.append(' Legend:')
|
|
|
|
for i, j in buildstatus_symbols.items():
|
|
|
|
r.append(' %s %s' % (j, i))
|
|
|
|
|
|
|
|
return r
|
|
|
|
|
|
|
|
|
2006-06-16 14:40:26 +02:00
|
|
|
def get_log(prj, package, platform, arch, offset):
|
|
|
|
u = makeurl(['result', prj, platform, package, arch, 'log?nostream=1&start=%s' % offset])
|
2006-07-12 16:14:50 +02:00
|
|
|
f = urlopen(u)
|
2006-06-16 14:40:26 +02:00
|
|
|
return f.read()
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-05-02 10:17:45 +02:00
|
|
|
|
2006-09-15 13:47:34 +02:00
|
|
|
def get_buildinfo(prj, package, platform, arch, specfile=None):
|
2006-07-05 12:25:31 +02:00
|
|
|
# http://api.opensuse.org/rpm/Subversion/Apache_SuSE_Linux_10.1/i586/subversion/buildinfo
|
|
|
|
u = makeurl(['rpm', prj, platform, arch, package, 'buildinfo'])
|
2006-09-15 13:47:34 +02:00
|
|
|
f = urlopen(u, data=specfile)
|
2006-07-05 12:25:31 +02:00
|
|
|
return f.read()
|
|
|
|
|
|
|
|
|
|
|
|
def get_buildconfig(prj, package, platform, arch):
|
|
|
|
# http://api.opensuse.org/rpm/<proj>/<repo>/_repository/<arch>/_buildconfig
|
|
|
|
u = makeurl(['rpm', prj, platform, '_repository', arch, '_buildconfig'])
|
2006-07-12 16:14:50 +02:00
|
|
|
f = urlopen(u)
|
2006-07-05 12:25:31 +02:00
|
|
|
return f.read()
|
|
|
|
|
|
|
|
|
2006-08-10 18:39:13 +02:00
|
|
|
def get_buildhistory(prj, package, platform, arch):
|
2006-09-25 17:11:03 +02:00
|
|
|
import time
|
|
|
|
|
2006-08-10 18:39:13 +02:00
|
|
|
u = makeurl(['rpm', prj, platform, arch, package, 'history'])
|
2006-07-12 16:14:50 +02:00
|
|
|
f = urlopen(u)
|
2006-09-25 17:11:03 +02:00
|
|
|
root = ET.parse(f).getroot()
|
|
|
|
|
|
|
|
r = []
|
|
|
|
for node in root.findall('entry'):
|
|
|
|
rev = int(node.get('rev'))
|
|
|
|
srcmd5 = node.get('srcmd5')
|
|
|
|
versrel = node.get('versrel')
|
|
|
|
bcnt = int(node.get('bcnt'))
|
2006-10-10 16:04:34 +02:00
|
|
|
t = time.localtime(int(node.get('time')))
|
2006-09-25 17:11:03 +02:00
|
|
|
t = time.strftime('%Y-%m-%d %H:%M:%S', t)
|
|
|
|
|
|
|
|
r.append('%s %s %6d %2d %s' % (t, srcmd5, rev, bcnt, versrel))
|
|
|
|
|
|
|
|
r.insert(0, 'time srcmd5 rev bcnt vers-rel')
|
|
|
|
|
|
|
|
return r
|
2006-05-19 22:13:29 +02:00
|
|
|
|
|
|
|
|
2006-09-25 17:11:03 +02:00
|
|
|
def cmd_rebuild(prj, package, repo, arch):
|
|
|
|
cmd = '?cmd=rebuild'
|
|
|
|
if repo:
|
|
|
|
cmd += '&repo=%s' % repo
|
|
|
|
if arch:
|
|
|
|
cmd += '&arch=%s' % arch
|
|
|
|
u = makeurl(['source', prj, package, cmd])
|
2006-06-26 17:11:22 +02:00
|
|
|
try:
|
|
|
|
# adding data to the request makes it a POST
|
2006-10-10 16:04:34 +02:00
|
|
|
f = urllib2.urlopen(u, data='')
|
2006-06-26 17:11:22 +02:00
|
|
|
except urllib2.HTTPError, e:
|
|
|
|
print >>sys.stderr, 'could not trigger rebuild for project \'%s\' package \'%s\'' % (prj, package)
|
|
|
|
print >>sys.stderr, u
|
|
|
|
print >>sys.stderr, e
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
root = ET.parse(f).getroot()
|
|
|
|
#code = root.get('code')
|
|
|
|
return root.find('summary').text
|
2006-06-08 12:30:29 +02:00
|
|
|
|
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
def store_read_project(dir):
|
|
|
|
p = open(os.path.join(dir, store, '_project')).readlines()[0].strip()
|
|
|
|
return p
|
|
|
|
|
2006-05-02 10:17:45 +02:00
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
def store_read_package(dir):
|
|
|
|
p = open(os.path.join(dir, store, '_package')).readlines()[0].strip()
|
|
|
|
return p
|
|
|
|
|
2006-08-11 12:37:29 +02:00
|
|
|
|
2006-05-23 10:43:04 +02:00
|
|
|
def get_osc_version():
|
|
|
|
return __version__
|
2006-04-20 16:26:50 +02:00
|
|
|
|