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
|
|
|
|
2023-06-19 00:10:39 +03:00
|
|
|
test -z "$maybe_modules" && 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")/.."
|
|
|
|
|
2023-06-19 00:10:39 +03:00
|
|
|
no_git_error=
|
|
|
|
if ! test -e ".git"; then
|
|
|
|
no_git_error='no git checkout exists'
|
|
|
|
elif test -z "$GIT"; then
|
|
|
|
no_git_error='git binary not found'
|
|
|
|
fi
|
|
|
|
|
|
|
|
is_git() {
|
|
|
|
test -z "$no_git_error"
|
|
|
|
}
|
|
|
|
|
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
|
|
|
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
|
2023-05-30 17:03:50 +03:00
|
|
|
echo " $ ./configure --disable-download"
|
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() {
|
2023-06-19 00:10:39 +03:00
|
|
|
if is_git && test "$1" = "validate"; 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
|
|
|
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"
|
2023-05-30 17:03:50 +03:00
|
|
|
echo " --enable-download"
|
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
|
|
|
fi
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2023-05-30 18:27:48 +03:00
|
|
|
check_updated() {
|
|
|
|
local CURSTATUS OLDSTATUS
|
|
|
|
CURSTATUS=$($GIT submodule status $module)
|
|
|
|
OLDSTATUS=$(grep $module $substat)
|
|
|
|
test "$CURSTATUS" = "$OLDSTATUS"
|
|
|
|
}
|
|
|
|
|
2023-06-19 00:10:39 +03:00
|
|
|
if is_git; then
|
|
|
|
test -e $substat || touch $substat
|
|
|
|
modules=""
|
|
|
|
for m in $maybe_modules
|
|
|
|
do
|
|
|
|
$GIT submodule status $m 1> /dev/null 2>&1
|
|
|
|
if test $? = 0
|
|
|
|
then
|
|
|
|
modules="$modules $m"
|
|
|
|
grep $m $substat > /dev/null 2>&1 || $GIT submodule status $module >> $substat
|
|
|
|
else
|
|
|
|
echo "warn: ignoring non-existent submodule $m"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
modules=$maybe_modules
|
2023-05-25 13:36:28 +03:00
|
|
|
fi
|
|
|
|
|
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)
|
2020-01-29 13:21:13 +03:00
|
|
|
for module in $modules; do
|
2023-06-19 00:10:39 +03:00
|
|
|
if is_git; then
|
|
|
|
check_updated $module || validate_error "$command"
|
|
|
|
elif ! (set xyz "$module"/* && test -e "$2"); then
|
|
|
|
# The directory does not exist or it contains no files
|
|
|
|
echo "$0: sources not available for $module and $no_git_error"
|
|
|
|
validate_error "$command"
|
|
|
|
fi
|
2020-01-29 13:21:13 +03:00
|
|
|
done
|
2017-09-29 13:11:56 +03:00
|
|
|
;;
|
2023-06-19 00:10:39 +03:00
|
|
|
|
2017-09-29 13:11:56 +03:00
|
|
|
update)
|
2023-06-19 00:10:39 +03:00
|
|
|
is_git || {
|
|
|
|
echo "$0: unexpectedly called with submodules but $no_git_error"
|
|
|
|
exit 1
|
|
|
|
}
|
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"
|
2023-05-30 18:27:48 +03:00
|
|
|
for module in $modules; do
|
|
|
|
check_updated $module || echo Updated "$module"
|
|
|
|
done
|
2017-10-20 17:02:43 +03:00
|
|
|
|
2023-07-25 12:56:51 +03:00
|
|
|
(while read -r REPLY; do
|
2023-05-30 18:10:29 +03:00
|
|
|
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
|