Skip to content

Commit

Permalink
sync bootstrap changes for gcc11
Browse files Browse the repository at this point in the history
  • Loading branch information
smuzaffar committed Oct 11, 2021
1 parent 18b6e5f commit 1619992
Show file tree
Hide file tree
Showing 15 changed files with 198 additions and 126 deletions.
55 changes: 0 additions & 55 deletions bazel-0.29.1-patches.patch

This file was deleted.

2 changes: 1 addition & 1 deletion bison.spec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### RPM external bison 3.5
### RPM external bison 3.6.1
## INITENV SET BISON_PKGDATADIR %{i}/share/bison

Source: http://ftp.gnu.org/gnu/%{n}/%{n}-%{realversion}.tar.gz
Expand Down
11 changes: 3 additions & 8 deletions bootstrap-bundle.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
### RPM external bootstrap-bundle 2.0
## INITENV +PATH PATH %{i}/bin
## INITENV SET MAGIC %{i}/share/misc/magic.mgc
### RPM external bootstrap-bundle 3.0
## NO_AUTO_DEPENDENCY
## NOCOMPILER

BuildRequires: gcc
Expand Down Expand Up @@ -40,6 +39,7 @@ cp -P $GCC_ROOT/lib/libelf.%{soname}* %{i}/lib
cp -P $GCC_ROOT/lib/libelf-*.%{soname} %{i}/lib
cp -P $GCC_ROOT/lib/libdw.%{soname}* %{i}/lib
cp -P $GCC_ROOT/lib/libdw-*.%{soname} %{i}/lib
cp -P $GCC_ROOT/bin/readelf %{i}/bin
%endif

find %{i}/bin -type f -writable -exec %{strip} {} \;
Expand All @@ -55,8 +55,3 @@ mv %{i}/lib/lib{lua,archive}.a %{i}/tmp
rm -f %{i}/lib/*.{l,}a
mv %{i}/tmp/lib* %{i}/lib/
rm -rf %{i}/tmp

touch %{i}/etc/profile.d/dependencies-setup.sh %{i}/etc/profile.d/dependencies-setup.csh

%post
rm -f $RPM_INSTALL_PREFIX/%{pkgrel}/etc/profile.d/dependencies-setup.*
1 change: 0 additions & 1 deletion file-bootstrap.spec
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
### RPM external file-bootstrap 5.33
%define file_tag %(echo FILE%{realversion} | tr . _)
Source: https://github.com/file/file/archive/%{file_tag}.tar.gz
BuildRequires: autotools

%prep
%setup -n file-%{file_tag}
Expand Down
13 changes: 0 additions & 13 deletions frontier_client-2.8.20-openssl11.patch

This file was deleted.

2 changes: 1 addition & 1 deletion libarchive-bootstrap.spec
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### RPM external libarchive-bootstrap 3.3.2
### RPM external libarchive-bootstrap 3.5.1
Source0: http://www.libarchive.org/downloads/libarchive-%{realversion}.tar.gz

Requires: xz-bootstrap
Expand Down
18 changes: 17 additions & 1 deletion madgraph5amcatnlo.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ Provides: perl(Compress::Zlib)
Provides: perl(List::Util)
Source: https://launchpad.net/mg5amcnlo/2.0/2.7.x/+download/MG5_aMC_v%{realversion}.py3.tar.gz
Patch0: madgraph5amcatnlo-config
# Compile and install internal and external packages
Patch1: madgraph5amcatnlo-compile
#Python 3.9, use of math.gcd instead of fractions.gcd
Patch1: madgraph5amcatnlo-py39
Patch2: madgraph5amcatnlo-py39

Requires: python3 py3-six
Requires: hepmc
Expand All @@ -22,6 +24,7 @@ Requires: thepeg
%setup -n MG5_aMC_v%{versiontag}_py3
%patch0 -p1
%patch1 -p1
%patch2 -p1

sed -i -e "s|\${HEPMC_ROOT}|${HEPMC_ROOT}|g" input/mg5_configuration.txt
sed -i -e "s|\${PYTHIA8_ROOT}|${PYTHIA8_ROOT}|g" input/mg5_configuration.txt
Expand All @@ -34,6 +37,18 @@ sed -i -e "s|SHFLAG = \-fPIC|SHFLAG = \-fPIC \-fcommon|g" vendor/StdHEP/src/stdh

%build
export FC="$(which gfortran) -std=legacy"
# Save patched config
cp input/mg5_configuration.txt input/mg5_configuration_patched.txt

# Compile in advance
chmod +x bin/compile.py
./bin/compile.py
# Remove compile script after compilation
rm bin/compile.py

# Add back patched config after compilation since its get overwritten
# Save patched config
mv input/mg5_configuration_patched.txt input/mg5_configuration.txt

# Start small NLO event generation to make sure that all additional packages are compiled
cat <<EOF > basiceventgeneration.txt
Expand All @@ -48,6 +63,7 @@ EOF
find . -type f -name '*.tgz' -delete

%install
sed -i -e "s|@MADGRAPH5AMCATNLO_ROOT@|%{i}|g" input/mg5_configuration.txt
rsync -avh %{_builddir}/MG5_aMC_v%{versiontag}_py3/ %{i}/
sed -ideleteme 's|#!.*/bin/python|#!/usr/bin/env python|' \
%{i}/Template/LO/bin/internal/addmasses_optional.py \
Expand Down
11 changes: 0 additions & 11 deletions make-4.2.1.patch

This file was deleted.

21 changes: 21 additions & 0 deletions patchelf-bootstrap.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
### RPM external patchelf-bootstrap 0.13
## NO_AUTO_RUNPATH

%define git_branch master
%define git_commit %{realversion}
Source0: git://github.com/NixOS/patchelf.git?obj=%{git_branch}/%{git_commit}&export=patchelf-%{realversion}&output=/patchelf-%{realversion}.tgz
BuildRequires: autotools

%define drop_files %{i}/share

%prep
%setup -n patchelf-%{realversion}

%build

./bootstrap.sh
./configure --prefix=%{i}
make %{makeprocesses}

%install
make install
1 change: 1 addition & 0 deletions root.spec
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ cmake ../%{n}-%{realversion} \
-DCMAKE_LINKER=ld \
-DCMAKE_VERBOSE_MAKEFILE=TRUE \
-Droot7=ON \
-Druntime_cxxmodules=ON \
-Dfail-on-missing=ON \
-Dgnuinstall=OFF \
-Droofit=ON \
Expand Down
31 changes: 16 additions & 15 deletions rpm-preamble.file
Original file line number Diff line number Diff line change
Expand Up @@ -168,31 +168,23 @@
# No %_excludedocs
# No Packager:
# No Provides:
# FIXME need %make -> gmake/make as appropriate?

# Define a little helper scriptlet to source package inits from other
# packages. This allows cross-package environment setup to work while
# building. See above how we determine the list by parsing the spec
# itself.
%{expand:%%define rpmbuild_libdir :%(echo $LD_LIBRARY_PATH | tr ':' '\n' | grep '/external/bootstrap-bundle/')}
%define rpmbuild_env LD_LIBRARY_PATH=${LD_LIBRARY_PATH}%{rpmbuild_libdir}
%define drop_bootstrap_path export PATH=$(echo $PATH | tr ':' '\\n' | grep -v '/external/bootstrap-bundle/' | tr '\\n' ':' | sed 's|:*$||')
%define drop_bootstrap_lib export LD_LIBRARY_PATH=$(echo $LD_LIBRARY_PATH | tr ':' '\\n' | grep -v '/external/bootstrap-bundle/' | tr '\\n' ':' | sed 's|:*$||')
%define drop_bootstrap_env %{drop_bootstrap_path}; %{drop_bootstrap_lib}
%define drop_bootstrap_path export PATH=$(echo $PATH | tr ':' '\\n' | grep -v '/external/bootstrap-bundle/' | tr '\\n' ':' | sed 's|:*$||')
%define drop_bootstrap_lib export %{dynamic_path_var}=$(echo $%{dynamic_path_var} | tr ':' '\\n' | grep -v '/external/bootstrap-bundle/' | tr '\\n' ':' | sed 's|:*$||')
%define disable_recursive_env %{drop_bootstrap_path}; %{drop_bootstrap_lib}; export _CMSBUILD_BUILD_ENV_=1
%if "%archfirst" == "yes"
%define initenv_all %{drop_bootstrap_env} ; for x in %{allpkgreqs} .; do i=%{cmsroot}/%{cmsplatf}/$x/etc/profile.d/init.sh; [ -f $i ] && . $i; done
%define initenv_direct %{drop_bootstrap_env} ; for x in %{directpkgreqs} %{builddirectpkgreqs} .; do i=%{cmsroot}/%{cmsplatf}/$x/etc/profile.d/init.sh; [ -f $i ] && . $i; done
%define post_initenv unset %{dynamic_path_var}; for x in %{allpkgreqs} %{pkgdir} ; do i=$RPM_INSTALL_PREFIX/%{cmsplatf}/$x/etc/profile.d/init.sh; [ -f $i ] && . $i; done
%define initenv_all %{disable_recursive_env} ; for x in %{allpkgreqs} .; do i=%{cmsroot}/%{cmsplatf}/$x/etc/profile.d/init.sh; [ -f $i ] && . $i; done
%define initenv_direct %{disable_recursive_env} ; for x in %{directpkgreqs} %{builddirectpkgreqs} .; do i=%{cmsroot}/%{cmsplatf}/$x/etc/profile.d/init.sh; [ -f $i ] && . $i; done
%else
%define initenv_all %{drop_bootstrap_env} ; for x in %{allpkgreqs} .; do i=%{cmsroot}/$x/%{cmsplatf}/etc/profile.d/init.sh; [ -f $i ] && . $i; done
%define initenv_direct %{drop_bootstrap_env} ; for x in %{directpkgreqs} %{builddirectpkgreqs} .; do i=%{cmsroot}/$x/%{cmsplatf}/etc/profile.d/init.sh; [ -f $i ] && . $i; done
%define post_initenv unset %{dynamic_path_var}; for x in %{allpkgreqs} %{pkgdir} ; do i=$RPM_INSTALL_PREFIX/$x/%{cmsplatf}/etc/profile.d/init.sh; [ -f $i ] && . $i; done
%define initenv_all %{disable_recursive_env} ; for x in %{allpkgreqs} .; do i=%{cmsroot}/$x/%{cmsplatf}/etc/profile.d/init.sh; [ -f $i ] && . $i; done
%define initenv_direct %{disable_recursive_env} ; for x in %{directpkgreqs} %{builddirectpkgreqs} .; do i=%{cmsroot}/$x/%{cmsplatf}/etc/profile.d/init.sh; [ -f $i ] && . $i; done
%endif
%define initenv %initenv_all

%define add_rpath (RPATH_ELF_BIN=$(find $RPM_INSTALL_PREFIX/%{pkgrel} -type f -exec file {} \\; | grep ' ELF ' | grep ' executable' | cut -d':' -f1) && \
echo "$RPATH_ELF_BIN" | xargs -n 1 -I{} -P $(getconf _NPROCESSORS_ONLN) sh -c "cp {} {}.post-tmp && chmod u+w {}.post-tmp && patchelf --set-rpath $%{dynamic_path_var} --force-rpath {}.post-tmp && chmod --reference={} {}.post-tmp && mv {}.post-tmp {}" )

%if "%{?compiling_processes:set}" == "set"
%define makeprocesses -j %compiling_processes
%else
Expand Down Expand Up @@ -224,6 +216,15 @@
sed -i -e "${lnum}c#!/usr/bin/env python" $py \
done

#RunPath commands
%define runpath_install \
script=${RPM_POPTEXEC_PATH}/set_runpath; \
if [ -e %{i}/etc/profile.d/set_runpath ] ; then script=%{i}/etc/profile.d/set_runpath; fi ;\
force_rpath=""; \
if [ "%{force_rpath}" = "true" ] ; then force_rpath='--force-rpath'; fi; \
. %{i}/etc/profile.d/init.sh; \
PATH="${RPM_POPTEXEC_PATH}:${PATH}" $script --prefix %{cmsroot}/%{cmsplatf} --package %{i} --jobs %{compiling_processes} %{?runpath_opts:%runpath_opts} ${force_rpath}

# On macosx one needs to use the -x option, to avoid excessive stripping.
%ifos darwin
%define strip strip -x
Expand Down
111 changes: 111 additions & 0 deletions rpm-set_runpath.file
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/bin/bash -ex

function set_runpath()
{
[ $(readelf -d ${1} 2>&1 | grep '(NEEDED)' |wc -l) -eq 0 ] && return
cp ${1} ${1}.post-tmp
chmod u+w ${1}.post-tmp
local ERR=true
if patchelf --set-rpath ${LD_LIBRARY_PATH_ENV} ${FORCE_RPATH} ${1}.post-tmp ; then
if [ "${SET_RUNPATH}" = "" ] ; then
if patchelf --shrink-rpath ${1}.post-tmp ; then
rpath=""
local d=$(dirname ${1} | sed 's|^./||')
local r1=$(echo $d | sed 's|[^/][^/]*|..|g')
local r2="${r1}/../../.."
for p in $(patchelf --print-rpath ${1}.post-tmp | tr ':' '\n') ; do
case $p in
${PACKAGE_PATH}/${d}) rpath="${rpath}:\$ORIGIN" ;;
${PACKAGE_PATH}/*) p=$(echo $p | sed "s|${PACKAGE_PATH}/||"); rpath="${rpath}:\$ORIGIN/${r1}/${p}" ;;
${INSTALL_PREFIX}/*) p=$(echo $p | sed "s|${INSTALL_PREFIX}/||"); rpath="${rpath}:\$ORIGIN/${r2}/${p}" ;;
*) rpath="${rpath}:${p}" ;;
esac
done
rpath=$(echo ${rpath} | sed 's|^:||')
if [ "${rpath}" != "" -a "${rpath}" != "${LD_LIBRARY_PATH_ENV}" ] ; then
patchelf --set-rpath ${rpath} ${FORCE_RPATH} ${1}.post-tmp
fi
ERR=false
fi
else
ERR=false
fi
fi
if $ERR ; then
touch ${PACKAGE_PATH}/error.set_runpath
echo "ERROR: $1"
rm ${1}.post-tmp
else
chmod --reference=${1} ${1}.post-tmp
mv ${1}.post-tmp ${1}
touch ${1}.cmsdist_runpath
fi
}

INSTALL_PREFIX=""
PACKAGE_PATH=""
FORCE_RPATH=""
SET_RUNPATH=""
MATCH="lib lib64 bin"
NAME="py pyc pyi h hh hpp inc"
MAX_JOBS=$(getconf _NPROCESSORS_ONLN)
let STIME=$(date +%s)

while [ ! X$# = X0 ]; do
arg=$1 ; shift
case $arg in
--prefix) INSTALL_PREFIX=$1 ; shift ;;
--package) PACKAGE_PATH=$1 ; shift ;;
--force-rpath) FORCE_RPATH='--force-rpath' ;;
--rpath) SET_RUNPATH=$1 ; shift ;;
-m|--match) MATCH="$MATCH $1"; shift ;;
-n|--not-name) NAME="$NAME $1" ; shift ;;
--jobs) MAX_JOBS="$1" ; shift ;;
--help)
echo "Usage: $0 --prefix /install/prefix/arch --package package-rootdir [--force-rpath] [--rpath runpath-to-set] [--patchelf patchelf-path] [--jobs N] [--help]"
echo "e.g."
echo "$0 --prefix /build/cms/slc7_amd64_gcc900 --package /build/cms/slc7_amd64_gcc900/lcg/root/6.24.00 --patchelf /build/cms/slc7_amd64_gcc900/externals/rpm/4.15.0/bin/patchelf"
exit 0
;;
*) echo "Unknown command $1" ; exit 1 ;;
esac
done

[ "${INSTALL_PREFIX}" != "" ] || exit 1
[ "${PACKAGE_PATH}" != "" ] || exit 1

LD_LIBRARY_PATH_ENV="${SET_RUNPATH}"
if [ "${SET_RUNPATH}" = "" ] ; then
case $(uname -s) in
Linux) LD_LIBRARY_PATH_ENV="${LD_LIBRARY_PATH}" ;;
Darwin) LD_LIBRARY_PATH_ENV="${DYLD_FALLBACK_LIBRARY_PATH}" ;;
esac
fi

cnt=0
pcnt=0
if [ "${LD_LIBRARY_PATH_ENV}" != "" ] ; then
pushd ${PACKAGE_PATH}
rm -f error.set_runpath
mdir="" ; name=""
for d in $(echo ${MATCH} | tr ' ' '\n' | grep -v '^$' | sort | uniq) ; do mdir="${mdir} -path './$d/*' -o "; done
for d in $(echo ${NAME} | tr ' ' '\n' | grep -v '^$' | sort | uniq) ; do name="${name} -not -name '*.$d' -a "; done
mdir=$(echo "$mdir" | sed 's|-o $||')
name=$(echo "$name" | sed 's|-a $||')
mkdir -p ./etc/profile.d
for fpath in $(eval "find . -path './*/__pycache__' -prune -o \( $mdir \) -a \( $name \) -a -type f -print") ; do
let cnt=$cnt+1
while [ $(jobs -p | wc -l) -gt ${MAX_JOBS} ] ; do sleep 0.1 ; done
set_runpath $fpath &
done
wait
find . -name '*.cmsdist_runpath' -type f > etc/profile.d/set_runpath.txt
cat etc/profile.d/set_runpath.txt | xargs --no-run-if-empty rm -f
pcnt=$(cat etc/profile.d/set_runpath.txt | wc -l)
popd
fi

let DTIME=$(date +%s)-${STIME} || true
echo "Runpath took ${DTIME} secs for $pcnt/$cnt files"

[ ! -e ${PACKAGE_PATH}/error.set_runpath ] || exit 1
Loading

0 comments on commit 1619992

Please sign in to comment.