Commit 1d0e0ab0 authored by Alessandro Rubini's avatar Alessandro Rubini

scripts/check-submodule: really check submodules of ../

The should pick other repositories from ../ only if both use and them
are submodules of ../ .

Only checking that ../zio is a directory is not enough, because it
can be a separate clone (old version, for example) or worse an
intermediate directory that doesn't host headers.

A user reported painful build errors for this reason.
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 9074f5b8
#!/bin/bash
if [ $# -gt 2 -o $# -lt 1 ]; then
echo "Use: \"$0 <repo-name> <user-provided-path>\" >& 2"
echo "Example: \"$0 spec-sw $SPEC_SW\" >& 2"
exit 1
fi
repo_name=$1
repo_path=$2
# User-provided takes precedence
if [ "$repo_path" != "" ]; then
echo "Using user-supplied submodule path for $repo_name [$repo_path]" 1>&2
path=$repo_path
elif [ -d "../$repo_name" ]; then
echo "Using Git repo in parent directory for $repo_name [../$repo_name]" 1>&2
path="../$repo_name"
else
echo "Using local submodule checkout for $repo_name" 1>&2
git submodule update --init $repo_name 1>&2
path=$repo_name
echo "Submodule \"$repo_name\": using provided path \"$repo_path\"" >&2
echo $(readlink -f $repo_path)
exit 0
fi
# If this project and the other project are both submodules, pick ../<repo>
# Otherwise, pick subdirectory of current project
if [ ! -f ../.gitmodules ]; then
# dot-dot has no submodules, pick subdir
echo "Submodule \"$repo_name\": using local copy" >&2
echo $(readlink -f $repo_name)
exit 0
fi
this_dir=$(basename $(/bin/pwd))
if ! grep "submodule \"$this_dir\"" ../.gitmodules > /dev/null; then
# we are not a submodule of dot-dot
echo "Submodule \"$repo_name\": using local copy" >&2
echo $(readlink -f $repo_name)
exit 0
fi
if ! grep "submodule \"$repo_name\"" ../.gitmodules > /dev/null; then
# our repo is not a submodule of dot-dot
echo $FMC_SUBDIR
echo "Submodule \"$repo_name\": using local copy" >&2
echo $(readlink -f $repo_name)
exit 0
fi
echo `readlink -f $path`
\ No newline at end of file
echo "Submodule \"$repo_name\": using copy in parent directory" >&2
echo $(readlink -f ../$repo_name)
exit 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment