summaryrefslogtreecommitdiffstats
path: root/scripts/patchtest-setup-sharedir
blob: a1497987cb18da4ce201cddc9a65a7890da82f4e (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
92
93
94
95
#!/bin/bash -e
#
# patchtest-setup-sharedir: Setup a directory for storing mboxes and
# repositories to be shared with the guest machine, including updates to
# the repos if the directory already exists
#
# Copyright (C) 2023 BayLibre Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# Author: Trevor Gamblin <tgamblin@baylibre.com>

# poky repository
POKY_REPO="https://git.yoctoproject.org/poky"

# patchtest repository
PATCHTEST_REPO="https://git.yoctoproject.org/patchtest"

# the name of the directory
SHAREDIR="patchtest_share"

help()
{
    echo "Usage: patchtest-setup-sharedir [ -d | --directory SHAREDIR ]
        [ -p | --patchtest PATCHTEST_REPO ]
        [ -y | --poky POKY_REPO ]"
    exit 2
}

while [ "$1" != "" ]; do
    case $1 in
    -d|--directory)
        SHAREDIR=$2
        shift 2
        ;;
    -p|--patchtest)
        PATCHTEST_REPO=$2
        shift 2
        ;;
    -y|--poky)
        POKY_REPO=$2
        shift 2
        ;;
    -h|--help)
        help
        ;;
    *)
        echo "Unknown option $1"
        help
        ;;
    esac
done

# define MBOX_DIR where the patch series will be stored by
# get-latest-series
MBOX_DIR="${SHAREDIR}/mboxes"

# Create SHAREDIR if it doesn't exist
if [ ! -d "$SHAREDIR" ]; then
    mkdir -p "${SHAREDIR}"
    echo "Created ${SHAREDIR}"
fi

# Create the mboxes directory if it doesn't exist
if [ ! -d "$MBOX_DIR" ]; then
    mkdir -p "${MBOX_DIR}"
    echo "Created ${MBOX_DIR}"
fi

# clone poky if it's not already present; otherwise, update it
if [ ! -d "$POKY_REPO" ]; then
    BASENAME=$(basename ${POKY_REPO})
    git clone "${POKY_REPO}" "${SHAREDIR}/${BASENAME}"
else
    (cd "${SHAREDIR}/$BASENAME" && git pull)
fi

# clone patchtest if it's not already present; otherwise, update it
if [ ! -d "$PATCHTEST_REPO" ]; then
    BASENAME=$(basename ${PATCHTEST_REPO})
    git clone "${PATCHTEST_REPO}" "${SHAREDIR}/${BASENAME}"
else
    (cd "${SHAREDIR}/$BASENAME" && git pull)
fi