-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgear-update-sh-functions
More file actions
92 lines (78 loc) · 2.53 KB
/
gear-update-sh-functions
File metadata and controls
92 lines (78 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/sh -eu
#
# Copyright (C) 2006-2018 Alexey Gladkov <legion@altlinux.org>
# Copyright (C) 2006-2009 Dmitry V. Levin <ldv@altlinux.org>
# Copyright (C) 2006 Sergey Vlasov <vsu@altlinux.org>
#
# This file is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
#
if [ -z "${__included_gear_update_sh_functions-}" ]; then
__included_gear_update_sh_functions=1
. gear-utils-sh-functions
gear_update_verbose=
gear_update_force=
gear_update_canon_destdir=
validate_destdir()
{
[ "$#" -eq 2 ] ||
fatal "validate_destdir: invalid ($#) number of arguments."
local src_dir="$1"; shift
local dst_dir="$1"; shift
[ -z "$gear_update_force" ] ||
return 0
if [ "$dst_dir" = '.' ] && [ -d '.git' ] && [ -d "$src_dir/.git" ]; then
fatal "$gear_update_canon_destdir/.git: Cowardly refusing to replace git directory."
fi
}
update_destdir()
{
[ "$#" -eq 3 ] ||
fatal "update_destdir: invalid ($#) number of arguments."
local command="$1"; shift
local src_dir="$1"; shift
local dst_dir="$1"; shift
local cmd=
case "$command" in
copy) cmd="cp -a" ;;
move) cmd="mv" ;;
esac
[ -n "$cmd" ] ||
fatal "update_destdir: invalid command: $command"
[ "$dst_dir" = '.' ] ||
mkdir $gear_update_verbose -p -- "$dst_dir"
local i=$((${gear_update_strip_components:-0} + 1))
find "$src_dir" -mindepth $i -maxdepth $i \! \( -name '.git' -o -name '.gear' -o -name '.gear-rules' -o -name '.gear-tags' \) -print0 |
xargs -r0 -I'{}' $cmd -- '{}' "$dst_dir/"
}
check_source_type()
{ fatal "check_source_type(): Undefined function."; }
unpack_source()
{ fatal "unpack_source(): Undefined function."; }
list_source()
{ fatal "list_source(): Undefined function."; }
gear_update_handler()
{
[ "$#" -gt 0 ] ||
fatal "More arguments required."
case "$1" in
--check-type) check_source_type ;;
--unpack) unpack_source ;;
--ls) list_source ;;
*)
fatal "unrecognized option: $1"
;;
esac
}
fi #__included_gear_update_sh_functions