summaryrefslogtreecommitdiffstats
path: root/scripts/ci/checkout-oe.sh
blob: 8744b2f0ba2b9f210a4799519af717e70c9e9e9d (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
#!/usr/bin/env bash

set -euo pipefail

set -x

REMOTE_SOURCE=${REMOTE_SOURCE:-https://github.com/advancedtelematic}
MANIFEST=${MANIFEST:-master}
CURRENT_PROJECT=${CURRENT_PROJECT:-meta-updater}

#CURRENT_REV=$(git rev-parse HEAD)
LOCAL_REPO=$PWD

mkdir -p updater-repo

cd updater-repo

repo init -m "${MANIFEST}.xml" -u "$REMOTE_SOURCE/updater-repo"

git -C .repo/manifests reset --hard

# patch manifest:
# - add a new "ats" remote that points to "$REMOTE_SOURCE"
# - change projects that contain "advancedtelematic" to use the ats remote
# - remove the current project from the manifest
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" \
    -i "/manifest/project[contains(@name, 'advancedtelematic')]" -t attr -n "remote" -v "ats" \
    -d "/manifest/project[@path=\"$CURRENT_PROJECT\"]" \
    "$MANIFEST_FILE"

# hack: sed on `advancedtelematic/` names, to remove this unwanted prefix
sed -i 's#name="advancedtelematic/#name="#g' "$MANIFEST_FILE"

repo manifest

repo forall -c 'git reset --hard ; git clean -fdx'

repo sync -d --force-sync

rm -f "$CURRENT_PROJECT"
ln -s "$LOCAL_REPO" "$CURRENT_PROJECT"

repo manifest -r