diff options
Diffstat (limited to 'scripts/patchtest-setup-sharedir')
-rwxr-xr-x | scripts/patchtest-setup-sharedir | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/scripts/patchtest-setup-sharedir b/scripts/patchtest-setup-sharedir new file mode 100755 index 0000000000..a1497987cb --- /dev/null +++ b/scripts/patchtest-setup-sharedir | |||
@@ -0,0 +1,95 @@ | |||
1 | #!/bin/bash -e | ||
2 | # | ||
3 | # patchtest-setup-sharedir: Setup a directory for storing mboxes and | ||
4 | # repositories to be shared with the guest machine, including updates to | ||
5 | # the repos if the directory already exists | ||
6 | # | ||
7 | # Copyright (C) 2023 BayLibre Inc. | ||
8 | # | ||
9 | # This program is free software; you can redistribute it and/or modify | ||
10 | # it under the terms of the GNU General Public License version 2 as | ||
11 | # published by the Free Software Foundation. | ||
12 | # | ||
13 | # This program is distributed in the hope that it will be useful, | ||
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | # GNU General Public License for more details. | ||
17 | # | ||
18 | # You should have received a copy of the GNU General Public License along | ||
19 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
20 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
21 | # | ||
22 | # Author: Trevor Gamblin <tgamblin@baylibre.com> | ||
23 | |||
24 | # poky repository | ||
25 | POKY_REPO="https://git.yoctoproject.org/poky" | ||
26 | |||
27 | # patchtest repository | ||
28 | PATCHTEST_REPO="https://git.yoctoproject.org/patchtest" | ||
29 | |||
30 | # the name of the directory | ||
31 | SHAREDIR="patchtest_share" | ||
32 | |||
33 | help() | ||
34 | { | ||
35 | echo "Usage: patchtest-setup-sharedir [ -d | --directory SHAREDIR ] | ||
36 | [ -p | --patchtest PATCHTEST_REPO ] | ||
37 | [ -y | --poky POKY_REPO ]" | ||
38 | exit 2 | ||
39 | } | ||
40 | |||
41 | while [ "$1" != "" ]; do | ||
42 | case $1 in | ||
43 | -d|--directory) | ||
44 | SHAREDIR=$2 | ||
45 | shift 2 | ||
46 | ;; | ||
47 | -p|--patchtest) | ||
48 | PATCHTEST_REPO=$2 | ||
49 | shift 2 | ||
50 | ;; | ||
51 | -y|--poky) | ||
52 | POKY_REPO=$2 | ||
53 | shift 2 | ||
54 | ;; | ||
55 | -h|--help) | ||
56 | help | ||
57 | ;; | ||
58 | *) | ||
59 | echo "Unknown option $1" | ||
60 | help | ||
61 | ;; | ||
62 | esac | ||
63 | done | ||
64 | |||
65 | # define MBOX_DIR where the patch series will be stored by | ||
66 | # get-latest-series | ||
67 | MBOX_DIR="${SHAREDIR}/mboxes" | ||
68 | |||
69 | # Create SHAREDIR if it doesn't exist | ||
70 | if [ ! -d "$SHAREDIR" ]; then | ||
71 | mkdir -p "${SHAREDIR}" | ||
72 | echo "Created ${SHAREDIR}" | ||
73 | fi | ||
74 | |||
75 | # Create the mboxes directory if it doesn't exist | ||
76 | if [ ! -d "$MBOX_DIR" ]; then | ||
77 | mkdir -p "${MBOX_DIR}" | ||
78 | echo "Created ${MBOX_DIR}" | ||
79 | fi | ||
80 | |||
81 | # clone poky if it's not already present; otherwise, update it | ||
82 | if [ ! -d "$POKY_REPO" ]; then | ||
83 | BASENAME=$(basename ${POKY_REPO}) | ||
84 | git clone "${POKY_REPO}" "${SHAREDIR}/${BASENAME}" | ||
85 | else | ||
86 | (cd "${SHAREDIR}/$BASENAME" && git pull) | ||
87 | fi | ||
88 | |||
89 | # clone patchtest if it's not already present; otherwise, update it | ||
90 | if [ ! -d "$PATCHTEST_REPO" ]; then | ||
91 | BASENAME=$(basename ${PATCHTEST_REPO}) | ||
92 | git clone "${PATCHTEST_REPO}" "${SHAREDIR}/${BASENAME}" | ||
93 | else | ||
94 | (cd "${SHAREDIR}/$BASENAME" && git pull) | ||
95 | fi | ||