Skip to content
Snippets Groups Projects
Commit 1c799c74 authored by Andreas Gnau's avatar Andreas Gnau :speech_balloon:
Browse files

bcmkernel: bcm_git: Factor out importing and merging

Factor out importing and merging to separate functions. This will make
it easier to run the steps just for one tarball or tarballs with
differing naming conventions such as wifi-tarballs.
parent 4697b003
No related branches found
No related tags found
No related merge requests found
...@@ -104,6 +104,165 @@ is_module_already_added_to_repo() ...@@ -104,6 +104,165 @@ is_module_already_added_to_repo()
esac esac
} }
import_module()
{
local repo="$1"
local module="$2"
local version="$3"
local tar_path="$4"
local tar="$(basename "$tar_path")"
if is_module_already_added_to_repo "$repo" "$module" "$version"
then
echo "Already added ${version} "$module" (corresponding branch/tag exists already). Skipping!"
return 0
fi
set -u
# Set up git branch
case ${module} in
"data_full_release")
# for each data_full_release we create a new commit on the broadcom branch
echo -e "\t${tar} this is the base module"
# prep repo. clean out all old files
git -C ${repo} checkout broadcom
git -C ${repo} rm -rq .
;;
*)
# for all addon-modules, branch off from data_full_release tag
# to apply addon in the next step
git_new_branch "$repo" "$version" "$module"
esac
# Unpack outer tarball to temporary directory inside repo
mkdir "${repo}/git_tmp"
echo "Unpacking outer tarball $tar"
pv ${tar_path} | tar -xz -C ${repo}/git_tmp
local latest_file="$(get_latest_file_in_path "${repo}/git_tmp")"
local git_commit_date="$(get_file_modification_date_as_git_date "$latest_file")"
# XXX: These special cases can be generalized and the cd-ing can be avoided
# XXX: maybe check that README in outer tar matches what we expect, so we get notified
# when the script needs updating for new instructions. Overkill or useful sanity check?
case ${module} in
"data_full_release")
tar_src=$( basename $tar | sed -e "s/${module}/data_src/")
echo "unpack $tar_src"
mkdir ${repo}/bcm963xx
# exclude any included git repo
pv ${repo}/git_tmp/${tar_src} | tar -xz --exclude=\.git -C ${repo}/bcm963xx
do_merge=1
;;
"voice_addon"|"voice_eptapp_addon")
( cd_repo $repo
cd git_tmp
# if you think that you can do "yes | ./bcmvoiceinstall ../" you are wrong. does not work.
echo "yy" | ./bcmvoiceinstall ../bcm963xx
)
;;
"data_gfast_src")
( cd_repo $repo
tar -xf git_tmp/*tar.gz -C bcm963xx
)
;;
"xpon_src")
( cd_repo $repo
rm -rf bcm963xx/userspace/private/apps/omcid/*
rm -rf bcm963xx/bcmdrivers/broadcom/char/gpon/*
rm -rf bcm963xx/userspace/private/libs/eponsdk
tar -xf git_tmp/*tar.gz -C bcm963xx
)
;;
"bdkuserspace_src"|"openwrtsupport_src")
( cd_repo $repo
for tar in git_tmp/*tar.gz
do
tar --overwrite -xf $tar -C bcm963xx
done
)
;;
*)
echo -e "\t ${module} from ${tar} not supported"
return 1
;;
esac
rm -rf ${repo}/git_tmp
# add files to git
echo "Now adding files to git. this takes some time"
git -C "$repo" add -A -f
local tar_md5="$(md5sum "${tar_path}" | cut -f1 -d ' ')"
local tar_sha256="$(sha256sum "${tar_path}" | cut -f1 -d ' ')"
case ${module} in
"data_full_release")
( echo "Add Broadcom release $version"
echo
echo "Filename: ${tar}"
echo "SHA256: ${tar_sha256}"
echo "MD5: ${tar_md5}" ) | \
git -C "$repo" commit \
--author="broadcom release <broadcom_release@broadcom.com>" \
--date="$git_commit_date" \
-F - \
-q
git -C ${repo} tag bcm_${version}_t
;;
*)
( echo "Add ${module} to release ${version}"
echo
echo "Filename: ${tar}"
echo "SHA256: ${tar_sha256}"
echo "MD5: ${tar_md5}" ) | \
git -C "$repo" commit \
--author="broadcom release <broadcom_release@broadcom.com>" \
--date="$git_commit_date" \
-F - \
-q
;;
esac
}
merge_module_into_bcm_branch()
{
# requires to be on the right branch bcm_$version
local repo="$1"
local module="$2"
local version="$3"
case ${module} in
"data_full_release")
true
;;
*)
echo "trying to merge ${module} from branch ${version}_${module}"
if git -C ${repo} branch | grep "bcm_${version}_${module}$"
then
if ! git -C ${repo} merge --no-commit --no-ff -Xtheirs bcm_${version}_${module}
then
# so this merge did not work. clean up and skip it.
git -C ${repo} merge --abort
git -C ${repo} reset --hard
git -C ${repo} clean -ffxd
return
fi
local status="$(git -C "$repo" status --porcelain)"
if [ -n "$status" ]; then
git -C ${repo} commit --author="broadcom release <broadcom_release@broadcom.com>" \
-m "Merge in bcm_${version}_${module}"
else
echo "No changes => not committing anything. ${module} ${version} has probably already been merged"
fi
fi
;;
esac
}
add_release () add_release ()
{ {
local version=$1 local version=$1
...@@ -120,161 +279,31 @@ add_release () ...@@ -120,161 +279,31 @@ add_release ()
for module in $bcm_modules for module in $bcm_modules
do do
tar="bcm963xx_${version}_${module}.tar.gz" tar="bcm963xx_${version}_${module}.tar.gz"
if is_module_already_added_to_repo "$repo" "$module" "$version" if ! [ -f ${tar_dir}/${tar} ]
then
echo "Already added ${version} "$module" (corresponding branch/tag exists already). Skipping!"
continue
elif ! [ -f ${tar_dir}/${tar} ]
then then
echo -e "\ttar not found. skipping $tar" echo -e "\ttar not found. skipping $tar"
continue continue
fi fi
import_module "$repo" "$module" "$version" "${tar_dir}/${tar}"
# Set up git branch
case ${module} in
"data_full_release")
# for each data_full_release we create a new commit on the broadcom branch
echo -e "\t${tar} this is the base module"
# prep repo. clean out all old files
git -C ${repo} checkout broadcom
git -C ${repo} rm -rq .
;;
*)
# for all addon-modules, branch off from data_full_release tag
# to apply addon in the next step
git_new_branch "$repo" "$version" "$module"
esac
# Unpack outer tarball to temporary directory inside repo
mkdir "${repo}/git_tmp"
echo "Unpacking outer tarball $tar"
local tar_name="$(basename $tar)"
pv ${tar_dir}/${tar} | tar -xz -C ${repo}/git_tmp
local latest_file="$(get_latest_file_in_path "${repo}/git_tmp")"
local git_commit_date="$(get_file_modification_date_as_git_date "$latest_file")"
case ${module} in
"data_full_release")
tar_src=$( basename $tar | sed -e "s/${module}/data_src/")
echo "unpack $tar_src"
mkdir ${repo}/bcm963xx
# exclude any included git repo
pv ${repo}/git_tmp/${tar_src} | tar -xz --exclude=\.git -C ${repo}/bcm963xx
do_merge=1
;;
"voice_addon"|"voice_eptapp_addon")
( cd_repo $repo
cd git_tmp
# if you think that you can do "yes | ./bcmvoiceinstall ../" you are wrong. does not work.
echo "yy" | ./bcmvoiceinstall ../bcm963xx
)
;;
"data_gfast_src")
( cd_repo $repo
tar -xf git_tmp/*tar.gz -C bcm963xx
)
;;
"xpon_src")
( cd_repo $repo
rm -rf bcm963xx/userspace/private/apps/omcid/*
rm -rf bcm963xx/bcmdrivers/broadcom/char/gpon/*
rm -rf bcm963xx/userspace/private/libs/eponsdk
tar -xf git_tmp/*tar.gz -C bcm963xx
)
;;
"bdkuserspace_src"|"openwrtsupport_src")
( cd_repo $repo
for tar in git_tmp/*tar.gz
do
tar --overwrite -xf $tar -C bcm963xx
done
)
;;
*)
echo -e "\t${tar}"
;;
esac
rm -rf ${repo}/git_tmp
# add files to git
echo "Now adding files to git. this takes some time"
git -C "$repo" add -A -f
local tar_md5="$(md5sum "${tar_dir}/${tar}" | cut -f1 -d ' ')"
local tar_sha256="$(sha256sum "${tar_dir}/${tar}" | cut -f1 -d ' ')"
case ${module} in
"data_full_release")
( echo "Add Broadcom release $version"
echo
echo "Filename: ${tar_name}"
echo "SHA256: ${tar_sha256}"
echo "MD5: ${tar_md5}" ) | \
git -C "$repo" commit \
--author="broadcom release <broadcom_release@broadcom.com>" \
--date="$git_commit_date" \
-F - \
-q
git -C ${repo} tag bcm_${version}_t
;;
*)
( echo "Add ${module} to release ${version}"
echo
echo "Filename: ${tar_name}"
echo "SHA256: ${tar_sha256}"
echo "MD5: ${tar_md5}" ) | \
git -C "$repo" commit \
--author="broadcom release <broadcom_release@broadcom.com>" \
--date="$git_commit_date" \
-F - \
-q
;;
esac
done done
# All modules have been added. Make the main branch and do the octopus merge. # All modules have been added. Make the main branch and do the octopus merge.
# but only if the tag exist. # but only if the tag exist.
# BUG: so octopus do not work since broadcom adds the same binary file in mutiple addon modules. :( # BUG: so octopus do not work since broadcom adds the same binary file in mutiple addon modules. :(
if [ "$do_merge" == "1" ] if git -C ${repo} tag | grep "bcm_${version}_t$"
then then
if git -C ${repo} tag | grep "bcm_${version}_t$" git -C ${repo} reset --hard
then git -C ${repo} clean -ffxd
git -C ${repo} reset --hard git -C ${repo} checkout bcm_${version}_t
git -C ${repo} clean -ffxd git -C ${repo} branch bcm_${version} || true # Ignore if branch exists already
git -C ${repo} checkout bcm_${version}_t git -C ${repo} checkout bcm_${version}
git -C ${repo} branch bcm_${version} git -C ${repo} reset --hard
git -C ${repo} checkout bcm_${version} git -C ${repo} clean -ffxd
git -C ${repo} reset --hard branch_list=""
git -C ${repo} clean -ffxd for module in $bcm_modules
branch_list="" do
for module in $bcm_modules merge_module_into_bcm_branch "$repo" "$module" "$version"
do done
case ${module} in
"data_full_release")
true
;;
*)
echo "trying to merge ${module} from branch ${version}_${module}"
if git -C ${repo} branch | grep "bcm_${version}_${module}$"
then
if ! git -C ${repo} merge --no-commit --no-ff -Xtheirs bcm_${version}_${module}
then
# so this merge did not work. clean up and skip it.
git -C ${repo} merge --abort
git -C ${repo} reset --hard
git -C ${repo} clean -ffxd
return
fi
git -C ${repo} commit --author="broadcom release<broadcom_release@broadcom.com>" \
-m "Merge in bcm_${version}_${module}"
fi
;;
esac
done
fi
fi fi
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment