<p>Holger Freyther has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/11580">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">misc: Use RPATH to avoid having tests to set LD_LIBRARY_PATH<br><br>Instead of each binary launcher having to check if there is a lib/<br>directory and then setting a LD_LIBRARY_PATH we can use an RPATH and<br>know these binaries pick-up the right libraries.<br><br>This requires I6e4ad2e3855af7bcefc22d4190cc4e6f58581857.<br><br>Change-Id: If771767dd82662e13b6b10ee7a8b8d0c84dcbdb1<br>---<br>M contrib/jenkins-build-common.sh<br>1 file changed, 22 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-gsm-tester refs/changes/80/11580/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/contrib/jenkins-build-common.sh b/contrib/jenkins-build-common.sh</span><br><span>index 17ab7df..63058eb 100644</span><br><span>--- a/contrib/jenkins-build-common.sh</span><br><span>+++ b/contrib/jenkins-build-common.sh</span><br><span>@@ -175,6 +175,27 @@</span><br><span>         done</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+add_rpath() {</span><br><span style="color: hsl(120, 100%, 40%);">+ # Adds an RPATH to executables in bin/ or sbin/ to search for the</span><br><span style="color: hsl(120, 100%, 40%);">+     # (Osmocom) libraries in `basepath /proc/self/exe`/../lib/. Adds an</span><br><span style="color: hsl(120, 100%, 40%);">+   # RPATH to a library to search in the same directory as the library.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        # NOTE: Binaries should not have the SUID bit set and should run as the</span><br><span style="color: hsl(120, 100%, 40%);">+       # user executing the binary.</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+        # Add an rpath relative to the binary and library if the directory</span><br><span style="color: hsl(120, 100%, 40%);">+    # exists.</span><br><span style="color: hsl(120, 100%, 40%);">+     if [ -d bin/ ]; then</span><br><span style="color: hsl(120, 100%, 40%);">+          find bin -depth -type f -exec patchelf --set-rpath '$ORIGIN/../lib/' {} \;</span><br><span style="color: hsl(120, 100%, 40%);">+    fi</span><br><span style="color: hsl(120, 100%, 40%);">+    if [ -d sbin/ ]; then</span><br><span style="color: hsl(120, 100%, 40%);">+         find sbin -depth -type f -exec patchelf --set-rpath '$ORIGIN/../lib/' {} \;</span><br><span style="color: hsl(120, 100%, 40%);">+   fi</span><br><span style="color: hsl(120, 100%, 40%);">+    if [ -d lib/ ]; then</span><br><span style="color: hsl(120, 100%, 40%);">+          find lib -depth -type f -name "lib*.so.*" -exec patchelf --set-rpath '$ORIGIN/' {} \;</span><br><span style="color: hsl(120, 100%, 40%);">+       fi</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> create_bin_tgz() {</span><br><span>   # build the archive that is going to be copied to the tester</span><br><span> </span><br><span>@@ -190,6 +211,7 @@</span><br><span>   prune_files sbin "$wanted_binaries_sbin"</span><br><span> </span><br><span>   cd "$prefix_real"</span><br><span style="color: hsl(120, 100%, 40%);">+  add_rpath</span><br><span>   this="$name.build-${BUILD_NUMBER-$(date +%Y-%m-%d_%H_%M_%S)}"</span><br><span>   tar="${this}.tgz"</span><br><span>   tar czf "$base/$tar" *</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/11580">change 11580</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/11580"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-gsm-tester </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: If771767dd82662e13b6b10ee7a8b8d0c84dcbdb1 </div>
<div style="display:none"> Gerrit-Change-Number: 11580 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Holger Freyther <holger@freyther.de> </div>