|
| 1 | +# Kernel Patch Validator |
| 2 | + |
| 3 | +[](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html) |
| 4 | +[](https://github.com/ipenas-cl/kernel-patch-validator/issues) |
| 5 | + |
| 6 | +Never send a bad patch again! This toolkit helps you validate patches before sending them to Linux kernel mailing lists. |
| 7 | + |
| 8 | +Born from real experience of patch rejections and maintainer feedback, this validator catches the common mistakes that immediately mark you as a novice contributor. |
| 9 | + |
| 10 | +## Quick Start |
| 11 | + |
| 12 | +```bash |
| 13 | +# Validate a single patch |
| 14 | +./scripts/validate-patch.sh my-patch.patch |
| 15 | + |
| 16 | +# Run interactive pre-send checklist |
| 17 | +./scripts/pre-send-checklist.sh |
| 18 | + |
| 19 | +# Create patch with template |
| 20 | +cp templates/commit-message.template my-commit.txt |
| 21 | +# Edit my-commit.txt, then: |
| 22 | +git commit -F my-commit.txt |
| 23 | +``` |
| 24 | + |
| 25 | +## Directory Structure |
| 26 | + |
| 27 | +``` |
| 28 | +kernel-patch-validator/ |
| 29 | +├── docs/ |
| 30 | +│ ├── KERNEL_CONTRIBUTION_GUIDE.md # Complete guide |
| 31 | +│ ├── KERNEL_ANTIPATTERNS.md # What NOT to do |
| 32 | +│ └── KERNEL_QUICK_REFERENCE.md # Quick reference |
| 33 | +├── scripts/ |
| 34 | +│ ├── validate-patch.sh # Automated validator |
| 35 | +│ └── pre-send-checklist.sh # Interactive checklist |
| 36 | +├── templates/ |
| 37 | +│ ├── commit-message.template # Perfect commit message |
| 38 | +│ ├── email-response.template # How to reply to reviews |
| 39 | +│ └── cover-letter.template # For patch series |
| 40 | +└── README.md # This file |
| 41 | +``` |
| 42 | + |
| 43 | +## Features |
| 44 | + |
| 45 | +### validate-patch.sh |
| 46 | + |
| 47 | +Automated checks for: |
| 48 | +- ✓ Future dates (2025 bug) |
| 49 | +- ✓ Signed-off-by presence |
| 50 | +- ✓ Subject line format |
| 51 | +- ✓ Version changelog placement |
| 52 | +- ✓ Fixes: tag format |
| 53 | +- ✓ Cc: stable format |
| 54 | +- ✓ checkpatch.pl compliance |
| 55 | +- ✓ Patch applies cleanly |
| 56 | +- ✓ Single purpose patches |
| 57 | +- ✓ Commit message quality |
| 58 | +- ✓ Novice patterns detection |
| 59 | + |
| 60 | +### pre-send-checklist.sh |
| 61 | + |
| 62 | +Interactive checklist covering: |
| 63 | +- Basic sanity checks |
| 64 | +- Patch quality |
| 65 | +- Format requirements |
| 66 | +- Recipient validation |
| 67 | +- Timing considerations |
| 68 | +- Final preparations |
| 69 | + |
| 70 | +## Common Workflows |
| 71 | + |
| 72 | +### Single Patch |
| 73 | +```bash |
| 74 | +# 1. Create your patch |
| 75 | +git format-patch -1 |
| 76 | + |
| 77 | +# 2. Validate it |
| 78 | +./scripts/validate-patch.sh 0001-my-patch.patch |
| 79 | + |
| 80 | +# 3. Find maintainers |
| 81 | +./scripts/get_maintainer.pl 0001-my-patch.patch |
| 82 | + |
| 83 | +# 4. Run final checklist |
| 84 | +./scripts/pre-send-checklist.sh |
| 85 | + |
| 86 | +# 5. Send it |
| 87 | +git send-email --to="maintainer@example.com" 0001-my-patch.patch |
| 88 | +``` |
| 89 | + |
| 90 | +### Patch Series (v2) |
| 91 | +```bash |
| 92 | +# 1. Create series with cover letter |
| 93 | +git format-patch -3 --cover-letter -v2 |
| 94 | + |
| 95 | +# 2. Edit cover letter using template |
| 96 | +cp templates/cover-letter.template v2-0000-cover-letter.patch |
| 97 | +# Edit... |
| 98 | + |
| 99 | +# 3. Validate each patch |
| 100 | +for patch in v2-*.patch; do |
| 101 | + ./scripts/validate-patch.sh "$patch" |
| 102 | +done |
| 103 | + |
| 104 | +# 4. Send series |
| 105 | +git send-email --to="maintainer@example.com" v2-*.patch |
| 106 | +``` |
| 107 | + |
| 108 | +### Responding to Review |
| 109 | +```bash |
| 110 | +# Use the template |
| 111 | +cp templates/email-response.template response.txt |
| 112 | +# Edit response.txt with your replies |
| 113 | +# Send using your email client (keep plain text!) |
| 114 | +``` |
| 115 | + |
| 116 | +## Installation |
| 117 | + |
| 118 | +```bash |
| 119 | +# Clone the repository |
| 120 | +git clone https://github.com/ipenas-cl/kernel-patch-validator.git ~/kernel-patch-validator |
| 121 | + |
| 122 | +# Run the installer |
| 123 | +cd ~/kernel-patch-validator |
| 124 | +./INSTALL.sh |
| 125 | + |
| 126 | +# Restart your shell or source your bashrc |
| 127 | +source ~/.bashrc |
| 128 | +``` |
| 129 | + |
| 130 | +## Tips |
| 131 | + |
| 132 | +1. **Always validate before sending** - It takes 30 seconds and saves embarrassment |
| 133 | +2. **Use templates** - Don't write commit messages from scratch |
| 134 | +3. **Read the docs** - Especially KERNEL_ANTIPATTERNS.md |
| 135 | +4. **Be patient** - Wait 24h between versions, 1 week before pinging |
| 136 | +5. **Test everything** - "Compile tested only" = "I'm lazy" |
| 137 | + |
| 138 | +## The Golden Rules |
| 139 | + |
| 140 | +1. One logical change per patch |
| 141 | +2. Explain WHY, not WHAT |
| 142 | +3. Use git send-email (no attachments!) |
| 143 | +4. Run checkpatch.pl --strict |
| 144 | +5. Actually test your changes |
| 145 | +6. Check your system date isn't 2025 |
| 146 | +7. Put v2+ changelogs after --- |
| 147 | +8. Use get_maintainer.pl for recipients |
| 148 | +9. Wait patiently for reviews |
| 149 | +10. Thank reviewers, even harsh ones |
| 150 | + |
| 151 | +## Troubleshooting |
| 152 | + |
| 153 | +**"Patch contains future date (2025)"** |
| 154 | +- Fix your system date/time |
| 155 | +- Regenerate the patch |
| 156 | + |
| 157 | +**"checkpatch.pl failed"** |
| 158 | +- Read /tmp/checkpatch.out |
| 159 | +- Fix ALL warnings for staging drivers |
| 160 | +- Use --strict for best results |
| 161 | + |
| 162 | +**"Patch doesn't apply cleanly"** |
| 163 | +- Wrong base tree? |
| 164 | +- Rebase on latest upstream |
| 165 | +- Check git remote configuration |
| 166 | + |
| 167 | +## Contributing |
| 168 | + |
| 169 | +Found a bug or have a suggestion? Please contribute! |
| 170 | + |
| 171 | +1. Fork the repository |
| 172 | +2. Create a feature branch (`git checkout -b feature/amazing-feature`) |
| 173 | +3. Commit your changes (`git commit -m 'Add amazing feature'`) |
| 174 | +4. Push to the branch (`git push origin feature/amazing-feature`) |
| 175 | +5. Open a Pull Request |
| 176 | + |
| 177 | +This toolkit is meant to help everyone avoid novice mistakes. |
| 178 | + |
| 179 | +## Inspiration |
| 180 | + |
| 181 | +This validator was created after experiencing real patch rejections from Linux kernel maintainers including: |
| 182 | +- Dan Carpenter's feedback on patch quality |
| 183 | +- Greg KH's automated responses about patch format |
| 184 | +- Multiple v2, v3, v4+ iterations learning the process |
| 185 | + |
| 186 | +Every check in this validator represents a real mistake that was made and learned from. |
| 187 | + |
| 188 | +## License |
| 189 | + |
| 190 | +GPL-2.0 (same as Linux kernel) - see [LICENSE](LICENSE) file. |
| 191 | + |
| 192 | +## Acknowledgments |
| 193 | + |
| 194 | +- Linux kernel maintainers for their patience with novice contributors |
| 195 | +- The kernel documentation team for comprehensive guides |
| 196 | +- The staging tree maintainers for providing a learning environment |
| 197 | + |
| 198 | +--- |
| 199 | + |
| 200 | +Remember: It's better to be slow and correct than fast and wrong! |
0 commit comments