Install install-distro-packages.sh only for legacy jobs

Move install-distro-packages.sh from project-config to here so that we
can install it with legacy jobs only.
Add it to legacy/pre.yaml script.

Change-Id: I607baac9308abf7149b71419b9bb4c3c162677bf
This commit is contained in:
Andreas Jaeger 2018-02-07 17:26:12 +01:00
parent a91c4268ac
commit ecc577eb0e
2 changed files with 69 additions and 3 deletions

View File

@ -0,0 +1,63 @@
#!/bin/bash -xe
# set a default path to the preinstalled bindep entrypoint
export BINDEP=${BINDEP:-/usr/bindep-env/bin/bindep}
function is_fedora {
[ -f /usr/bin/yum ] && cat /etc/*release | grep -q -e "Fedora"
}
YUM=yum
if is_fedora; then
YUM=dnf
fi
# figure out which bindep list to use
if [ -n "$PACKAGES" ] ; then
# already set in the calling environment
:
elif [ -e bindep.txt ] ; then
# project has its own bindep list
export PACKAGES=bindep.txt
elif [ -e other-requirements.txt ] ; then
# project has its own bindep list
export PACKAGES=other-requirements.txt
else
# use the bindep fallback list preinstalled on the worker
export PACKAGES=/usr/local/jenkins/common_data/bindep-fallback.txt
fi
# an install loop, retrying to check that all requested packages are obtained
try=0
# Install test profile using bindep
until $BINDEP -b -f $PACKAGES test; do
if [ $try -gt 2 ] ; then
set +x
echo -e "\nERROR: These requested packages were not installed:\n" \
"\n`$BINDEP -b -f $PACKAGES test`\n" 1>&2
set -x
exit 1
fi
# don't abort inside the loop, we check for the desired outcome
set +e
if apt-get -v >/dev/null 2>&1 ; then
sudo apt-get -qq update
sudo PATH=/usr/sbin:/sbin:$PATH DEBIAN_FRONTEND=noninteractive \
apt-get -q --option "Dpkg::Options::=--force-confold" \
--assume-yes install `$BINDEP -b -f $PACKAGES test`
elif emerge --version >/dev/null 2>&1 ; then
sudo emerge -uDNq --jobs=4 @world
sudo PATH=/usr/sbin:/sbin:$PATH emerge -q --jobs=4 \
`$BINDEP -b -f $PACKAGES test`
elif zypper --version >/dev/null 2>&1 ; then
sudo PATH=/usr/sbin:/sbin:$PATH zypper --non-interactive install \
`$BINDEP -b -f $PACKAGES test`
else
sudo PATH=/usr/sbin:/sbin:$PATH $YUM install -y \
`$BINDEP -b -f $PACKAGES test`
fi
set -e
try=$(( $try+1 ))
done

View File

@ -44,11 +44,14 @@
- id_rsa
- id_rsa.pub
- name: Copy zuul-sudo-grep.sh to the script dir on the node
- name: Copy files to the script dir on the node
copy:
dest: /usr/local/jenkins/slave_scripts/zuul-sudo-grep.sh
src: zuul-sudo-grep.sh
dest: '/usr/local/jenkins/slave_scripts/{{ item }}'
src: '{{ item }}'
mode: 0755
with_items:
- install-distro-packages.sh
- zuul-sudo-grep.sh
become: true
- name: Add sudoers role for zuul-sudo-grep.sh