pkg.sh: Add option -W to log-install

This is like log-install -W, except that it installs a wrapper
script instead of a link for executables

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2017-07-19 11:30:08 +00:00
commit a4ef394a95

View file

@ -598,6 +598,37 @@ upload_pkg()
fi fi
} }
install_exe_wrapper()
{
local from="`realpath $1`"
local to="$2"
local ext=${from##*.}
local tmp=$to.tmp
case $ext in
py)
echo -e "#!/bin/bash\nexec /usr/bin/python \"$from\"" \"$to\" > "$tmp"
;;
pl)
echo -e "#!/bin/bash\nexec /usr/bin/perl \"$from\"" \"$to\" > "$tmp"
;;
sh)
echo -e "#!/bin/bash\n. \"$from\"" \"$to\" > "$tmp"
;;
*)
if file "$from" | grep -qi executable; then
echo -e "#!/bin/bash\n. \"$from\"" \"$to\" > "$tmp"
else
ln -sf $from $to
return
fi
;;
esac
chmod 755 "$tmp"
mv "$tmp" $to
}
cmd_build() cmd_build()
{ {
build_pkg build_pkg
@ -636,8 +667,9 @@ cmd_log_install()
local c_prefix= local c_prefix=
local c_opmode=opmode_install local c_opmode=opmode_install
local c_absolute=0 local c_absolute=0
local c_wrap=0
set -- `getopt 'DLi:a:f:l:bg:cdm:o:psS:vA' $*` set -- `getopt 'DLWi:a:f:l:bg:cdm:o:psS:vA' $*`
cfgfile_macro() cfgfile_macro()
{ {
@ -690,6 +722,9 @@ cmd_log_install()
;; ;;
-L) -L)
c_opmode=opmode_link;; c_opmode=opmode_link;;
-W)
c_opmode=opmode_link
c_wrap=1;;
-A) -A)
c_absolute=1;; c_absolute=1;;
*) *)
@ -736,7 +771,11 @@ cmd_log_install()
fi fi
check_create_parent $c_create_leading_dirs $c_target check_create_parent $c_create_leading_dirs $c_target
cd `dirname $c_target` cd `dirname $c_target`
ln -sf $c_source `basename $c_target` if [ "$c_wrap" = 1 ]; then
install_exe_wrapper $c_source $c_target
else
ln -sf $c_source `basename $c_target`
fi
;; ;;
*) *)