+get_tools_repo () {
+ msg_step="Clone the tools repo"
+ echo_step_start
+
+ cd ${SCRIPTS_DIR}
+ if [ -d tools/.git ]; then
+ echo_info "The 'tools' repo already exists, skipping"
+ else
+ git clone https://opendev.org/starlingx/tools.git
+ fi
+
+ echo_step_end
+}
+
+config_mock () {
+ msg_step="mock custumizations"
+ echo_step_start
+ # forcing chroots since a couple of packages naughtily insist on network access and
+ # we dont have nspawn and networks happy together.
+ sudo groupadd -f -g 9001 mockbuild
+ sudo useradd -s /sbin/nologin -u 9001 -g 9001 mockbuild || echo "User mockbuild already exists."
+ [ -L /var/lib/mock ] || {
+ sudo rmdir /var/lib/mock
+ sudo ln -s ${LOCALDISK}/loadbuild/mock /var/lib/mock
+ }
+
+ [ -L /var/cache/mock ] || {
+ sudo mv /var/cache/mock/* ${LOCALDISK}/loadbuild/mock-cache/
+ sudo rmdir /var/cache/mock
+ sudo ln -s ${LOCALDISK}/loadbuild/mock-cache /var/cache/mock
+ }
+ echo "config_opts['use_nspawn'] = False" | sudo tee -a /etc/mock/site-defaults.cfg
+ echo "config_opts['rpmbuild_networking'] = True" | sudo tee -a /etc/mock/site-defaults.cfg
+ echo | sudo tee -a /etc/mock/site-defaults.cfg
+
+ echo_step_end
+}
+
+install_mock_overlay () {
+ msg_step="Inherited tools for mock stuff"
+ echo_step_start
+
+ # we at least need the mock_cache_unlock tool
+ # they install into /usr/bin
+ cp -rf ${TOOLS_DIR}/toCOPY/mock_overlay ${TMP_OPT_DIR}/mock_overlay
+ cd ${TMP_OPT_DIR}/mock_overlay
+ make
+ sudo make install
+
+ echo_step_end
+}
+
+config_yum () {
+ msg_step="configs for yum and rpm"
+ echo_step_start
+
+ # Customizations for mirror creation
+ sudo rm -f /etc/yum.repos.d/*
+ sudo cp -f ${TOOLS_DIR}/centos-mirror-tools/yum.repos.d/* /etc/yum.repos.d/
+ sudo cp -f ${TOOLS_DIR}/centos-mirror-tools/rpm-gpg-keys/* /etc/pki/rpm-gpg/
+
+ # Import GPG keys
+ sudo rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
+
+ # Try to continue a yum command even if a StarlingX repo is unavailable.
+ sudo yum-config-manager --setopt=StarlingX\*.skip_if_unavailable=1 --save
+
+ echo_step_end
+}
+
+create_py27_venv () {
+ msg_step="Create a sane py27 virtualenv"
+ echo_step_start
+
+ virtualenv ${TMP_OPT_DIR}/py27
+ source ${TMP_OPT_DIR}/py27/bin/activate
+ pip install -c ${TOOLS_DIR}/toCOPY/builder-opt-py27-constraints.txt tox
+ sudo ln -s ${TMP_OPT_DIR}/py27/bin/tox /usr/bin
+
+ echo_step_end
+}
+
+setup_lighttpd () {
+ msg_step="Setup for lighttpd"
+ echo_step_start
+
+ sudo mkdir -p /www
+ sudo chown ${USER}:${BUILD_GROUP} /www
+ mkdir -p /www/run
+ mkdir -p /www/logs
+ mkdir -p /www/home
+ mkdir -p /www/root/htdocs/localdisk
+ mkdir -p /www/root/htdocs/$(dirname ${WORKSPACE})
+ ln -s ${LOCALDISK}/loadbuild /www/root/htdocs/localdisk/loadbuild
+ ln -s ${LOCALDISK}/designer /www/root/htdocs/localdisk/designer
+ ln -s ${MIRROR_DIR}/CentOS /www/root/htdocs/CentOS
+ ln -s ${WORKSPACE} /www/root/htdocs/${WORKSPACE}
+
+ # lighthttpd setup
+ # chmod for /var/log/lighttpd fixes a centos issue
+ # in place sed for server root since it's expanded soon thereafter
+ # echo "server.bind = \"localhost\"" >> /etc/lighttpd/lighttpd.conf && \
+ sudo mkdir -p /var/log/lighttpd
+ sudo chmod a+rwx /var/log/lighttpd/
+ sudo sed -i -e 's%^var\.log_root.*$%var.log_root = "/www/logs"%g' \
+ -e 's%^var\.server_root.*$%var.server_root = "/www/root"%g' \
+ -e 's%^var\.home_dir.*$%var.home_dir = "/www/home"%g' \
+ -e 's%^var\.state_dir.*$%var.state_dir = "/www/run"%g' \
+ -e "s/server.port/#server.port/g" \
+ -e "s/server.use-ipv6/#server.use-ipv6/g" \
+ -e "s/server.username/#server.username/g" \
+ -e "s/server.groupname/#server.groupname/g" \
+ -e "s/server.bind/#server.bind/g" \
+ -e "s/server.document-root/#server.document-root/g" \
+ -e "s/server.dirlisting/#server.dirlisting/g" \
+ /etc/lighttpd/lighttpd.conf
+
+ echo "server.port = 8088" | sudo tee -a /etc/lighttpd/lighttpd.conf
+ echo "server.use-ipv6 = \"disable\"" | sudo tee -a /etc/lighttpd/lighttpd.conf
+ echo "server.username = \"$USER\"" | sudo tee -a /etc/lighttpd/lighttpd.conf
+ echo "server.groupname = \"$BUILD_GROUP\"" | sudo tee -a /etc/lighttpd/lighttpd.conf
+ echo "server.bind = \"localhost\"" | sudo tee -a /etc/lighttpd/lighttpd.conf
+ echo "server.document-root = \"/www/root/htdocs\"" | sudo tee -a /etc/lighttpd/lighttpd.conf
+
+ sudo sed -i "s/dir-listing.activate/#dir-listing.activate/g" \
+ /etc/lighttpd/conf.d/dirlisting.conf
+
+ echo "dir-listing.activate = \"enable\"" | sudo tee -a /etc/lighttpd/conf.d/dirlisting.conf
+
+ sudo /usr/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
+
+ echo_step_end
+}