#!/bin/sh # Simple script to update the version of DTC carried by the Linux kernel # # This script assumes that the dtc and the linux git trees are in the # same directory. After building dtc in the dtc directory, it copies the # source files and generated source files into the scripts/dtc directory # in the kernel and creates a git commit updating them to the new # version. # # Usage: from the top level Linux source tree, run: # $ ./scripts/dtc/update-dtc-source.sh # # The script will change into the dtc tree, build and test dtc, copy the # relevant files into the kernel tree and create a git commit. The commit # message will need to be modified to reflect the version of DTC being # imported # # TODO: # This script is pretty basic, but it is seldom used so a few manual tasks # aren't a big deal. If anyone is interested in making it more robust, the # the following would be nice: # * Actually fail to complete if any testcase fails. # - The dtc "make check" target needs to return a failure # * Extract the version number from the dtc repo for the commit message # * Build dtc in the kernel tree # * run 'make check" on dtc built from the kernel tree set -ev global DTC_UPSTREAM_PATH := "$[pwd]/../dtc" global DTC_LINUX_PATH := "$[pwd]/scripts/dtc" global DTC_SOURCE := '"checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c \ srcpos.h treesource.c util.c util.h version_gen.h Makefile.dtc \ dtc-lexer.l dtc-parser.y'" global DTC_GENERATED := '"dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h'" global LIBFDT_SOURCE := '"Makefile.libfdt fdt.c fdt.h fdt_empty_tree.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c fdt_wip.c libfdt.h libfdt_env.h libfdt_internal.h'" # Build DTC cd $DTC_UPSTREAM_PATH make clean make check # Copy the files into the Linux tree cd $DTC_LINUX_PATH for f in [$DTC_SOURCE] { cp $(DTC_UPSTREAM_PATH)/$(f) $(f) git add $(f) } for f in [$DTC_GENERATED] { cp $(DTC_UPSTREAM_PATH)/$f $(f)_shipped git add $(f)_shipped } for f in [$LIBFDT_SOURCE] { cp $(DTC_UPSTREAM_PATH)/libfdt/$(f) libfdt/$(f) git add libfdt/$(f) } sed -i -- 's/#include /#include "libfdt_env.h"/g' ./libfdt/libfdt.h sed -i -- 's/#include /#include "fdt.h"/g' ./libfdt/libfdt.h git add ./libfdt/libfdt.h git commit -e -v -m "scripts/dtc: Update to upstream version [CHANGEME]" (CommandList children: [ (C {(set)} {(-ev)}) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DTC_UPSTREAM_PATH) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(pwd)})]) left_token: spids: [85 87] ) (/../dtc) } spids: [84] ) ] spids: [84] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DTC_LINUX_PATH) op: Equal rhs: { (CommandSubPart command_list: (CommandList children:[(C {(pwd)})]) left_token: spids: [91 93] ) (/scripts/dtc) } spids: [90] ) ] spids: [90] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DTC_SOURCE) op: Equal rhs: { (DQ ("checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c srcpos.c ") ("\t\tsrcpos.h treesource.c util.c util.h version_gen.h Makefile.dtc ") ("\t\tdtc-lexer.l dtc-parser.y") ) } spids: [97] ) ] spids: [97] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:DTC_GENERATED) op: Equal rhs: {(DQ ("dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h"))} spids: [106] ) ] spids: [106] ) (Assignment keyword: Assign_None pairs: [ (assign_pair lhs: (LhsName name:LIBFDT_SOURCE) op: Equal rhs: { (DQ ( "Makefile.libfdt fdt.c fdt.h fdt_empty_tree.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c fdt_wip.c libfdt.h libfdt_env.h libfdt_internal.h" ) ) } spids: [111] ) ] spids: [111] ) (C {(cd)} {($ VSub_Name "$DTC_UPSTREAM_PATH")}) (C {(make)} {(clean)}) (C {(make)} {(check)}) (C {(cd)} {($ VSub_Name "$DTC_LINUX_PATH")}) (ForEach iter_name: f iter_words: [{($ VSub_Name "$DTC_SOURCE")}] do_arg_iter: False body: (DoGroup children: [ (C {(cp)} {(${ VSub_Name DTC_UPSTREAM_PATH) (/) (${ VSub_Name f)} {(${ VSub_Name f)}) (C {(git)} {(add)} {(${ VSub_Name f)}) ] spids: [149 175] ) spids: [145 147] ) (ForEach iter_name: f iter_words: [{($ VSub_Name "$DTC_GENERATED")}] do_arg_iter: False body: (DoGroup children: [ (C {(cp)} {(${ VSub_Name DTC_UPSTREAM_PATH) (/) ($ VSub_Name "$f")} {(${ VSub_Name f) (_shipped)} ) (C {(git)} {(add)} {(${ VSub_Name f) (_shipped)}) ] spids: [186 212] ) spids: [182 184] ) (ForEach iter_name: f iter_words: [{($ VSub_Name "$LIBFDT_SOURCE")}] do_arg_iter: False body: (DoGroup children: [ (C {(cp)} {(${ VSub_Name DTC_UPSTREAM_PATH) (/libfdt/) (${ VSub_Name f)} {(libfdt/) (${ VSub_Name f)} ) (C {(git)} {(add)} {(libfdt/) (${ VSub_Name f)}) ] spids: [223 251] ) spids: [219 221] ) (C {(sed)} {(-i)} {(--)} {(SQ <"s/#include /#include \"libfdt_env.h\"/g">)} {(./libfdt/libfdt.h)} ) (C {(sed)} {(-i)} {(--)} {(SQ <"s/#include /#include \"fdt.h\"/g">)} {(./libfdt/libfdt.h)}) (C {(git)} {(add)} {(./libfdt/libfdt.h)}) (C {(git)} {(commit)} {(-e)} {(-v)} {(-m)} {(DQ ("scripts/dtc: Update to upstream version [CHANGEME]"))}) ] )