mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-25 01:16:14 +01:00
- 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)
This commit is contained in:
parent
70e3cbbd33
commit
f0690d4e2f
2
NEWS
2
NEWS
@ -10,6 +10,8 @@
|
|||||||
- show review states on "review list"
|
- show review states on "review list"
|
||||||
- new source service commands "localrun" and "disabledrun" to generate files without _service: prefix
|
- new source service commands "localrun" and "disabledrun" to generate files without _service: prefix
|
||||||
- add "request supersede" and "review supersede" to supersede with existing request
|
- 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
|
# Features which requires OBS 2.2
|
||||||
#
|
#
|
||||||
|
@ -4696,10 +4696,15 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
|
|
||||||
usage:
|
usage:
|
||||||
osc service COMMAND (inside working copy)
|
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:
|
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).
|
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
|
disabledrun dr run only disabled services locally and store files as local created
|
||||||
remoterun rr trigger a re-run on the server side
|
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)
|
args = slash_split(args)
|
||||||
|
|
||||||
package = repo = arch = code = None
|
package = singleservice = mode = repo = arch = code = None
|
||||||
apiurl = self.get_api_url()
|
apiurl = self.get_api_url()
|
||||||
|
|
||||||
if len(args) < 2:
|
if len(args) < 3:
|
||||||
if is_package_dir(os.curdir):
|
if is_package_dir(os.curdir):
|
||||||
project = store_read_project(os.curdir)
|
project = store_read_project(os.curdir)
|
||||||
package = store_read_package(os.curdir)
|
package = store_read_package(os.curdir)
|
||||||
apiurl = store_read_apiurl(os.curdir)
|
apiurl = store_read_apiurl(os.curdir)
|
||||||
else:
|
else:
|
||||||
raise oscerr.WrongArgs('Too few arguments.')
|
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]
|
project = args[1]
|
||||||
package = args[2]
|
package = args[2]
|
||||||
else:
|
else:
|
||||||
@ -4729,17 +4736,18 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
|
|
||||||
if command == "remoterun" or command == "rr":
|
if command == "remoterun" or command == "rr":
|
||||||
print runservice(apiurl, project, package)
|
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 command == "run" or command == "localrun" or command == "disabledrun" or command == "lr" or command == "dr" or command == "r":
|
||||||
if not is_package_dir(os.curdir):
|
if not is_package_dir(os.curdir):
|
||||||
raise oscerr.WrongArgs('Local directory is no package')
|
raise oscerr.WrongArgs('Local directory is no package')
|
||||||
p = Package(".")
|
p = Package(".")
|
||||||
if command == "localrun" or command == "lr":
|
if command == "localrun" or command == "lr":
|
||||||
p.run_source_services( "local" )
|
mode = "local"
|
||||||
elif command == "disabledrun" or command == "dr":
|
elif command == "disabledrun" or command == "dr":
|
||||||
p.run_source_services( "disabled" )
|
mode = "disabled"
|
||||||
else:
|
|
||||||
p.run_source_services()
|
p.run_source_services( mode, singleservice )
|
||||||
|
|
||||||
@cmdln.option('-a', '--arch', metavar='ARCH',
|
@cmdln.option('-a', '--arch', metavar='ARCH',
|
||||||
help='trigger rebuilds for a specific architecture')
|
help='trigger rebuilds for a specific architecture')
|
||||||
|
18
osc/core.py
18
osc/core.py
@ -300,7 +300,7 @@ class Serviceinfo:
|
|||||||
r.append( s )
|
r.append( s )
|
||||||
return r
|
return r
|
||||||
|
|
||||||
def execute(self, dir, callmode = ""):
|
def execute(self, dir, callmode = None, singleservice = None):
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
# cleanup existing generated files
|
# cleanup existing generated files
|
||||||
@ -308,8 +308,16 @@ class Serviceinfo:
|
|||||||
if filename.startswith('_service:') or filename.startswith('_service_'):
|
if filename.startswith('_service:') or filename.startswith('_service_'):
|
||||||
os.unlink(os.path.join(dir, filename))
|
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
|
# 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":
|
if service['mode'] == "disabled" and callmode != "disabled":
|
||||||
continue
|
continue
|
||||||
if service['mode'] != "disabled" and callmode == "disabled":
|
if service['mode'] != "disabled" and callmode == "disabled":
|
||||||
@ -2015,15 +2023,15 @@ rev: %s
|
|||||||
|
|
||||||
print 'At revision %s.' % self.rev
|
print 'At revision %s.' % self.rev
|
||||||
|
|
||||||
def run_source_services(self, mode=""):
|
def run_source_services(self, mode=None, singleservice=None):
|
||||||
curdir = os.getcwd()
|
curdir = os.getcwd()
|
||||||
os.chdir(self.absdir) # e.g. /usr/lib/obs/service/verify_file fails if not inside the project dir.
|
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'):
|
if self.filenamelist.count('_service') or self.filenamelist_unvers.count('_service'):
|
||||||
service = ET.parse(os.path.join(self.absdir, '_service')).getroot()
|
service = ET.parse(os.path.join(self.absdir, '_service')).getroot()
|
||||||
si = Serviceinfo()
|
|
||||||
si.read(service)
|
si.read(service)
|
||||||
si.readProjectFile(self.apiurl, self.prjname)
|
si.readProjectFile(self.apiurl, self.prjname)
|
||||||
si.execute(self.absdir, mode)
|
si.execute(self.absdir, mode, singleservice)
|
||||||
os.chdir(curdir)
|
os.chdir(curdir)
|
||||||
|
|
||||||
def prepare_filelist(self):
|
def prepare_filelist(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user