Patrick Williams | ac13d5f | 2023-11-24 18:59:46 -0600 | [diff] [blame^] | 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 | # SPDX-License-Identifier: GPL-2.0-only |
| 10 | # |
| 11 | |
| 12 | # poky repository |
| 13 | POKY_REPO="https://git.yoctoproject.org/poky" |
| 14 | |
| 15 | # patchtest repository |
| 16 | PATCHTEST_REPO="https://git.yoctoproject.org/patchtest" |
| 17 | |
| 18 | # the name of the directory |
| 19 | SHAREDIR="patchtest_share" |
| 20 | |
| 21 | help() |
| 22 | { |
| 23 | echo "Usage: patchtest-setup-sharedir [ -d | --directory SHAREDIR ] |
| 24 | [ -p | --patchtest PATCHTEST_REPO ] |
| 25 | [ -y | --poky POKY_REPO ]" |
| 26 | exit 2 |
| 27 | } |
| 28 | |
| 29 | while [ "$1" != "" ]; do |
| 30 | case $1 in |
| 31 | -d|--directory) |
| 32 | SHAREDIR=$2 |
| 33 | shift 2 |
| 34 | ;; |
| 35 | -p|--patchtest) |
| 36 | PATCHTEST_REPO=$2 |
| 37 | shift 2 |
| 38 | ;; |
| 39 | -y|--poky) |
| 40 | POKY_REPO=$2 |
| 41 | shift 2 |
| 42 | ;; |
| 43 | -h|--help) |
| 44 | help |
| 45 | ;; |
| 46 | *) |
| 47 | echo "Unknown option $1" |
| 48 | help |
| 49 | ;; |
| 50 | esac |
| 51 | done |
| 52 | |
| 53 | # define MBOX_DIR where the patch series will be stored by |
| 54 | # get-latest-series |
| 55 | MBOX_DIR="${SHAREDIR}/mboxes" |
| 56 | |
| 57 | # Create SHAREDIR if it doesn't exist |
| 58 | if [ ! -d "$SHAREDIR" ]; then |
| 59 | mkdir -p "${SHAREDIR}" |
| 60 | echo "Created ${SHAREDIR}" |
| 61 | fi |
| 62 | |
| 63 | # Create the mboxes directory if it doesn't exist |
| 64 | if [ ! -d "$MBOX_DIR" ]; then |
| 65 | mkdir -p "${MBOX_DIR}" |
| 66 | echo "Created ${MBOX_DIR}" |
| 67 | fi |
| 68 | |
| 69 | # clone poky if it's not already present; otherwise, update it |
| 70 | if [ ! -d "$POKY_REPO" ]; then |
| 71 | BASENAME=$(basename ${POKY_REPO}) |
| 72 | git clone "${POKY_REPO}" "${SHAREDIR}/${BASENAME}" |
| 73 | else |
| 74 | (cd "${SHAREDIR}/$BASENAME" && git pull) |
| 75 | fi |
| 76 | |
| 77 | # clone patchtest if it's not already present; otherwise, update it |
| 78 | if [ ! -d "$PATCHTEST_REPO" ]; then |
| 79 | BASENAME=$(basename ${PATCHTEST_REPO}) |
| 80 | git clone "${PATCHTEST_REPO}" "${SHAREDIR}/${BASENAME}" |
| 81 | else |
| 82 | (cd "${SHAREDIR}/$BASENAME" && git pull) |
| 83 | fi |