Index: src/scripts/save_pinned_deps |
diff --git a/src/scripts/save_pinned_deps b/src/scripts/save_pinned_deps |
new file mode 100755 |
index 0000000000000000000000000000000000000000..ab2061359cee0e4e37b13bd9f90fe70cf991a671 |
--- /dev/null |
+++ b/src/scripts/save_pinned_deps |
@@ -0,0 +1,128 @@ |
+#!/bin/bash |
+ |
+# Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+# Save the current state of the tree into a pinned deps file that can later |
+# be used to reconstruct the same tree. |
+ |
+# Load common constants. This should be the first executable line. |
+# The path to common.sh should be relative to your script's location. |
+. "$(dirname "$0")/common.sh" |
+ |
+# Script must be run outside the chroot, I am not sure why this is but inside |
+# the chroot "gclient" is aliased to a warning about using gclient in the |
+# chroot. |
+assert_outside_chroot |
+ |
+# Flags |
+BASE_URL="http://src.chromium.org/git" |
+ |
+DEFINE_string depfile "" "The path to the depfile to create." |
+DEFINE_boolean commit ${FLAGS_FALSE} "Commit the resulting depfile." |
+DEFINE_boolean substitute ${FLAGS_FALSE} "Substitute a new base git URL." |
+DEFINE_string base ${BASE_URL} "Base git URL to substitute" |
+ |
+# Parse command line |
+FLAGS_HELP="usage: $0 [flags]" |
+FLAGS "$@" || exit 1 |
+eval set -- "${FLAGS_ARGV}" |
+check_flags_only_and_allow_null_arg "$@" && set -- |
+ |
+# Die on any errors. |
+set -e |
+ |
+if [ -z "$FLAGS_depfile" ] ; then |
+ echo "Error: --depfile is required." |
+ exit 1 |
+fi |
+ |
+DEPPATH="${GCLIENT_ROOT}/deps" |
+DEPFILE="${DEPPATH}/${FLAGS_depfile}" |
+ |
+TEMPFILE=$(tempfile) |
+DIRNAME=$(dirname "${DEPFILE}") |
+FILENAME=$(basename "${DEPFILE}") |
+ |
+cleanup() { |
+ # Disable die on error. |
+ set +e |
+ |
+ if [ -f "${TEMPFILE}" ]; then |
+ rm "${TEMPFILE}" |
+ fi |
+ |
+ if [ -f "${DEPFILE}" ]; then |
+ rm "${DEPFILE}" |
+ fi |
+ |
+ # Turn die on error back on. |
+ set -e |
+} |
+ |
+reset_repository() { |
+ echo "Resetting DEPS repository" |
+ |
+ pushd "${DEPPATH}" |
+ |
+ [ -d ".git" ] || die "${DEPPATH} is not a git repository." |
+ |
+ git reset --hard origin/master |
+ |
+ popd |
+} |
+ |
+generate_depfile() { |
+ echo "Writing pinned DEPS file to ${DEPFILE}" |
+ |
+ mkdir -p "${DIRNAME}" |
+ |
+ gclient revinfo --snapshot > "${TEMPFILE}" |
+ |
+ ARGS="" |
+ |
+ if [[ $FLAGS_substitute -eq $FLAGS_TRUE ]]; then |
+ ARGS="${ARGS} -s -b ${FLAGS_base}" |
+ fi |
+ |
+ ARGS="${ARGS} ${TEMPFILE}" |
+ |
+ "${SCRIPTS_DIR}/make_relative_solution" ${ARGS} > ${DEPFILE} |
+ |
+ rm -f "${TEMPFILE}" |
+} |
+ |
+commit_depfile() { |
+ echo "Commiting pinned DEPS file" |
+ |
+ pushd "${DEPPATH}" |
+ |
+ git add "${FLAGS_depfile}" |
+ git commit -m "Automated buildbot update of pinned DEPS file." |
+ git reset --hard HEAD |
+ git clean -f |
+ git remote update |
+ git rebase -s ours origin/master |
+ git push |
+ |
+ popd |
+} |
+ |
+# |
+# Generate a pinned deps file from the current gclient sync and check it into |
+# the deps.git repository. |
+# |
+trap "cleanup" EXIT |
+ |
+if [[ $FLAGS_commit -eq $FLAGS_TRUE ]]; then |
+ reset_repository |
+fi |
+ |
+generate_depfile |
+ |
+if [[ $FLAGS_commit -eq $FLAGS_TRUE ]]; then |
+ commit_depfile |
+fi |
+ |
+trap - EXIT |