1- """ SystemAdministrator service is a tool to control and monitor the DIRAC services and agents
2- """
1+ """SystemAdministrator service is a tool to control and monitor the DIRAC services and agents"""
2+
33import socket
44import os
55import re
@@ -254,17 +254,38 @@ def export_addDefaultOptionsToCS(self, componentType, system, component, overwri
254254 types_updateSoftware = [str ]
255255
256256 def export_updateSoftware (self , version ):
257+ """Update DIRAC, or its extension, to a version. Use extension_name==version for the DIRAC extension.
258+
259+ A version can be:
260+ - a PEP440 valid version of DIRAC.
261+ - a PEP440 valid version of a DIRAC extension.
262+ - "integration" or "devel" or "master" or "main" would all be interpreted as git+https://github.com/DIRACGrid/DIRAC.git@integration#egg=DIRAC[server]
263+ - a git tag/branch like git+https://github.com/fstagni/DIRAC.git@test_branch#egg=DIRAC[server]
264+ """
257265 # Validate and normalise the requested version
258266 primaryExtension = None
259267 if "==" in version :
260268 primaryExtension , version = version .split ("==" )
261- try :
262- version = Version (version )
263- except InvalidVersion :
264- self .log .exception ("Invalid version passed" , version )
265- return S_ERROR (f"Invalid version passed { version !r} " )
266- isPrerelease = version .is_prerelease
267- version = f"v{ version } "
269+
270+ released_version = True
271+ isPrerelease = False
272+
273+ # Special cases (e.g. installing the integration/main branch)
274+ if version .lower () in ["integration" , "devel" , "master" , "main" ]:
275+ released_version = False
276+ version = "git+https://github.com/DIRACGrid/DIRAC.git@integration#egg=DIRAC[server]"
277+
278+ if released_version :
279+ try :
280+ version = Version (version )
281+ isPrerelease = version .is_prerelease
282+ version = f"v{ version } "
283+ except InvalidVersion :
284+ if "https://" in version :
285+ released_version = False
286+ else :
287+ self .log .exception ("Invalid version passed" , version )
288+ return S_ERROR (f"Invalid version passed { version !r} " )
268289
269290 # Find what to install
270291 otherExtensions = []
@@ -290,10 +311,11 @@ def export_updateSoftware(self, version):
290311 installer .flush ()
291312 self .log .info ("Downloaded DIRACOS installer to" , installer .name )
292313
314+ directory = version if released_version else version .split ("@" )[1 ].split ("#" )[0 ]
293315 newProPrefix = os .path .join (
294316 rootPath ,
295317 "versions" ,
296- f"{ version } -{ datetime .utcnow ().strftime ('%s' )} " ,
318+ f"{ directory } -{ datetime .utcnow ().strftime ('%s' )} " ,
297319 )
298320 installPrefix = os .path .join (newProPrefix , f"{ platform .system ()} -{ platform .machine ()} " )
299321 self .log .info ("Running DIRACOS installer for prefix" , installPrefix )
@@ -313,7 +335,15 @@ def export_updateSoftware(self, version):
313335 cmd = [f"{ installPrefix } /bin/pip" , "install" , "--no-color" , "-v" ]
314336 if isPrerelease :
315337 cmd += ["--pre" ]
316- cmd += [f"{ primaryExtension } [server]=={ version } " ]
338+ if released_version :
339+ cmd += [f"{ primaryExtension } [server]=={ version } " ]
340+ else :
341+ # from here on we assume a version like git+https://github.com/DIRACGrid/DIRAC.git@integration#egg=DIRAC[server]
342+ # is specified, for the primaryExtension
343+ if not version .startswith ("git+" ):
344+ version = f"git+{ version } "
345+ cmd += [version ]
346+
317347 cmd += [f"{ e } [server]" for e in otherExtensions ]
318348 r = subprocess .run (
319349 cmd ,
0 commit comments