| OLD | NEW |
| 1 #!/bin/bash -p | 1 #!/bin/bash -p |
| 2 | 2 |
| 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 # usage: dirdiffer.sh old_dir new_dir patch_dir | 7 # usage: dirdiffer.sh old_dir new_dir patch_dir |
| 8 # | 8 # |
| 9 # dirdiffer creates a patch directory patch_dir that represents the difference | 9 # dirdiffer creates a patch directory patch_dir that represents the difference |
| 10 # between old_dir and new_dir. patch_dir can be used with dirpatcher to | 10 # between old_dir and new_dir. patch_dir can be used with dirpatcher to |
| 11 # recreate new_dir given old_dir. | 11 # recreate new_dir given old_dir. |
| 12 # | 12 # |
| 13 # dirdiffer operates recursively, properly handling ordinary files, symbolic | 13 # dirdiffer operates recursively, properly handling ordinary files, symbolic |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 # exits with a nonzero status, and patch_dir should not be used. | 56 # exits with a nonzero status, and patch_dir should not be used. |
| 57 # | 57 # |
| 58 # Environment variables: | 58 # Environment variables: |
| 59 # DIRDIFFER_EXCLUDE | 59 # DIRDIFFER_EXCLUDE |
| 60 # When an entry in new_dir matches this regular expression, it will not be | 60 # When an entry in new_dir matches this regular expression, it will not be |
| 61 # included in patch_dir. All prospective paths in new_dir will be matched | 61 # included in patch_dir. All prospective paths in new_dir will be matched |
| 62 # against this regular expression, including directories. If a directory | 62 # against this regular expression, including directories. If a directory |
| 63 # matches this pattern, dirdiffer will also ignore the directory's contents. | 63 # matches this pattern, dirdiffer will also ignore the directory's contents. |
| 64 # DIRDIFFER_NO_DIFF | 64 # DIRDIFFER_NO_DIFF |
| 65 # When an entry in new_dir matches this regular expression, it will not be | 65 # When an entry in new_dir matches this regular expression, it will not be |
| 66 # represented in patch_dir by a $gbs file prepared by goobsdif. It will only | 66 # represented in patch_dir by a $gbs file prepared by goobsdiff. It will only |
| 67 # appear as a $bz2, $gz, or $raw file. Only files in new_dir, not | 67 # appear as a $bz2, $gz, or $raw file. Only files in new_dir, not |
| 68 # directories, will be matched against this regular expression. | 68 # directories, will be matched against this regular expression. |
| 69 # | 69 # |
| 70 # Exit codes: | 70 # Exit codes: |
| 71 # 0 OK | 71 # 0 OK |
| 72 # 1 Unknown failure | 72 # 1 Unknown failure |
| 73 # 2 Incorrect number of parameters | 73 # 2 Incorrect number of parameters |
| 74 # 3 Input directories do not exist or are not directories | 74 # 3 Input directories do not exist or are not directories |
| 75 # 4 Output directory already exists | 75 # 4 Output directory already exists |
| 76 # 5 Parent of output directory does not exist or is not a directory | 76 # 5 Parent of output directory does not exist or is not a directory |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 unset g_cleanup[${#g_cleanup[@]}] | 426 unset g_cleanup[${#g_cleanup[@]}] |
| 427 | 427 |
| 428 if [[ -n "${rsync_output}" ]]; then | 428 if [[ -n "${rsync_output}" ]]; then |
| 429 err "verification failed" | 429 err "verification failed" |
| 430 exit 16 | 430 exit 16 |
| 431 fi | 431 fi |
| 432 } | 432 } |
| 433 | 433 |
| 434 # shell_safe_path ensures that |path| is safe to pass to tools as a | 434 # shell_safe_path ensures that |path| is safe to pass to tools as a |
| 435 # command-line argument. If the first character in |path| is "-", "./" is | 435 # command-line argument. If the first character in |path| is "-", "./" is |
| 436 # prepended to it. The possibily-modified |path| is output. | 436 # prepended to it. The possibly-modified |path| is output. |
| 437 shell_safe_path() { | 437 shell_safe_path() { |
| 438 local path="${1}" | 438 local path="${1}" |
| 439 if [[ "${path:0:1}" = "-" ]]; then | 439 if [[ "${path:0:1}" = "-" ]]; then |
| 440 echo "./${path}" | 440 echo "./${path}" |
| 441 else | 441 else |
| 442 echo "${path}" | 442 echo "${path}" |
| 443 fi | 443 fi |
| 444 } | 444 } |
| 445 | 445 |
| 446 dirs_contained() { | 446 dirs_contained() { |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 trap - EXIT | 534 trap - EXIT |
| 535 } | 535 } |
| 536 | 536 |
| 537 if [[ ${#} -ne 3 ]]; then | 537 if [[ ${#} -ne 3 ]]; then |
| 538 usage | 538 usage |
| 539 exit 2 | 539 exit 2 |
| 540 fi | 540 fi |
| 541 | 541 |
| 542 main "${@}" | 542 main "${@}" |
| 543 exit ${?} | 543 exit ${?} |
| OLD | NEW |