summaryrefslogtreecommitdiffstats
path: root/scripts/ci/configure.sh
blob: ae78f0667fa802c2fa0156faf60567369de4ccb1 (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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash

set -euo pipefail
set -x

TEST_MACHINE=${TEST_MACHINE:-qemux86-64}
TEST_BUILD_DIR=${TEST_BUILD_DIR:-build}
TEST_REPO_DIR=${TEST_REPO_DIR:-updater-repo}
TEST_BITBAKE_COMMON_DIR=${TEST_BITBAKE_COMMON_DIR:-}

TEST_AKTUALIZR_REMOTE=${TEST_AKTUALIZR_REMOTE:-}
TEST_AKTUALIZR_TAG=${TEST_AKTUALIZR_TAG:-}
if [ -n "$TEST_AKTUALIZR_REMOTE" ]; then
    if [ -n "$TEST_AKTUALIZR_TAG" ]; then
        TEST_AKTUALIZR_BRANCH=""
        TEST_AKTUALIZR_REV=""
    else
        TEST_AKTUALIZR_DIR=${TEST_AKTUALIZR_DIR:-.}
        TEST_AKTUALIZR_BRANCH=${TEST_AKTUALIZR_BRANCH:-master}
        TEST_AKTUALIZR_REV=${TEST_AKTUALIZR_REV:-$(GIT_DIR="$TEST_AKTUALIZR_DIR/.git" git rev-parse "$TEST_AKTUALIZR_REMOTE/$TEST_AKTUALIZR_BRANCH")}
    fi
fi

TEST_AKTUALIZR_CREDENTIALS=${TEST_AKTUALIZR_CREDENTIALS:-}

# move existing conf directory to backup, before generating a new one
rm -rf "$TEST_BUILD_DIR/conf.old" || true
mv "$TEST_BUILD_DIR/conf" "$TEST_BUILD_DIR/conf.old" || true

(
set +euo pipefail
set +x
echo ">> Running envsetup.sh"
METADIR=$(realpath "$TEST_REPO_DIR")
export METADIR
. "$TEST_REPO_DIR/meta-updater/scripts/envsetup.sh" "$TEST_MACHINE" "$TEST_BUILD_DIR"
)

set +x

SITE_CONF="$TEST_BUILD_DIR/conf/site.conf"

echo ">> Set common bitbake config options"
cat << EOF > "$SITE_CONF"
SANITY_TESTED_DISTROS = ""
IMAGE_FEATURES += "ssh-server-openssh"

EOF

if [ -n "$TEST_AKTUALIZR_REMOTE" ]; then
    echo ">> Set aktualizr branch in bitbake's config"
    if [ -n "$TEST_AKTUALIZR_TAG" ]; then
        # tag case
        cat << EOF >> "$SITE_CONF"
SRCREV_pn-aktualizr = ""
SRCREV_pn-aktualizr-native = ""
BRANCH_pn-aktualizr = ";nobranch=1;tag=$TEST_AKTUALIZR_TAG"
BRANCH_pn-aktualizr-native = "\${BRANCH_pn-aktualizr}"
EOF
    else
        # branch case
        cat << EOF >> "$SITE_CONF"
SRCREV_pn-aktualizr = "$TEST_AKTUALIZR_REV"
SRCREV_pn-aktualizr-native = "\${SRCREV_pn-aktualizr}"
BRANCH_pn-aktualizr = "$TEST_AKTUALIZR_BRANCH"
BRANCH_pn-aktualizr-native = "\${BRANCH_pn-aktualizr}"
EOF
    fi
fi

if [[ -n $TEST_AKTUALIZR_CREDENTIALS ]]; then
    echo ">> Set aktualizr credentials"
    cat << EOF >> "$SITE_CONF"
SOTA_PACKED_CREDENTIALS = "$TEST_AKTUALIZR_CREDENTIALS"
EOF
fi

if [[ -n $TEST_BITBAKE_COMMON_DIR ]]; then
    echo ">> Set caching"
    SSTATE_DIR="$TEST_BITBAKE_COMMON_DIR/sstate-cache"
    DL_DIR="$TEST_BITBAKE_COMMON_DIR/downloads"
    mkdir -p "$SSTATE_DIR" "$DL_DIR"

    cat << EOF >> "$SITE_CONF"
SSTATE_DIR = "$SSTATE_DIR"
DL_DIR = "$DL_DIR"
EOF
fi

echo -e ">> Final configuration (site.conf):\\n"
cat "$SITE_CONF"