Sumit Garg | de31e60 | 2024-02-22 15:06:02 +0530 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # SPDX-License-Identifier: GPL-2.0+ |
| 3 | # |
| 4 | # Copyright 2024 Linaro Ltd. |
| 5 | # |
| 6 | # Usage: from the top level U-Boot source tree, run: |
| 7 | # $ ./dts/update-dts-subtree.sh pull <release-tag> |
| 8 | # $ ./dts/update-dts-subtree.sh pick <commit-id> |
| 9 | # |
| 10 | # The script will pull changes from devicetree-rebasing repo into U-Boot |
| 11 | # as a subtree located as <U-Boot>/dts/upstream sub-directory. It will |
| 12 | # automatically create a squash/merge commit listing the commits imported. |
| 13 | |
| 14 | set -e |
| 15 | |
| 16 | merge_commit_msg=$(cat << EOF |
| 17 | Subtree merge tag '$2' of devicetree-rebasing repo [1] into dts/upstream |
| 18 | |
| 19 | [1] https://git.kernel.org/pub/scm/linux/kernel/git/devicetree/devicetree-rebasing.git/ |
| 20 | EOF |
| 21 | ) |
| 22 | |
| 23 | remote_add_and_fetch() { |
| 24 | if ! git remote get-url devicetree-rebasing 2>/dev/null |
| 25 | then |
| 26 | echo "Warning: Script automatically adds new git remote via:" |
| 27 | echo " git remote add devicetree-rebasing \\" |
| 28 | echo " https://git.kernel.org/pub/scm/linux/kernel/git/devicetree/devicetree-rebasing.git" |
| 29 | git remote add devicetree-rebasing \ |
| 30 | https://git.kernel.org/pub/scm/linux/kernel/git/devicetree/devicetree-rebasing.git |
| 31 | fi |
| 32 | git fetch devicetree-rebasing master |
| 33 | } |
| 34 | |
| 35 | if [ "$1" = "pull" ] |
| 36 | then |
| 37 | remote_add_and_fetch |
| 38 | git subtree pull --prefix dts/upstream devicetree-rebasing \ |
| 39 | "$2" --squash -m "${merge_commit_msg}" |
| 40 | elif [ "$1" = "pick" ] |
| 41 | then |
| 42 | remote_add_and_fetch |
| 43 | git cherry-pick -x --strategy=subtree -Xsubtree=dts/upstream/ "$2" |
| 44 | else |
| 45 | echo "usage: $0 <op> <ref>" |
| 46 | echo " <op> pull or pick" |
| 47 | echo " <ref> release tag [pull] or commit id [pick]" |
| 48 | fi |