Skip to content

Commit

Permalink
Merge branch 'dev' into dev-bake
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsuya-ishihara committed Nov 25, 2024
2 parents e324863 + 31fb79c commit e2e9203
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions setup-dependency.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ function help {
echo "-h show this help"
echo "-c clean (rm -rf) dependency repositories"
echo "-n <count> max count for recursive check (default=2)"
echo "-r update depedency-release.repos"
echo "-s <sed cmd> apply sed to dependency.repos file with the command"
}

clean=0
count=3
release=0
sed_cmd=

while getopts "hcn:" arg; do
while getopts "hcn:rs:" arg; do
case $arg in
h)
help
Expand All @@ -49,9 +53,23 @@ while getopts "hcn:" arg; do
n)
count=$OPTARG
;;
r)
release=1
;;
s)
sed_cmd=$OPTARG
;;
esac
done

## export dependencies to dependency-release.repos
if [[ $release -eq 1 ]]; then
mv .git .git-back # work around to eliminate the current repository itself
vcs export -n --exact-with-tags > dependency-release.repos
mv .git-back .git # restore the .git dir
exit
fi


if [[ $clean -eq 1 ]]; then
pwd=$(pwd)
Expand All @@ -68,6 +86,16 @@ if [[ $clean -eq 1 ]]; then
exit
fi


## for release
if [[ -e dependency-release.repos ]]; then
echo "setup dependency from release"
vcs import < dependency-release.repos
exit
fi


## for dev
declare -A visited

for (( i=1; i<=count; i++ ))
Expand All @@ -80,9 +108,20 @@ do
flag=1
visited[$line]=1

temp_file=$(mktemp)
echo "Temporary file created: $temp_file"
cat $line > $temp_file
if [[ ! -z $sed_cmd ]]; then
com="sed -i '$sed_cmd' $temp_file"
echo $com
eval $com
if [[ $? -ne 0 ]]; then
exit 1
fi
fi
blue "$(dirname $line)/ vcs import < $temp_file"
pushd $(dirname $line)
blue "$(dirname $line)/ vcs import < $(basename $line)"
vcs import < $(basename $line)
vcs import < $temp_file
popd
fi
done
Expand Down

0 comments on commit e2e9203

Please sign in to comment.