Tom Rini | 53633a8 | 2024-02-29 12:33:36 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -e |
| 4 | |
| 5 | cd $(dirname $0)/.. |
| 6 | |
| 7 | UPSTREAM_GIT="git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git" |
| 8 | |
| 9 | BRANCHES="master filter-state upstream/master upstream/dts" |
| 10 | |
| 11 | if [ ! -f scripts/filter.sh ] ; then |
| 12 | echo "`pwd`: does not appear to be a device-tree.git" 1>&2 |
| 13 | exit 1 |
| 14 | fi |
| 15 | |
| 16 | if [ -z "$LATEST_VERSION" ] ; then |
| 17 | FINGER_BANNER="https://www.kernel.org/finger_banner" |
| 18 | LATEST_VERSION=$(wget --quiet -O - "$FINGER_BANNER" |\ |
| 19 | sed -n -e '0,/^The latest mainline version of the Linux kernel is:\s*\(.*\)$/s//\1/p') |
| 20 | fi |
| 21 | |
| 22 | if [ -z "$LATEST_VERSION" ] ; then |
| 23 | echo "Unable to determine latest version" 1>&2 |
| 24 | exit 1 |
| 25 | fi |
| 26 | |
| 27 | echo "Latest Version: v$LATEST_VERSION" |
| 28 | if ! git show-ref --quiet --verify refs/tags/v${LATEST_VERSION} ; then |
| 29 | echo "Latest version is new" |
| 30 | fi |
| 31 | if ! git show-ref --quiet --verify refs/tags/v${LATEST_VERSION}-dts ; then |
| 32 | echo "Latest version is unmerged" |
| 33 | fi |
| 34 | echo |
| 35 | |
| 36 | echo "Current State:" |
| 37 | for branch in $BRANCHES ; do |
| 38 | REF=$(git show-ref --verify refs/heads/${branch}) |
| 39 | if [ $? -ne 0 ] ; then |
| 40 | echo "Tree is missing required branch ${branch}, aborting" 1>&2 |
| 41 | exit 1 |
| 42 | fi |
| 43 | echo " ${REF}" |
| 44 | done |
| 45 | echo |
| 46 | |
| 47 | trap ' |
| 48 | if [ -n "$FILTER_OUTPUT" ] ; then |
| 49 | echo "---------------------------------------------------------------------" |
| 50 | echo "Filter Output:" |
| 51 | echo "---------------------------------------------------------------------" |
| 52 | echo "$FILTER_OUTPUT" |
| 53 | echo |
| 54 | fi |
| 55 | if [ -n "$MERGE_OUTPUT" ] ; then |
| 56 | echo "---------------------------------------------------------------------" |
| 57 | echo "Merge Output:" |
| 58 | echo "---------------------------------------------------------------------" |
| 59 | echo "$MERGE_OUTPUT" |
| 60 | echo |
| 61 | fi |
| 62 | ' EXIT |
| 63 | |
| 64 | FILTER_OUTPUT=`( |
| 65 | set -e |
| 66 | echo "Switching to master branch" |
| 67 | git checkout master |
| 68 | |
| 69 | echo "Fetching $UPSTREAM_GIT master" |
| 70 | git fetch --tags "$UPSTREAM_GIT" master |
| 71 | echo |
| 72 | |
| 73 | echo "Filtering" |
| 74 | ./scripts/filter.sh |
| 75 | echo |
| 76 | ) 2>&1 ` |
| 77 | |
| 78 | #git push --dry-run origin filter-state upstream/dts upstream/master |
| 79 | #git push --dry-run origin --tags |
| 80 | #echo |
| 81 | |
| 82 | DATE=$(date +%Y%m%d) |
| 83 | TESTBRANCH=test-${DATE} |
| 84 | MERGE_OUTPUT=`( |
| 85 | set -e |
| 86 | git checkout -b ${TESTBRANCH} origin/master |
| 87 | git -c merge.renameLimit=1000000 merge --no-edit upstream/dts |
| 88 | ) 2>&1 ` |
| 89 | REF=$(git show-ref --verify refs/heads/${TESTBRANCH}) |
| 90 | echo "Testing: ${REF}" |
| 91 | if git log ${TESTBRANCH} -- MAINTAINERS | grep --quiet . ; then |
| 92 | echo "Filter branch has upstream-only content (MAINTAINERS file)" |
| 93 | exit 1 |
| 94 | fi |
| 95 | |
| 96 | make clean -s |
| 97 | TEST_OUTPUT=`make -k -s 2>&1 || true` |
| 98 | if [ -z "${TEST_OUTPUT}" ]; then |
| 99 | echo "Success!" |
| 100 | else |
| 101 | echo "---------------------------------------------------------------------" |
| 102 | echo "Test Output:" |
| 103 | echo "---------------------------------------------------------------------" |
| 104 | echo "$TEST_OUTPUT" |
| 105 | fi |
| 106 | echo |
| 107 | |
| 108 | echo "Switching back to master branch" |
| 109 | git checkout master |
| 110 | |
| 111 | echo "Recording refs/tests/${DATE}" |
| 112 | git update-ref refs/tests/${DATE} ${TESTBRANCH} |
| 113 | |
| 114 | echo "Removing ${TESTBRANCH}" |
| 115 | git branch -D "${TESTBRANCH}" |
| 116 | |
| 117 | echo "Final State:" |
| 118 | for branch in ${BRANCHES} ; do |
| 119 | REF=$(git show-ref --verify refs/heads/${branch}) |
| 120 | echo " ${REF}" |
| 121 | done |
| 122 | echo |
| 123 | |
| 124 | exit 0 |