patchtest-setup-sharedir 1.9 KB

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