6 # Wait for other apt process to finish by checking the dpkg lock file.
8 while sudo lsof ${DPKG_LOCK} > /dev/null 2>&1 ; do
9 echo "DPKG file locked: ${DPKG_LOCK}."
10 echo " Waiting for another pkg instalaltion process to finish ..."
12 if [[ ${try} -gt 60 ]] ; then
13 echo "ERROR: Max number of re-tries reached, exiting..."
19 sudo apt install -y -q=3 python3-minimal python3-pip virtualenv
21 # workaround for https://github.com/pypa/virtualenv/issues/1029
25 echo "----------------------------------------------------"
26 echo "Info: Create virtualenv to update Jenkins slaves"
27 virtualenv -p python3 --quiet --no-site-packages .venv
28 source .venv/bin/activate
29 pip install python-openstackclient
30 echo "----------------------------------------------------"
31 echo "Info : Installing packer version ${PACKER_VERSION}"
32 wget -q "https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER_VERSION}_linux_amd64.zip" -O /tmp/packer.zip
33 unzip /tmp/packer.zip > /dev/null 2>&1
34 sudo mv -f ./packer /usr/local/bin/packer
35 sudo chmod +x /usr/local/bin/packer
36 echo "----------------------------------------------------"
38 /bin/rm -f /tmp/packer.zip
39 # shellcheck disable=SC1091
41 echo "----------------------------------------------------"
42 echo "Info: Create backup of existing image"
44 BACKUP_ZONE_ID=$(openstack image list --property name=${IMAGE} -f value -c ID)
45 openstack image set --name "${IMAGE}-backup-$GIT_COMMIT" "$BACKUP_ZONE_ID"
46 echo "----------------------------------------------------"
47 echo "Info: Updating the CI slave image"
48 cd "infra/jenkins/slave-setup/${TARGET}/"
49 packer validate *-ubuntu*.json
50 packer build *-ubuntu*.json
51 echo "----------------------------------------------------"