build_inf_prepare_jenkins: fix for lighttpd config
[pti/rtp.git] / scripts / build_inf_centos / build_inf_prepare_jenkins.sh
index 5e941eb..dc71a93 100755 (executable)
@@ -93,6 +93,7 @@ export BUILD_GROUP="jenkins"
 export WGET_OPENDEV="wget --no-check-certificate"
 export LOCALDISK="${WORKSPACE}/localdisk"
 export MIRROR_DIR="${WORKSPACE}/mirror"
+export TOOLS_DIR="${WORKSPACE}/tools"
 
 mkdir -p ${LOCALDISK}/loadbuild/mock-cache
 mkdir -p ${LOCALDISK}/loadbuild/mock
@@ -122,13 +123,11 @@ sudo yum install -y \
     createrepo \
     createrepo_c \
     deltarpm \
-    docker-client \
     expat-devel \
     flex \
     isomd5sum \
     gcc \
     gettext \
-    git \
     libguestfs-tools \
     libtool \
     libxml2 \
@@ -169,15 +168,17 @@ sudo yum install -y \
     wget
 
 # clone the tools repo
-cd ~
+cd ${WORKSPACE}
 git clone https://opendev.org/starlingx/tools.git
 
 # mock custumizations
 # forcing chroots since a couple of packages naughtily insist on network access and
 # we dont have nspawn and networks happy together.
+sudo groupadd -g 9001 mockbuild
 sudo useradd -s /sbin/nologin -u 9001 -g 9001 mockbuild
 sudo rmdir /var/lib/mock
 sudo ln -s ${LOCALDISK}/loadbuild/mock /var/lib/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
@@ -200,14 +201,14 @@ export GOPATH="/usr/local/go"
 export PATH="${GOPATH}/bin:${PATH}"
 sudo yum install -y golang
 sudo mkdir -p ${GOPATH}/bin
-curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sudo sh
+curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sudo -E sh
 
 # pip installs
 # Install required python modules globally; versions are in the constraints file.
 # Be careful not to replace modules provided by RPMs as it may break
 # other system packages. Look for warnings similar to "Uninstalling a
 # distutils installed project has been deprecated" from pip.
-sudo pip install -c ~/tools/toCOPY/builder-constraints.txt \
+sudo pip install -c ${TOOLS_DIR}/toCOPY/builder-constraints.txt \
     testrepository \
     fixtures \
     pbr \
@@ -216,32 +217,25 @@ sudo pip install -c ~/tools/toCOPY/builder-constraints.txt \
     junitxml \
     testtools
 
-# Create a sane py27 virtualenv
-virtualenv /opt/py27 && \
-    source /opt/py27/bin/activate && \
-    sudo pip install -c ~/tools/toCOPY/builder-opt-py27-constraints.txt \
-            tox \
-        && \
-    for prog in tox ; do \
-        ln -s /opt/py27/bin/$prog /usr/bin ; \
-    done
+
 
 # Inherited  tools for mock stuff
 # we at least need the mock_cache_unlock tool
 # they install into /usr/bin
-sudo cp -rf ~/tools/toCOPY/mock_overlay /opt/mock_overlay
-cd /opt/mock_overlay
+mkdir -p ${WORKSPACE}/opt
+cp -rf ${TOOLS_DIR}/toCOPY/mock_overlay ${WORKSPACE}/opt/mock_overlay
+cd ${WORKSPACE}/opt/mock_overlay
 make
 sudo make install
 
 # This image requires a set of scripts and helpers
 # for working correctly, in this section they are
 # copied inside the image.
-sudo cp ~/tools/toCOPY/finishSetup.sh /usr/local/bin
-sudo cp ~/tools/toCOPY/populate_downloads.sh /usr/local/bin
-sudo cp ~/tools/toCOPY/generate-local-repo.sh /usr/local/bin
-sudo cp ~/tools/toCOPY/generate-centos-repo.sh /usr/local/bin
-sudo cp ~/tools/toCOPY/lst_utils.sh /usr/local/bin
+sudo cp ${TOOLS_DIR}/toCOPY/finishSetup.sh /usr/local/bin
+sudo cp ${TOOLS_DIR}/toCOPY/populate_downloads.sh /usr/local/bin
+sudo cp ${TOOLS_DIR}/toCOPY/generate-local-repo.sh /usr/local/bin
+sudo cp ${TOOLS_DIR}/toCOPY/generate-centos-repo.sh /usr/local/bin
+sudo cp ${TOOLS_DIR}/toCOPY/lst_utils.sh /usr/local/bin
 
 # centos locales are broken. this needs to be run after the last yum install/update
 sudo localedef -i en_US -f UTF-8 en_US.UTF-8
@@ -251,10 +245,11 @@ sudo mkdir -p /www/run
 sudo mkdir -p /www/logs
 sudo mkdir -p /www/home
 sudo mkdir -p /www/root/htdocs/localdisk
+sudo mkdir -p /www/root/htdocs/$(dirname ${WORKSPACE})
 sudo ln -s ${LOCALDISK}/loadbuild /www/root/htdocs/localdisk/loadbuild
-sudo ln -s ${MIRROR_DIR}/CentOS /www/root/htdocs/CentOS
 sudo ln -s ${LOCALDISK}/designer /www/root/htdocs/localdisk/designer
-sudo ln -s ${WORKSPACE} /www/root/htdocs/workspace
+sudo ln -s ${MIRROR_DIR}/CentOS /www/root/htdocs/CentOS
+sudo ln -s ${WORKSPACE} /www/root/htdocs/${WORKSPACE}
 
 # lighthttpd setup
 # chmod for /var/log/lighttpd fixes a centos issue
@@ -273,7 +268,6 @@ sudo sed -i -e 's%^var\.log_root.*$%var.log_root = "/www/logs"%g' \
     -e "s/server.bind/#server.bind/g" \
     -e "s/server.document-root/#server.document-root/g" \
     -e "s/server.dirlisting/#server.dirlisting/g" \
-    -e "s/dir-listing.activate/#dir-listing.activate/g" \
     /etc/lighttpd/lighttpd.conf
 
 echo "server.port = 8088" | sudo tee -a /etc/lighttpd/lighttpd.conf 
@@ -282,16 +276,23 @@ 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
 
+ps -ef|grep lighttpd || true
+curl 127.0.0.1:8088${WORKSPACE} || true
+
 sudo chmod a+x /usr/local/bin/*
 
 # Customizations for mirror creation
 sudo rm -f /etc/yum.repos.d/*
-sudo cp -f ~/tools/centos-mirror-tools/yum.repos.d/* /etc/yum.repos.d/
-sudo cp -f ~/tools/centos-mirror-tools/rpm-gpg-keys/* /etc/pki/rpm-gpg/
+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*
@@ -299,4 +300,10 @@ 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
 
+# Create a sane py27 virtualenv
+virtualenv ${WORKSPACE}/opt/py27
+source ${WORKSPACE}/opt/py27/bin/activate
+pip install -c ${TOOLS_DIR}/toCOPY/builder-opt-py27-constraints.txt tox
+sudo ln -s ${WORKSPACE}/opt/py27/bin/tox /usr/bin
+
 echo_step_end