diff --git a/NEWS b/NEWS index eb01cf5c..ca2b3894 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,8 @@ - show review states on "review list" - new source service commands "localrun" and "disabledrun" to generate files without _service: prefix - add "request supersede" and "review supersede" to supersede with existing request + - make it possible to run single source services, even when not specified in _service file. + (For example for doing a version update without creating a _service file: osc service lr update_source) # # Features which requires OBS 2.2 # diff --git a/osc/commandline.py b/osc/commandline.py index 4e7378ab..fa8da2b8 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -4696,10 +4696,15 @@ Please submit there instead, or use --nodevelproject to force direct submission. usage: osc service COMMAND (inside working copy) - osc service COMMAND PROJECT PACKAGE + osc service run [SOURCE_SERVICE] + osc service localrun [SOURCE_SERVICE] + osc service disabledrun + osc service remoterun [PROJECT PACKAGE] COMMAND can be: - run r run defined services locally + run r run defined services locally, it takes an optional parameter to run only a + specified source service. In case paramteres exists for this one in _service file + they are used. localrun lr run defined services locally and store files as local created (skip _service: prefix). disabledrun dr run only disabled services locally and store files as local created remoterun rr trigger a re-run on the server side @@ -4709,17 +4714,19 @@ Please submit there instead, or use --nodevelproject to force direct submission. args = slash_split(args) - package = repo = arch = code = None + package = singleservice = mode = repo = arch = code = None apiurl = self.get_api_url() - if len(args) < 2: + if len(args) < 3: if is_package_dir(os.curdir): project = store_read_project(os.curdir) package = store_read_package(os.curdir) apiurl = store_read_apiurl(os.curdir) else: raise oscerr.WrongArgs('Too few arguments.') - elif len(args) == 3: + if len(args) == 2: + singleservice = args[1] + elif len(args) == 3 and command == "remoterun": project = args[1] package = args[2] else: @@ -4729,17 +4736,18 @@ Please submit there instead, or use --nodevelproject to force direct submission. if command == "remoterun" or command == "rr": print runservice(apiurl, project, package) + return if command == "run" or command == "localrun" or command == "disabledrun" or command == "lr" or command == "dr" or command == "r": if not is_package_dir(os.curdir): raise oscerr.WrongArgs('Local directory is no package') p = Package(".") if command == "localrun" or command == "lr": - p.run_source_services( "local" ) + mode = "local" elif command == "disabledrun" or command == "dr": - p.run_source_services( "disabled" ) - else: - p.run_source_services() + mode = "disabled" + + p.run_source_services( mode, singleservice ) @cmdln.option('-a', '--arch', metavar='ARCH', help='trigger rebuilds for a specific architecture') diff --git a/osc/core.py b/osc/core.py index 24eee5f8..a83cafe0 100644 --- a/osc/core.py +++ b/osc/core.py @@ -300,7 +300,7 @@ class Serviceinfo: r.append( s ) return r - def execute(self, dir, callmode = ""): + def execute(self, dir, callmode = None, singleservice = None): import tempfile # cleanup existing generated files @@ -308,8 +308,16 @@ class Serviceinfo: if filename.startswith('_service:') or filename.startswith('_service_'): os.unlink(os.path.join(dir, filename)) + allservices = self.services or [] + if singleservice and not singleservice in allservices: + # set array to the manual specified singleservice, if it is not part of _service file + data = { 'name' : singleservice, 'command' : singleservice, 'mode' : '' } + allservices = [data] + # recreate files - for service in self.services: + for service in allservices: + if singleservice and service['name'] != singleservice: + continue if service['mode'] == "disabled" and callmode != "disabled": continue if service['mode'] != "disabled" and callmode == "disabled": @@ -2015,15 +2023,15 @@ rev: %s print 'At revision %s.' % self.rev - def run_source_services(self, mode=""): + def run_source_services(self, mode=None, singleservice=None): curdir = os.getcwd() os.chdir(self.absdir) # e.g. /usr/lib/obs/service/verify_file fails if not inside the project dir. + si = Serviceinfo() if self.filenamelist.count('_service') or self.filenamelist_unvers.count('_service'): service = ET.parse(os.path.join(self.absdir, '_service')).getroot() - si = Serviceinfo() si.read(service) - si.readProjectFile(self.apiurl, self.prjname) - si.execute(self.absdir, mode) + si.readProjectFile(self.apiurl, self.prjname) + si.execute(self.absdir, mode, singleservice) os.chdir(curdir) def prepare_filelist(self):