您的当前位置:首页>关注 > 正文

cmake-3.19.6-Linux自解压程序 简单的自解压程序|天天动态

来源:CSDN 时间:2022-12-30 10:08:51


(资料图)

Linux 自解压程序 简单的自解压程序 生成可执行程序 执行自解压程序 脚本 autopack_run.sh 简单的自解压程序 参考cmake-3.19.6-Linux-x86_64 写了一个自解压的可执行程序

生成可执行程序

cat ./autopack_run.sh test.tar.gz > test_auto_run.sh

执行自解压程序 方法1: sh 直接执行

ssh test_auto_run.sh

方法2:增加可执行权限

chmod +x test_auto_run.sh./test_auto_run.sh

脚本 autopack_run.sh

#!/bin/shMY_APPNAME="autopack_run"MY_VERSION="1.0.0"MY_COPYRIGHT="Copyright (c) Allen"UNPACK_SUBDIR="DATA_DIR"TAR_GZ_START_LINE=$(awk "/^__STARTS_TAR_GZ_FILE_HERE__/ {print NR + 1; exit 0; }" "$0")#interactive=TRUEinteractive=FALSE# Display usageautopack_runusage(){  cat/dev/null; then    autopack_runprefix_dir=`echo $a | sed " do ="" "$@";="" in="" a="" for="" g"}autopack_runinclude_subdir="" \="" \\="" "s="" sed="" "$1"="" (){ ="" paths.autopack_runfix_slashes="" windows="" fix="" to="" function="" helper="" $my_copyright"}#="" $my_version,="" "$my_appname="" versionautopack_runversion(){ ="" display="" 1}#="" exit="" $1 ="" 1}autopack_runecho_exit(){ ="" subdirectoryeof ="" ${unpack_subdir}="" the=""  exclude="" --exclude-subdir="" subdirectory =""  include="" --include-subdir="" install ="" which=""  directory="" --prefix="dir" version ="" autopack_run="" print="" --version="" message ="" this=""  print="" --help="" descriptions] ="" after="" brackets="" [defaults="" $0=""> /dev/null 2> /dev/null; then    autopack_runusage  fi    if echo $a | grep "^--version" > /dev/null 2> /dev/null; then    autopack_runversion    exit 2  fi  if echo $a | grep "^--include-subdir" > /dev/null 2> /dev/null; then    autopack_runinclude_subdir=TRUE  fi  if echo $a | grep "^--exclude-subdir" > /dev/null 2> /dev/null; then    autopack_runinclude_subdir=FALSE  fidoneif [ "x${autopack_runinclude_subdir}x" != "xx" ]then  interactive=FALSEfiautopack_runversionecho "This is a self-extracting archive."toplevel="`pwd`"if [ "x${autopack_runprefix_dir}x" != "xx" ]then  toplevel="${autopack_runprefix_dir}"fiecho "The archive will be extracted to: ${toplevel}"if [ "x${interactive}x" = "xTRUEx" ]then  echo ""  echo "If you want to stop extracting, please press."  if [ "x${autopack_runinclude_subdir}x" = "xx" ]  then    echo "Do you want to include the subdirectory ${UNPACK_SUBDIR}?"    echo "Saying yes will install in: \"${toplevel}/${UNPACK_SUBDIR}\" "        echo "Saying no  will install in: \"${toplevel}\" [Yn]: "    read line leftover    autopack_runinclude_subdir=TRUE    case ${line} in      n* | N*)        autopack_runinclude_subdir=FALSE    esac  fifi  if [ "x${autopack_runinclude_subdir}x" = "xTRUEx" ]then  toplevel="${toplevel}/${UNPACK_SUBDIR}"  mkdir -p "${toplevel}"fiechoecho "Using target directory: ${toplevel}"echo "Extracting, please wait..."echo ""# so at first try to tail some file to see if tail fails if used with "-n"# if so, don"t use "-n"use_new_tail_syntax="-n"tail $use_new_tail_syntax +1 "$0" > /dev/null 2> /dev/null || use_new_tail_syntax=""extractor="tar xvzf -"tail $use_new_tail_syntax +${TAR_GZ_START_LINE} "$0" | (cd "${toplevel}" && ${extractor}) || autopack_runecho_exit "Problem unpacking the ${UNPACK_SUBDIR}"echo "Unpacking finished successfully. File List:"ls -l ${UNPACK_SUBDIR}exit 0#-----------------------------------------------------------#      Start of TAR.GZ file#-----------------------------------------------------------;__STARTS_TAR_GZ_FILE_HERE__

标签:

最新新闻:

新闻放送
Top