Creating a patch. Why mine so different? Quilt problem I think

So I'm working with the TP-Link TD-W8968 V3.
I have learnt how to make a custom image for my device.
Now I am trying to create a patch. I have very little grasp on it yet. My main question is this...
I read this file for clues on how to create my image. But take for example the first patched file 01_leds. In thier patch the enrty is

diff --git a/target/linux/brcm63xx/base-files/etc/board.d/01_leds b/target/linux/brcm63xx/base-files/etc/board.d/01_leds
index 4163214732..8472912bce 100755
--- a/target/linux/brcm63xx/base-files/etc/board.d/01_leds
+++ b/target/linux/brcm63xx/base-files/etc/board.d/01_leds
@@ -61,6 +61,9 @@ homehub2a)
 r5010un_v2)
 	ucidef_set_led_usbdev "usb" "USB" "R5010UNv2:green:usb" "1-1"
 	;;
+td-w8968)
+	ucidef_set_led_netdev "wan" "WAN" "TD-W8968:green:inet" "eth0.2"
+	;;
 esac

showing practically only the new lines added. When I try to create a patch it includes the entire contents of the edited file. How do I make quilt recognize only my new lines and not include the entire file?

https://openwrt.org/docs/guide-developer/build-system/use-patches-with-buildsystem

You probably just need to tweak ~/.quiltrc

I am using that config.
Following the instructions down at "Adding or editing kernel patches" section I run

make target/linux/{clean,prepare} V=s QUILT=1
cd build_dir/target-*/linux-*/linux-*
quilt new platform/581-board_td-w8968_v3.patch
quilt add ~/openwrt/target/linux/brcm63xx/base-files/etc/board.d/01_leds
quilt edit ~/openwrt/target/linux/brcm63xx/base-files/etc/board.d/01_leds

I then edit the file and run

quilt refresh
cd ~/openwrt
make target/linux/update

and check the patch file it creates. That is where it is listing the entire contents of ~/openwrt/target/linux/brcm63xx/base-files/etc/board.d/01_leds

Why are you using quilt????
It is only needed for a patch series of multiple patches (like the actual kernel patches). Not for editing a normal file...
Using quilt there sounds wrong.

Normal git diff should show your changes to that file.

I'm using quilt because the page didn't mention git. I dunno what I'm doing which is why I was following their instructions. I wanted to make a patch so could include the model for future openwrt users.

If you edit existing files, you can simply edit them, and then finally take "git diff" to show the edits.
And do " git diff > newdevice.patch " to get a patch file. Or if you add new files, you may need to git add them first, and then take a "git diff HEAD"

Quilt is mainly meant for editing a long series of consecutive patches that during the compile process edit partially same files, which are usually downloaded from upstream and then patched in Openwrt to be suitable for our needs. (If the edited files would be in Openwrt sources, they would be edited directly, not patched in the compile time.)

Examples:
the kernel patches that modify the kernel sources downloaded from upstream:
https://github.com/openwrt/openwrt/tree/master/target/linux/brcm63xx/patches-4.14
patches modify package source code downloaded from upstream:
https://github.com/openwrt/openwrt/tree/master/package/network/utils/iproute2/patches

The big difference is that you are not editing patch files that are in the Openwrt source, but you are editing source files and then want to create an external patch to repeat those changes.

1 Like

Great info thanks @hnyman. I'll see how I go.

@hnyman got around to trying it this morning.

diff --git a/target/linux/brcm63xx/base-files/etc/board.d/01_leds b/target/linux/brcm63xx/base-files/etc/board.d/01_leds
index d25d37e847..64710280f7 100755
--- a/target/linux/brcm63xx/base-files/etc/board.d/01_leds
+++ b/target/linux/brcm63xx/base-files/etc/board.d/01_leds
@@ -80,6 +80,9 @@ r1000h)
 r5010un_v2)
 	ucidef_set_led_usbdev "usb" "USB" "R5010UNv2:green:usb" "1-1"
 	;;
+td-w8968)
+	ucidef_set_led_netdev "wan" "WAN" "TD-W8968:green:inet" "eth0.2"
+	;;
 esac
 
 board_config_flush

:grinning:

Just thought I'd add a couple of notes for other noobs reading this.

To apply the patch I ran

patch -p1 < yourpatch.patch

the -p1 removes the a/ & b/ from the paths made with git diff as seen below

--- a/target/linux/brcm63xx/base-files/etc/board.d/01_leds
+++ b/target/linux/brcm63xx/base-files/etc/board.d/01_leds

I also noticed that running the patch command broke my symlinks. I had desktop shortcuts to the files I was editing and after running patch they were broken

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.