LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 727|回复: 1

为什么我打不上这个补丁??

[复制链接]
发表于 2006-6-11 15:37:42 | 显示全部楼层 |阅读模式
bbmd@debian:/etc/init.d$ sudo patch -p2 < /home/bbmd/rc.patch
patch: **** Only garbage was found in the patch input.

这是一个给/etc/init.d/rc打的补丁,要怎么打上去?
  1. #! /bin/sh
  2. #
  3. # rc
  4. #
  5. # Starts/stops services on runlevel changes.
  6. #
  7. # Optimization: A start script is not run when the service was already
  8. # configured to run in the previous runlevel.  A stop script is not run
  9. # when the the service was already configured not to run in the previous
  10. # runlevel.
  11. #
  12. # Authors:
  13. #      Miquel van Smoorenburg <miquels@ci...>
  14. #      Bruce Perens <Bruce@Pi...>

  15. PATH=/sbin:/bin:/usr/sbin:/usr/bin
  16. export PATH

  17. # Un-comment the following for debugging.
  18. # debug=echo
  19. test -f /etc/default/bootsplash && . /etc/default/bootsplash
  20. rc_splash() {
  21.     #test "$SPLASH" != "no" && test "$_rc_splash" -eq 1 && /sbin/splash "$1"
  22.     test "$SPLASH" != "no" && /sbin/splash.sh "$1"

  23.     # make sure we don't add unless we really made progress
  24.     if [ "$1" != "master" -a "$1" != "splash start" -a "$1" != "shutdown" ]
  25.     then
  26.        progress=$(( $progress + 1 ))
  27.     fi
  28. }

  29. # Specify method used to enable concurrent init.d scripts.
  30. # Valid options are 'none', 'shell' and 'startpar'
  31. CONCURRENCY=none

  32. # Make sure the name survive changing the argument list
  33. scriptname="$0"

  34. umask 022

  35. #
  36. # Start script or program.
  37. #
  38. case "$CONCURRENCY" in
  39.    none)
  40.         startup() {
  41.                 action=$1
  42.                 shift
  43.                 scripts="$@"
  44.                 sh=sh
  45.                 # Debian Policy 9.3.1 requires .sh scripts in runlevel S to be sourced
  46.                 # However, some important packages currently contain .sh scripts
  47.                 # that do "exit" at some point, thus killing this process.  Bad!
  48.                 #[ S = "$runlevel" ] && sh=.
  49.                 for script in $scripts ; do
  50.                         case "$script" in
  51.                           *.sh)
  52.                                 if [ "." = "$sh" ] ; then
  53.                                         set "$action"
  54.                                         RC_SAVE_PATH="$PATH"
  55.                                         $debug . "$script"
  56.                                         PATH="$RC_SAVE_PATH"
  57.                                 else
  58.                                         $debug $sh "$script" $action
  59.                                 fi
  60.                                 ;;
  61.                           *)
  62.                                 $debug "$script" $action
  63.                                 ;;
  64.                         esac
  65.                         rc_splash "$script $action" # handle bootsplash stuff
  66.                 done
  67.         }
  68.         ;;
  69.    shell)
  70.         startup() {
  71.                 action=$1
  72.                 shift
  73.                 scripts="$@"
  74.                 sh=sh
  75.                 # Debian Policy 9.3.1 requires .sh scripts in runlevel S to be sourced
  76.                 # However, some important packages currently contain .sh scripts
  77.                 # that do "exit" at some point, thus killing this process.  Bad!
  78.                 #[ S = "$runlevel" ] && sh=.
  79.                 backgrounded=0
  80.                 for script in $scripts ; do
  81.                         case "$script" in
  82.                           *.sh)
  83.                                 if [ "." = "$sh" ] ; then
  84.                                         set "$action"
  85.                                         RC_SAVE_PATH="$PATH"
  86.                                         $debug . "$script"
  87.                                         PATH="$RC_SAVE_PATH"
  88.                                 else
  89.                                         $debug $sh "$script" $action
  90.                                 fi
  91.                                 ;;
  92.                           *)
  93.                                 $debug "$script" $action &
  94.                                 backgrounded=1
  95.                                 ;;
  96.                         esac
  97.                 done
  98.                 [ 1 = "$backgrounded" ] && wait
  99.         }
  100.         ;;
  101.    startpar)
  102.         startup() {
  103.                 action=$1
  104.                 shift
  105.                 scripts="$@"
  106.                 sh=sh
  107.                 # Debian Policy 9.3.1 requires .sh scripts in runlevel S to be sourced
  108.                 # However, some important packages currently contain .sh scripts
  109.                 # that do "exit" at some point, thus killing this process.  Bad!
  110.                 #[ S = "$runlevel" ] && sh=.
  111.                 # Make sure .sh scripts are sourced in runlevel S
  112.                 if [ "." = "$sh" ] ; then
  113.                         newscripts=
  114.                         for script in $scripts ; do
  115.                                 case "$script" in
  116.                                   *.sh)
  117.                                         set "$action"
  118.                                         RC_SAVE_PATH="$PATH"
  119.                                         $debug . "$script"
  120.                                         PATH="$RC_SAVE_PATH"
  121.                                         ;;
  122.                                   *)
  123.                                         newscripts="$newscripts $script"
  124.                                         ;;
  125.                                 esac
  126.                         done
  127.                         scripts="$newscripts"
  128.                 fi

  129.                 # startpar is not working as it should yet [pere 2005-09-10]
  130.                 [ -n "$scripts" ] && $debug startpar -a $action $scripts
  131.                 $debug startpar -a $action $scripts
  132.         }
  133.         ;;
  134. esac

  135. on_exit() {
  136.      echo "error: '$scriptname' exited outside the expected code flow."
  137. }
  138. trap on_exit EXIT # Enable emergency handler

  139. # Ignore CTRL-C only in this shell, so we can interrupt subprocesses.
  140. trap ":" INT QUIT TSTP

  141. # Set onlcr to avoid staircase effect.
  142. stty onlcr 0>&1

  143. # Now find out what the current and what the previous runlevel are.

  144. runlevel=$RUNLEVEL
  145. # Get first argument. Set new runlevel to this argument.
  146. [ "$1" != "" ] && runlevel=$1
  147. if [ "$runlevel" = "" ]
  148. then
  149.         echo "Usage: $scriptname <runlevel>" >&2
  150.         exit 1
  151. fi
  152. previous=$PREVLEVEL
  153. [ "$previous" = "" ] && previous=N

  154. export runlevel previous

  155. if [ S = "$runlevel" ]
  156. then
  157.         #
  158.         # See if system needs to be setup. This is ONLY meant to
  159.         # be used for the initial setup after a fresh installation!
  160.         #
  161.         if [ -x /sbin/unconfigured.sh ]
  162.         then
  163.                 /sbin/unconfigured.sh
  164.         fi
  165. fi

  166. . /etc/default/rcS
  167. export VERBOSE
  168. #
  169. # initialize boosplash progress bar variables
  170. #
  171. runrcS=/etc/rcS.d
  172. runrc=/etc/rc$runlevel.d
  173. prerc=/etc/rc$previous.d

  174. SSC=($(echo $runrc/S*))
  175.    case "$SSC" in
  176.       *\*)
  177.         sscripts=0 ;;
  178.       *)
  179.         sscripts=${#SSC[*]} ;;
  180.    esac

  181. if [ "$previous" != "N" ]; then
  182.    KSC=($(echo $runrc/K*))
  183.      case "$KSC" in
  184.         *\*)
  185.           kscripts=0 ;;
  186.         *)
  187.           kscripts=${#KSC[*]} ;;
  188.      esac
  189. fi

  190. if [ "$previous" = "N" -a "$runlevel" != "S" ]; then
  191.    SSC=($(echo $runrcS/S*))
  192.      case "$SSC" in
  193.        *\*)
  194.          sscripts=0 ;;
  195.        *)
  196.         progress=${#SSC[*]}
  197.         sscripts=$((${#SSC[*]} + $sscripts)) ;;
  198.      esac
  199. else
  200.     if [ "$runlevel" = "S" ]; then
  201.       #
  202.       # The system is started, let bootsplash know which is next (default)
  203.       # runlevel to calculate correct progress bar size.
  204.       #
  205.       SSC=($(echo $runrcS/S*))
  206.       NXT=($( grep initdefault /etc/inittab | sed {s/:/\ /g} ))
  207.       nextlevel=${NXT[1]}
  208.       nextrc="/etc/rc$nextlevel.d"
  209.       NSC=($(echo $nextrc/S*))
  210.       sscripts=$((${#SSC[*]} + ${#NSC[*]}))
  211.     fi
  212.     progress=0
  213. fi

  214. #
  215. # let bootsplash know if we are shutting down or starting up
  216. #
  217. if [ "$runlevel" = "0" -o "$runlevel" = "6" ]
  218.    then
  219.      kscripts=$(($kscripts+$sscripts))
  220.      rc_splash "splash start"
  221.      rc_splash "shutdown"
  222.    else
  223.      rc_splash "splash start"
  224. fi

  225. export sscripts progress kscripts

  226. # Is there an rc directory for this new runlevel?
  227. if [ -d /etc/rc$runlevel.d ]
  228. then
  229.         # First, run the KILL scripts.
  230.         if [ "$previous" != N ]
  231.         then
  232.                 # Run all scripts with the same level in parallel
  233.                 CURLEVEL=""
  234.                 for s in /etc/rc$runlevel.d/K*
  235.                 do
  236.                         level=$(echo $s | sed 's/.*\/K\([0-9][0-9]\).*/\1/')
  237.                         if [ "$level" = "$CURLEVEL" ]
  238.                         then
  239.                                 continue
  240.                         fi
  241.                         CURLEVEL=$level
  242.                         SCRIPTS=""
  243.                         for i in /etc/rc$runlevel.d/K$level*
  244.                         do
  245.                                 # Check if the script is there.
  246.                                 [ ! -f $i ] && continue

  247.                                 #
  248.                                 # Find stop script in previous runlevel but
  249.                                 # no start script there.
  250.                                 #
  251.                                 suffix=${i#/etc/rc$runlevel.d/K[0-9][0-9]}
  252.                                 previous_stop=/etc/rc$previous.d/K[0-9][0-9]$suffix
  253.                                 previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix
  254.                                 #
  255.                                 # If there is a stop script in the previous level
  256.                                 # and _no_ start script there, we don't
  257.                                 # have to re-stop the service.
  258.                                 #
  259.                [ -f $previous_stop ] && [ ! -f $previous_start ] && $progress$(($progress+2)) &&
  260. continue

  261.                                 # Stop the service.
  262.                                 SCRIPTS="$SCRIPTS $i"
  263.                         done
  264.                         startup stop $SCRIPTS
  265.                 done
  266.         fi

  267.         case "$runlevel" in
  268.           0|6)
  269.                 ACTION=stop
  270.                 first_step=100
  271.                 progress_size=100
  272.                 step_change=-1
  273.                 ;;
  274.           S)
  275.                 ACTION=start
  276.                 first_step=0
  277.                 progress_size=100
  278.                 step_change=1
  279.                 ;;
  280.           *)
  281.                 ACTION=start
  282.                 first_step=0
  283.                 progress_size=100
  284.                 step_change=1
  285.                 ;;
  286.         esac

  287.         # Count the number of scripts we need to run (for usplash progress bar)
  288.         num_steps=0
  289.         for s in /etc/rc$runlevel.d/S*; do
  290.                 num_steps=$(($num_steps + 1))
  291.                 case "${s##/etc/rc$runlevel.d/S??}" in
  292.                   gdm|xdm|kdm)
  293.                         break
  294.                         ;;
  295.                 esac
  296.         done

  297.         # Now run the START scripts for this runlevel.
  298.         # Run all scripts with the same level in parallel
  299.         CURLEVEL=""
  300.         step=0
  301.         for s in /etc/rc$runlevel.d/S*
  302.         do
  303.                 level=$(echo $s | sed 's/.*\/S\([0-9][0-9]\).*/\1/')
  304.                 if [ "$level" = "$CURLEVEL" ]
  305.                 then
  306.                         continue
  307.                 fi
  308.                 CURLEVEL=$level
  309.                 SCRIPTS=""
  310.                 for i in /etc/rc$runlevel.d/S$level*
  311.                 do
  312.                         [ ! -f $i ] && continue

  313.                         if [ "$previous" != N ]
  314.                         then
  315.                                 #
  316.                                 # Find start script in previous runlevel and
  317.                                 # stop script in this runlevel.
  318.                                 #
  319.                                 suffix=${i#/etc/rc$runlevel.d/S[0-9][0-9]}
  320.                                 stop=/etc/rc$runlevel.d/K[0-9][0-9]$suffix
  321.                                 previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix
  322.                                 #
  323.                                 # If there is a start script in the previous level
  324.                                 # and _no_ stop script in this level, we don't
  325.                                 # have to re-start the service.
  326.                                 #
  327.           [ -f $previous_start ] && [ ! -f $stop ] && $progress = $(($progress+2)) && continue
  328.                         fi
  329.                         SCRIPTS="$SCRIPTS $i"
  330.                 done
  331.                 startup $ACTION $SCRIPTS

  332.                 # Use 50% of the progress bar for rcS and the rest for the
  333.                 # runlevel we want to end up in
  334.                 step=$(($step + $step_change))
  335.                 #progress=$(($step * $progress_size / $num_steps + $first_step))
  336.                 if type usplash_write >/dev/null 2>&1; then
  337.                         usplash_write "PROGRESS $progress" || true
  338.                 fi
  339.         done
  340. fi
  341. [ $runlevel != "S" ] && rc_splash "master"   # finish up bootsplash

  342. if [ S = "$runlevel" ]
  343. then
  344.         #
  345.         # For compatibility, run the files in /etc/rc.boot too.
  346.         #
  347.         [ -d /etc/rc.boot ] && run-parts /etc/rc.boot

  348.         #
  349.         # Finish setup if needed. The comment above about
  350.         # /sbin/unconfigured.sh applies here as well!
  351.         #
  352.         if [ -x /sbin/setup.sh ]
  353.         then
  354.                 /sbin/setup.sh
  355.         fi
  356. fi

  357. trap - EXIT # Disable emergency handler

  358. exit 0
复制代码
发表于 2006-6-14 05:12:41 | 显示全部楼层
this does not look like a patch. it just a regular script. you need to diff out the patch and apply it.
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表