mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-27 10:16:14 +01:00
Add .old dir support for source services
Some services expect "old" service files (that is, files from a previous service run) to be present in an ".old" dir. Hence, osc should support that. Instead of removing all files from a previous service run, move them to the ".old" dir, run the services, and, finally, remove the ".old" dir. Unfortunately, the location of the ".old" dir is hardcoded in the specific services. That is, we have to be careful if an ".old" dir exists (in this case, we error out). Based on [1]. [1] https://github.com/openSUSE/osc/pull/846
This commit is contained in:
parent
7b5d105523
commit
89bb15d3b6
21
osc/core.py
21
osc/core.py
@ -410,16 +410,27 @@ class Serviceinfo:
|
||||
return r
|
||||
|
||||
def execute(self, dir, callmode = None, singleservice = None, verbose = None):
|
||||
old_dir = os.path.join(dir, '.old')
|
||||
if os.path.exists(old_dir) or os.path.islink(old_dir):
|
||||
msg = '"%s" exists, please remove it' % old_dir
|
||||
raise oscerr.OscIOError(None, msg)
|
||||
try:
|
||||
os.mkdir(old_dir)
|
||||
return self._execute(dir, old_dir, callmode, singleservice,
|
||||
verbose)
|
||||
finally:
|
||||
if os.path.exists(old_dir):
|
||||
shutil.rmtree(old_dir)
|
||||
|
||||
def _execute(self, dir, old_dir, callmode=None, singleservice=None,
|
||||
verbose=None):
|
||||
import tempfile
|
||||
|
||||
# cleanup existing generated files
|
||||
for filename in os.listdir(dir):
|
||||
if filename.startswith('_service:') or filename.startswith('_service_'):
|
||||
ent = os.path.join(dir, filename)
|
||||
if os.path.isdir(ent):
|
||||
shutil.rmtree(ent)
|
||||
else:
|
||||
os.unlink(ent)
|
||||
os.rename(os.path.join(dir, filename),
|
||||
os.path.join(old_dir, filename))
|
||||
|
||||
allservices = self.services or []
|
||||
service_names = [s['name'] for s in allservices]
|
||||
|
Loading…
Reference in New Issue
Block a user