From 7ba1563d79b655231db8741225729a61fd819f55 Mon Sep 17 00:00:00 2001 From: "djmm@google.com" Date: Fri, 13 Nov 2009 00:00:16 +0000 Subject: [PATCH] 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 --- archive_build.sh | 12 +++++++++--- enter_chroot.sh | 19 +++++++++++++------ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/archive_build.sh b/archive_build.sh index 4385e83b45..f140685abc 100755 --- a/archive_build.sh +++ b/archive_build.sh @@ -35,12 +35,18 @@ set -e # Get version information . "${SCRIPTS_DIR}/chromeos_version.sh" -# Get subversion revision -SVN_REVISION=`svn info | grep "Revision: " | awk '{print $2}'` +# Get subversion or git revision +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 # 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 # if an output line of the form "last change: XXX" exists diff --git a/enter_chroot.sh b/enter_chroot.sh index 1bfdc6bc81..101280dee8 100755 --- a/enter_chroot.sh +++ b/enter_chroot.sh @@ -22,7 +22,7 @@ DEFINE_string trunk "$GCLIENT_ROOT" \ DEFINE_boolean mount $FLAGS_FALSE "Only set up 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 FLAGS_HELP="USAGE: $0 [flags] [VAR=value] [-- \"command\"] @@ -100,13 +100,13 @@ fi trap teardown_env EXIT setup_env -if [ $FLAGS_svn_rev -eq $FLAGS_TRUE ] +if [ $FLAGS_revision -eq $FLAGS_TRUE ] then # Get the subversion revision to pass into the chroot. # # 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 - # the wrong version, which would mess up the .svn directories. + # svn/git inside the chroot, and (2) if there were it would likely be + # the wrong version, which would mess up the .svn/.git directories. # # Note that this fixes $CHROMEOS_REVISION at the time the chroot is # 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 # really a single revision anyway, since the developer may have # 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 # 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 trap - EXIT