From 7f9800d203def78c8fc5d5cf36b7546697714a53 Mon Sep 17 00:00:00 2001 From: Hamish Coleman Date: Tue, 6 Aug 2019 16:19:39 +0100 Subject: [PATCH] Add a rudimentary config file - this (finally) removes the need to ever build in a dirty checkout, which makes the build strings and debuging clearer --- Makefile | 55 +++++++++---------- defconfig | 4 ++ scripts/hexpatch.pl | 2 +- ...e.patch.OFF => 006_battery_validate.patch} | 0 ...e.patch.OFF => 006_battery_validate.patch} | 0 ...patch.OFF => 007_capslock_ctrl_swap.patch} | 3 + ...e.patch.OFF => 006_battery_validate.patch} | 0 ...e.patch.OFF => 006_battery_validate.patch} | 0 ...e.patch.OFF => 006_battery_validate.patch} | 0 ...patch.OFF => 007_capslock_ctrl_swap.patch} | 3 + ....patch.OFF => 007_capslock_esc_swap.patch} | 3 + ...{007_dvorak.patch.OFF => 007_dvorak.patch} | 3 + ...ch.OFF => 007_dvorak_caps_ctrl_swap.patch} | 3 + ...e.patch.OFF => 006_battery_validate.patch} | 0 ...patch.OFF => 007_capslock_ctrl_swap.patch} | 3 + ....patch.OFF => 007_capslock_esc_swap.patch} | 3 + ...{007_dvorak.patch.OFF => 007_dvorak.patch} | 3 + ...ch.OFF => 007_dvorak_caps_ctrl_swap.patch} | 3 + 18 files changed, 57 insertions(+), 31 deletions(-) create mode 100644 defconfig rename t430.G1HT34WW.img.d/{006_battery_validate.patch.OFF => 006_battery_validate.patch} (100%) rename t430.G1HT35WW.img.d/{006_battery_validate.patch.OFF => 006_battery_validate.patch} (100%) rename t430.G1HT35WW.img.d/{007_capslock_ctrl_swap.patch.OFF => 007_capslock_ctrl_swap.patch} (95%) rename t430s.G7HT39WW.img.d/{006_battery_validate.patch.OFF => 006_battery_validate.patch} (100%) rename w530.G4HT39WW.img.d/{006_battery_validate.patch.OFF => 006_battery_validate.patch} (100%) rename x230.G2HT35WW.img.d/{006_battery_validate.patch.OFF => 006_battery_validate.patch} (100%) rename x230.G2HT35WW.img.d/{007_capslock_ctrl_swap.patch.OFF => 007_capslock_ctrl_swap.patch} (95%) rename x230.G2HT35WW.img.d/{007_capslock_esc_swap.patch.OFF => 007_capslock_esc_swap.patch} (89%) rename x230.G2HT35WW.img.d/{007_dvorak.patch.OFF => 007_dvorak.patch} (95%) rename x230.G2HT35WW.img.d/{007_dvorak_caps_ctrl_swap.patch.OFF => 007_dvorak_caps_ctrl_swap.patch} (96%) rename x230t.GCHT25WW.img.d/{006_battery_validate.patch.OFF => 006_battery_validate.patch} (100%) rename x230t.GCHT25WW.img.d/{007_capslock_ctrl_swap.patch.OFF => 007_capslock_ctrl_swap.patch} (94%) rename x230t.GCHT25WW.img.d/{007_capslock_esc_swap.patch.OFF => 007_capslock_esc_swap.patch} (91%) rename x230t.GCHT25WW.img.d/{007_dvorak.patch.OFF => 007_dvorak.patch} (95%) rename x230t.GCHT25WW.img.d/{007_dvorak_caps_ctrl_swap.patch.OFF => 007_dvorak_caps_ctrl_swap.patch} (96%) diff --git a/Makefile b/Makefile index 2205b34..3a30d21 100644 --- a/Makefile +++ b/Makefile @@ -112,46 +112,41 @@ install.radare.projects: mkdir -p ~/.config/radare2/projects/x260.R02HT29W.d/ cp -fs $(PWD)/radare/x260.R02HT29W ~/.config/radare2/projects + +.config: + cp defconfig .config +include .config + +PATCHES-$(CONFIG_KEYBOARD) += \ + 001_keysym.patch 002_dead_keys.patch 003_keysym_replacements.patch \ + 004_fn_keys.patch 005_fn_key_swap.patch + +PATCHES-$(CONFIG_BATTERY) += \ + 006_battery_validate.patch + +# To enable other misc patches: +# - add a new CONFIG_something value to the defconfig and .config +# - add a new PATCHES-$(CONFIG_something) line referencing the patch +# - optionally, add a patch_enable/patch_disable stanza +# - however, that will get messy quickly, so perhaps a real config target + # # These enable and disable targets change which patches are configured to be -# applied - -PATCHES_KEYBOARD := 001_keysym.patch 002_dead_keys.patch \ - 003_keysym_replacements.patch 004_fn_keys.patch 005_fn_key_swap.patch +# applied. +# TODO - actually edit the .config, dont just keep appending new stuff to it patch_enable_battery: - $(call patch_enable,006_battery_validate.patch) + echo "CONFIG_BATTERY = y" >>.config patch_disable_battery: - $(call patch_disable,006_battery_validate.patch) + echo "CONFIG_BATTERY = n" >>.config patch_enable_keyboard: - for j in $(PATCHES_KEYBOARD); do \ - $(call patch_enable,$$j); \ - done + echo "CONFIG_KEYBOARD = y" >>.config patch_disable_keyboard: - for j in $(PATCHES_KEYBOARD); do \ - $(call patch_disable,$$j); \ - done - -# $1 is the old patch name -# $2 is the new patch name -define patch_mv - for i in *.img.d; do \ - if [ -e $$i/$1 ]; then mv $$i/$1 $$i/$2; fi; \ - done -endef + echo "CONFIG_KEYBOARD = n" >>.config -# $1 is the patch name -define patch_enable - $(call patch_mv,$1.OFF,$1) -endef - -# $1 is the patch name -define patch_disable - $(call patch_mv,$1,$1.OFF) -endef # TODO - the scripts/describe output depends on Descriptions.txt - # could parse that file and create some deps @@ -188,7 +183,7 @@ endef # Generate a working file with any known patches applied %.img: %.img.orig @cp --reflink=auto $< $@ - ./scripts/hexpatch.pl --rm_on_fail --report $@.report $@ $@.d/*.patch + ./scripts/hexpatch.pl --rm_on_fail --report $@.report $@ $(addprefix $@.d/,$(PATCHES-y)) # using both __DIR and __FL2 is a hack to get around needing to quote the # DOS path separator. It feels like there should be a better way if I put diff --git a/defconfig b/defconfig new file mode 100644 index 0000000..b269094 --- /dev/null +++ b/defconfig @@ -0,0 +1,4 @@ +# Configuration for which patches to apply + +CONFIG_KEYBOARD = y +CONFIG_BATTERY = n diff --git a/scripts/hexpatch.pl b/scripts/hexpatch.pl index ae6dd69..8eeea17 100755 --- a/scripts/hexpatch.pl +++ b/scripts/hexpatch.pl @@ -226,7 +226,7 @@ sub main() { } my $binaryfile = shift @ARGV; - if (!defined($binaryfile) or !defined($ARGV[0])) { + if (!defined($binaryfile)) { usage(); } diff --git a/t430.G1HT34WW.img.d/006_battery_validate.patch.OFF b/t430.G1HT34WW.img.d/006_battery_validate.patch similarity index 100% rename from t430.G1HT34WW.img.d/006_battery_validate.patch.OFF rename to t430.G1HT34WW.img.d/006_battery_validate.patch diff --git a/t430.G1HT35WW.img.d/006_battery_validate.patch.OFF b/t430.G1HT35WW.img.d/006_battery_validate.patch similarity index 100% rename from t430.G1HT35WW.img.d/006_battery_validate.patch.OFF rename to t430.G1HT35WW.img.d/006_battery_validate.patch diff --git a/t430.G1HT35WW.img.d/007_capslock_ctrl_swap.patch.OFF b/t430.G1HT35WW.img.d/007_capslock_ctrl_swap.patch similarity index 95% rename from t430.G1HT35WW.img.d/007_capslock_ctrl_swap.patch.OFF rename to t430.G1HT35WW.img.d/007_capslock_ctrl_swap.patch index e5d20e3..d351055 100644 --- a/t430.G1HT35WW.img.d/007_capslock_ctrl_swap.patch.OFF +++ b/t430.G1HT35WW.img.d/007_capslock_ctrl_swap.patch @@ -5,6 +5,9 @@ Also, swapping your capslock and ctrl keys is something that your Operating System can do, so patching the EC firmware is quite an overkill for this task. +To enable this patch, you will need to edit the PATCHES-* variable inside +the Makefile + --- t430.G1HT35WW.img.prepatched.hex 2019-01-15 03:40:49.758801095 +0000 +++ t430.G1HT35WW.img.swapctrlcaps.hex 2019-01-15 03:41:10.240081095 +0000 @@ -8505,7 +8505,7 @@ diff --git a/t430s.G7HT39WW.img.d/006_battery_validate.patch.OFF b/t430s.G7HT39WW.img.d/006_battery_validate.patch similarity index 100% rename from t430s.G7HT39WW.img.d/006_battery_validate.patch.OFF rename to t430s.G7HT39WW.img.d/006_battery_validate.patch diff --git a/w530.G4HT39WW.img.d/006_battery_validate.patch.OFF b/w530.G4HT39WW.img.d/006_battery_validate.patch similarity index 100% rename from w530.G4HT39WW.img.d/006_battery_validate.patch.OFF rename to w530.G4HT39WW.img.d/006_battery_validate.patch diff --git a/x230.G2HT35WW.img.d/006_battery_validate.patch.OFF b/x230.G2HT35WW.img.d/006_battery_validate.patch similarity index 100% rename from x230.G2HT35WW.img.d/006_battery_validate.patch.OFF rename to x230.G2HT35WW.img.d/006_battery_validate.patch diff --git a/x230.G2HT35WW.img.d/007_capslock_ctrl_swap.patch.OFF b/x230.G2HT35WW.img.d/007_capslock_ctrl_swap.patch similarity index 95% rename from x230.G2HT35WW.img.d/007_capslock_ctrl_swap.patch.OFF rename to x230.G2HT35WW.img.d/007_capslock_ctrl_swap.patch index d0d9307..e9bdf65 100644 --- a/x230.G2HT35WW.img.d/007_capslock_ctrl_swap.patch.OFF +++ b/x230.G2HT35WW.img.d/007_capslock_ctrl_swap.patch @@ -5,6 +5,9 @@ Also, swapping your capslock and ctrl keys is something that your Operating System can do, so patching the EC firmware is quite an overkill for this task. +To enable this patch, you will need to edit the PATCHES-* variable inside +the Makefile + --- x230.G2HT35WW.img.dvorak.hex 2017-09-20 19:57:42.206883067 +0300 +++ x230.G2HT35WW.img.prepatched.hex 2017-09-20 19:58:00.471897920 +0300 @@ -8515,7 +8515,7 @@ diff --git a/x230.G2HT35WW.img.d/007_capslock_esc_swap.patch.OFF b/x230.G2HT35WW.img.d/007_capslock_esc_swap.patch similarity index 89% rename from x230.G2HT35WW.img.d/007_capslock_esc_swap.patch.OFF rename to x230.G2HT35WW.img.d/007_capslock_esc_swap.patch index d157c05..0b8e2f6 100644 --- a/x230.G2HT35WW.img.d/007_capslock_esc_swap.patch.OFF +++ b/x230.G2HT35WW.img.d/007_capslock_esc_swap.patch @@ -1,5 +1,8 @@ This swaps capslock and escape. +To enable this patch, you will need to edit the PATCHES-* variable inside +the Makefile + @@ capslock_esc_swap @@ 000218b0 9e 9e 00 9f 9f 00 4a 4a 00 00 00 00 b2 00 00 00 |......JJ........| 000218c0 b4 16 02 00 40 00 00 00 58 18 02 00 18 18 02 00 |....@...X.......| diff --git a/x230.G2HT35WW.img.d/007_dvorak.patch.OFF b/x230.G2HT35WW.img.d/007_dvorak.patch similarity index 95% rename from x230.G2HT35WW.img.d/007_dvorak.patch.OFF rename to x230.G2HT35WW.img.d/007_dvorak.patch index 36fc770..365f698 100644 --- a/x230.G2HT35WW.img.d/007_dvorak.patch.OFF +++ b/x230.G2HT35WW.img.d/007_dvorak.patch @@ -1,3 +1,6 @@ +To enable this patch, you will need to edit the PATCHES-* variable inside +the Makefile + --- x230.G2HT35WW.img.hex 2017-09-20 21:12:02.011604376 +0300 +++ x230.G2HT35WW.img.dvorak.hex 2017-09-20 22:04:57.510398990 +0300 @@ -8514,14 +8514,14 @@ diff --git a/x230.G2HT35WW.img.d/007_dvorak_caps_ctrl_swap.patch.OFF b/x230.G2HT35WW.img.d/007_dvorak_caps_ctrl_swap.patch similarity index 96% rename from x230.G2HT35WW.img.d/007_dvorak_caps_ctrl_swap.patch.OFF rename to x230.G2HT35WW.img.d/007_dvorak_caps_ctrl_swap.patch index 18e0866..a119b65 100644 --- a/x230.G2HT35WW.img.d/007_dvorak_caps_ctrl_swap.patch.OFF +++ b/x230.G2HT35WW.img.d/007_dvorak_caps_ctrl_swap.patch @@ -1,3 +1,6 @@ +To enable this patch, you will need to edit the PATCHES-* variable inside +the Makefile + --- x230.G2HT35WW.img.hex 2017-09-20 21:12:02.011604376 +0300 +++ x230.G2HT35WW.img.dvorak.hex 2017-09-20 22:02:06.947252472 +0300 @@ -8514,14 +8514,14 @@ diff --git a/x230t.GCHT25WW.img.d/006_battery_validate.patch.OFF b/x230t.GCHT25WW.img.d/006_battery_validate.patch similarity index 100% rename from x230t.GCHT25WW.img.d/006_battery_validate.patch.OFF rename to x230t.GCHT25WW.img.d/006_battery_validate.patch diff --git a/x230t.GCHT25WW.img.d/007_capslock_ctrl_swap.patch.OFF b/x230t.GCHT25WW.img.d/007_capslock_ctrl_swap.patch similarity index 94% rename from x230t.GCHT25WW.img.d/007_capslock_ctrl_swap.patch.OFF rename to x230t.GCHT25WW.img.d/007_capslock_ctrl_swap.patch index bc1baa4..a5da8f9 100644 --- a/x230t.GCHT25WW.img.d/007_capslock_ctrl_swap.patch.OFF +++ b/x230t.GCHT25WW.img.d/007_capslock_ctrl_swap.patch @@ -1,3 +1,6 @@ +To enable this patch, you will need to edit the PATCHES-* variable inside +the Makefile + --- x230t.GCHT25WW.img.prepatched.hex 2017-08-27 00:07:20.937481818 +0300 +++ x230t.GCHT25WW.img.hex 2017-08-27 00:07:05.234482494 +0300 @@ -8658,7 +8658,7 @@ diff --git a/x230t.GCHT25WW.img.d/007_capslock_esc_swap.patch.OFF b/x230t.GCHT25WW.img.d/007_capslock_esc_swap.patch similarity index 91% rename from x230t.GCHT25WW.img.d/007_capslock_esc_swap.patch.OFF rename to x230t.GCHT25WW.img.d/007_capslock_esc_swap.patch index ae1d696..1d9c40a 100644 --- a/x230t.GCHT25WW.img.d/007_capslock_esc_swap.patch.OFF +++ b/x230t.GCHT25WW.img.d/007_capslock_esc_swap.patch @@ -1,3 +1,6 @@ +To enable this patch, you will need to edit the PATCHES-* variable inside +the Makefile + --- x230t.GCHT25WW.img.orig.hex 2017-07-12 12:51:57.975502349 -0400 +++ x230t.GCHT25WW.img.hex 2017-07-12 12:52:03.703479675 -0400 @@ -8657,8 +8657,8 @@ diff --git a/x230t.GCHT25WW.img.d/007_dvorak.patch.OFF b/x230t.GCHT25WW.img.d/007_dvorak.patch similarity index 95% rename from x230t.GCHT25WW.img.d/007_dvorak.patch.OFF rename to x230t.GCHT25WW.img.d/007_dvorak.patch index 8ae0ddc..d2e6377 100644 --- a/x230t.GCHT25WW.img.d/007_dvorak.patch.OFF +++ b/x230t.GCHT25WW.img.d/007_dvorak.patch @@ -1,3 +1,6 @@ +To enable this patch, you will need to edit the PATCHES-* variable inside +the Makefile + --- x230t.GCHT25WW.img.prepatched.hex 2017-08-27 19:56:22.362861225 +0300 +++ x230t.GCHT25WW.img.dvorak.hex 2017-08-27 20:50:41.571755322 +0300 @@ -8657,14 +8657,14 @@ diff --git a/x230t.GCHT25WW.img.d/007_dvorak_caps_ctrl_swap.patch.OFF b/x230t.GCHT25WW.img.d/007_dvorak_caps_ctrl_swap.patch similarity index 96% rename from x230t.GCHT25WW.img.d/007_dvorak_caps_ctrl_swap.patch.OFF rename to x230t.GCHT25WW.img.d/007_dvorak_caps_ctrl_swap.patch index 4917be1..d68a07e 100644 --- a/x230t.GCHT25WW.img.d/007_dvorak_caps_ctrl_swap.patch.OFF +++ b/x230t.GCHT25WW.img.d/007_dvorak_caps_ctrl_swap.patch @@ -1,3 +1,6 @@ +To enable this patch, you will need to edit the PATCHES-* variable inside +the Makefile + --- x230t.GCHT25WW.img.prepatched.hex 2017-08-27 19:56:22.362861225 +0300 +++ x230t.GCHT25WW.img.dvorak.hex 2017-08-27 21:00:04.865220520 +0300 @@ -8657,14 +8657,14 @@