From 055fd87fab63257ff669cbb9d92302791ed80984 Mon Sep 17 00:00:00 2001
From: Eric Cano <Eric.Cano@cern.ch>
Date: Tue, 28 Mar 2017 18:17:13 +0200
Subject: [PATCH] Added symlinking of buildtree in bin/lib.

Fixed home directory not readable (prevented the frontend from running).
Added installation of CASTOR's rmcd to the image.
---
 .../buildtree_runner/vmBootstrap/bootstrapSystem.sh    |  1 +
 .../docker/buildtree_runner/cc7/opt/run/bin/ctacli.sh  |  2 ++
 .../buildtree_runner/cc7/opt/run/bin/ctafrontend.sh    |  2 ++
 .../docker/buildtree_runner/cc7/opt/run/bin/init.sh    |  2 ++
 .../buildtree_runner/cc7/opt/run/bin/init_pod.sh       |  3 +++
 .../docker/buildtree_runner/cc7/opt/run/bin/rmcd.sh    |  1 +
 .../docker/buildtree_runner/cc7/opt/run/bin/taped.sh   |  2 +-
 .../docker/buildtree_runner/cc7/stage1-rpms/Dockerfile |  3 +++
 .../docker/ctafrontend/cc7/opt/run/bin/taped.sh        |  2 +-
 continuousintegration/orchestration/pod-ctacli.yaml    | 10 ++++++++++
 continuousintegration/orchestration/pod-ctaeos.yaml    | 10 ++++++++++
 .../orchestration/pod-ctafrontend.yaml                 | 10 ++++++++++
 continuousintegration/orchestration/pod-init.yaml      | 10 ++++++++++
 continuousintegration/orchestration/pod-tpsrv.yaml     | 10 ++++++++++
 14 files changed, 66 insertions(+), 2 deletions(-)

diff --git a/continuousintegration/buildtree_runner/vmBootstrap/bootstrapSystem.sh b/continuousintegration/buildtree_runner/vmBootstrap/bootstrapSystem.sh
index ac4d54fc02..9bae682429 100755
--- a/continuousintegration/buildtree_runner/vmBootstrap/bootstrapSystem.sh
+++ b/continuousintegration/buildtree_runner/vmBootstrap/bootstrapSystem.sh
@@ -9,6 +9,7 @@ passwd eric
 cat >> /etc/sudoers << EOFsudoers
 eric ALL=(ALL) NOPASSWD: ALL
 EOFsudoers
+chmod a+rx ~eric
 sudo -u eric cp /vmBootstrap/gitScripts/.git-* ~eric/
 cat /vmBootstrap/gitScripts/bash_profile.hook >> ~eric/.bash_profile
 sudo -u eric cp /vmBootstrap/tigConf/tigrc ~eric/.tigrc
diff --git a/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/ctacli.sh b/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/ctacli.sh
index e213aa3983..0c4a74a2ac 100755
--- a/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/ctacli.sh
+++ b/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/ctacli.sh
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+/opt/run/bin/init_pod.sh
+
 cat <<EOF > /etc/cta/cta-cli.conf
 # The CTA frontend address in the form <FQDN>:<TCPPort>
 # solved by kubernetes DNS server so KIS...
diff --git a/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/ctafrontend.sh b/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/ctafrontend.sh
index 835ab806a0..851a63d5c3 100755
--- a/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/ctafrontend.sh
+++ b/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/ctafrontend.sh
@@ -1,5 +1,7 @@
 #!/bin/sh 
 
+/opt/run/bin/init_pod.sh
+
 yes | cp -r /opt/ci/ctafrontend/etc / 
 
 /opt/run/bin/init_objectstore.sh
diff --git a/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/init.sh b/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/init.sh
index b3dfde0ae3..896cc0ef67 100755
--- a/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/init.sh
+++ b/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/init.sh
@@ -1,5 +1,7 @@
 #!/bin/sh 
 
+/opt/run/bin/init_pod.sh
+
 echo "Using this configuration for library:"
 /opt/run/bin/init_library.sh
 cat /tmp/library-rc.sh
diff --git a/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/init_pod.sh b/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/init_pod.sh
index a42de022f7..10945c2da3 100755
--- a/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/init_pod.sh
+++ b/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/init_pod.sh
@@ -8,3 +8,6 @@ echo "DONE"
 #echo -n "Yum should resolve names using IPv4 DNS: "
 #echo "ip_resolve=IPv4" >> /etc/yum.conf
 #echo "DONE"
+
+# Here we will symlink the builtree's contents to /usr/bin and /usr/lib64.
+/opt/run/bin/mkSymlinks.sh
diff --git a/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/rmcd.sh b/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/rmcd.sh
index 8afe144d31..e3e8b1847e 100755
--- a/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/rmcd.sh
+++ b/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/rmcd.sh
@@ -9,6 +9,7 @@ cat /tmp/library-rc.sh
 . /tmp/library-rc.sh
 
 # to get rmcd logs to stdout
+mkdir -p /var/log/castor
 mkfifo /var/log/castor/rmcd_legacy.log
 for ((;;)); do cat </var/log/castor/rmcd_legacy.log; done &
 disown
diff --git a/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/taped.sh b/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/taped.sh
index 27f5d67627..6bf1920b63 100755
--- a/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/taped.sh
+++ b/continuousintegration/docker/buildtree_runner/cc7/opt/run/bin/taped.sh
@@ -70,7 +70,7 @@ tail -F /cta-taped.log &
 # working correctly
 echo BUILDTREE_BASE=${BUILDTREE_BASE}
 echo BUILDTREE_SUBDIR=${BUILDTREE_SUBDIR}
-runuser -c "${BUILDTREE_BASE}/${BUILDTREE_SUBDIR}/tapeserver/cta-taped ${CTA_TAPED_OPTIONS}"
+runuser -c "/usr/bin/cta-taped ${CTA_TAPED_OPTIONS}"
 
 echo "taped died"
 
diff --git a/continuousintegration/docker/buildtree_runner/cc7/stage1-rpms/Dockerfile b/continuousintegration/docker/buildtree_runner/cc7/stage1-rpms/Dockerfile
index 47fc2d7c5a..32920011a8 100644
--- a/continuousintegration/docker/buildtree_runner/cc7/stage1-rpms/Dockerfile
+++ b/continuousintegration/docker/buildtree_runner/cc7/stage1-rpms/Dockerfile
@@ -55,6 +55,8 @@ RUN yum install -y \
 # Populate local repository and enable it, then install any rpm that is needed for
 # any container. Finally add needed directories.
 RUN yum-config-manager --enable epel --setopt="epel.priority=4" \
+  && \
+    yum-config-manager --enable castor \
   && \
     yum install -y\
       eos-client \
@@ -81,6 +83,7 @@ RUN yum-config-manager --enable epel --setopt="epel.priority=4" \
       protobuf3 \
       cryptopp \
       json-c \
+      castor-rmc-server \
   && \
     yum clean all \
   && \
diff --git a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/taped.sh b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/taped.sh
index 49769a7f7e..61e08a6d9b 100755
--- a/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/taped.sh
+++ b/continuousintegration/docker/ctafrontend/cc7/opt/run/bin/taped.sh
@@ -71,7 +71,7 @@ tail -F /cta-taped.log &
 # cta-taped is ran with runuser to avoid a bug with Docker that prevents both
 # the setresgid(-1, 1474, -1) and setresuid(-1, 14029, -1) system calls from
 # working correctly
-runuser -c "/bin/cta-taped ${CTA_TAPED_OPTIONS}"
+runuser -c "/usr/bin/cta-taped ${CTA_TAPED_OPTIONS}"
 
 echo "taped died"
 
diff --git a/continuousintegration/orchestration/pod-ctacli.yaml b/continuousintegration/orchestration/pod-ctacli.yaml
index b0d54509fd..f0d313a7f9 100644
--- a/continuousintegration/orchestration/pod-ctacli.yaml
+++ b/continuousintegration/orchestration/pod-ctacli.yaml
@@ -21,6 +21,16 @@ spec:
           fieldPath: metadata.namespace
     - name: INSTANCE_NAME
       value: "$(MY_NAMESPACE)"
+    - name: BUILDTREE_BASE
+      valueFrom:
+        configMapKeyRef:
+          name: buildtree
+          key: base
+    - name: BUILDTREE_SUBDIR
+      valueFrom:
+        configMapKeyRef:
+          name: buildtree
+          key: subdir
     - name: TERM
       value: "xterm"
     command: ['/opt/run/bin/ctacli.sh']
diff --git a/continuousintegration/orchestration/pod-ctaeos.yaml b/continuousintegration/orchestration/pod-ctaeos.yaml
index 3744bdebf3..f141172e82 100644
--- a/continuousintegration/orchestration/pod-ctaeos.yaml
+++ b/continuousintegration/orchestration/pod-ctaeos.yaml
@@ -23,6 +23,16 @@ spec:
       value: "$(MY_NAMESPACE)"
     - name: frontend
       value: 'cta-frontend:10955'
+    - name: BUILDTREE_BASE
+      valueFrom:
+        configMapKeyRef:
+          name: buildtree
+          key: base
+    - name: BUILDTREE_SUBDIR
+      valueFrom:
+        configMapKeyRef:
+          name: buildtree
+          key: subdir
     - name: TERM
       value: "xterm"
     command: ['/opt/run/bin/ctaeos-mgm.sh']
diff --git a/continuousintegration/orchestration/pod-ctafrontend.yaml b/continuousintegration/orchestration/pod-ctafrontend.yaml
index aedfcd3576..09acb3659b 100644
--- a/continuousintegration/orchestration/pod-ctafrontend.yaml
+++ b/continuousintegration/orchestration/pod-ctafrontend.yaml
@@ -21,6 +21,16 @@ spec:
           fieldPath: metadata.namespace
     - name: INSTANCE_NAME
       value: "$(MY_NAMESPACE)"
+    - name: BUILDTREE_BASE
+      valueFrom:
+        configMapKeyRef:
+          name: buildtree
+          key: base
+    - name: BUILDTREE_SUBDIR
+      valueFrom:
+        configMapKeyRef:
+          name: buildtree
+          key: subdir
     - name: TERM
       value: "xterm"
     command: ['/opt/run/bin/ctafrontend.sh']
diff --git a/continuousintegration/orchestration/pod-init.yaml b/continuousintegration/orchestration/pod-init.yaml
index 36ff9ed56d..3c8bce4b8c 100644
--- a/continuousintegration/orchestration/pod-init.yaml
+++ b/continuousintegration/orchestration/pod-init.yaml
@@ -31,6 +31,16 @@ spec:
         configMapKeyRef:
           name: init
           key: keepobjectstore
+    - name: BUILDTREE_BASE
+      valueFrom:
+        configMapKeyRef:
+          name: buildtree
+          key: base
+    - name: BUILDTREE_SUBDIR
+      valueFrom:
+        configMapKeyRef:
+          name: buildtree
+          key: subdir
     command: ['/opt/run/bin/init.sh']
     args: ["none"]
     volumeMounts:
diff --git a/continuousintegration/orchestration/pod-tpsrv.yaml b/continuousintegration/orchestration/pod-tpsrv.yaml
index 0380829fc7..aa19be1c35 100644
--- a/continuousintegration/orchestration/pod-tpsrv.yaml
+++ b/continuousintegration/orchestration/pod-tpsrv.yaml
@@ -21,6 +21,16 @@ spec:
       valueFrom:
         fieldRef:
           fieldPath: metadata.namespace
+    - name: BUILDTREE_BASE
+      valueFrom:
+        configMapKeyRef:
+          name: buildtree
+          key: base
+    - name: BUILDTREE_SUBDIR
+      valueFrom:
+        configMapKeyRef:
+          name: buildtree
+          key: subdir
     - name: INSTANCE_NAME
       value: "$(MY_NAMESPACE)"
     - name: TERM
-- 
GitLab