2006-04-20 16:26:50 +02:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
|
|
|
# Copyright (C) 2006 Peter Poeml. 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.
|
|
|
|
|
2006-05-10 16:34:59 +02:00
|
|
|
from core import *
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
|
|
|
cmd = sys.argv[1]
|
|
|
|
project = package = filename = None
|
|
|
|
# try:
|
|
|
|
# project = sys.argv[2]
|
|
|
|
# package = sys.argv[3]
|
|
|
|
# filename = sys.argv[4]
|
|
|
|
# except:
|
|
|
|
# pass
|
|
|
|
|
|
|
|
if cmd == 'init':
|
|
|
|
project = sys.argv[2]
|
|
|
|
package = sys.argv[3]
|
|
|
|
init_package_dir(project, package, os.path.curdir)
|
|
|
|
print 'Initializing %s (Project: %s, Package: %s)' % (os.curdir, project, package)
|
|
|
|
|
|
|
|
elif cmd == 'ls':
|
|
|
|
if len(sys.argv) == 2:
|
|
|
|
print '\n'.join(get_slash_source())
|
|
|
|
if len(sys.argv) == 3:
|
|
|
|
project = sys.argv[2]
|
|
|
|
print '\n'.join(meta_get_packagelist(project))
|
|
|
|
if len(sys.argv) == 4:
|
|
|
|
project = sys.argv[2]
|
|
|
|
package = sys.argv[3]
|
|
|
|
print '\n'.join(meta_get_filelist(project, package))
|
|
|
|
|
|
|
|
elif cmd == 'meta':
|
|
|
|
if len(sys.argv) == 4:
|
|
|
|
project = sys.argv[2]
|
|
|
|
package = sys.argv[3]
|
|
|
|
print ''.join(show_package_meta(project, package))
|
2006-04-28 17:37:25 +02:00
|
|
|
print ''.join(show_files_meta(project, package))
|
2006-04-20 16:26:50 +02:00
|
|
|
elif len(sys.argv) == 3:
|
|
|
|
project = sys.argv[2]
|
|
|
|
print ''.join(show_project_meta(project))
|
|
|
|
|
|
|
|
elif cmd == 'diff':
|
|
|
|
wd = os.curdir
|
|
|
|
package = store_read_package(wd)
|
|
|
|
project = store_read_project(wd)
|
|
|
|
if len(sys.argv) > 2:
|
|
|
|
filename = sys.argv[2]
|
|
|
|
if filename:
|
|
|
|
print get_source_file_diff(project, package, filename)
|
|
|
|
else:
|
|
|
|
d = []
|
|
|
|
for filename in meta_get_filelist(project, package):
|
|
|
|
d.append(get_source_file_diff(project, package, filename))
|
|
|
|
print ''.join(d)
|
|
|
|
|
|
|
|
|
2006-05-11 09:27:50 +02:00
|
|
|
elif cmd == 'co' or cmd == 'checkout':
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
try:
|
|
|
|
project = sys.argv[2]
|
|
|
|
package = sys.argv[3]
|
|
|
|
filename = sys.argv[4]
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
|
|
|
|
if filename:
|
|
|
|
get_source_file(project, package, filename)
|
|
|
|
|
|
|
|
elif package:
|
|
|
|
checkout_package(project, package)
|
|
|
|
|
|
|
|
else:
|
|
|
|
# all packages
|
|
|
|
for package in meta_get_packagelist(project):
|
|
|
|
checkout_package(project, package)
|
|
|
|
|
|
|
|
|
|
|
|
elif cmd == 'st' or cmd == 'status':
|
|
|
|
|
2006-05-11 09:27:50 +02:00
|
|
|
args = parseargs()
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
for arg in args:
|
|
|
|
|
|
|
|
if os.path.isfile(arg):
|
|
|
|
wd = os.path.dirname(arg)
|
|
|
|
filenames = [ os.path.basename(arg) ]
|
|
|
|
elif os.path.isdir(arg):
|
|
|
|
wd = arg
|
|
|
|
package = store_read_package(wd)
|
|
|
|
project = store_read_project(wd)
|
|
|
|
filenames = meta_get_filelist(project, package)
|
|
|
|
|
|
|
|
# add files which are not listed in _meta
|
|
|
|
for i in os.listdir(arg):
|
|
|
|
if i not in filenames and i not in exclude_stuff:
|
|
|
|
filenames.insert(0, i)
|
|
|
|
|
|
|
|
os.chdir(wd)
|
2006-04-28 17:37:25 +02:00
|
|
|
check_store_version()
|
2006-04-20 16:26:50 +02:00
|
|
|
|
2006-04-24 14:04:20 +02:00
|
|
|
filelist = localmeta_get_filelist()
|
2006-04-20 16:26:50 +02:00
|
|
|
for filename in filenames:
|
2006-04-24 14:04:20 +02:00
|
|
|
s = get_file_status(project, package, filename, filelist=filelist)
|
2006-05-11 13:26:53 +02:00
|
|
|
if not s.startswith(' '):
|
|
|
|
print s
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
elif cmd == 'add':
|
2006-05-11 09:27:50 +02:00
|
|
|
if len(sys.argv) < 3:
|
|
|
|
print '%s requires at least one argument' % cmd
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
filenames = parseargs()
|
|
|
|
|
2006-04-27 15:35:43 +02:00
|
|
|
for filename in filenames:
|
|
|
|
if not os.path.exists(filename):
|
|
|
|
print "file '%s' does not exist" % filename
|
|
|
|
sys.exit(1)
|
2006-04-20 16:26:50 +02:00
|
|
|
for filename in filenames:
|
|
|
|
localmeta_addfile(filename)
|
|
|
|
print 'A ', filename
|
|
|
|
|
|
|
|
elif cmd == 'addremove':
|
2006-05-11 09:27:50 +02:00
|
|
|
args = parseargs()
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
for arg in args:
|
|
|
|
|
|
|
|
if os.path.isfile(arg):
|
|
|
|
wd = os.path.dirname(arg)
|
|
|
|
filenames = [ os.path.basename(arg) ]
|
|
|
|
elif os.path.isdir(arg):
|
|
|
|
wd = arg
|
|
|
|
package = store_read_package(wd)
|
|
|
|
project = store_read_project(wd)
|
|
|
|
filenames = meta_get_filelist(project, package)
|
|
|
|
|
|
|
|
# add files which are not listed in _meta
|
|
|
|
for i in os.listdir(arg):
|
|
|
|
if i not in filenames and i not in exclude_stuff:
|
|
|
|
filenames.insert(0, i)
|
|
|
|
|
|
|
|
|
2006-04-24 14:04:20 +02:00
|
|
|
|
|
|
|
filelist = localmeta_get_filelist()
|
2006-04-20 16:26:50 +02:00
|
|
|
for filename in filenames:
|
2006-04-24 14:04:20 +02:00
|
|
|
st = get_file_status(project, package, filename, filelist=filelist)
|
2006-04-20 16:26:50 +02:00
|
|
|
if st.startswith('?'):
|
|
|
|
localmeta_addfile(filename)
|
|
|
|
print 'A ', filename
|
|
|
|
elif st.startswith('!'):
|
|
|
|
print 'D ', filename
|
|
|
|
localmeta_removefile(filename)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif cmd == 'ci' or cmd == 'checkin':
|
2006-05-11 09:27:50 +02:00
|
|
|
args = parseargs()
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
for arg in args:
|
|
|
|
|
|
|
|
if os.path.isfile(arg):
|
|
|
|
wd = os.path.dirname(arg)
|
|
|
|
filenames = [ os.path.basename(arg) ]
|
|
|
|
elif os.path.isdir(arg):
|
|
|
|
wd = arg
|
|
|
|
package = store_read_package(wd)
|
|
|
|
project = store_read_project(wd)
|
|
|
|
filenames = meta_get_filelist(project, package)
|
|
|
|
|
|
|
|
# add files which are not listed in _meta
|
|
|
|
for i in os.listdir(arg):
|
|
|
|
if i not in filenames and i not in exclude_stuff:
|
|
|
|
filenames.insert(0, i)
|
|
|
|
|
|
|
|
os.chdir(wd)
|
|
|
|
|
|
|
|
files_to_send = []
|
|
|
|
files_to_delete = []
|
|
|
|
|
2006-04-24 14:04:20 +02:00
|
|
|
filelist = localmeta_get_filelist()
|
2006-04-20 16:26:50 +02:00
|
|
|
for filename in filenames:
|
2006-04-24 14:04:20 +02:00
|
|
|
st = get_file_status(project, package, filename, filelist=filelist)
|
2006-04-20 16:26:50 +02:00
|
|
|
if st.startswith('A') or st.startswith('M'):
|
|
|
|
files_to_send.append(filename)
|
|
|
|
print 'Sending %s' % filename
|
|
|
|
elif st.startswith('D'):
|
|
|
|
files_to_delete.append(filename)
|
|
|
|
print 'Deleting %s' % filename
|
|
|
|
|
|
|
|
if not files_to_send and not files_to_delete:
|
|
|
|
print 'nothing to do'
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
print 'Transmitting file data ',
|
|
|
|
for filename in files_to_send:
|
|
|
|
put_source_file(project, package, filename)
|
|
|
|
copy_file(filename, os.path.join(store, filename))
|
|
|
|
for filename in files_to_delete:
|
|
|
|
del_source_file(project, package, filename)
|
|
|
|
print
|
|
|
|
|
|
|
|
|
|
|
|
elif cmd == 'up' or cmd == 'update':
|
|
|
|
|
2006-05-11 09:27:50 +02:00
|
|
|
args = parseargs()
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
for arg in args:
|
|
|
|
|
|
|
|
if os.path.isfile(arg):
|
|
|
|
wd = os.path.dirname(arg)
|
|
|
|
filenames = [ os.path.basename(arg) ]
|
|
|
|
elif os.path.isdir(arg):
|
|
|
|
wd = arg
|
|
|
|
package = store_read_package(wd)
|
|
|
|
project = store_read_project(wd)
|
|
|
|
|
|
|
|
## add files which are not listed in _meta
|
|
|
|
#for i in os.listdir(arg):
|
|
|
|
# if i not in filenames and i not in exclude_stuff:
|
|
|
|
# filenames.insert(0, i)
|
|
|
|
|
2006-04-24 14:04:20 +02:00
|
|
|
olddir = os.getcwd()
|
2006-04-20 16:26:50 +02:00
|
|
|
os.chdir(wd)
|
2006-04-28 17:37:25 +02:00
|
|
|
check_store_version()
|
|
|
|
|
|
|
|
# save filelist before replacing the meta file
|
|
|
|
filenames = localmeta_get_filelist()
|
2006-04-20 16:26:50 +02:00
|
|
|
os.chdir(store)
|
2006-04-28 17:37:25 +02:00
|
|
|
# update filelist
|
|
|
|
f = open('_files', 'w')
|
|
|
|
f.write(''.join(show_files_meta(project, package)))
|
|
|
|
f.close()
|
|
|
|
|
|
|
|
# which files do no longer exist upstream?
|
|
|
|
disappeared = []
|
|
|
|
upstream_files = meta_get_filelist(project, package)
|
|
|
|
for filename in filenames:
|
|
|
|
if filename not in upstream_files:
|
|
|
|
disappeared.append(filename)
|
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
for filename in filenames:
|
2006-04-28 17:37:25 +02:00
|
|
|
if filename in disappeared:
|
|
|
|
print 'D %s' % filename
|
|
|
|
os.unlink(filename)
|
|
|
|
continue
|
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
get_source_file(project, package, filename)
|
|
|
|
wcfilename = os.path.join(os.pardir, os.path.basename(filename))
|
|
|
|
|
|
|
|
if not os.path.exists(wcfilename):
|
|
|
|
print 'A %s' % filename
|
|
|
|
copy_file(filename, wcfilename)
|
|
|
|
|
|
|
|
elif dgst(wcfilename) != dgst(filename):
|
|
|
|
print 'U %s' % filename
|
|
|
|
copy_file(filename, wcfilename)
|
|
|
|
|
|
|
|
else:
|
|
|
|
pass
|
|
|
|
|
|
|
|
# get current meta file
|
|
|
|
f = open('_meta', 'w')
|
|
|
|
f.write(''.join(show_package_meta(project, package)))
|
|
|
|
f.close()
|
|
|
|
|
2006-04-24 14:04:20 +02:00
|
|
|
os.chdir(olddir)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif cmd == 'rm' or cmd == 'delete':
|
2006-05-11 09:27:50 +02:00
|
|
|
if len(sys.argv) < 3:
|
2006-04-20 16:26:50 +02:00
|
|
|
print '%s requires at least one argument' % cmd
|
|
|
|
sys.exit(1)
|
|
|
|
|
2006-05-11 09:27:50 +02:00
|
|
|
args = parseargs()
|
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
for arg in args:
|
|
|
|
|
2006-04-25 14:25:53 +02:00
|
|
|
olddir = os.getcwd()
|
|
|
|
|
|
|
|
wd = os.path.dirname(arg) or os.curdir
|
|
|
|
filename = arg
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
os.chdir(wd)
|
|
|
|
|
2006-04-25 14:25:53 +02:00
|
|
|
localmeta_removefile(filename)
|
|
|
|
print 'D %s' % filename
|
|
|
|
|
|
|
|
os.chdir(olddir)
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
|
|
|
|
elif cmd == 'id':
|
|
|
|
print ''.join(get_user_id(sys.argv[2]))
|
|
|
|
|
|
|
|
elif cmd == 'platforms':
|
2006-05-02 10:17:45 +02:00
|
|
|
if len(sys.argv) > 2:
|
|
|
|
project = sys.argv[2]
|
2006-04-20 16:26:50 +02:00
|
|
|
print '\n'.join(get_platforms_of_project(project))
|
|
|
|
else:
|
|
|
|
print '\n'.join(get_platforms())
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-04-29 22:44:09 +02:00
|
|
|
elif cmd == 'results_meta':
|
2006-04-25 18:19:42 +02:00
|
|
|
wd = os.curdir
|
|
|
|
package = store_read_package(wd)
|
|
|
|
project = store_read_project(wd)
|
|
|
|
if len(sys.argv) > 2:
|
|
|
|
platform = sys.argv[2]
|
2006-04-29 22:44:09 +02:00
|
|
|
print ''.join(show_results_meta(project, package, platform))
|
2006-04-20 16:26:50 +02:00
|
|
|
else:
|
|
|
|
for platform in get_platforms_of_project(project):
|
2006-04-29 22:44:09 +02:00
|
|
|
print ''.join(show_results_meta(project, package, platform))
|
|
|
|
|
|
|
|
elif cmd == 'results':
|
|
|
|
if len(sys.argv) > 3:
|
|
|
|
print 'getting results for more than one package is not supported'
|
|
|
|
print sys.exit(1)
|
|
|
|
|
|
|
|
if len(sys.argv) == 3:
|
|
|
|
wd = sys.argv[2]
|
|
|
|
else:
|
|
|
|
wd = os.curdir
|
|
|
|
package = store_read_package(wd)
|
|
|
|
project = store_read_project(wd)
|
|
|
|
|
|
|
|
for platform in get_platforms_of_project(project):
|
2006-05-02 10:17:45 +02:00
|
|
|
print '\n'.join(get_results(project, package, platform))
|
2006-04-29 22:44:09 +02:00
|
|
|
|
2006-04-20 16:26:50 +02:00
|
|
|
|
|
|
|
elif cmd == 'log':
|
|
|
|
wd = os.curdir
|
|
|
|
package = store_read_package(wd)
|
|
|
|
project = store_read_project(wd)
|
|
|
|
|
|
|
|
platform = sys.argv[2]
|
|
|
|
arch = sys.argv[3]
|
|
|
|
print ''.join(get_log(project, package, platform, arch))
|
|
|
|
|
|
|
|
else:
|
|
|
|
print "unknown command '%s'" % cmd
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
init_basicauth()
|
|
|
|
main()
|
|
|
|
|