forked from strv/vcstool-utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimport_all.sh
executable file
·77 lines (69 loc) · 1.9 KB
/
import_all.sh
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
#!/bin/bash
if [[ $# -lt 1 ]]; then
echo "Continuously recursively imports repositories defined in repositories file."
echo "Use with vcstool https://github.com/dirk-thomas/vcstool"
echo ""
echo "Usage : $0 [OPTIONS] DIR"
echo "DIR : base directory to find repositories file"
echo ""
echo "OPTIONS"
echo " -s SUFFIX : Repositories file suffix. (default: .repos)"
echo ""
echo "Example"
echo " For ROS user"
echo " $0 -s .rosintsall ~/catkin_ws/src"
echo " Note: better to set \"src\" directory as a target"
exit 1
fi
SUFFIX=.repos
while [[ $# != 0 ]]; do
case ${1} in
-s )
SUFFIX=${2}
shift 2
if [[ $# == 0 ]]; then
echo "Target directory is not specified"
exit 1
fi
;;
*)
DIR=${1}
break
;;
esac
done
if [ -d "${DIR}" ]; then
TARGET_DIR=$(cd "$(dirname "${DIR}")" || exit 1; pwd)/$(basename "${DIR}")
else
echo "Target directory non-existent"
exit 1
fi
echo "Target suffix : ${SUFFIX}"
echo "Start importing in ${TARGET_DIR}"
mapfile -t TARGETS < <(find "${TARGET_DIR}"/* -type f -name "*${SUFFIX}")
if [ ${#TARGETS[@]} -eq 0 ]; then
echo "No repositories file found"
exit 1
fi
DO=true
trap 'DO=false; exit 1' INT
COMPLETES=()
while [ ${#TARGETS[@]} != ${#COMPLETES[@]} ] && [ ${DO} == true ];do
for ROSINSTALL in "${TARGETS[@]}"; do
SKIP=false
for COMPLETE in "${COMPLETES[@]}"; do
if [[ ${ROSINSTALL} == "${COMPLETE}" ]]; then
SKIP=true
break
fi
done
if [[ ${SKIP} == false ]]; then
break
fi
done
echo "Import ${ROSINSTALL}"
vcs import --recursive "${TARGET_DIR}" < "${ROSINSTALL}"
COMPLETES+=("${ROSINSTALL}")
mapfile -t TARGETS < <(find "${TARGET_DIR}"/* -type f -name "*${SUFFIX}")
done
echo "Complete!"