diff --git a/containers/jug/setup_detectors.py b/containers/jug/setup_detectors.py index 766aebd26ee778264ac616271247a60be446af47..11beda56786014fa02fdfe0cc29d096145aee4e6 100755 --- a/containers/jug/setup_detectors.py +++ b/containers/jug/setup_detectors.py @@ -8,33 +8,6 @@ import subprocess from datetime import datetime DETECTOR_REPO_GROUP = 'https://github.com/eic' -DETECTOR_BEAMLINE_ENV =''' -#!/bin/sh -export DETECTOR={detector} -export DETECTOR_PATH={data_prefix} -export DETECTOR_CONFIG={detector} -export DETECTOR_VERSION={version} -export BEAMLINE_PATH={data_prefix} -export BEAMLINE_CONFIG={ip} -export BEAMLINE_CONFIG_VERSION={ip_version} -## note: we will phase out the JUGGLER_* flavor of variables in the future -export JUGGLER_DETECTOR=$DETECTOR -export JUGGLER_DETECTOR_CONFIG=$DETECTOR_CONFIG -export JUGGLER_DETECTOR_VERSION=$DETECTOR_VERSION -export JUGGLER_DETECTOR_PATH=$DETECTOR_PATH -export JUGGLER_BEAMLINE_CONFIG=$BEAMLINE_CONFIG -export JUGGLER_BEAMLINE_CONFIG_VERSION=$BEAMLINE_CONFIG_VERSION -export JUGGLER_INSTALL_PREFIX=/usr/local - -## Export detector libraries -export LD_LIBRARY_PATH={prefix}/lib${{LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}} - -## modify PS1 for this detector version -export PS1="${{PS1:-}}" -export PS1="{branch}${{PS1_SIGIL}}>${{PS1#*>}}" -unset branch -''' - DETECTOR_ENV =''' #!/bin/sh export DETECTOR={detector} @@ -99,7 +72,7 @@ if __name__ == '__main__': default_version = cfg['version'] default_found = True print(' - {}: {}{}'.format(det, branch, default_str)) - print(' --> Building and installing detector/ip libraries') + print(' --> Building and installing detector libraries') process_list = [] for det in detectors: if not args.nightly and 'nightly' in detectors[det]: @@ -109,53 +82,41 @@ if __name__ == '__main__': version = cfg['version'] if branch != 'nightly' else 'nightly' prefix = '{}/{}-{}'.format(args.prefix, det, version) data_dir = '{}/share/{}'.format(prefix, det) - ## build list of projects to install - proj_vers_list = [(det, cfg['version'])] - if 'ip' in cfg: - ip = cfg['ip'] - proj_vers_list.append((ip['config'], ip['version'])) - ## build and install projects - for (proj, vers) in proj_vers_list: - print(' - {}-{}'.format(proj, vers)) - ## clone/build/install detector libraries - cmd = ['rm -rf /tmp/build /tmp/det', - '&&', - 'git clone --depth 1 -b {version} {repo_grp}/{detector}.git /tmp/det'.format( - version=vers, - repo_grp=DETECTOR_REPO_GROUP, - detector=proj), - '&&', - 'cmake -B /tmp/build -S /tmp/det -DCMAKE_CXX_STANDARD=17', - '-DCMAKE_CXX_FLAGS="-Wno-psabi"', - '-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache', - '-DCMAKE_INSTALL_PREFIX={prefix}'.format(prefix=prefix), - '&&', - 'cmake --build /tmp/build -j$(($(($(nproc)/4))+1)) -- install'] + ## build and install + print(' - {}-{}'.format(det, cfg['version'])) + ## clone/build/install detector libraries + cmd = ['rm -rf /tmp/build /tmp/det', + '&&', + 'git clone --depth 1 -b {version} {repo_grp}/{detector}.git /tmp/det'.format( + version=cfg['version'], + repo_grp=DETECTOR_REPO_GROUP, + detector=det), + '&&', + 'cmake -B /tmp/build -S /tmp/det -DCMAKE_CXX_STANDARD=17', + '-DCMAKE_CXX_FLAGS="-Wno-psabi"', + '-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache', + '-DCMAKE_INSTALL_PREFIX={prefix}'.format(prefix=prefix), + '&&', + 'cmake --build /tmp/build -j$(($(($(nproc)/4))+1)) -- install'] + print(' '.join(cmd)) + subprocess.check_call(' '.join(cmd), shell=True) + ## write version info to jug_info if available + if os.path.exists('/etc/jug_info'): + cmd = ['cd /tmp/det', + '&&', + 'echo " - {detector}/{branch}: {version}-$(git rev-parse HEAD)"'.format( + detector=det, + branch=branch, + version=cfg['version']), + '>> /etc/jug_info', + '&&', + 'cd -'] print(' '.join(cmd)) subprocess.check_call(' '.join(cmd), shell=True) - ## write version info to jug_info if available - if os.path.exists('/etc/jug_info'): - cmd = ['cd /tmp/det', - '&&', - 'echo " - {detector}/{branch}: {version}-$(git rev-parse HEAD)"'.format( - detector=proj, - branch=branch, - version=cfg['version']), - '>> /etc/jug_info', - '&&', - 'cd -'] - print(' '.join(cmd)) - subprocess.check_call(' '.join(cmd), shell=True) - ## also copy over IP configuration to the detector - if 'ip' in cfg and os.path.exists('/tmp/det/{ip}'.format(ip=cfg['ip']['config'])): - cmd = 'cp -r /tmp/det/{ip} {data_dir}'.format( - ip=ip['config'], data_dir=data_dir) - print(cmd) - subprocess.check_call(cmd, shell=True) - ## cleanup - cmd = 'rm -rf /tmp/det /tmp/build' - print(cmd) - subprocess.check_call(cmd, shell=True) + ## cleanup + cmd = 'rm -rf /tmp/det /tmp/build' + print(cmd) + subprocess.check_call(cmd, shell=True) # be resilient against failures if os.path.exists(prefix): ## create a shortcut for the prefix if desired @@ -167,24 +128,13 @@ if __name__ == '__main__': subprocess.check_call(cmd, shell=True) ## write an environment file for this detector with open('{prefix}/setup.sh'.format(prefix=prefix), 'w') as f: - if 'ip' in cfg: - print(DETECTOR_BEAMLINE_ENV.format( - prefix=prefix, - detector=det, - data_prefix=data_dir, - version=cfg['version'], - ip=ip['config'], - ip_version=ip['version'], - branch=branch), - file=f) - else: - print(DETECTOR_ENV.format( - prefix=prefix, - detector=det, - data_prefix=data_dir, - version=cfg['version'], - branch=branch), - file=f) + print(DETECTOR_ENV.format( + prefix=prefix, + detector=det, + data_prefix=data_dir, + version=cfg['version'], + branch=branch), + file=f) ## run once inside global prefix to initialize artifacts in /opt/detectors os.environ['DETECTOR_PATH'] = args.prefix cmd = f'cd {args.prefix} && source {prefix}/setup.sh && checkGeometry -c {prefix}/share/{det}/{det}.xml'