mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-23 06:31:18 +02:00
Use git for "revision" if svn is unavailable.
Review URL: http://chromereview.prom.corp.google.com/1186033 git-svn-id: svn://chrome-svn/chromeos/trunk@219 06c00378-0e64-4dae-be16-12b19f9950a1
This commit is contained in:
parent
b085577b4b
commit
7ba1563d79
@ -35,12 +35,18 @@ set -e
|
|||||||
# Get version information
|
# Get version information
|
||||||
. "${SCRIPTS_DIR}/chromeos_version.sh"
|
. "${SCRIPTS_DIR}/chromeos_version.sh"
|
||||||
|
|
||||||
# Get subversion revision
|
# Get subversion or git revision
|
||||||
SVN_REVISION=`svn info | grep "Revision: " | awk '{print $2}'`
|
REVISION=$(svn info 2>&-| grep "Revision: " | awk '{print $2}')
|
||||||
|
if [ -z "$REVISION" ]
|
||||||
|
then
|
||||||
|
# Use git:8 chars of sha1
|
||||||
|
REVISION=$(git rev-parse HEAD)
|
||||||
|
REVISION=${REVISION:8}
|
||||||
|
fi
|
||||||
|
|
||||||
# Use the version number plus revision as the last change. (Need both, since
|
# Use the version number plus revision as the last change. (Need both, since
|
||||||
# trunk builds multiple times with the same version string.)
|
# trunk builds multiple times with the same version string.)
|
||||||
LAST_CHANGE="${CHROMEOS_VERSION_STRING}-r${SVN_REVISION}"
|
LAST_CHANGE="${CHROMEOS_VERSION_STRING}-r${REVISION}"
|
||||||
|
|
||||||
# The Chromium buildbot scripts only create a clickable link to the archive
|
# The Chromium buildbot scripts only create a clickable link to the archive
|
||||||
# if an output line of the form "last change: XXX" exists
|
# if an output line of the form "last change: XXX" exists
|
||||||
|
@ -22,7 +22,7 @@ DEFINE_string trunk "$GCLIENT_ROOT" \
|
|||||||
|
|
||||||
DEFINE_boolean mount $FLAGS_FALSE "Only set up mounts."
|
DEFINE_boolean mount $FLAGS_FALSE "Only set up mounts."
|
||||||
DEFINE_boolean unmount $FLAGS_FALSE "Only tear down mounts."
|
DEFINE_boolean unmount $FLAGS_FALSE "Only tear down mounts."
|
||||||
DEFINE_boolean svn_rev $FLAGS_FALSE "Pass subversion revision into chroot."
|
DEFINE_boolean revision $FLAGS_FALSE "Pass subversion revision into chroot."
|
||||||
|
|
||||||
# More useful help
|
# More useful help
|
||||||
FLAGS_HELP="USAGE: $0 [flags] [VAR=value] [-- \"command\"]
|
FLAGS_HELP="USAGE: $0 [flags] [VAR=value] [-- \"command\"]
|
||||||
@ -100,13 +100,13 @@ fi
|
|||||||
trap teardown_env EXIT
|
trap teardown_env EXIT
|
||||||
setup_env
|
setup_env
|
||||||
|
|
||||||
if [ $FLAGS_svn_rev -eq $FLAGS_TRUE ]
|
if [ $FLAGS_revision -eq $FLAGS_TRUE ]
|
||||||
then
|
then
|
||||||
# Get the subversion revision to pass into the chroot.
|
# Get the subversion revision to pass into the chroot.
|
||||||
#
|
#
|
||||||
# This must be determined outside the chroot because (1) there is no
|
# This must be determined outside the chroot because (1) there is no
|
||||||
# svn inside the chroot, and (2) if there were it would likely be
|
# svn/git inside the chroot, and (2) if there were it would likely be
|
||||||
# the wrong version, which would mess up the .svn directories.
|
# the wrong version, which would mess up the .svn/.git directories.
|
||||||
#
|
#
|
||||||
# Note that this fixes $CHROMEOS_REVISION at the time the chroot is
|
# Note that this fixes $CHROMEOS_REVISION at the time the chroot is
|
||||||
# entered. That's ok for the main use case of automated builds,
|
# entered. That's ok for the main use case of automated builds,
|
||||||
@ -114,11 +114,18 @@ then
|
|||||||
# so always have up-to-date info. For developer builds, there isn't
|
# so always have up-to-date info. For developer builds, there isn't
|
||||||
# really a single revision anyway, since the developer may have
|
# really a single revision anyway, since the developer may have
|
||||||
# hand-sync'd some subdirs and edited files in others.
|
# hand-sync'd some subdirs and edited files in others.
|
||||||
SVNREV="CHROMEOS_REVISION=$(svn info | grep "Revision: " | awk '{print $2}')"
|
REVISION="$(svn info 2>&- | grep "Revision: " | awk '{print $2}')"
|
||||||
|
if [ -z "$REVISION" ]
|
||||||
|
then
|
||||||
|
# Use git:8 chars of sha1
|
||||||
|
REVISION=$(git rev-parse HEAD)
|
||||||
|
REVISION="${REVISION:8}"
|
||||||
|
fi
|
||||||
|
REVISION="CHROMEOS_REVISION=$REVISION"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run command or interactive shell
|
# Run command or interactive shell
|
||||||
sudo chroot "$FLAGS_chroot" sudo -i -u $USER $SVNREV "$@"
|
sudo chroot "$FLAGS_chroot" sudo -i -u $USER $REVISION "$@"
|
||||||
|
|
||||||
# Remove trap and explicitly unmount
|
# Remove trap and explicitly unmount
|
||||||
trap - EXIT
|
trap - EXIT
|
||||||
|
Loading…
x
Reference in New Issue
Block a user