Commit b4b6293c authored by Marco Clemencic's avatar Marco Clemencic
Browse files

First commit

see LbEnv!59
parents
Pipeline #721946 passed with stages
in 47 seconds
stages:
- test
- package
- deploy
variables:
RPM_REPO: incubator
RPM_REPO_EOS: /eos/project/l/lhcbwebsites/www/lhcb-rpm/${RPM_REPO}
RPM_REPO_URL: "http://lhcb-rpm.web.cern.ch/lhcb-rpm/${RPM_REPO}/"
pack-rpm:
stage: package
#only: [tags]
dependencies: []
image: gitlab-registry.cern.ch/lhcb-core/lbdocker/centos7-build
variables:
NO_LBLOGIN: "1"
NO_CVMFS: "1"
script:
- if [ -n "${CI_COMMIT_TAG}" ] ; then
- version=${CI_COMMIT_TAG}
- release=$(curl --silent ${RPM_REPO_URL} | grep LbEnv-${version} |
sed 's/<[^>]*>//g;s/\.noarch\.rpm.*//' |
awk -F- '{if (rev < $NF) rev = $NF}END{print rev + 1}' || true)
- else
- version=$(git describe --tags)
- release=${version#*-}
- version=${version%%-*}
- if [ "${release}" = "${version}" ] ; then release=1 ; fi
- fi
- release=${release//-/.}
- mkdir -p /userhome/rpmbuild/SOURCES
- git archive --output=/userhome/rpmbuild/SOURCES/LbEnv-${version}.tar.gz --prefix=LbEnv-${version}/ HEAD
- "sed -i \"s/^Version: .*/Version: ${version}/;s/^Release: .*/Release: ${release}/\" LbEnv.spec"
- rpmbuild -ba LbEnv.spec
- mkdir -p public
- mv /userhome/rpmbuild/SRPMS/LbEnv-${version}-${release}.src.rpm public
- mv /userhome/rpmbuild/RPMS/noarch/LbEnv-${version}-${release}.noarch.rpm public
artifacts:
paths:
- public
when: always
expire_in: 1 week
# see https://gitlab.cern.ch/gitlabci-examples/deploy_eos for the details
# of the configuration
deploy-rpm:
stage: deploy
only:
- tags
dependencies:
- pack-rpm
image: gitlab-registry.cern.ch/ci-tools/ci-web-deployer:latest
script:
- test -z "$EOS_ACCOUNT_USERNAME" -o -z "$EOS_ACCOUNT_PASSWORD" && exit 0 || true
# we do not publish the source RPM
- rm -fv public/*.src.rpm
# Script that performs the deploy to EOS. Makes use of the variables defined in the project
# It will copy the generated content to the folder in EOS
- export EOS_PATH=${RPM_REPO_EOS}
- find public -type f -ls
- deploy-eos
# do not run any globally defined before_script or after_script for this step
before_script: []
after_script: []
This diff is collapsed.
%define prefix /opt/LHCbSoft
%global __os_install_post /usr/lib/rpm/check-buildroot
Name: LbEnv
# version and release values are filled by the gitlab-ci job
Version: 0
Release: 0
Vendor: LHCb
Summary: Entry scripts for LHCb login environment
License: GPLv3
URL: https://gitlab.cern.ch/lhcb-core/%{name}
Source0: https://gitlab.cern.ch/lhcb-core/%{name}/-/archive/%{version}/%{name}-%{version}.tar.gz
Group: LHCb
BuildArch: noarch
AutoReqProv: no
Prefix: %{prefix}
Provides: /bin/sh
Provides: /bin/bash
%description
Entry scripts for LHCb login environment
%prep
%setup -q
%build
%install
mkdir -p ${RPM_BUILD_ROOT}%{prefix}/etc/cern_profile.d
install -m 0644 data/etc/cern_profile.*sh ${RPM_BUILD_ROOT}/%{prefix}/etc
install -m 0644 data/etc/cern_profile.d/*.*sh ${RPM_BUILD_ROOT}/%{prefix}/etc/cern_profile.d
mkdir -p ${RPM_BUILD_ROOT}%{prefix}/bin
install -m 0755 'data/bin/host_os' ${RPM_BUILD_ROOT}/%{prefix}/bin
for flavour in stable testing unstable ; do
for suff in '' .sh .csh ; do
tgt=${RPM_BUILD_ROOT}/%{prefix}/LbEnv-${flavour}${suff}
install -m 0644 "data/LbEnv-flavour${suff}" "${tgt}"
sed -i "s/%flavour%/${flavour}/g" "${tgt}"
done
done
for suff in '' .sh .csh ; do
ln -s LbEnv-stable${suff} ${RPM_BUILD_ROOT}/%{prefix}/LbEnv${suff}
done
%clean
%post -p /bin/bash
for flavour in stable testing unstable ; do
for suff in '' .sh .csh ; do
tgt=${RPM_INSTALL_PREFIX}/LbEnv-${flavour}${suff}
sed -i "s#%\(target_dir\|siteroot\)%#${RPM_INSTALL_PREFIX}#g;s#%lbenv_root%#${RPM_INSTALL_PREFIX}/var/lib/LbEnv/${flavour}#g" "${tgt}"
done
done
for script in ${RPM_INSTALL_PREFIX}/etc/cern_profile.{sh,csh} \
${RPM_INSTALL_PREFIX}/etc/cern_profile.d/cern_env.{sh,csh} ; do
sed -i "s#%target_dir%#${RPM_INSTALL_PREFIX}#g" "${script}"
done
%postun -p /bin/bash
%files
%defattr(-,root,root)
%{prefix}/etc/cern_profile.sh
%{prefix}/etc/cern_profile.csh
%{prefix}/etc/cern_profile.d/cern_env.sh
%{prefix}/etc/cern_profile.d/cern_env.csh
%{prefix}/bin/host_os
%{prefix}/LbEnv
%{prefix}/LbEnv.sh
%{prefix}/LbEnv.csh
%{prefix}/LbEnv-stable
%{prefix}/LbEnv-stable.sh
%{prefix}/LbEnv-stable.csh
%{prefix}/LbEnv-testing
%{prefix}/LbEnv-testing.sh
%{prefix}/LbEnv-testing.csh
%{prefix}/LbEnv-unstable
%{prefix}/LbEnv-unstable.sh
%{prefix}/LbEnv-unstable.csh
%changelog
* Mon Feb 25 2015 Marco Clemencic <marco.clemencic@cern.ch>
- first version
#!/usr/bin/printf you must "source %s"\n
###############################################################################
# (c) Copyright 2018 CERN #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "LICENSE". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
test -n "$tcsh" && set _shell_ext='csh' || _shell_ext='sh'
source %target_dir%/LbEnv-%flavour%.$_shell_ext
unset _shell_ext
#!/usr/bin/printf you must "source %s"\n
###############################################################################
# (c) Copyright 2018 CERN #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "LICENSE". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
if ( ! $?LBENV_SOURCED ) then
set _host_os=`%target_dir%/bin/host_os`
if ( -e %lbenv_root%/$_host_os/bin/activate.csh ) then
source %lbenv_root%/$_host_os/bin/activate.csh
eval `python -m LbEnv --csh --siteroot %siteroot% !:2* || echo deactivate`
else
echo "Platform not supported ($_host_os)"
endif
unset _host_os
else
if ( $?LBENV_ALIASES ) then
source "$LBENV_ALIASES"
endif
endif
#!/usr/bin/printf you must "source %s"\n
###############################################################################
# (c) Copyright 2018 CERN #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "LICENSE". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
if [ -z "$LBENV_SOURCED" ] ; then
_host_os=$(%target_dir%/bin/host_os)
if [ -e %lbenv_root%/$_host_os/bin/activate ] ; then
source %lbenv_root%/$_host_os/bin/activate
eval $(python -m LbEnv --sh --siteroot %siteroot% "$@" || echo deactivate)
else
echo "Platform not supported ($_host_os)"
fi
unset _host_os
else
if [ -n "$LBENV_ALIASES" ] ; then
source "$LBENV_ALIASES"
fi
fi
#!/bin/bash
###############################################################################
# (c) Copyright 2018 CERN #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "LICENSE". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
if [ -e /etc/redhat-release ] ; then
if grep -q -E '(CentOS|Scientific Linux).*release 7' /etc/redhat-release ; then
_os=centos7
elif grep -q -E '(CentOS|Scientific Linux).*release 6' /etc/redhat-release ; then
_os=slc6
elif grep -q -E '(CentOS|Scientific Linux).*release 5' /etc/redhat-release ; then
_os=slc5
fi
elif [ -e /etc/lsb-release ] ; then
_os=$(awk -F= '/^DISTRIB_ID/{n=tolower($2)}/^DISTRIB_RELEASE/{gsub("\\.", "", $2); v=$2}END{print n""v}' /etc/lsb-release)
fi
echo $(uname -m)-${_os}
#!/usr/bin/printf you must "source %s"\n
###############################################################################
# (c) Copyright 2019 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
# see cern_profile.sh for documentation
if ( -e "${HOME}" && ! ( -e "${HOME}/.nogrouplogin" || -e "${HOME}/.noLHCBLoginscript" ) ) then
# customization enabled
foreach _f ( %target_dir%/etc/cern_profile.d/*.csh )
source ${_f}
endif
if ( ! -e "${HOME}/.nolbenv" ) then
# LbEnv enabled
# - check the requested flavour
if ( -e "${HOME}/.devLHCBLoginscript" ) then
# this is legacy for...
set _lbenv_flavour=testing
else
# this is the default
set _lbenv_flavour=stable
endif
if ( -e "${HOME}/.lbenv_flavour" ) then
# check the content of the special file
set _lbenv_flavour=`cat "${HOME}/.lbenv_flavour"`
switch ("${_lbenv_flavour}")
case stable:
case testing:
case unstable:
breaksw # these are fine, nothing to do
default:
# anything else maps to stable
set _lbenv_flavour=stable
breaksw
endsw
endif
# source the LbEnv main script
if ( -e %target_dir%/LbEnv-${_lbenv_flavour}.csh ) then
source %target_dir%/LbEnv-${_lbenv_flavour}.csh
endif
endif
endif
#!/usr/bin/printf you must "source %s"\n
###############################################################################
# (c) Copyright 2019 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
# CERN specific environment
setenv LHCBDEV /afs/cern.ch/lhcb/software/DEV
setenv LHCBDOC /eos/project/l/lhcbwebsites/www/projects
setenv LHCBNIGHTLIES /cvmfs/lhcbdev.cern.ch/nightlies
# For grid usage
if ( ! -n ?$X509_CERT_DIR ) then
if ( -d /etc/grid-security/certificates ) then
setenv X509_CERT_DIR /etc/grid-security/certificates
elif ( -d /cvmfs/lhcb.cern.ch/etc/grid-security/certificates ) then
setenv X509_CERT_DIR /cvmfs/lhcb.cern.ch/etc/grid-security/certificates
fi
fi
if ( ! $?X509_VOMS_DIR ) then
if ( -d /etc/grid-security/vomsdir ) then
setenv X509_VOMS_DIR /etc/grid-security/vomsdir
elif ( -d /cvmfs/lhcb.cern.ch/etc/grid-security/vomsdir ) then
setenv X509_VOMS_DIR /cvmfs/lhcb.cern.ch/etc/grid-security/vomsdir
fi
fi
# Variable to access the LHCb CASTOR instance
setenv STAGE_HOST castorlhcb.cern.ch
# LHCb Emacs mode
setenv EMACSDIR /cvmfs/lhcb.cern.ch/lib/lhcb/TOOLS/Tools/Emacs/pro
#!/usr/bin/printf you must "source %s"\n
###############################################################################
# (c) Copyright 2019 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
# CERN specific environment
export LHCBDEV=/afs/cern.ch/lhcb/software/DEV
export LHCBDOC=/eos/project/l/lhcbwebsites/www/projects
export LHCBNIGHTLIES=/cvmfs/lhcbdev.cern.ch/nightlies
# For grid usage
if [ ! -n "$X509_CERT_DIR" ] ; then
if [ -d /etc/grid-security/certificates ] ; then
export X509_CERT_DIR=/etc/grid-security/certificates
elif [ -d /cvmfs/lhcb.cern.ch/etc/grid-security/certificates ] ; then
export X509_CERT_DIR=/cvmfs/lhcb.cern.ch/etc/grid-security/certificates
fi
fi
if [ ! -n "$X509_VOMS_DIR" ] ; then
if [ -d /etc/grid-security/vomsdir ] ; then
export X509_VOMS_DIR=/etc/grid-security/vomsdir
elif [ -d /cvmfs/lhcb.cern.ch/etc/grid-security/vomsdir ] ; then
export X509_VOMS_DIR=/cvmfs/lhcb.cern.ch/etc/grid-security/vomsdir
fi
fi
# Variable to access the LHCb CASTOR instance
export STAGE_HOST=castorlhcb.cern.ch
# LHCb Emacs mode
export EMACSDIR=/cvmfs/lhcb.cern.ch/lib/lhcb/TOOLS/Tools/Emacs/pro
#!/usr/bin/printf you must "source %s"\n
###############################################################################
# (c) Copyright 2019 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
#.md
# # Environment customization logic for CERN site.
#
# By default this script sets site specific environment variables and enable
# the LHCb User Environment (LbEnv) toolkit (e.g. lb-run, lb-dev).
#
# The user can control the behaviour of the script by means of special files
# in the home directory:
# - `.nogrouplogin`: if present, completely disable customization
# - `.nolbenv`: if present, disable LbEnv, but keep site specific variables
# - `.lbenv_flavour`: it must contain any of _stable_, _testing_ or _unstable_
# to select the version of LbEnv kit to use. If missing or invalid, it is
# equivalent to _stable_
#
# For backward compatibility we also accept:
# - `.noLHCBLoginscript`: same as `.nogrouplogin`
# - `.devLHCBLoginscript`: if present, equivalent to `.lbenv_flavour` containing
# _testing_
#
if [ -e "${HOME}" -a ! \( -e "${HOME}/.nogrouplogin" -o -e "${HOME}/.noLHCBLoginscript" \) ] ; then
# customization enabled
for _f in %target_dir%/etc/cern_profile.d/*.sh ; do
source ${_f}
fi
if [ ! -e "${HOME}/.nolbenv" ] ; then
# LbEnv enabled
# - check the requested flavour
if [ -e "${HOME}/.devLHCBLoginscript" ] ; then
# this is legacy for...
_lbenv_flavour=testing
else
# this is the default
_lbenv_flavour=stable
fi
if [ -e "${HOME}/.lbenv_flavour" ] ; then
# check the content of the special file
_lbenv_flavour=$(cat "${HOME}/.lbenv_flavour")
case "${_lbenv_flavour}" in
stable|testing|unstable) ;; # these are fine, nothing to do
*) _lbenv_flavour=stable ;; # anything else maps to stable
esac
fi
# source the LbEnv main script
if [ -e %target_dir%/LbEnv-${_lbenv_flavour}.sh ] ; then
source %target_dir%/LbEnv-${_lbenv_flavour}.sh
fi
fi
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment