1d18719a4STom Rini#!/bin/sh 2d18719a4STom Rini# Simple script to update the version of DTC carried by the Linux kernel 3d18719a4STom Rini# 4d18719a4STom Rini# This script assumes that the dtc and the linux git trees are in the 5d18719a4STom Rini# same directory. After building dtc in the dtc directory, it copies the 6d18719a4STom Rini# source files and generated source files into the scripts/dtc directory 7d18719a4STom Rini# in the kernel and creates a git commit updating them to the new 8d18719a4STom Rini# version. 9d18719a4STom Rini# 10d18719a4STom Rini# Usage: from the top level Linux source tree, run: 11d18719a4STom Rini# $ ./scripts/dtc/update-dtc-source.sh 12d18719a4STom Rini# 13d18719a4STom Rini# The script will change into the dtc tree, build and test dtc, copy the 14d18719a4STom Rini# relevant files into the kernel tree and create a git commit. The commit 15d18719a4STom Rini# message will need to be modified to reflect the version of DTC being 16d18719a4STom Rini# imported 17d18719a4STom Rini# 18d18719a4STom Rini# TODO: 19d18719a4STom Rini# This script is pretty basic, but it is seldom used so a few manual tasks 20d18719a4STom Rini# aren't a big deal. If anyone is interested in making it more robust, the 21d18719a4STom Rini# the following would be nice: 22d18719a4STom Rini# * Actually fail to complete if any testcase fails. 23d18719a4STom Rini# - The dtc "make check" target needs to return a failure 24d18719a4STom Rini# * Extract the version number from the dtc repo for the commit message 25d18719a4STom Rini# * Build dtc in the kernel tree 26d18719a4STom Rini# * run 'make check" on dtc built from the kernel tree 27d18719a4STom Rini 28d18719a4STom Riniset -ev 29d18719a4STom Rini 30d18719a4STom RiniDTC_UPSTREAM_PATH=`pwd`/../dtc 31d18719a4STom RiniDTC_LINUX_PATH=`pwd`/scripts/dtc 32d18719a4STom Rini 33d18719a4STom RiniDTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c \ 34d18719a4STom Rini srcpos.h treesource.c util.c util.h version_gen.h Makefile.dtc \ 35d18719a4STom Rini dtc-lexer.l dtc-parser.y" 36d18719a4STom RiniDTC_GENERATED="dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h" 37*b7638540SRob HerringLIBFDT_SOURCE="Makefile.libfdt fdt.c fdt.h fdt_addresses.c fdt_empty_tree.c \ 38*b7638540SRob Herring fdt_overlay.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c \ 39*b7638540SRob Herring fdt_wip.c libfdt.h libfdt_env.h libfdt_internal.h" 40d18719a4STom Rini 41d18719a4STom Riniget_last_dtc_version() { 42d18719a4STom Rini git log --oneline scripts/dtc/ | grep 'upstream' | head -1 | sed -e 's/^.* \(.*\)/\1/' 43d18719a4STom Rini} 44d18719a4STom Rini 45d18719a4STom Rinilast_dtc_ver=$(get_last_dtc_version) 46d18719a4STom Rini 47d18719a4STom Rini# Build DTC 48d18719a4STom Rinicd $DTC_UPSTREAM_PATH 49d18719a4STom Rinimake clean 50d18719a4STom Rinimake check 51d18719a4STom Rinidtc_version=$(git describe HEAD) 52d18719a4STom Rinidtc_log=$(git log --oneline ${last_dtc_ver}..) 53d18719a4STom Rini 54d18719a4STom Rini 55d18719a4STom Rini# Copy the files into the Linux tree 56d18719a4STom Rinicd $DTC_LINUX_PATH 57d18719a4STom Rinifor f in $DTC_SOURCE; do 58d18719a4STom Rini cp ${DTC_UPSTREAM_PATH}/${f} ${f} 59d18719a4STom Rini git add ${f} 60d18719a4STom Rinidone 61d18719a4STom Rinifor f in $DTC_GENERATED; do 62d18719a4STom Rini cp ${DTC_UPSTREAM_PATH}/$f ${f}_shipped 63d18719a4STom Rini git add ${f}_shipped 64d18719a4STom Rinidone 65d18719a4STom Rinifor f in $LIBFDT_SOURCE; do 66d18719a4STom Rini cp ${DTC_UPSTREAM_PATH}/libfdt/${f} libfdt/${f} 67d18719a4STom Rini git add libfdt/${f} 68d18719a4STom Rinidone 69d18719a4STom Rini 70d18719a4STom Rinised -i -- 's/#include <libfdt_env.h>/#include "libfdt_env.h"/g' ./libfdt/libfdt.h 71d18719a4STom Rinised -i -- 's/#include <fdt.h>/#include "fdt.h"/g' ./libfdt/libfdt.h 72d18719a4STom Rinigit add ./libfdt/libfdt.h 73d18719a4STom Rini 74d18719a4STom Rinicommit_msg=$(cat << EOF 75d18719a4STom Riniscripts/dtc: Update to upstream version ${dtc_version} 76d18719a4STom Rini 77d18719a4STom RiniThis adds the following commits from upstream: 78d18719a4STom Rini 79d18719a4STom Rini${dtc_log} 80d18719a4STom RiniEOF 81d18719a4STom Rini) 82d18719a4STom Rini 83d18719a4STom Rinigit commit -e -v -s -m "${commit_msg}" 84