已合并
修复mindie整包非root用户安装失败 #931
hw-zhoutianyang创建于 4月21日
修复mindie整包非root用户安装失败 #931
已合并
hw-zhoutianyang创建于 4月21日
1 个文件变更+39-35
@@ -1,4 +1,3 @@
1-#!/bin/bash
2cat << EOF > "$archname"1cat << EOF > "$archname"
3#!/bin/bash2#!/bin/bash
4# This script was generated using Makeself $MS_VERSION3# This script was generated using Makeself $MS_VERSION
@@ -27,6 +26,7 @@ export ARCHIVE_DIR
27name_of_file="\$0 "26name_of_file="\$0 "
28package_name=\`echo \$name_of_file | cut -d "/" -f2 | sed "s/.run//g" \`27package_name=\`echo \$name_of_file | cut -d "/" -f2 | sed "s/.run//g" \`
29pwd_of_file="\$PWD"28pwd_of_file="\$PWD"
29+SHA_ARG=""
30label="$LABEL"30label="$LABEL"
31script="$SCRIPT"31script="$SCRIPT"
32scriptargs="$SCRIPTARGS"32scriptargs="$SCRIPTARGS"
@@ -45,7 +45,6 @@ export_conf="$EXPORT_CONF"
45decrypt_cmd="$DECRYPT_CMD"45decrypt_cmd="$DECRYPT_CMD"
46skip="$SKIP"46skip="$SKIP"
47PACKAGE_LOG_NAME=makeself47PACKAGE_LOG_NAME=makeself
48-readonly user_n=\$(whoami)
49info_record_path="\$HOME/log/mindie"48info_record_path="\$HOME/log/mindie"
50info_record_file="operation.log"49info_record_file="operation.log"
51info_record_file_bak="operation.log.bak"50info_record_file_bak="operation.log.bak"
@@ -98,7 +97,7 @@ function check_path() {
98 exit 197 exit 1
99 fi98 fi
100}99}
101- 100+ 
102function log_check() {101function log_check() {
103 local log_size102 local log_size
104 log_size=\$(find \$log_file -exec ls -l {} \; | awk '{ print \$5 }')103 log_size=\$(find \$log_file -exec ls -l {} \; | awk '{ print \$5 }')
@@ -106,7 +105,7 @@ function log_check() {
106 rotate_log105 rotate_log
107 fi106 fi
108}107}
109- 108+ 
110# usage log "INFO" "this is message"109# usage log "INFO" "this is message"
111function log() {110function log() {
112 if [ ! -d "\$info_record_path" ];then111 if [ ! -d "\$info_record_path" ];then
@@ -237,11 +236,10 @@ Options:
237 --info Print embedded info : title, default target directory, embedded script ...236 --info Print embedded info : title, default target directory, embedded script ...
238 --list Print the list of files in the archive237 --list Print the list of files in the archive
239 --check Checks integrity and version dependency of the archive238 --check Checks integrity and version dependency of the archive
240- --quiet Quiet install mode, skip human-computer interactions239+ --quiet | -q Quiet install mode, skip human-computer interactions
241 If the package requires an EULA, quiet installations are useful for scripting the installation240 If the package requires an EULA, quiet installations are useful for scripting the installation
242 Using this option means accepting the EULA241 Using this option means accepting the EULA
243 --extract=<path> Extract directly to a target directory (absolute or relative)242 --extract=<path> Extract directly to a target directory (absolute or relative)
244- --tar arg1 [arg2 ...] Access the contents of the archive through the tar command
245\${helpheader}243\${helpheader}
246EOH244EOH
247}245}
@@ -329,7 +327,7 @@ MS_Decompress()
329 else327 else
330 eval "$GUNZIP_CMD"328 eval "$GUNZIP_CMD"
331 fi329 fi
332- 330+ 
333 if test \$? -ne 0; then331 if test \$? -ne 0; then
334 echo " ... Decompression failed." >&2332 echo " ... Decompression failed." >&2
335 log "ERROR" "Decompression failed."333 log "ERROR" "Decompression failed."
@@ -486,7 +484,7 @@ fi
486 484 
487if test x"$NEED_ROOT" = xy -a \`id -u\` -ne 0; then485if test x"$NEED_ROOT" = xy -a \`id -u\` -ne 0; then
488 echo "Administrative privileges required for this archive (use su or sudo)" >&2486 echo "Administrative privileges required for this archive (use su or sudo)" >&2
489- exit 1 487+ exit 1
490fi488fi
491 489 
492if test x"\$copy" \!= xphase2; then490if test x"\$copy" \!= xphase2; then
@@ -512,30 +510,6 @@ phase2)
512 ;;510 ;;
513esac511esac
514 512 
515-if test x"\$nox11" = xn; then
516- if tty -s; then # Do we have a terminal?
517- :
518- else
519- if test x"\$DISPLAY" != x -a x"\$xterm_loop" = x; then # No, but do we have X?
520- if xset q > /dev/null 2>&1; then # Check for valid DISPLAY variable
521- GUESS_XTERMS="xterm gnome-terminal rxvt dtterm eterm Eterm xfce4-terminal lxterminal kvt konsole aterm terminology"
522- for a in \$GUESS_XTERMS; do
523- if type \$a >/dev/null 2>&1; then
524- XTERM=\$a
525- break
526- fi
527- done
528- chmod a+x \$0 || echo Please add execution rights on \$0
529- if test \`echo "\$0" | cut -c1\` = "/"; then # Spawn a terminal!
530- exec \$XTERM -e "\$0 --xwin \$initargs"
531- else
532- exec \$XTERM -e "./\$0 --xwin \$initargs"
533- fi
534- fi
535- fi
536- fi
537-fi
538- 
539if test x"\$targetdir" = x.; then513if test x"\$targetdir" = x.; then
540 tmpdir="."514 tmpdir="."
541else515else
@@ -610,8 +584,6 @@ do
610 if test x"\$ownership" = xy; then584 if test x"\$ownership" = xy; then
611 (cd "\$tmpdir"; chown -R \`id -u\` .; chgrp -R \`id -g\` .)585 (cd "\$tmpdir"; chown -R \`id -u\` .; chgrp -R \`id -g\` .)
612 fi586 fi
613- shopt -s nullglob && chmod 550 "\$tmpdir"/*.run "\$tmpdir"/*.gz "\$tmpdir"/*.sh && chmod 440 "\$tmpdir"/*.info "\$tmpdir"/*.txt
614- shopt -s nullglob && chmod 550 "\$tmpdir" "\$tmpdir"/scripts "\$tmpdir"/scripts/*
615 else587 else
616 echo >&2588 echo >&2
617 echo "Unable to decompress \$0" >&2589 echo "Unable to decompress \$0" >&2
@@ -667,11 +639,43 @@ if test x"\$script" != x; then
667 fi639 fi
668fi640fi
669 641 
642+change_permission()
643+{
644+ shopt -s nullglob
645+ 
646+ for file in "\$tmpdir"/*.run "\$tmpdir"/*.gz "\$tmpdir"/*.sh; do
647+ if [ -e "\$file" ]; then
648+ chmod 550 "\$file"
649+ fi
650+ done
651+ 
652+ for info_file in "\$tmpdir"/*.info "\$tmpdir"/*.txt; do
653+ if [ -e "\$info_file" ]; then
654+ chmod 440 "\$info_file"
655+ fi
656+ done
657+ 
658+ if [ -d "\$tmpdir" ]; then
659+ chmod 550 "\$tmpdir"
660+ fi
661+ 
662+ if [ -d "\$tmpdir"/scripts ]; then
663+ chmod 550 "\$tmpdir"/scripts
664+ for script_file in "\$tmpdir"/scripts/*; do
665+ if [ -e "\$script_file" ]; then
666+ chmod 550 "\$script_file"
667+ fi
668+ done
669+ fi
670+}
671+ 
672+change_permission
670MS_exec_cleanup673MS_exec_cleanup
671 674 
672if test x"\$keep" = xn; then675if test x"\$keep" = xn; then
673 cd "\$TMPROOT"676 cd "\$TMPROOT"
677+ chmod +wx -R "\$tmpdir"
674 rm -rf "\$tmpdir"678 rm -rf "\$tmpdir"
675fi679fi
676eval \$finish; exit \$res680eval \$finish; exit \$res
677-EOF681+EOF