Adding Peter Thatcher to the owners file.
[chromium-blink-merge.git] / build / android / pylib / efficient_android_directory_copy.sh
blob7021109e273e1b45649159405d14e1f27fe4a7fe
1 #!/system/bin/sh
3 # Copyright 2014 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
7 # Android shell script to make the destination directory identical with the
8 # source directory, without doing unnecessary copies. This assumes that the
9 # the destination directory was originally a copy of the source directory, and
10 # has since been modified.
12 source=$1
13 dest=$2
14 echo copying $source to $dest
16 delete_extra() {
17 # Don't delete symbolic links, since doing so deletes the vital lib link.
18 if [ ! -L "$1" ]
19 then
20 if [ ! -e "$source/$1" ]
21 then
22 echo rm -rf "$dest/$1"
23 rm -rf "$dest/$1"
24 elif [ -d "$1" ]
25 then
26 for f in "$1"/*
28 delete_extra "$f"
29 done
34 copy_if_older() {
35 if [ -d "$1" ] && [ -e "$dest/$1" ]
36 then
37 if [ ! -e "$dest/$1" ]
38 then
39 echo cp -a "$1" "$dest/$1"
40 cp -a "$1" "$dest/$1"
41 else
42 for f in "$1"/*
44 copy_if_older "$f"
45 done
47 elif [ ! -e "$dest/$1" ] || [ "$1" -ot "$dest/$1" ] || [ "$1" -nt "$dest/$1" ]
48 then
49 # dates are different, so either the destination of the source has changed.
50 echo cp -a "$1" "$dest/$1"
51 cp -a "$1" "$dest/$1"
55 if [ -e "$dest" ]
56 then
57 echo cd "$dest"
58 cd "$dest"
59 for f in ./*
61 if [ -e "$f" ]
62 then
63 delete_extra "$f"
65 done
66 else
67 echo mkdir "$dest"
68 mkdir "$dest"
70 echo cd "$source"
71 cd "$source"
72 for f in ./*
74 if [ -e "$f" ]
75 then
76 copy_if_older "$f"
78 done