+++ /dev/null
-#!/bin/sh
-set -x
-
-git_url=`git config remote.origin.url`
-
-prj_name=`basename $git_url`
-
-pkg=$1
-
-pkg_name=`basename $pkg`
-
-echo $prj_name
-
-#curl -i -Fjson='{"parameter": [{"name":"pkg", "value":"'$prj_name'"},{"name":"tag", "value":"'$tag'"}]}' -FSubmit=Build "http://gerrit2.bj.intel.com:8082/job/upload/build" -v
-
-curl -i -Fname=pkg.tar.bz2 -Ffile0=@"$pkg" -Fjson='{"parameter": [{"name": "pkg.tar.bz2", "file": "file0"},{"name":"pkg", "value":"'$pkg_name'"}]}' -FSubmit=Build "http://gerrit2.bj.intel.com:8082/job/uploader/build" -v
\ No newline at end of file
--- /dev/null
+#!/usr/bin/python -tt
+# vim: ai ts=4 sts=4 et sw=4
+#
+# Copyright (c) 2011 Intel, Inc.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the Free
+# Software Foundation; version 2 of the License
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc., 59
+# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+"""Implementation of subcmd: import
+"""
+
+import os
+
+# internal modules
+import msger
+import errors
+import git
+import srcserver as ss
+
+def do(opts, args):
+ if not args or len(args) != 1:
+ raise errors.Usage('Must specify the path of tarball and only one')
+
+ tarfp = args[0]
+ tarname = os.path.basename(tarfp)
+
+ gitname = os.path.basename(git.config('remote.origin.url'))
+
+
+ # FIXME "pkg_name" in shell means the obs prj?
+ if opts.obsprj:
+ obspkg = opts.obsprj
+ else:
+ obspkg = gitname
+
+ params = {'parameter': [
+ {"name": "pkg.tar.bz2", "file": "file0"},
+ {"name": "pkg", "value": tarname}
+ ]}
+
+ msger.info('uploading tarball %s to src server ...' % tarfp)
+ ss.upload(params, tarfp)
+ # TODO need to check the result and get the md5sum
+ # TODO update sources automatically?
class ConfigError(CmdError):
keyword = '<config>'
+
+class GitInvalid(CmdError):
+ keywork = '<git>'
+
+ def __str__(self):
+ return 'Dir %s is not a valid git tree' % str(self.msg)
# with this program; if not, write to the Free Software Foundation, Inc., 59
# Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+import os
+
import runner
+import errors
__all__ = ['config', 'branch', 'status', 'ls_files']
+def _run_git(cmd, args=[]):
+ if not os.path.isdir('.git'):
+ raise errors.GitInvalid(os.getcwd())
+
+ return runner.outs(['git', cmd] + args)
+
def config(*args):
- return runner.outs(['git', 'config'] + list(args))
+ return _run_git('config', list(args))
def branch(all=False, current=False, *args):
- cmdln = ['git', 'branch']
+ args = list(args)
if all:
- cmdln.append('-a')
- cmdln += list(args)
+ args.insert(0, '-a')
- branches = runner.outs(cmdln).splitlines()
+ branches = _run_git('branch', args).splitlines()
curbr = ''
for br in branches:
return branches
def status(*args):
- outs = runner.outs(['git', 'status', '-s'] + list(args))
+ outs = _run_git('status', ['-s'] + list(args))
sts = {}
for line in outs.splitlines():
return sts
def ls_files():
- return runner.outs('git ls-files').splitlines()
+ return _run_git('ls-files').splitlines()
+
cmdln += ' -F%s=%s ' % (k, v)
cmdln += '%s/%s' % (SRCSERVER, api.lstrip('/'))
+ msger.debug('curl cmdln: '+cmdln)
return runner.outs(cmdln)
def build_trigger(params, tarfp):
_call_curl('job/build/build',
- '-i',
+ '-i',
name=tarfp,
file0='@'+tarfp,
Submit='Build',
return json.loads(retstr)
+def upload(params, tarfp):
+ _call_curl('job/upload/build',
+ '-i',
+ name='pkg.tar.bz2', # must wrong here, plz FIXME
+ file0='@'+tarfp,
+ Submit='Build',
+ json="%s" % json.dumps(params))
+
if len(sys.argv) > 1 and 'install' in sys.argv:
try:
import platform
- (dist, ver, id) = platform.linux_distribution()
+ (dist, ver, rid) = platform.linux_distribution()
# for debian-like distros, mods will be installed to
# ${PYTHONLIB}/dist-packages
"""${cmd_name}: test building for current pkg
Usage:
- gbs build [OBS_project]
+ gbs build [options] [OBS_project]
${cmd_option_list}
"""
"""${cmd_name}: prepare packaging files for current pkg
Usage:
- gbs packaging
+ gbs packaging [options]
${cmd_option_list}
"""
from gitbuildsys import cmd_packaging as cmd
cmd.do(opts, args)
+ @cmdln.option('--obsprj', default=None,
+ help='Specify OBS prj name if not the same as git')
+ @cmdln.alias("upload")
@_fall_to_shell('import')
def do_import(self, subcmd, opts, *args):
- """${cmd_name}: import new tarballs for current pkg
+ """${cmd_name}: import/upload new tarballs for current pkg
Usage:
- gbs import
+ gbs import [options] <tarball>
${cmd_option_list}
"""