From 727cd1a666f4577f12bb981639c6b7014b09b614 Mon Sep 17 00:00:00 2001 From: Natalia Serrano Date: Wed, 14 Aug 2024 12:50:17 +0200 Subject: [PATCH] refs #596 unhardcode gitrelease --- boottoolsfunctions/__init__.py | 7 ++----- boottoolsgenerator.py | 17 ++++++++--------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/boottoolsfunctions/__init__.py b/boottoolsfunctions/__init__.py index b47fc63..1e8cc09 100644 --- a/boottoolsfunctions/__init__.py +++ b/boottoolsfunctions/__init__.py @@ -174,13 +174,10 @@ def btogGetOsInfo1 (type_client): os.exit (1) return osdistrib, oscodename, osrelease, osarch, oshttp -def btogGetOsInfo2 (type_client, versionboottools, osdistrib, oscodename, osrelease, osarch, oshttp): - branch = 'master' - giturl = f'https://api.github.com/repos/opengnsys/OpenGnsys/commits?sha={branch}&path=/client' - gitrelease = 'r20240808' ## TODO: are we going to keep the following? $(curl -s "$GITURL" | jq -r '"r" + (.[0].commit.committer.date | split("-") | join("")[:8]) + "." + (.[0].sha[:7])') +def btogGetOsInfo2 (ogrepo_dir, versionboottools, oscodename, osrelease, osarch): + gitrelease = subprocess.run (['git', '--git-dir', f'{ogrepo_dir}/.git', 'log', '--date', 'format:r%Y%m%d', '--format=%ad', '-1'], capture_output=True, text=True).stdout.strip() nameisoclient ='-'.join ([versionboottools, oscodename, osrelease, osarch, gitrelease]) namehostclient = '-'.join ([versionboottools, oscodename, gitrelease]) - return gitrelease, nameisoclient, namehostclient def btogSetFsVirtual (btrootfsimg, btrootfsimglabel, btrootfsmnt, btvirtualdisksize, bttargetdir, osarch): diff --git a/boottoolsgenerator.py b/boottoolsgenerator.py index 515ebf7..23cacf6 100755 --- a/boottoolsgenerator.py +++ b/boottoolsgenerator.py @@ -33,14 +33,10 @@ def _logging(): logger = _logging() -def clone_client_dirs(): +def clone_client_dirs (ogrepo_url, ogrepo_branch, ogrepo_dir): if not os.path.exists ('/tmp/opengnsys/engine'): - branch = 'main' - tmpdir, _ = _run (['mktemp', '--tmpdir', '--directory', 'oggit.XXXXXX']) - logger.debug (f'tmpdir "{tmpdir}"') - _run (['git', 'clone', '-c', 'http.sslVerify=false', '--branch', branch, 'https://ognproject.evlt.uma.es/gitea/opengnsys/opengnsys.git', tmpdir]) - _run (['rsync', '-aH', f'{tmpdir}/client/engine', f'{tmpdir}/client/shared', '/tmp/opengnsys/']) - _run (['rm', '-rf', tmpdir]) + _run (['git', 'clone', '-c', 'http.sslVerify=false', '--branch', ogrepo_branch, ogrepo_url, ogrepo_dir]) + _run (['rsync', '-aH', f'{ogrepo_dir}/client/engine', f'{ogrepo_dir}/client/shared', '/tmp/opengnsys/']) type_client = sys.argv[1] if len(sys.argv)>1 else 'host' #WORKDIR = '/tmp/opengnsys_installer' @@ -54,13 +50,16 @@ if os.getuid(): #os.chdir ('/tmp') logger.info ('OpenGnsys CLIENT installation begins') -clone_client_dirs() +ogrepo_url = 'https://ognproject.evlt.uma.es/gitea/opengnsys/opengnsys.git' +ogrepo_branch = 'main' +ogrepo_dir = '/tmp/ogrepo' +clone_client_dirs (ogrepo_url, ogrepo_branch, ogrepo_dir) ####################################################################3 logger.info ('FASE 1 - Asignación de variables') osdistrib, oscodename, osrelease, osarch, oshttp = btogGetOsInfo1(type_client) btdir, bttargetdir, btrootfsimg, btrootfsmnt, btrootfsimglabel, log_file, versionboottools, btvirtualdisksize = btogGetVar(osarch) -gitrelease, nameisoclient, namehostclient = btogGetOsInfo2(type_client, versionboottools, osdistrib, oscodename, osrelease, osarch, oshttp) +gitrelease, nameisoclient, namehostclient = btogGetOsInfo2(ogrepo_dir, versionboottools, oscodename, osrelease, osarch) def _mount_rootfs(): global btrootfsimg, btrootfsmnt