4317.1.1
by Mark Shuttleworth
Initial batch of setup and maintenance scripts for LP |
1 |
#! /bin/bash
|
8452.3.3
by Karl Fogel
* utilities/: Add copyright header block to source files that were |
2 |
#
|
13135.1.1
by Steve Kowalik
Remove warnings from rf-get. |
3 |
# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
|
8687.15.3
by Karl Fogel
Shorten the copyright header block to two lines. |
4 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
8452.3.3
by Karl Fogel
* utilities/: Add copyright header block to source files that were |
5 |
#
|
6567.2.2
by Barry Warsaw
Respond to review comments. |
6 |
# Update your copy of trunk and the necessary source dependencies, and make
|
7 |
# sure all source dependencies are properly linked in to all the branches you
|
|
8 |
# are working on.
|
|
9 |
||
8698.7.1
by Gavin Panella
Lots of changes to rocketfuel-get so I feel more comfortable running it. |
10 |
# Stop if there's an error, and treat unset variables as errors.
|
11 |
set -eu
|
|
8486.13.1
by Curtis Hovey
Partial completion of a devpad-free rocketfuel get. |
12 |
|
13145.1.1
by Gavin Panella
Link sourcecode in parallel. On a 4-core machine this cuts the time taken by about 70%. |
13 |
# A rough measure of how much stuff we can do in parallel.
|
14 |
CPU_COUNT="$(egrep -c '^processor\b' /proc/cpuinfo)" |
|
15 |
||
8698.7.3
by Gavin Panella
Use a helper function, run-child, to indent stdout of some child processes. |
16 |
# Helper function to run a child process, indenting stdout to aid
|
17 |
# readability.
|
|
18 |
run-child() { |
|
19 |
"$@" | sed -e "s/^/ /" |
|
20 |
}
|
|
21 |
||
8698.7.1
by Gavin Panella
Lots of changes to rocketfuel-get so I feel more comfortable running it. |
22 |
# Load local settings.
|
23 |
if [ -e "$HOME/.rocketfuel-env.sh" ] |
|
24 |
then
|
|
25 |
source "$HOME/.rocketfuel-env.sh" |
|
26 |
else
|
|
27 |
echo "Please run rocketfuel-setup first." >&2 |
|
6673.1.5
by Barry Warsaw
Respond to Edwin's review. |
28 |
exit 1 |
29 |
fi
|
|
4317.1.1
by Mark Shuttleworth
Initial batch of setup and maintenance scripts for LP |
30 |
|
8698.7.1
by Gavin Panella
Lots of changes to rocketfuel-get so I feel more comfortable running it. |
31 |
LP_DOWNLOAD_CACHE_PATH="$LP_PROJECT_ROOT/$LP_SOURCEDEPS_DIR/download-cache" |
32 |
LP_EGGS_PATH="$LP_PROJECT_ROOT/$LP_SOURCEDEPS_DIR/eggs" |
|
13314.4.15
by Ian Booth
Fix yui directory issues |
33 |
YUI_PATH="$LP_PROJECT_ROOT/$LP_SOURCEDEPS_DIR/yui" |
8698.7.1
by Gavin Panella
Lots of changes to rocketfuel-get so I feel more comfortable running it. |
34 |
LP_DOWNLOAD_CACHE_PATH="$(eval echo ${LP_DOWNLOAD_CACHE_PATH})" |
35 |
LP_EGGS_PATH="$(eval echo ${LP_EGGS_PATH})" |
|
36 |
||
37 |
# Pull launchpad devel from launchpad.
|
|
38 |
INITIAL_REV=$(bzr revno "$LP_TRUNK_PATH") |
|
39 |
bzr pull -d "$LP_TRUNK_PATH" |
|
40 |
FINAL_REV=$(bzr revno "$LP_TRUNK_PATH") |
|
41 |
||
8697.8.1
by Barry Warsaw
Fix bug 390702 by explicitly adding --standalone to bzr branch command. |
42 |
# Make sure our directories are around.
|
13314.4.15
by Ian Booth
Fix yui directory issues |
43 |
mkdir -p "$LP_SOURCEDEPS_PATH" "$LP_EGGS_PATH" "$YUI_PATH" |
8698.7.1
by Gavin Panella
Lots of changes to rocketfuel-get so I feel more comfortable running it. |
44 |
|
45 |
# Get/update the download cache.
|
|
46 |
if [ -d "$LP_DOWNLOAD_CACHE_PATH" ] |
|
47 |
then
|
|
48 |
bzr up "$LP_DOWNLOAD_CACHE_PATH" |
|
49 |
else
|
|
50 |
bzr co lp:lp-source-dependencies "$LP_DOWNLOAD_CACHE_PATH" |
|
8486.13.2
by Curtis Hovey
Merge from launchpad devel. Reconciled devpad removals. |
51 |
fi
|
8486.13.1
by Curtis Hovey
Partial completion of a devpad-free rocketfuel get. |
52 |
|
53 |
# Add or update sourcepackages.
|
|
8698.7.1
by Gavin Panella
Lots of changes to rocketfuel-get so I feel more comfortable running it. |
54 |
sourcedeps_conf="$(dirname "$0")/sourcedeps.conf" |
55 |
if [ ! -e "$sourcedeps_conf" ] |
|
8486.13.1
by Curtis Hovey
Partial completion of a devpad-free rocketfuel get. |
56 |
then
|
8698.7.1
by Gavin Panella
Lots of changes to rocketfuel-get so I feel more comfortable running it. |
57 |
# Use the global deps which are stable.
|
58 |
echo "Could not find $sourcedeps_conf" >&2 |
|
59 |
sourcedeps_conf="$LP_TRUNK_PATH/utilities/sourcedeps.conf" |
|
8486.13.1
by Curtis Hovey
Partial completion of a devpad-free rocketfuel get. |
60 |
fi
|
61 |
||
62 |
echo "Updating sourcecode dependencies in rocketfuel:" |
|
13145.1.1
by Gavin Panella
Link sourcecode in parallel. On a 4-core machine this cuts the time taken by about 70%. |
63 |
run-child \
|
64 |
"$LP_TRUNK_PATH/utilities/update-sourcecode" \ |
|
65 |
"$LP_SOURCEDEPS_PATH" "$sourcedeps_conf" |
|
8486.13.1
by Curtis Hovey
Partial completion of a devpad-free rocketfuel get. |
66 |
|
67 |
# Update the current trees in the repo.
|
|
68 |
echo "Updating sourcecode dependencies in current local branches:" |
|
13709.2.1
by Jeroen Vermeulen
Make rocketfuel-get suitable for dogfood-style setups with lp-sourcedeps among the branches. |
69 |
|
70 |
# Find directories among local branches containing "sourcecode" directories.
|
|
71 |
# Prints each as a null-terminated record (since Unix filenames may contain
|
|
72 |
# newlines).
|
|
73 |
find_branches_to_relink() { |
|
74 |
find "$LP_PROJECT_PATH" \ |
|
75 |
-mindepth 2 -maxdepth 2 -type d -name sourcecode -printf '%h\0' |
|
76 |
}
|
|
77 |
||
78 |
# Some old setups (notably dogfood) may have lp-sourcedeps mixed in with the
|
|
79 |
# local branches. Echo stdin to stdout, with these filenames filtered out.
|
|
80 |
# Filenames must be null-terminated on input, and remain null-terminated on
|
|
81 |
# output.
|
|
82 |
filter_branches_to_relink() { |
|
83 |
grep -vz '/lp-sourcedeps$'
|
|
84 |
}
|
|
85 |
||
86 |
# Re-link the sourcecode directories for local branches. Takes the branch
|
|
87 |
# paths from stdin, as null-terminated records.
|
|
88 |
relink_branches() { |
|
13145.1.1
by Gavin Panella
Link sourcecode in parallel. On a 4-core machine this cuts the time taken by about 70%. |
89 |
run-child xargs --no-run-if-empty \
|
90 |
--max-procs="${CPU_COUNT}" --max-args=1 --null \ |
|
91 |
"$LP_TRUNK_PATH/utilities/link-external-sourcecode" \ |
|
92 |
--parent "$LP_PROJECT_ROOT/$LP_SOURCEDEPS_DIR" --target |
|
13709.2.1
by Jeroen Vermeulen
Make rocketfuel-get suitable for dogfood-style setups with lp-sourcedeps among the branches. |
93 |
}
|
94 |
||
95 |
# Actually do it:
|
|
96 |
find_branches_to_relink | filter_branches_to_relink | relink_branches |
|
97 |
||
4343.1.1
by Mark Shuttleworth
Link all current branches to current sourcecode deps |
98 |
|
8698.7.1
by Gavin Panella
Lots of changes to rocketfuel-get so I feel more comfortable running it. |
99 |
# Build launchpad if there were changes.
|
8486.13.2
by Curtis Hovey
Merge from launchpad devel. Reconciled devpad removals. |
100 |
if [ $FINAL_REV != $INITIAL_REV ]; |
8486.13.1
by Curtis Hovey
Partial completion of a devpad-free rocketfuel get. |
101 |
then
|
8734.1.1
by Gavin Panella
Use LP_TRUNK_PATH, not LP_TRUNK_NAME. |
102 |
make -C "$LP_TRUNK_PATH" |
8486.13.1
by Curtis Hovey
Partial completion of a devpad-free rocketfuel get. |
103 |
fi
|