summaryrefslogtreecommitdiffstats
path: root/meta/classes/utils.bbclass
diff options
context:
space:
mode:
Diffstat (limited to 'meta/classes/utils.bbclass')
-rw-r--r--meta/classes/utils.bbclass34
1 files changed, 34 insertions, 0 deletions
diff --git a/meta/classes/utils.bbclass b/meta/classes/utils.bbclass
index b4eb3d38ab..b617632d9f 100644
--- a/meta/classes/utils.bbclass
+++ b/meta/classes/utils.bbclass
@@ -184,6 +184,40 @@ END
184 chmod +x $cmd 184 chmod +x $cmd
185} 185}
186 186
187create_cmdline_shebang_wrapper () {
188 # Create a wrapper script where commandline options are needed
189 #
190 # These are useful to work around shebang relocation issues, where shebangs are too
191 # long or have arguments in them, thus preventing them from using the /usr/bin/env
192 # shebang
193 #
194 # Usage: create_cmdline_wrapper FILENAME <extra-options>
195
196 cmd=$1
197 shift
198
199 echo "Generating wrapper script for $cmd"
200
201 # Strip #! and get remaining interpreter + arg
202 argument="$(basename "$(head -n1 $cmd | sed -e 's|#![ ]*||g' )")"
203 # strip the shebang from the real script as we do not want it to be usable anyway
204 tail -n +2 $cmd > $cmd.real
205 cmdname=$(basename $cmd)
206 dirname=$(dirname $cmd)
207 cmdoptions=$@
208 if [ "${base_prefix}" != "" ]; then
209 relpath=`python3 -c "import os; print(os.path.relpath('${D}${base_prefix}', '$dirname'))"`
210 cmdoptions=`echo $@ | sed -e "s:${base_prefix}:\\$realdir/$relpath:g"`
211 fi
212 cat <<END >$cmd
213#!/usr/bin/env bash
214realpath=\`readlink -fn \$0\`
215realdir=\`dirname \$realpath\`
216exec -a \$realdir/$cmdname $argument \$realdir/$cmdname.real $cmdoptions "\$@"
217END
218 chmod +x $cmd
219}
220
187create_wrapper () { 221create_wrapper () {
188 # Create a wrapper script where extra environment variables are needed 222 # Create a wrapper script where extra environment variables are needed
189 # 223 #