Back to home page

OSCL-LXR

 
 

    


0001 #!/bin/sh
0002 # SPDX-License-Identifier: GPL-2.0
0003 # Simple script to update the version of DTC carried by the Linux kernel
0004 #
0005 # This script assumes that the dtc and the linux git trees are in the
0006 # same directory. After building dtc in the dtc directory, it copies the
0007 # source files and generated source file(s) into the scripts/dtc directory
0008 # in the kernel and creates a git commit updating them to the new
0009 # version.
0010 #
0011 # Usage: from the top level Linux source tree, run:
0012 # $ ./scripts/dtc/update-dtc-source.sh
0013 #
0014 # The script will change into the dtc tree, build and test dtc, copy the
0015 # relevant files into the kernel tree and create a git commit. The commit
0016 # message will need to be modified to reflect the version of DTC being
0017 # imported
0018 #
0019 # TODO:
0020 # This script is pretty basic, but it is seldom used so a few manual tasks
0021 # aren't a big deal. If anyone is interested in making it more robust, the
0022 # the following would be nice:
0023 # * Actually fail to complete if any testcase fails.
0024 #   - The dtc "make check" target needs to return a failure
0025 # * Extract the version number from the dtc repo for the commit message
0026 # * Build dtc in the kernel tree
0027 # * run 'make check" on dtc built from the kernel tree
0028 
0029 set -ev
0030 
0031 DTC_UPSTREAM_PATH=`pwd`/../dtc
0032 DTC_LINUX_PATH=`pwd`/scripts/dtc
0033 
0034 DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c \
0035                 srcpos.h treesource.c util.c util.h version_gen.h \
0036                 dtc-lexer.l dtc-parser.y"
0037 LIBFDT_SOURCE="fdt.c fdt.h fdt_addresses.c fdt_empty_tree.c \
0038                 fdt_overlay.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c \
0039                 fdt_wip.c libfdt.h libfdt_env.h libfdt_internal.h"
0040 FDTOVERLAY_SOURCE=fdtoverlay.c
0041 
0042 get_last_dtc_version() {
0043         git log --oneline scripts/dtc/ | grep 'upstream' | head -1 | sed -e 's/^.* \(.*\)/\1/'
0044 }
0045 
0046 last_dtc_ver=$(get_last_dtc_version)
0047 
0048 # Build DTC
0049 cd $DTC_UPSTREAM_PATH
0050 make clean
0051 make check
0052 dtc_version=$(git describe HEAD)
0053 dtc_log=$(git log --oneline ${last_dtc_ver}..)
0054 
0055 
0056 # Copy the files into the Linux tree
0057 cd $DTC_LINUX_PATH
0058 for f in $DTC_SOURCE $FDTOVERLAY_SOURCE; do
0059         cp ${DTC_UPSTREAM_PATH}/${f} ${f}
0060         git add ${f}
0061 done
0062 for f in $LIBFDT_SOURCE; do
0063        cp ${DTC_UPSTREAM_PATH}/libfdt/${f} libfdt/${f}
0064        git add libfdt/${f}
0065 done
0066 
0067 sed -i -- 's/#include <libfdt_env.h>/#include "libfdt_env.h"/g' ./libfdt/libfdt.h
0068 sed -i -- 's/#include <fdt.h>/#include "fdt.h"/g' ./libfdt/libfdt.h
0069 git add ./libfdt/libfdt.h
0070 
0071 commit_msg=$(cat << EOF
0072 scripts/dtc: Update to upstream version ${dtc_version}
0073 
0074 This adds the following commits from upstream:
0075 
0076 ${dtc_log}
0077 EOF
0078 )
0079 
0080 git commit -e -v -s -m "${commit_msg}"