Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Side by Side Diff: src/scripts/save_pinned_deps

Issue 2112003: Create a tool to save a pinned dep file for the current sync. (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: Fix repository reset and verify that we are in a git repo. Created 10 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/scripts/make_relative_solution ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/bin/bash
2
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 # Save the current state of the tree into a pinned deps file that can later
8 # be used to reconstruct the same tree.
9
10 # Load common constants. This should be the first executable line.
11 # The path to common.sh should be relative to your script's location.
12 . "$(dirname "$0")/common.sh"
13
14 # Script must be run outside the chroot, I am not sure why this is but inside
15 # the chroot "gclient" is aliased to a warning about using gclient in the
16 # chroot.
17 assert_outside_chroot
18
19 # Flags
20 BASE_URL="http://src.chromium.org/git"
21
22 DEFINE_string depfile "" "The path to the depfile to create."
23 DEFINE_boolean commit ${FLAGS_FALSE} "Commit the resulting depfile."
24 DEFINE_boolean substitute ${FLAGS_FALSE} "Substitute a new base git URL."
25 DEFINE_string base ${BASE_URL} "Base git URL to substitute"
26
27 # Parse command line
28 FLAGS_HELP="usage: $0 [flags]"
29 FLAGS "$@" || exit 1
30 eval set -- "${FLAGS_ARGV}"
31 check_flags_only_and_allow_null_arg "$@" && set --
32
33 # Die on any errors.
34 set -e
35
36 if [ -z "$FLAGS_depfile" ] ; then
37 echo "Error: --depfile is required."
38 exit 1
39 fi
40
41 DEPPATH="${GCLIENT_ROOT}/deps"
42 DEPFILE="${DEPPATH}/${FLAGS_depfile}"
43
44 TEMPFILE=$(tempfile)
45 DIRNAME=$(dirname "${DEPFILE}")
46 FILENAME=$(basename "${DEPFILE}")
47
48 cleanup() {
49 # Disable die on error.
50 set +e
51
52 if [ -f "${TEMPFILE}" ]; then
53 rm "${TEMPFILE}"
54 fi
55
56 if [ -f "${DEPFILE}" ]; then
57 rm "${DEPFILE}"
58 fi
59
60 # Turn die on error back on.
61 set -e
62 }
63
64 reset_repository() {
65 echo "Resetting DEPS repository"
66
67 pushd "${DEPPATH}"
68
69 [ -d ".git" ] || die "${DEPPATH} is not a git repository."
70
71 git reset --hard origin/master
72
73 popd
74 }
75
76 generate_depfile() {
77 echo "Writing pinned DEPS file to ${DEPFILE}"
78
79 mkdir -p "${DIRNAME}"
80
81 gclient revinfo --snapshot > "${TEMPFILE}"
82
83 ARGS=""
84
85 if [[ $FLAGS_substitute -eq $FLAGS_TRUE ]]; then
86 ARGS="${ARGS} -s -b ${FLAGS_base}"
87 fi
88
89 ARGS="${ARGS} ${TEMPFILE}"
90
91 "${SCRIPTS_DIR}/make_relative_solution" ${ARGS} > ${DEPFILE}
92
93 rm -f "${TEMPFILE}"
94 }
95
96 commit_depfile() {
97 echo "Commiting pinned DEPS file"
98
99 pushd "${DEPPATH}"
100
101 git add "${FLAGS_depfile}"
102 git commit -m "Automated buildbot update of pinned DEPS file."
103 git reset --hard HEAD
104 git clean -f
105 git remote update
106 git rebase -s ours origin/master
107 git push
108
109 popd
110 }
111
112 #
113 # Generate a pinned deps file from the current gclient sync and check it into
114 # the deps.git repository.
115 #
116 trap "cleanup" EXIT
117
118 if [[ $FLAGS_commit -eq $FLAGS_TRUE ]]; then
119 reset_repository
120 fi
121
122 generate_depfile
123
124 if [[ $FLAGS_commit -eq $FLAGS_TRUE ]]; then
125 commit_depfile
126 fi
127
128 trap - EXIT
OLDNEW
« no previous file with comments | « src/scripts/make_relative_solution ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698