2017-09-29 13:11:56 +03:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# This code is licensed under the GPL version 2 or later. See
|
|
|
|
# the COPYING file in the top-level directory.
|
|
|
|
|
|
|
|
substat=".git-submodule-status"
|
|
|
|
|
|
|
|
command=$1
|
|
|
|
shift
|
2017-10-27 12:49:58 +03:00
|
|
|
maybe_modules="$@"
|
2017-09-29 13:11:56 +03:00
|
|
|
|
configure: replace --enable/disable-git-update with --with-git-submodules
Replace the --enable-git-update and --disable-git-update configure params
with the param --with-git-submodules=(update|validate|ignore) to
allow 3 options for building from a git repo.
This is needed because downstream packagers, e.g. Debian, Ubuntu, etc,
also keep the source code in git, but do not want to enable the
'git_update' mode; with the current code, that's not possible even
if the downstream package specifies --disable-git-update.
The previous parameters are deprecated but still available; the
--enable-git-update parameter maps to --with-git-submodules=update and
--disable-git-update parameter maps to --with-git-submodules=validate.
The configure script behavior is slightly modified, where previously
the dtc, capstone, and slirp submodules were not validated when
--disable-git-update was specified (but were updated with git-update
enabled), now they are validated when using --with-git-submodules=validate
and are only ignored when using --with-git-submodules=ignore.
Signed-off-by: Dan Streetman <ddstreet@canonical.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-19 20:20:46 +03:00
|
|
|
# if --with-git-submodules=ignore, do nothing
|
|
|
|
test "$command" = "ignore" && exit 0
|
|
|
|
|
2023-05-25 13:36:28 +03:00
|
|
|
test -z "$GIT" && GIT=$(command -v git)
|
2017-10-20 17:02:43 +03:00
|
|
|
|
configure: replace --enable/disable-git-update with --with-git-submodules
Replace the --enable-git-update and --disable-git-update configure params
with the param --with-git-submodules=(update|validate|ignore) to
allow 3 options for building from a git repo.
This is needed because downstream packagers, e.g. Debian, Ubuntu, etc,
also keep the source code in git, but do not want to enable the
'git_update' mode; with the current code, that's not possible even
if the downstream package specifies --disable-git-update.
The previous parameters are deprecated but still available; the
--enable-git-update parameter maps to --with-git-submodules=update and
--disable-git-update parameter maps to --with-git-submodules=validate.
The configure script behavior is slightly modified, where previously
the dtc, capstone, and slirp submodules were not validated when
--disable-git-update was specified (but were updated with git-update
enabled), now they are validated when using --with-git-submodules=validate
and are only ignored when using --with-git-submodules=ignore.
Signed-off-by: Dan Streetman <ddstreet@canonical.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-19 20:20:46 +03:00
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
|
|
|
|
update_error() {
|
2017-10-20 17:02:43 +03:00
|
|
|
echo "$0: $*"
|
|
|
|
echo
|
|
|
|
echo "Unable to automatically checkout GIT submodules '$modules'."
|
|
|
|
echo "If you require use of an alternative GIT binary (for example to"
|
2023-05-25 13:36:28 +03:00
|
|
|
echo "enable use of a transparent proxy), please disable automatic"
|
|
|
|
echo "GIT submodule checkout with:"
|
2017-10-26 15:52:26 +03:00
|
|
|
echo
|
configure: replace --enable/disable-git-update with --with-git-submodules
Replace the --enable-git-update and --disable-git-update configure params
with the param --with-git-submodules=(update|validate|ignore) to
allow 3 options for building from a git repo.
This is needed because downstream packagers, e.g. Debian, Ubuntu, etc,
also keep the source code in git, but do not want to enable the
'git_update' mode; with the current code, that's not possible even
if the downstream package specifies --disable-git-update.
The previous parameters are deprecated but still available; the
--enable-git-update parameter maps to --with-git-submodules=update and
--disable-git-update parameter maps to --with-git-submodules=validate.
The configure script behavior is slightly modified, where previously
the dtc, capstone, and slirp submodules were not validated when
--disable-git-update was specified (but were updated with git-update
enabled), now they are validated when using --with-git-submodules=validate
and are only ignored when using --with-git-submodules=ignore.
Signed-off-by: Dan Streetman <ddstreet@canonical.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-19 20:20:46 +03:00
|
|
|
echo " $ ./configure --with-git-submodules=validate"
|
2017-10-26 15:52:26 +03:00
|
|
|
echo
|
|
|
|
echo "and then manually update submodules prior to running make, with:"
|
|
|
|
echo
|
2023-05-25 13:36:28 +03:00
|
|
|
echo " $ GIT='tsocks git' scripts/git-submodule.sh update $modules"
|
2017-10-26 15:52:26 +03:00
|
|
|
echo
|
2017-10-20 17:02:43 +03:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
configure: replace --enable/disable-git-update with --with-git-submodules
Replace the --enable-git-update and --disable-git-update configure params
with the param --with-git-submodules=(update|validate|ignore) to
allow 3 options for building from a git repo.
This is needed because downstream packagers, e.g. Debian, Ubuntu, etc,
also keep the source code in git, but do not want to enable the
'git_update' mode; with the current code, that's not possible even
if the downstream package specifies --disable-git-update.
The previous parameters are deprecated but still available; the
--enable-git-update parameter maps to --with-git-submodules=update and
--disable-git-update parameter maps to --with-git-submodules=validate.
The configure script behavior is slightly modified, where previously
the dtc, capstone, and slirp submodules were not validated when
--disable-git-update was specified (but were updated with git-update
enabled), now they are validated when using --with-git-submodules=validate
and are only ignored when using --with-git-submodules=ignore.
Signed-off-by: Dan Streetman <ddstreet@canonical.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-19 20:20:46 +03:00
|
|
|
validate_error() {
|
|
|
|
if test "$1" = "validate"; then
|
|
|
|
echo "GIT submodules checkout is out of date, and submodules"
|
|
|
|
echo "configured for validate only. Please run"
|
|
|
|
echo " scripts/git-submodule.sh update $maybe_modules"
|
|
|
|
echo "from the source directory or call configure with"
|
|
|
|
echo " --with-git-submodules=update"
|
|
|
|
echo "To disable GIT submodules validation, use"
|
|
|
|
echo " --with-git-submodules=ignore"
|
|
|
|
fi
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2022-04-26 16:06:49 +03:00
|
|
|
if test -n "$maybe_modules" && ! test -e ".git"
|
|
|
|
then
|
|
|
|
echo "$0: unexpectedly called with submodules but no git checkout exists"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-05-25 13:36:28 +03:00
|
|
|
if test -n "$maybe_modules" && test -z "$GIT"
|
|
|
|
then
|
|
|
|
echo "$0: unexpectedly called with submodules but git binary not found"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2017-10-27 12:49:58 +03:00
|
|
|
modules=""
|
|
|
|
for m in $maybe_modules
|
|
|
|
do
|
|
|
|
$GIT submodule status $m 1> /dev/null 2>&1
|
|
|
|
if test $? = 0
|
|
|
|
then
|
|
|
|
modules="$modules $m"
|
|
|
|
else
|
|
|
|
echo "warn: ignoring non-existent submodule $m"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2017-09-29 13:11:56 +03:00
|
|
|
case "$command" in
|
configure: replace --enable/disable-git-update with --with-git-submodules
Replace the --enable-git-update and --disable-git-update configure params
with the param --with-git-submodules=(update|validate|ignore) to
allow 3 options for building from a git repo.
This is needed because downstream packagers, e.g. Debian, Ubuntu, etc,
also keep the source code in git, but do not want to enable the
'git_update' mode; with the current code, that's not possible even
if the downstream package specifies --disable-git-update.
The previous parameters are deprecated but still available; the
--enable-git-update parameter maps to --with-git-submodules=update and
--disable-git-update parameter maps to --with-git-submodules=validate.
The configure script behavior is slightly modified, where previously
the dtc, capstone, and slirp submodules were not validated when
--disable-git-update was specified (but were updated with git-update
enabled), now they are validated when using --with-git-submodules=validate
and are only ignored when using --with-git-submodules=ignore.
Signed-off-by: Dan Streetman <ddstreet@canonical.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-19 20:20:46 +03:00
|
|
|
status|validate)
|
|
|
|
test -f "$substat" || validate_error "$command"
|
2023-05-30 18:10:29 +03:00
|
|
|
test -z "$maybe_modules" && exit 0
|
2020-01-29 13:21:13 +03:00
|
|
|
for module in $modules; do
|
|
|
|
CURSTATUS=$($GIT submodule status $module)
|
|
|
|
OLDSTATUS=$(cat $substat | grep $module)
|
|
|
|
if test "$CURSTATUS" != "$OLDSTATUS"; then
|
configure: replace --enable/disable-git-update with --with-git-submodules
Replace the --enable-git-update and --disable-git-update configure params
with the param --with-git-submodules=(update|validate|ignore) to
allow 3 options for building from a git repo.
This is needed because downstream packagers, e.g. Debian, Ubuntu, etc,
also keep the source code in git, but do not want to enable the
'git_update' mode; with the current code, that's not possible even
if the downstream package specifies --disable-git-update.
The previous parameters are deprecated but still available; the
--enable-git-update parameter maps to --with-git-submodules=update and
--disable-git-update parameter maps to --with-git-submodules=validate.
The configure script behavior is slightly modified, where previously
the dtc, capstone, and slirp submodules were not validated when
--disable-git-update was specified (but were updated with git-update
enabled), now they are validated when using --with-git-submodules=validate
and are only ignored when using --with-git-submodules=ignore.
Signed-off-by: Dan Streetman <ddstreet@canonical.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-19 20:20:46 +03:00
|
|
|
validate_error "$command"
|
2020-01-29 13:21:13 +03:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
exit 0
|
2017-09-29 13:11:56 +03:00
|
|
|
;;
|
|
|
|
update)
|
2023-05-30 18:10:29 +03:00
|
|
|
test -e $substat || touch $substat
|
|
|
|
test -z "$maybe_modules" && exit 0
|
2017-10-30 11:29:29 +03:00
|
|
|
|
2017-10-20 17:02:43 +03:00
|
|
|
$GIT submodule update --init $modules 1>/dev/null
|
configure: replace --enable/disable-git-update with --with-git-submodules
Replace the --enable-git-update and --disable-git-update configure params
with the param --with-git-submodules=(update|validate|ignore) to
allow 3 options for building from a git repo.
This is needed because downstream packagers, e.g. Debian, Ubuntu, etc,
also keep the source code in git, but do not want to enable the
'git_update' mode; with the current code, that's not possible even
if the downstream package specifies --disable-git-update.
The previous parameters are deprecated but still available; the
--enable-git-update parameter maps to --with-git-submodules=update and
--disable-git-update parameter maps to --with-git-submodules=validate.
The configure script behavior is slightly modified, where previously
the dtc, capstone, and slirp submodules were not validated when
--disable-git-update was specified (but were updated with git-update
enabled), now they are validated when using --with-git-submodules=validate
and are only ignored when using --with-git-submodules=ignore.
Signed-off-by: Dan Streetman <ddstreet@canonical.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
2021-01-19 20:20:46 +03:00
|
|
|
test $? -ne 0 && update_error "failed to update modules"
|
2017-10-20 17:02:43 +03:00
|
|
|
|
2023-05-30 18:10:29 +03:00
|
|
|
(while read -r; do
|
|
|
|
for module in $modules; do
|
|
|
|
case $REPLY in
|
|
|
|
*" $module "*) continue 2 ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
printf '%s\n' "$REPLY"
|
|
|
|
done
|
|
|
|
$GIT submodule status $modules
|
|
|
|
test $? -ne 0 && update_error "failed to save git submodule status" >&2) < $substat > $substat.new
|
|
|
|
mv -f $substat.new $substat
|
2017-09-29 13:11:56 +03:00
|
|
|
;;
|
|
|
|
esac
|
2017-10-20 17:02:43 +03:00
|
|
|
|
|
|
|
exit 0
|