Navigation Menu

Skip to content

Commit

Permalink
- make it possible to run single source services, even when not speci…
Browse files Browse the repository at this point in the history
…fied in _service file.

  (For example for doing a version update without creating a _service file: osc service lr update_source)
  • Loading branch information
adrianschroeter committed Feb 15, 2011
1 parent 70e3cbb commit f0690d4
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 15 deletions.
2 changes: 2 additions & 0 deletions NEWS
Expand Up @@ -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
#
Expand Down
26 changes: 17 additions & 9 deletions osc/commandline.py
Expand Up @@ -4696,10 +4696,15 @@ def do_service(self, subcmd, opts, *args):
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
Expand All @@ -4709,17 +4714,19 @@ def do_service(self, subcmd, opts, *args):

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:
Expand All @@ -4729,17 +4736,18 @@ def do_service(self, subcmd, opts, *args):

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')
Expand Down
20 changes: 14 additions & 6 deletions osc/core.py
Expand Up @@ -300,16 +300,24 @@ def addRecompressTar(self, serviceinfo_node):
r.append( s )
return r

def execute(self, dir, callmode = ""):
def execute(self, dir, callmode = None, singleservice = None):
import tempfile

# cleanup existing generated files
for filename in os.listdir(dir):
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":
Expand Down Expand Up @@ -2015,15 +2023,15 @@ def __update(self, kept, added, deleted, services, fm, 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()
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):
Expand Down

0 comments on commit f0690d4

Please sign in to comment.