blob: fdc0e481f989850c1da4ceb49832b93cfc156f2b (
plain)
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
|
#!/usr/bin/env bash
set -euo pipefail
set -x
REMOTE_SOURCE=${REMOTE_SOURCE:-https://github.com/advancedtelematic}
MANIFEST=${MANIFEST:-master}
CURRENT_PROJECT=${CURRENT_PROJECT:-}
# list of projects to pin to one version in the format:
# "project:rev;project2:rev2..."
PIN_LIST=${PIN_LIST:-}
#CURRENT_REV=$(git rev-parse HEAD)
LOCAL_REPO=$PWD
mkdir -p updater-repo
cd updater-repo
if [ -d .repo/manifests ]; then
git -C .repo/manifests reset --hard
fi
repo init -m "${MANIFEST}.xml" -u "$REMOTE_SOURCE/updater-repo"
# patch manifest:
# - add a new "ats" remote that points to "$REMOTE_SOURCE"
# - change projects that contain "advancedtelematic" to use the ats remote
MANIFEST_FILE=".repo/manifests/${MANIFEST}.xml"
xmlstarlet ed --omit-decl -L \
-s "/manifest" -t elem -n "remote" -v "" \
-i "/manifest/remote[last()]" -t attr -n "name" -v "ats" \
-i "/manifest/remote[last()]" -t attr -n "fetch" -v "$REMOTE_SOURCE" \
-d "/manifest/project[contains(@name, 'advancedtelematic')]/@remote" \
-i "/manifest/project[contains(@name, 'advancedtelematic')]" -t attr -n "remote" -v "ats" \
"$MANIFEST_FILE"
# hack: sed on `advancedtelematic/` names, to remove this unwanted prefix
sed -i 's#name="advancedtelematic/#name="#g' "$MANIFEST_FILE"
# pin projects from the list
(
IFS=";"
for pin in $PIN_LIST; do
IFS=":"
read -r project rev <<< "$pin"
xmlstarlet ed --omit-decl -L \
-d "/manifest/project[@name=\"$project\"]/@revision" \
-i "/manifest/project[@name=\"$project\"]/@revision" -t attr -n "revision" -v "$rev" \
-i "/manifest/project[@name=\"$project\"]" -t attr -n "revision" -v "$rev" \
"$MANIFEST_FILE"
IFS=";"
done
)
# Remove the current project from the manifest if we have it checked out
if [ -n "$CURRENT_PROJECT" ]; then
xmlstarlet ed --omit-decl -L \
-d "/manifest/project[@name=\"$CURRENT_PROJECT\"]" \
"$MANIFEST_FILE"
fi
repo manifest
repo forall -c 'git reset --hard ; git clean -fdx'
repo sync -d --force-sync
if [ -n "$CURRENT_PROJECT" ]; then
rm -f "$CURRENT_PROJECT"
ln -s "$LOCAL_REPO" "$CURRENT_PROJECT"
fi
repo manifest -r
|