1. Locate the hostapd Package Source
- Navigate to the OpenWRT source directory:
cd /path/to/openwrt/ - Locate the
hostapdpackage files:cd package/network/services/hostapd
2. Extract the Source Code
- Ensure you have the original source tarball downloaded:b
make package/network/services/hostapd/download - Extract the source files for modification:
make package/network/services/hostapd/prepare V=sThis will extract the source files into thebuild_dir/directory.
3. Make Changes to the Source Code
- Navigate to the extracted source directory:
cd build_dir/target-*/hostapd-*/ - Modify the source files as needed. For example:
nano src/ap/your_file.c
4. Generate the Patch File
- After making your changes, navigate back to the OpenWRT source directory:
cd /path/to/openwrt/ - Use
diffto create a patch file:diff -uNr package/network/services/hostapd/hostapd-*/src/ap/your_file.c \ build_dir/target-*/hostapd-*/src/ap/your_file.c > my_changes.patchReplaceyour_file.cwith the actual filename you modified. - To generate a patch file from two git branches:
git diff <source-branch> <target-branch> my-patch-file.patch
5. Add the Patch to OpenWRT
- Move your patch file to the
patchesdirectory forhostapd:mv my_changes.patch package/network/services/hostapd/patches/ - Ensure the patch is in the correct format:
- Patch files in OpenWRT use the naming convention
###-description.patch, where###is a three-digit number (e.g.,001-my-fix.patch).
- Patch files in OpenWRT use the naming convention
6. Rebuild and Test
- Clean and rebuild the package:
make package/network/services/hostapd/{clean,compile} V=s - If the build succeeds, the patch has been applied correctly, and you can test the resulting firmware.
7. Troubleshooting
- If the patch fails during application, verify that the paths in the patch file match the source tree structure.
- Use
patchto manually test the patch:patch -p1 < package/network/services/hostapd/patches/001-my-fix.patch
By following these steps, you can create, apply, and test a custom patch for the hostapd package in OpenWRT.
