xref: /freebsd/sys/contrib/device-tree/scripts/cronjob (revision 6be3386466ab79a84b48429ae66244f21526d3df)
1#!/bin/bash
2
3set -e
4
5cd $(dirname $0)/..
6
7UPSTREAM_GIT="git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git"
8
9BRANCHES="master filter-state upstream/master upstream/dts"
10
11if [ ! -f scripts/filter.sh ] ; then
12    echo "`pwd`: does not appear to be a device-tree.git" 1>&2
13    exit 1
14fi
15
16if [ -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')
20fi
21
22if [ -z "$LATEST_VERSION" ] ; then
23    echo "Unable to determine latest version" 1>&2
24    exit 1
25fi
26
27echo "Latest Version: v$LATEST_VERSION"
28if ! git show-ref --quiet --verify refs/tags/v${LATEST_VERSION} ; then
29    echo "Latest version is new"
30fi
31if ! git show-ref --quiet --verify refs/tags/v${LATEST_VERSION}-dts ; then
32    echo "Latest version is unmerged"
33fi
34echo
35
36echo "Current State:"
37for 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}"
44done
45echo
46
47trap '
48if [ -n "$FILTER_OUTPUT" ] ; then
49    echo "---------------------------------------------------------------------"
50    echo "Filter Output:"
51    echo "---------------------------------------------------------------------"
52    echo "$FILTER_OUTPUT"
53    echo
54fi
55if [ -n "$MERGE_OUTPUT" ] ; then
56    echo "---------------------------------------------------------------------"
57    echo "Merge Output:"
58    echo "---------------------------------------------------------------------"
59    echo "$MERGE_OUTPUT"
60    echo
61fi
62' EXIT
63
64FILTER_OUTPUT=`(
65set -e
66echo "Switching to master branch"
67git checkout master
68
69echo "Fetching $UPSTREAM_GIT master"
70git fetch --tags "$UPSTREAM_GIT" master
71echo
72
73echo "Filtering"
74./scripts/filter.sh
75echo
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
82DATE=$(date +%Y%m%d)
83TESTBRANCH=test-${DATE}
84MERGE_OUTPUT=`(
85set -e
86git checkout -b ${TESTBRANCH} origin/master
87git merge --no-edit upstream/dts
88) 2>&1 `
89REF=$(git show-ref --verify refs/heads/${TESTBRANCH})
90echo "Testing: ${REF}"
91if git log ${TESTBRANCH} -- MAINTAINERS | grep --quiet . ; then
92    echo "Filter branch has upstream-only content (MAINTAINERS file)"
93    exit 1
94fi
95
96make clean -s
97TEST_OUTPUT=`make -k -s 2>&1 || true`
98if [ -z "${TEST_OUTPUT}" ]; then
99    echo "Success!"
100else
101    echo "---------------------------------------------------------------------"
102    echo "Test Output:"
103    echo "---------------------------------------------------------------------"
104    echo "$TEST_OUTPUT"
105fi
106echo
107
108echo "Switching back to master branch"
109git checkout master
110
111echo "Recording refs/tests/${DATE}"
112git update-ref refs/tests/${DATE} ${TESTBRANCH}
113
114echo "Removing ${TESTBRANCH}"
115git branch -D "${TESTBRANCH}"
116
117echo "Final State:"
118for branch in ${BRANCHES} ; do
119    REF=$(git show-ref --verify refs/heads/${branch})
120    echo "  ${REF}"
121done
122echo
123
124exit 0
125