~launchpad-pqm/launchpad/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#! /bin/bash
#
# Copyright 2009 Canonical Ltd.  This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
#
# Update your copy of trunk and the necessary source dependencies, and make
# sure all source dependencies are properly linked in to all the branches you
# are working on.

# Stop if there's an error, and treat unset variables as errors.
set -eu

# Helper function to run a child process, indenting stdout to aid
# readability.
run-child() {
    "$@" | sed -e "s/^/        /"
}

# Load local settings.
if [ -e "$HOME/.rocketfuel-env.sh" ]
then
    source "$HOME/.rocketfuel-env.sh"
else
    echo "Please run rocketfuel-setup first." >&2
    exit 1
fi

LP_DOWNLOAD_CACHE_PATH="$LP_PROJECT_ROOT/$LP_SOURCEDEPS_DIR/download-cache"
LP_EGGS_PATH="$LP_PROJECT_ROOT/$LP_SOURCEDEPS_DIR/eggs"
LP_DOWNLOAD_CACHE_PATH="$(eval echo ${LP_DOWNLOAD_CACHE_PATH})"
LP_EGGS_PATH="$(eval echo ${LP_EGGS_PATH})"

# Pull launchpad devel from launchpad.
INITIAL_REV=$(bzr revno "$LP_TRUNK_PATH")
bzr pull -d "$LP_TRUNK_PATH"
FINAL_REV=$(bzr revno "$LP_TRUNK_PATH")

# Make sure our directories are around.
mkdir -p "$LP_SOURCEDEPS_PATH" "$LP_EGGS_PATH"

# Get/update the download cache.
if [ -d "$LP_DOWNLOAD_CACHE_PATH" ]
then
    bzr up "$LP_DOWNLOAD_CACHE_PATH"
else
    bzr co lp:lp-source-dependencies "$LP_DOWNLOAD_CACHE_PATH"
fi

# Add or update sourcepackages.
sourcedeps_conf="$(dirname "$0")/sourcedeps.conf"
if [ ! -e "$sourcedeps_conf" ]
then
    # Use the global deps which are stable.
    echo "Could not find $sourcedeps_conf" >&2
    sourcedeps_conf="$LP_TRUNK_PATH/utilities/sourcedeps.conf"
fi

echo "Updating sourcecode dependencies in rocketfuel:"
echo ""
echo "  NOTE: Each sourcedep may take a while; please be patient."
echo ""
echo "  ALSO NOTE: You can ignore any warnings you see below about how"
echo "  'You have not informed bzr of your Launchpad ID ...' etc."
echo "  See https://bugs.edge.launchpad.net/bzr/+bug/401617 for why."
echo ""
echo "    Sourcedeps: $LP_SOURCEDEPS_PATH"
while IFS="=" read package branch optional
do
    package_path="$LP_SOURCEDEPS_PATH/$package"
    echo "    Checking $package_path"
    if [ "$optional" ]
    then
        # The 'set +e' below is so that we don't exit when the 'bzr log' call
        # returns an error.
        set +e
        bzr log -l 1 -q "$branch" &> /dev/null
        retval=$?
        set -e
        if [ $retval -ne 0 ]
        then
            # We can't reach this branch, but it's optional anyway, so we'll
            # just move on.
            echo "Couldn't find $branch, skipping it."
            continue
        fi
        if [ -d "$package_path" ]
        then
            run-child bzr pull --remember "$branch" --directory "$package_path"
        else
            # This is either shipit or the openid-provider, and they share the
            # history with our main tree, so we'll do this hack to stack them
            # onto LP's trunk branch.
            run-child bzr branch --no-tree --stacked "$LP_TRUNK_PATH" "$package_path"
            run-child bzr pull --overwrite "$branch" -d "$package_path"
            run-child bzr checkout "$package_path" "$package_path"
        fi
    else
        if [ -d "$package_path" ]
        then
            run-child bzr pull --remember "$branch" --directory "$package_path"
        else
            run-child bzr branch --standalone "$branch" "$package_path"
        fi
    fi
done < "$sourcedeps_conf"

# Update the current trees in the repo.
echo "Updating sourcecode dependencies in current local branches:"
for branch in "$LP_PROJECT_PATH"/*
do
    if [ -d "$branch/sourcecode" ]
    then
        echo "    ${branch}"
        run-child "$LP_TRUNK_PATH/utilities/link-external-sourcecode" \
            --parent="$LP_PROJECT_ROOT/$LP_SOURCEDEPS_DIR" --target="$branch"
    fi
done

# Build launchpad if there were changes.
if [ $FINAL_REV != $INITIAL_REV ];
then
    make -C "$LP_TRUNK_PATH"
fi