From 6d3ad02111d37ced034331ea1ed7beeaad1eada3 Mon Sep 17 00:00:00 2001
From: hahn <axel.hahn@iml.unibe.ch>
Date: Thu, 10 Feb 2022 17:18:00 +0100
Subject: [PATCH] task#5047 - FIX EOL in ci-custom-vars

---
 public_html/deployment/classes/project.class.php | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/public_html/deployment/classes/project.class.php b/public_html/deployment/classes/project.class.php
index 954fade3..34abd6bb 100644
--- a/public_html/deployment/classes/project.class.php
+++ b/public_html/deployment/classes/project.class.php
@@ -1707,9 +1707,18 @@ class project extends base {
         // --------------------------------------------------
         $sCfgout=$sTempBuildDir . '/ci-custom-vars';
         if (isset($this->_aPrjConfig['deploy']["configfile"]) && $this->_aPrjConfig['deploy']["configfile"]){
-            file_put_contents($sCfgout, $this->_aPrjConfig['deploy']["configfile"]);
+                        
+            # task#5047 - FIX EOL
+            $sCfgContent=$this->_aPrjConfig['deploy']["configfile"];
+            // detect unix, linux, mac
+            if (DIRECTORY_SEPARATOR === '/') {
+                $sCfgContent=str_replace("\r\n", "\n", $sCfgContent);
+            }
+            # /task#5047
+            
+            file_put_contents($sCfgout, $sCfgContent);
             $sReturn.=$this->_execAndSend('ls -l ' . $sCfgout);
-            $sReturn.=$this->_execAndSend('cat ' . $sCfgout);
+            $sReturn.=$this->_execAndSend('cat ' . $sCfgout);                
         }
 
         $sReturn.=$this->_oHtml->getBox("success", t('class-project-info-build-checkout-ok'));
-- 
GitLab