Skip to content

Commit 1506e42

Browse files
committed
babs.sh git am fix for amd-fftw project
fix patch apply dir in case where same source directory is used by multiple projects. (to build same sources multiple times) fixes: #12 Signed-off-by: Mika Laitio <[email protected]>
1 parent b95d8b7 commit 1506e42

File tree

1 file changed

+55
-42
lines changed

1 file changed

+55
-42
lines changed

babs.sh

+55-42
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ func_repolist_upstream_remote_repo_add() {
139139
echo "${jj}: Creating source code directory: ${LIST_APP_SRC_CLONE_DIR[$jj]}"
140140
sleep 0.2
141141
mkdir -p ${LIST_APP_SRC_CLONE_DIR[$jj]}
142+
# LIST_APP_ADDED_UPSTREAM_REPO parameter is used in
143+
# situations where same src_code directory is used for building multiple projects
144+
# with just different configure parameters (for example amd-fftw)
145+
# in this case we want to add upstream repo and apply patches only once
142146
LIST_APP_ADDED_UPSTREAM_REPO[$jj]=1
143147
fi
144148
if [ "${LIST_APP_UPSTREAM_REPO_DEFINED[$jj]}" == "1" ]; then
@@ -169,7 +173,9 @@ func_repolist_upstream_remote_repo_add() {
169173
while [ "x${LIST_APP_SRC_CLONE_DIR[jj]}" != "x" ]
170174
do
171175
#echo "LIST_APP_ADDED_UPSTREAM_REPO[$jj]: ${LIST_APP_ADDED_UPSTREAM_REPO[$jj]}"
176+
# check if directory was just created and git fetch needs to be done
172177
if [ ${LIST_APP_ADDED_UPSTREAM_REPO[$jj]} -eq 1 ]; then
178+
echo "${jj}: git fetch on ${LIST_APP_SRC_CLONE_DIR[$jj]}"
173179
cd "${LIST_APP_SRC_CLONE_DIR[$jj]}"
174180
git fetch upstream
175181
if [ $? -ne 0 ]; then
@@ -195,6 +201,7 @@ func_repolist_upstream_remote_repo_add() {
195201
while [ "x${LIST_APP_PATCH_DIR[jj]}" != "x" ]
196202
do
197203
#echo "LIST_APP_ADDED_UPSTREAM_REPO[$jj]: ${LIST_APP_ADDED_UPSTREAM_REPO[$jj]}"
204+
# check if directory was just created and git am needs to be done
198205
if [ ${LIST_APP_ADDED_UPSTREAM_REPO[$jj]} -eq 1 ]; then
199206
TEMP_PATCH_DIR=${LIST_APP_PATCH_DIR[$jj]}
200207
cd "${LIST_APP_SRC_CLONE_DIR[$jj]}"
@@ -286,7 +293,7 @@ func_repolist_checkout_default_versions() {
286293
while [ "x${LIST_APP_PATCH_DIR[jj]}" != "x" ]
287294
do
288295
if [ "${LIST_APP_UPSTREAM_REPO_DEFINED[$jj]}" == "1" ]; then
289-
echo "Repository to reset: ${LIST_BINFO_APP_NAME[${jj}]}"
296+
echo "[$jj]: Repository to reset: ${LIST_BINFO_APP_NAME[${jj}]}"
290297
sleep 0.2
291298
cd "${LIST_APP_SRC_CLONE_DIR[$jj]}"
292299
git reset --hard
@@ -530,51 +537,57 @@ func_repolist_checkout_by_version_tag_file() {
530537
}
531538

532539
func_repolist_apply_patches() {
540+
declare -A DICTIONARY_PATCHED_PROJECTS
533541
echo "func_repolist_apply_patches"
534542
jj=0
535543
while [ "x${LIST_APP_SRC_CLONE_DIR[jj]}" != "x" ]
536544
do
537-
if [ "${LIST_APP_UPSTREAM_REPO_DEFINED[$jj]}" == "1" ]; then
538-
cd "${LIST_APP_SRC_CLONE_DIR[$jj]}"
539-
func_is_current_dir_a_git_repo_dir
540-
if [ $? -eq 0 ]; then
541-
TEMP_PATCH_DIR=${LIST_APP_PATCH_DIR[$jj]}
542-
echo "patch dir: ${TEMP_PATCH_DIR}"
543-
if [ -d "${TEMP_PATCH_DIR}" ]; then
544-
if [ ! -z "$(ls -A $TEMP_PATCH_DIR)" ]; then
545-
echo "${LIST_BINFO_APP_NAME[${jj}]}: applying patches"
546-
sleep 0.2
547-
git am --keep-cr "${TEMP_PATCH_DIR}"/*.patch
548-
if [ $? -ne 0 ]; then
549-
git am --abort
550-
echo ""
551-
echo "repository: ${LIST_APP_SRC_CLONE_DIR[${jj}]}"
552-
echo "git am ${TEMP_PATCH_DIR[jj]}/*.patch failed"
553-
echo ""
554-
exit 1
555-
else
556-
echo "patches applied: ${LIST_APP_SRC_CLONE_DIR[${jj}]}"
557-
#echo "git am ok"
558-
fi
559-
else
560-
echo "Warning, empty patch directory: ${TEMP_PATCH_DIR}"
561-
sleep 2
562-
fi
563-
else
564-
true
565-
echo "${LIST_BINFO_APP_NAME[${jj}]}: No patches to apply"
566-
#echo "patch directory does not exist: ${TEMP_PATCH_DIR}"
567-
#sleep 2
568-
fi
569-
sleep 0.2
570-
else
571-
echo "Warning, not a git repository: ${LIST_APP_SRC_CLONE_DIR[${jj}]}"
572-
sleep 2
573-
fi
574-
else
575-
echo "repo am paches skipped, no repository defined: ${LIST_BINFO_APP_NAME[${jj}]}"
576-
fi
577-
jj=$(( ${jj} + 1 ))
545+
if [ -z ${DICTIONARY_PATCHED_PROJECTS[${LIST_BINFO_APP_NAME[${jj}]}]} ]; then
546+
if [ "${LIST_APP_UPSTREAM_REPO_DEFINED[$jj]}" == "1" ]; then
547+
cd "${LIST_APP_SRC_CLONE_DIR[$jj]}"
548+
func_is_current_dir_a_git_repo_dir
549+
if [ $? -eq 0 ]; then
550+
TEMP_PATCH_DIR=${LIST_APP_PATCH_DIR[$jj]}
551+
echo "patch dir: ${TEMP_PATCH_DIR}"
552+
if [ -d "${TEMP_PATCH_DIR}" ]; then
553+
if [ ! -z "$(ls -A $TEMP_PATCH_DIR)" ]; then
554+
echo "[$jj]: ${LIST_BINFO_APP_NAME[${jj}]}: applying patches"
555+
sleep 0.2
556+
git am --keep-cr "${TEMP_PATCH_DIR}"/*.patch
557+
if [ $? -ne 0 ]; then
558+
git am --abort
559+
echo ""
560+
echo "repository: ${LIST_APP_SRC_CLONE_DIR[${jj}]}"
561+
echo "git am ${TEMP_PATCH_DIR[jj]}/*.patch failed"
562+
echo ""
563+
exit 1
564+
else
565+
echo "patches applied: ${LIST_APP_SRC_CLONE_DIR[${jj}]}"
566+
#echo "git am ok"
567+
fi
568+
DICTIONARY_PATCHED_PROJECTS[${LIST_BINFO_APP_NAME[${jj}]}]=1
569+
else
570+
echo "Warning, empty patch directory: ${TEMP_PATCH_DIR}"
571+
sleep 2
572+
fi
573+
else
574+
true
575+
echo "${LIST_BINFO_APP_NAME[${jj}]}: No patches to apply"
576+
#echo "patch directory does not exist: ${TEMP_PATCH_DIR}"
577+
#sleep 2
578+
fi
579+
sleep 0.2
580+
else
581+
echo "Warning, not a git repository: ${LIST_APP_SRC_CLONE_DIR[${jj}]}"
582+
sleep 2
583+
fi
584+
else
585+
echo "repo am paches skipped, no repository defined: ${LIST_BINFO_APP_NAME[${jj}]}"
586+
fi
587+
else
588+
echo "[$jj]: ${LIST_BINFO_APP_NAME[${jj}]}: patches already applied, skipping"
589+
fi
590+
jj=$(( ${jj} + 1 ))
578591
done
579592
}
580593

0 commit comments

Comments
 (0)