Skip to content

Commit 86b6ff2

Browse files
committed
fallback for git protocol
1 parent 37c5285 commit 86b6ff2

5 files changed

Lines changed: 61 additions & 84 deletions

File tree

scripts/source_sync_4.6.1.sh

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
set -e
23

34
# Copyright (c) 2012-2021 NVIDIA CORPORATION. All rights reserved.
45
#
@@ -46,7 +47,7 @@
4647

4748

4849
# verify that git is installed
49-
if ! which git > /dev/null ; then
50+
if ! which git > /dev/null ; then
5051
echo "ERROR: git is not installed. If your linux distro is 10.04 or later,"
5152
echo "git can be installed by 'sudo apt-get install git-core'."
5253
exit 1
@@ -85,8 +86,6 @@ SOURCE_INFO+="
8586
u:u-boot:nv-tegra.nvidia.com/3rdparty/u-boot.git:
8687
"
8788

88-
# exit on error on sync
89-
EOE=0
9089
# after processing SOURCE_INFO
9190
NSOURCES=0
9291
declare -a SOURCE_INFO_PROCESSED
@@ -104,9 +103,8 @@ function Usages {
104103
echo "Use: $1 [options]"
105104
echo "Available general options are,"
106105
echo " -h : help"
107-
echo " -e : exit on sync error"
108106
echo " -d [DIR] : root of source is DIR"
109-
echo " -t [TAG] : Git tag that will be used to sync all the sources"
107+
echo " -t [TAG] : git tag that will be used to sync all the sources"
110108
echo ""
111109
echo "By default, all sources are downloaded."
112110
echo "Only specified sources are downloaded, if one or more of the following options are mentioned."
@@ -228,7 +226,7 @@ function DownloadAndSync {
228226
}
229227

230228
# prepare processing ....
231-
GETOPT=":ehd:t:"
229+
GETOPT=":hd:t:"
232230

233231
OIFS="$IFS"
234232
IFS=$(echo -en "\n\b")
@@ -255,9 +253,6 @@ while getopts "$GETOPT" opt; do
255253
;;
256254
esac
257255
;;
258-
e)
259-
EOE=1
260-
;;
261256
h)
262257
Usages "$SCRIPT_NAME"
263258
exit 1
@@ -315,7 +310,6 @@ while getopts "$GETOPT" opt; do
315310
done
316311
shift $((OPTIND-1))
317312

318-
GRET=0
319313
for ((i=0; i < NSOURCES; i++)); do
320314
OPT=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 1 -d ':')
321315
WHAT=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 2 -d ':')
@@ -324,13 +318,11 @@ for ((i=0; i < NSOURCES; i++)); do
324318
DNLOAD=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 5 -d ':')
325319

326320
if [ $DALL -eq 1 -o "x${DNLOAD}" == "xy" ]; then
327-
DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "https://${REPO}" "${TAG}" "${OPT}"
328-
tRET=$?
329-
let GRET=GRET+tRET
330-
if [ $tRET -ne 0 -a $EOE -eq 1 ]; then
331-
exit $tRET
321+
if ! DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "https://${REPO}" "${TAG}" "${OPT}"; then
322+
if [[ $? == 1 ]]; then
323+
echo "Trying git protocol"
324+
DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "git://${REPO}" "${TAG}" "${OPT}"
325+
fi
332326
fi
333327
fi
334328
done
335-
336-
exit $GRET

scripts/source_sync_5.0.2.sh

Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
set -e
23

34
# Copyright (c) 2012-2022 NVIDIA CORPORATION. All rights reserved.
45
#
@@ -96,8 +97,6 @@ o:tegra/optee-src/nv-optee:nv-tegra.nvidia.com/tegra/optee-src/nv-optee.git:
9697
o:tegra/v4l2-src/v4l2_libs:nv-tegra.nvidia.com/tegra/v4l2-src/v4l2_libs.git:
9798
"
9899

99-
# exit on error on sync
100-
EOE=0
101100
# after processing SOURCE_INFO
102101
NSOURCES=0
103102
declare -a SOURCE_INFO_PROCESSED
@@ -115,7 +114,6 @@ function Usages {
115114
echo "Use: $1 [options]"
116115
echo "Available general options are,"
117116
echo " -h : help"
118-
echo " -e : exit on sync error"
119117
echo " -d [DIR] : root of source is DIR"
120118
echo " -t [TAG] : Git tag that will be used to sync all the sources"
121119
echo ""
@@ -218,24 +216,23 @@ function DownloadAndSync {
218216
UpdateTags $OPT $TAG
219217
fi
220218

221-
if [ ! -z "$TAG" ]; then
222-
pushd ${LDK_SOURCE_DIR} > /dev/null
223-
git tag -l 2>/dev/null | grep -q -P "^$TAG\$"
224-
if [ $? -eq 0 ]; then
219+
if [[ -n "$TAG" ]]; then
220+
if [ -n $(git -C $LDK_SOURCE_DIR tag -l "^$TAG\$") ]; then
225221
echo "Syncing up with tag $TAG..."
226-
git checkout -b mybranch_$(date +%Y-%m-%d-%s) $TAG
227-
echo "$2 source sync'ed to tag $TAG successfully!"
222+
if git -C $LDK_SOURCE_DIR checkout -b mybranch_$(date +%Y-%m-%d-%s) $TAG; then
223+
echo "$2 source sync'ed to tag $TAG successfully!"
224+
else
225+
echo "$2 could not sync to tag $TAG!"
226+
return 3
227+
fi
228228
else
229229
echo "Couldn't find tag $TAG"
230230
echo "$2 source sync to tag $TAG failed!"
231-
RET=1
231+
return 4
232232
fi
233-
popd > /dev/null
234233
fi
235234
echo ""
236-
echo ""
237-
238-
return "$RET"
235+
return 0;
239236
}
240237

241238
# prepare processing ....
@@ -266,9 +263,6 @@ while getopts "$GETOPT" opt; do
266263
;;
267264
esac
268265
;;
269-
e)
270-
EOE=1
271-
;;
272266
h)
273267
Usages "$SCRIPT_NAME"
274268
exit 1
@@ -326,7 +320,6 @@ while getopts "$GETOPT" opt; do
326320
done
327321
shift $((OPTIND-1))
328322

329-
GRET=0
330323
for ((i=0; i < NSOURCES; i++)); do
331324
OPT=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 1 -d ':')
332325
WHAT=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 2 -d ':')
@@ -335,14 +328,11 @@ for ((i=0; i < NSOURCES; i++)); do
335328
DNLOAD=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 5 -d ':')
336329

337330
if [ $DALL -eq 1 -o "x${DNLOAD}" == "xy" ]; then
338-
DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "https://${REPO}" "${TAG}" "${OPT}"
339-
tRET=$?
340-
let GRET=GRET+tRET
341-
if [ $tRET -ne 0 -a $EOE -eq 1 ]; then
342-
exit $tRET
331+
if ! DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "https://${REPO}" "${TAG}" "${OPT}"; then
332+
if [[ $? == 1 ]]; then
333+
echo "Trying git protocol"
334+
DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "git://${REPO}" "${TAG}" "${OPT}"
335+
fi
343336
fi
344337
fi
345338
done
346-
347-
exit $GRET
348-

scripts/source_sync_5.1.2.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/bin/bash
2+
set -e
23

34
# Copyright (c) 2012-2023 NVIDIA CORPORATION. All rights reserved.
45
#
@@ -194,9 +195,8 @@ function DownloadAndSync {
194195
if [ $? -ne 0 ]; then
195196
echo "But the directory is not a git repository -- clean it up first"
196197
echo ""
197-
echo ""
198198
popd > /dev/null
199-
return 1
199+
return 2
200200
fi
201201
git fetch --all 2>&1 >/dev/null
202202
popd > /dev/null
@@ -207,7 +207,6 @@ function DownloadAndSync {
207207
if [ $? -ne 0 ]; then
208208
echo "$2 source sync failed!"
209209
echo ""
210-
echo ""
211210
return 1
212211
fi
213212

@@ -222,17 +221,21 @@ function DownloadAndSync {
222221
UpdateTags $OPT $TAG
223222
fi
224223

225-
if [ ! -z "$TAG" ]; then
224+
if [[ -n "$TAG" ]]; then
226225
pushd ${LDK_SOURCE_DIR} > /dev/null
227226
git tag -l 2>/dev/null | grep -q -P "^$TAG\$"
228227
if [ $? -eq 0 ]; then
229228
echo "Syncing up with tag $TAG..."
230-
git checkout -b mybranch_$(date +%Y-%m-%d-%s) $TAG
231-
echo "$2 source sync'ed to tag $TAG successfully!"
229+
if git -C $LDK_SOURCE_DIR checkout -b mybranch_$(date +%Y-%m-%d-%s) $TAG; then
230+
echo "$2 source sync'ed to tag $TAG successfully!"
231+
else
232+
echo "$2 could not sync to tag $TAG!"
233+
return 3
234+
fi
232235
else
233236
echo "Couldn't find tag $TAG"
234237
echo "$2 source sync to tag $TAG failed!"
235-
RET=1
238+
return 4
236239
fi
237240
popd > /dev/null
238241
fi
@@ -330,7 +333,6 @@ while getopts "$GETOPT" opt; do
330333
done
331334
shift $((OPTIND-1))
332335

333-
GRET=0
334336
for ((i=0; i < NSOURCES; i++)); do
335337
OPT=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 1 -d ':')
336338
WHAT=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 2 -d ':')
@@ -339,13 +341,11 @@ for ((i=0; i < NSOURCES; i++)); do
339341
DNLOAD=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 5 -d ':')
340342

341343
if [ $DALL -eq 1 -o "x${DNLOAD}" == "xy" ]; then
342-
DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "https://${REPO}" "${TAG}" "${OPT}"
343-
tRET=$?
344-
let GRET=GRET+tRET
345-
if [ $tRET -ne 0 -a $EOE -eq 1 ]; then
346-
exit $tRET
344+
if ! DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "https://${REPO}" "${TAG}" "${OPT}"; then
345+
if [[ $? == 1 ]]; then
346+
echo "Trying git protocol"
347+
DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "git://${REPO}" "${TAG}" "${OPT}"
348+
fi
347349
fi
348350
fi
349351
done
350-
351-
exit $GRET

scripts/source_sync_6.x.sh

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ o:tegra/v4l2-src/v4l2_libs:nv-tegra.nvidia.com/tegra/v4l2-src/v4l2_libs.git:
9393
"
9494

9595
# exit on error on sync
96-
EOE=0
9796
# after processing SOURCE_INFO
9897
NSOURCES=0
9998
declare -a SOURCE_INFO_PROCESSED
@@ -111,9 +110,8 @@ function Usages {
111110
echo "Use: $1 [options]"
112111
echo "Available general options are,"
113112
echo " -h : help"
114-
echo " -e : exit on sync error"
115113
echo " -d [DIR] : root of source is DIR"
116-
echo " -t [TAG] : Git tag that will be used to sync all the sources"
114+
echo " -t [TAG] : git tag that will be used to sync all the sources"
117115
echo ""
118116
echo "By default, all sources are downloaded."
119117
echo "Only specified sources are downloaded, if one or more of the following options are mentioned."
@@ -184,21 +182,17 @@ function DownloadAndSync {
184182
if ! git status 2>&1 >/dev/null; then
185183
echo "But the directory is not a git repository -- clean it up first"
186184
echo ""
187-
echo ""
188185
popd > /dev/null
189-
return 1
186+
return 2
190187
fi
191188
git fetch --all 2>&1 >/dev/null
192189
popd > /dev/null
193190
else
194-
echo "Downloading default $WHAT source..."
191+
echo "Downloading default $WHAT source3..."
195192

196-
git clone "$REPO_URL" -n ${LDK_SOURCE_DIR} 2>&1 >/dev/null
197-
if [ $? -ne 0 ]; then
198-
echo "$2 source sync failed!"
199-
echo ""
200-
echo ""
201-
return 2
193+
if ! git clone "$REPO_URL" -n ${LDK_SOURCE_DIR} >/dev/null; then
194+
echo "$2 source sync failed"
195+
return 1
202196
fi
203197

204198
echo "The default $WHAT source is downloaded in: ${LDK_SOURCE_DIR}"
@@ -212,19 +206,19 @@ function DownloadAndSync {
212206
UpdateTags $OPT $TAG
213207
fi
214208

215-
if [ ! -z "$TAG" ]; then
216-
if [ -z $(git -C $LDK_SOURCE_DIR tag -l "^$TAG\$") ]; then
209+
if [[ -n "$TAG" ]]; then
210+
if [ -n $(git -C $LDK_SOURCE_DIR tag -l "^$TAG\$") ]; then
217211
echo "Syncing up with tag $TAG..."
218212
if git -C $LDK_SOURCE_DIR checkout -b mybranch_$(date +%Y-%m-%d-%s) $TAG; then
219-
echo "$2 source sync'ed to tag $TAG successfully!"
220-
else
221-
echo "$2 could not sync to tag $TAG!"
222-
return 3
223-
fi
213+
echo "$2 source sync'ed to tag $TAG successfully!"
214+
else
215+
echo "$2 could not sync to tag $TAG!"
216+
return 3
217+
fi
224218
else
225219
echo "Couldn't find tag $TAG"
226220
echo "$2 source sync to tag $TAG failed!"
227-
return 4
221+
return 4
228222
fi
229223
fi
230224
echo ""
@@ -259,9 +253,6 @@ while getopts "$GETOPT" opt; do
259253
;;
260254
esac
261255
;;
262-
e)
263-
EOE=1
264-
;;
265256
h)
266257
Usages "$SCRIPT_NAME"
267258
exit 1
@@ -327,10 +318,13 @@ for ((i=0; i < NSOURCES; i++)); do
327318
DNLOAD=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 5 -d ':')
328319

329320
if [ $DALL -eq 1 -o "x${DNLOAD}" == "xy" ]; then
330-
DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "https://${REPO}" "${TAG}" "${OPT}"
321+
if ! DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "https://${REPO}" "${TAG}" "${OPT}"; then
322+
if [[ $? == 1 ]]; then
323+
echo "Trying git protocol"
324+
DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "git://${REPO}" "${TAG}" "${OPT}"
325+
fi
326+
fi
331327
fi
332328
done
333329

334330
ln -sf ../../../../../../nvethernetrm ${LDK_DIR}/nvidia-oot/drivers/net/ethernet/nvidia/nvethernet/nvethernetrm
335-
336-
exit 0

setup_workspace.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function DisplayNvidiaLicense {
1919
echo -e "${license}"
2020

2121
read -t 30 -n 1 -s -r -e -p 'Press any key to continue (or wait 30 seconds..)'
22+
echo
2223
}
2324

2425

0 commit comments

Comments
 (0)