Skip to content

Commit abc6a3f

Browse files
committed
sync scripts updated
1 parent 180ee9c commit abc6a3f

4 files changed

Lines changed: 47 additions & 71 deletions

File tree

scripts/source_sync_4.6.1.sh

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -168,29 +168,23 @@ function DownloadAndSync {
168168
local REPO_URL="$3"
169169
local TAG="$4"
170170
local OPT="$5"
171-
local RET=0
172171

173172
if [ -d "${LDK_SOURCE_DIR}" ]; then
174173
echo "Directory for $WHAT, ${LDK_SOURCE_DIR}, already exists!"
175174
pushd "${LDK_SOURCE_DIR}" > /dev/null
176-
git status 2>&1 >/dev/null
177-
if [ $? -ne 0 ]; then
175+
if ! git status 2>&1 >/dev/null; then
178176
echo "But the directory is not a git repository -- clean it up first"
179177
echo ""
180-
echo ""
181178
popd > /dev/null
182-
return 1
179+
return 2
183180
fi
184181
git fetch --all 2>&1 >/dev/null
185182
popd > /dev/null
186183
else
187184
echo "Downloading default $WHAT source..."
188185

189-
git clone "$REPO_URL" -n ${LDK_SOURCE_DIR} 2>&1 >/dev/null
190-
if [ $? -ne 0 ]; then
191-
echo "$2 source sync failed!"
192-
echo ""
193-
echo ""
186+
if ! git clone -n "$REPO_URL" ${LDK_SOURCE_DIR} 2>&1 >/dev/null; then
187+
echo "$2 source sync failed"
194188
return 1
195189
fi
196190

@@ -205,24 +199,24 @@ function DownloadAndSync {
205199
UpdateTags $OPT $TAG
206200
fi
207201

208-
if [ ! -z "$TAG" ]; then
209-
pushd ${LDK_SOURCE_DIR} > /dev/null
210-
git tag -l 2>/dev/null | grep -q -P "^$TAG\$"
211-
if [ $? -eq 0 ]; then
202+
if [[ -n "$TAG" ]]; then
203+
if [ -n $(git -C $LDK_SOURCE_DIR tag -l "^$TAG\$") ]; then
212204
echo "Syncing up with tag $TAG..."
213-
git checkout -b mybranch_$(date +%Y-%m-%d-%s) $TAG
214-
echo "$2 source sync'ed to tag $TAG successfully!"
205+
if git -C $LDK_SOURCE_DIR checkout -b mybranch_$(date +%Y-%m-%d-%s) $TAG; then
206+
echo "$2 source sync'ed to tag $TAG successfully!"
207+
else
208+
echo "$2 could not sync to tag $TAG!"
209+
echo
210+
return 3
211+
fi
215212
else
216213
echo "Couldn't find tag $TAG"
217214
echo "$2 source sync to tag $TAG failed!"
218-
RET=1
215+
echo
216+
return 4
219217
fi
220-
popd > /dev/null
221218
fi
222-
echo ""
223-
echo ""
224-
225-
return "$RET"
219+
echo
226220
}
227221

228222
# prepare processing ....
@@ -318,12 +312,12 @@ for ((i=0; i < NSOURCES; i++)); do
318312
DNLOAD=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 5 -d ':')
319313

320314
if [ $DALL -eq 1 -o "x${DNLOAD}" == "xy" ]; then
321-
if DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "git://${REPO}" "${TAG}" "${OPT}"; then
315+
if DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "https://${REPO}" "${TAG}" "${OPT}"; then
322316
true
323317
else
324318
if [[ $? == 1 ]]; then
325-
echo "Trying https protocol"
326-
DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "https://${REPO}" "${TAG}" "${OPT}"
319+
echo "Trying git protocol"
320+
DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "git://${REPO}" "${TAG}" "${OPT}"
327321
fi
328322
fi
329323
fi

scripts/source_sync_5.0.2.sh

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -179,29 +179,23 @@ function DownloadAndSync {
179179
local REPO_URL="$3"
180180
local TAG="$4"
181181
local OPT="$5"
182-
local RET=0
183182

184183
if [ -d "${LDK_SOURCE_DIR}" ]; then
185184
echo "Directory for $WHAT, ${LDK_SOURCE_DIR}, already exists!"
186185
pushd "${LDK_SOURCE_DIR}" > /dev/null
187-
git status 2>&1 >/dev/null
188-
if [ $? -ne 0 ]; then
186+
if ! git status 2>&1 >/dev/null; then
189187
echo "But the directory is not a git repository -- clean it up first"
190188
echo ""
191-
echo ""
192189
popd > /dev/null
193-
return 1
190+
return 2
194191
fi
195192
git fetch --all 2>&1 >/dev/null
196193
popd > /dev/null
197194
else
198195
echo "Downloading default $WHAT source..."
199196

200-
git clone "$REPO_URL" -n ${LDK_SOURCE_DIR} 2>&1 >/dev/null
201-
if [ $? -ne 0 ]; then
197+
if ! git clone -n "$REPO_URL" ${LDK_SOURCE_DIR} 2>&1 >/dev/null; then
202198
echo "$2 source sync failed!"
203-
echo ""
204-
echo ""
205199
return 1
206200
fi
207201

@@ -223,16 +217,17 @@ function DownloadAndSync {
223217
echo "$2 source sync'ed to tag $TAG successfully!"
224218
else
225219
echo "$2 could not sync to tag $TAG!"
220+
echo
226221
return 3
227222
fi
228223
else
229224
echo "Couldn't find tag $TAG"
230225
echo "$2 source sync to tag $TAG failed!"
226+
echo
231227
return 4
232228
fi
233229
fi
234-
echo ""
235-
return 0;
230+
echo
236231
}
237232

238233
# prepare processing ....
@@ -328,12 +323,12 @@ for ((i=0; i < NSOURCES; i++)); do
328323
DNLOAD=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 5 -d ':')
329324

330325
if [ $DALL -eq 1 -o "x${DNLOAD}" == "xy" ]; then
331-
if DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "git://${REPO}" "${TAG}" "${OPT}"; then
326+
if DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "https://${REPO}" "${TAG}" "${OPT}"; then
332327
true
333328
else
334329
if [[ $? == 1 ]]; then
335-
echo "Trying https protocol"
336-
DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "https://${REPO}" "${TAG}" "${OPT}"
330+
echo "Trying git protocol"
331+
DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "git://${REPO}" "${TAG}" "${OPT}"
337332
fi
338333
fi
339334
fi

scripts/source_sync_5.1.2.sh

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ o:tegra/optee-src/nv-optee:nv-tegra.nvidia.com/tegra/optee-src/nv-optee.git:
101101
o:tegra/v4l2-src/v4l2_libs:nv-tegra.nvidia.com/tegra/v4l2-src/v4l2_libs.git:
102102
"
103103

104-
# exit on error on sync
105-
EOE=0
106104
# after processing SOURCE_INFO
107105
NSOURCES=0
108106
declare -a SOURCE_INFO_PROCESSED
@@ -120,7 +118,6 @@ function Usages {
120118
echo "Use: $1 [options]"
121119
echo "Available general options are,"
122120
echo " -h : help"
123-
echo " -e : exit on sync error"
124121
echo " -d [DIR] : root of source is DIR"
125122
echo " -t [TAG] : Git tag that will be used to sync all the sources"
126123
echo ""
@@ -186,13 +183,11 @@ function DownloadAndSync {
186183
local REPO_URL="$3"
187184
local TAG="$4"
188185
local OPT="$5"
189-
local RET=0
190186

191187
if [ -d "${LDK_SOURCE_DIR}" ]; then
192188
echo "Directory for $WHAT, ${LDK_SOURCE_DIR}, already exists!"
193189
pushd "${LDK_SOURCE_DIR}" > /dev/null
194-
git status 2>&1 >/dev/null
195-
if [ $? -ne 0 ]; then
190+
if ! git status 2>&1 >/dev/null; then
196191
echo "But the directory is not a git repository -- clean it up first"
197192
echo ""
198193
popd > /dev/null
@@ -203,10 +198,8 @@ function DownloadAndSync {
203198
else
204199
echo "Downloading default $WHAT source..."
205200

206-
git clone "$REPO_URL" -n ${LDK_SOURCE_DIR} 2>&1 >/dev/null
207-
if [ $? -ne 0 ]; then
208-
echo "$2 source sync failed!"
209-
echo ""
201+
if ! git clone -n "$REPO_URL" ${LDK_SOURCE_DIR} 2>&1 >/dev/null; then
202+
echo "$2 source sync failed"
210203
return 1
211204
fi
212205

@@ -222,31 +215,27 @@ function DownloadAndSync {
222215
fi
223216

224217
if [[ -n "$TAG" ]]; then
225-
pushd ${LDK_SOURCE_DIR} > /dev/null
226-
git tag -l 2>/dev/null | grep -q -P "^$TAG\$"
227-
if [ $? -eq 0 ]; then
218+
if [ -n $(git -C $LDK_SOURCE_DIR tag -l "^$TAG\$") ]; then
228219
echo "Syncing up with tag $TAG..."
229220
if git -C $LDK_SOURCE_DIR checkout -b mybranch_$(date +%Y-%m-%d-%s) $TAG; then
230221
echo "$2 source sync'ed to tag $TAG successfully!"
231222
else
232223
echo "$2 could not sync to tag $TAG!"
224+
echo
233225
return 3
234226
fi
235227
else
236228
echo "Couldn't find tag $TAG"
237229
echo "$2 source sync to tag $TAG failed!"
230+
echo
238231
return 4
239232
fi
240-
popd > /dev/null
241233
fi
242-
echo ""
243-
echo ""
244-
245-
return "$RET"
234+
echo
246235
}
247236

248237
# prepare processing ....
249-
GETOPT=":ehd:t:"
238+
GETOPT=":hd:t:"
250239

251240
OIFS="$IFS"
252241
IFS=$(echo -en "\n\b")
@@ -273,9 +262,6 @@ while getopts "$GETOPT" opt; do
273262
;;
274263
esac
275264
;;
276-
e)
277-
EOE=1
278-
;;
279265
h)
280266
Usages "$SCRIPT_NAME"
281267
exit 1
@@ -341,12 +327,12 @@ for ((i=0; i < NSOURCES; i++)); do
341327
DNLOAD=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 5 -d ':')
342328

343329
if [ $DALL -eq 1 -o "x${DNLOAD}" == "xy" ]; then
344-
if DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "git://${REPO}" "${TAG}" "${OPT}"; then
330+
if DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "https://${REPO}" "${TAG}" "${OPT}"; then
345331
true
346332
else
347333
if [[ $? == 1 ]]; then
348-
echo "Trying https protocol"
349-
DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "https://${REPO}" "${TAG}" "${OPT}"
334+
echo "Trying git protocol"
335+
DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "git://${REPO}" "${TAG}" "${OPT}"
350336
fi
351337
fi
352338
fi

scripts/source_sync_6.x.sh

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ function DownloadAndSync {
190190
else
191191
echo "Downloading default $WHAT source..."
192192

193-
if ! git clone "$REPO_URL" -n ${LDK_SOURCE_DIR} >/dev/null; then
193+
if ! git clone -n "$REPO_URL" ${LDK_SOURCE_DIR} 2>&1 >/dev/null; then
194194
echo "$2 source sync failed"
195195
return 1
196196
fi
@@ -213,20 +213,21 @@ function DownloadAndSync {
213213
echo "$2 source sync'ed to tag $TAG successfully!"
214214
else
215215
echo "$2 could not sync to tag $TAG!"
216+
echo
216217
return 3
217218
fi
218219
else
219220
echo "Couldn't find tag $TAG"
220221
echo "$2 source sync to tag $TAG failed!"
222+
echo
221223
return 4
222224
fi
223225
fi
224-
echo ""
225-
return 0;
226+
echo
226227
}
227228

228229
# prepare processing ....
229-
GETOPT=":ehd:t:"
230+
GETOPT=":hd:t:"
230231

231232
OIFS="$IFS"
232233
IFS=$(echo -en "\n\b")
@@ -318,12 +319,12 @@ for ((i=0; i < NSOURCES; i++)); do
318319
DNLOAD=$(echo "${SOURCE_INFO_PROCESSED[i]}" | cut -f 5 -d ':')
319320

320321
if [ $DALL -eq 1 -o "x${DNLOAD}" == "xy" ]; then
321-
if DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "git://${REPO}" "${TAG}" "${OPT}"; then
322+
if DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "https://${REPO}" "${TAG}" "${OPT}"; then
322323
true
323324
else
324325
if [[ $? == 1 ]]; then
325-
echo "Trying https protocol"
326-
DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "https://${REPO}" "${TAG}" "${OPT}"
326+
echo "Trying git protocol"
327+
DownloadAndSync "$WHAT" "${LDK_DIR}/${WHAT}" "git://${REPO}" "${TAG}" "${OPT}"
327328
fi
328329
fi
329330
fi

0 commit comments

Comments
 (0)