3 # Copyright (c) 2012-2017 NVIDIA CORPORATION. All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above copyright
11 # notice, this list of conditions and the following disclaimer in the
12 # documentation and/or other materials provided with the distribution.
13 # * Neither the name of NVIDIA CORPORATION nor the names of its
14 # contributors may be used to endorse or promote products derived
15 # from this software without specific prior written permission.
17 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
18 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
25 # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 # This script sync's NVIDIA's version of
32 # 1. the kernel source
33 # 2. the u-boot source
34 # from nv-tegra, NVIDIA's public git repository.
35 # The script also provides opportunities to the sync to a specific tag
36 # so that the binaries shipped with a release can be replicated.
39 # By default it will download all the listed sources
41 # Use the -t <TAG> option to provide the TAG to be used to sync all the sources.
42 # Use the -k <TAG> option to download only the kernel and device tree repos and optionally sync to TAG
43 # Use the -u <TAG> option to download only the u-boot repo and optionally sync to TAG
44 # For detailed usage information run with -h option.
48 # verify that git is installed
49 if ! which git > /dev/null ; then
50 echo "ERROR: git is not installed. If your linux distro is 10.04 or later,"
51 echo "git can be installed by 'sudo apt-get install git-core'."
56 LDK_DIR=$(cd `dirname $0` && pwd)
57 LDK_DIR="${LDK_DIR}/sources"
59 SCRIPT_NAME=`basename $0`
61 # NOTE: *Add only kernel repos here. Add new repos separately below. Keep related repos together*
63 k:kernel/kernel-4.4:nv-tegra.nvidia.com/linux-4.4.git:
64 k:kernel/t18x:nv-tegra.nvidia.com/linux-t18x.git:
65 k:kernel/nvgpu:nv-tegra.nvidia.com/linux-nvgpu.git:
66 k:kernel/nvhost:nv-tegra.nvidia.com/linux-nvhost.git:
67 k:kernel/nvmap:nv-tegra.nvidia.com/linux-nvmap.git:
68 k:kernel/nvmap-t18x:nv-tegra.nvidia.com/linux-nvmap-t18x.git:
69 k:kernel/display:nv-tegra.nvidia.com/linux-display.git:
70 k:hardware/nvidia/soc/t18x:nv-tegra.nvidia.com/device/hardware/nvidia/soc/t18x.git:
71 k:hardware/nvidia/platform/tegra/common:nv-tegra.nvidia.com/device/hardware/nvidia/platform/tegra/common.git:
72 k:hardware/nvidia/platform/t18x/common:nv-tegra.nvidia.com/device/hardware/nvidia/platform/t18x/common.git:
73 k:hardware/nvidia/platform/t18x/quill:nv-tegra.nvidia.com/device/hardware/nvidia/platform/t18x/quill.git:
74 k:hardware/nvidia/soc/t210:nv-tegra.nvidia.com/device/hardware/nvidia/soc/t210.git:
75 k:hardware/nvidia/platform/t210/common:nv-tegra.nvidia.com/device/hardware/nvidia/platform/t210/common.git:
76 k:hardware/nvidia/platform/t210/jetson:nv-tegra.nvidia.com/device/hardware/nvidia/platform/t210/jetson.git:
77 k:hardware/nvidia/soc/tegra:nv-tegra.nvidia.com/device/hardware/nvidia/soc/tegra.git:
80 u:u-boot:nv-tegra.nvidia.com/3rdparty/u-boot.git:
83 # exit on error on sync
85 # after processing SOURCE_INFO
87 declare -a SOURCE_INFO_PROCESSED
99 echo "Use: $1 [options]"
100 echo "Available general options are,"
102 echo " -e : exit on sync error"
103 echo " -d [DIR] : root of source is DIR"
104 echo " -t [TAG] : Git tag that will be used to sync all the sources"
106 echo "By default, all sources are downloaded."
107 echo "Only specified sources are downloaded, if one or more of the following options are mentioned."
109 echo "$SOURCE_INFO" | while read LINE; do
110 if [ ! -z "$LINE" ]; then
111 OP=$(echo "$LINE" | cut -f 1 -d ':')
112 DESC=$(echo "$LINE" | cut -f 2 -d ':')
113 if [[ ! " ${PROCESSED[@]} " =~ " ${OP} " ]]; then
114 echo " -${OP} [TAG]: Download $DESC source and optionally sync to TAG"
117 echo " and download $DESC source and sync to the same TAG"
124 function ProcessSwitch {
130 for ((i=0; i < NSOURCES; i++)); do
131 local OP=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 1 -d ':')
132 if [ "-${OP}" == "$SWITCH" ]; then
133 SOURCE_INFO_PROCESSED[i]="${SOURCE_INFO_PROCESSED[i]}${TAG}:y"
139 if [ "$found" == 1 ]; then
143 echo "Terminating... wrong switch: ${SWITCH}" >&2
144 Usages "$SCRIPT_NAME"
148 function UpdateTags {
153 for ((i=0; i < NSOURCES; i++)); do
154 local OP=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 1 -d ':')
155 if [ "${OP}" == "$SWITCH" ]; then
156 SOURCE_INFO_PROCESSED[i]=$(echo "${SOURCE_INFO_PROCESSED[i]}" \
157 | awk -F: -v OFS=: -v var="${TAG}" '{$4=var; print}')
162 function DownloadAndSync {
163 local WHAT_SOURCE="$1"
164 local LDK_SOURCE_DIR="$2"
170 if [ -d "${LDK_SOURCE_DIR}" ] ; then
171 echo "Directory for $WHAT, ${LDK_SOURCE_DIR}, already exists!"
172 pushd "${LDK_SOURCE_DIR}" > /dev/null
173 git status 2>&1 >/dev/null
174 if [ $? -ne 0 ]; then
175 echo "But the directory is not a git repository -- clean it up first"
181 git fetch --all 2>&1 >/dev/null
184 echo "Downloading default $WHAT source..."
186 git clone "$REPO_URL" -n ${LDK_SOURCE_DIR} 2>&1 >/dev/null
187 if [ $? -ne 0 ]; then
188 echo "$2 source sync failed!"
194 echo "The default $WHAT source is downloaded in: ${LDK_SOURCE_DIR}"
197 if [ -z "$TAG" ]; then
198 echo "Please enter a tag to sync $2 source to"
199 echo -n "(enter nothing to skip): "
205 if [ ! -z "$TAG" ]; then
206 pushd ${LDK_SOURCE_DIR} > /dev/null
207 git tag -l 2>/dev/null | grep -q -P "^$TAG\$"
208 if [ $? -eq 0 ]; then
209 echo "Syncing up with tag $TAG..."
210 git checkout -b mybranch_$(date +%Y-%m-%d-%s) $TAG
211 echo "$2 source sync'ed to tag $TAG successfully!"
213 echo "Couldn't find tag $TAG"
214 echo "$2 source sync to tag $TAG failed!"
225 # prepare processing ....
229 IFS=$(echo -en "\n\b")
230 SOURCE_INFO_PROCESSED=($(echo "$SOURCE_INFO"))
232 NSOURCES=${#SOURCE_INFO_PROCESSED[*]}
234 for ((i=0; i < NSOURCES; i++)); do
235 OP=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 1 -d ':')
236 GETOPT="${GETOPT}${OP}:"
239 # parse the command line first
240 while getopts "$GETOPT" opt; do
245 Usages "$SCRIPT_NAME"
257 Usages "$SCRIPT_NAME"
263 for ((i=0; i < NSOURCES; i++)); do
264 OP=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 1 -d ':')
265 if [[ ! " ${PROCESSED[@]} " =~ " ${OP} " ]]; then
274 eval arg=\$$((OPTIND-1))
277 Usages "$SCRIPT_NAME"
281 ProcessSwitch "-$opt" ""
287 ProcessSwitch "-$opt" "$OPTARG"
295 Usages "$SCRIPT_NAME"
300 ProcessSwitch "-$OPTARG" ""
305 echo "Terminating... wrong switch: $@" >&2
306 Usages "$SCRIPT_NAME"
314 for ((i=0; i < NSOURCES; i++)); do
315 OPT=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 1 -d ':')
316 WHAT=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 2 -d ':')
317 REPO=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 3 -d ':')
318 TAG=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 4 -d ':')
319 DNLOAD=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 5 -d ':')
321 if [ $DALL -eq 1 -o "x${DNLOAD}" == "xy" ]; then
322 DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "git://${REPO}" "${TAG}" "${OPT}"
325 if [ $tRET -ne 0 -a $EOE -eq 1 ]; then