Skip to content

Commit 29dea54

Browse files
committed
Initial release of kernel patch validator v1.0.0
This validator helps avoid common mistakes that mark contributors as novices. Created after real experience with patch rejections and maintainer feedback. Features: - Automated patch validation (12+ checks) - Quick sanity checks for common errors - Interactive pre-send checklist - Complete documentation and guides - Templates for commits and emails - Git integration and aliases - GitHub Actions support Every check represents a real mistake that was made and learned from. Signed-off-by: Ignacio Pena <ignacio.pena87@gmail.com>
0 parents  commit 29dea54

16 files changed

+1855
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Validate Kernel Patches
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '**.patch'
7+
push:
8+
paths:
9+
- '**.patch'
10+
11+
jobs:
12+
validate:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v3
17+
18+
- name: Set up kernel repository
19+
run: |
20+
git clone --depth=1 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git kernel
21+
22+
- name: Find and validate patches
23+
run: |
24+
echo "=== Finding patch files ==="
25+
find . -name "*.patch" -type f | while read patch; do
26+
echo ""
27+
echo "Validating: $patch"
28+
./scripts/validate-patch.sh "$patch" "$PWD/kernel" || true
29+
done
30+
31+
- name: Summary
32+
if: always()
33+
run: |
34+
echo ""
35+
echo "=== Validation Complete ==="
36+
echo "Check the output above for any errors or warnings."
37+
echo "RED errors must be fixed before sending!"
38+
echo "YELLOW warnings should be considered."

.gitignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Ignore common patch files
2+
*.patch
3+
*.orig
4+
*.rej
5+
6+
# Ignore temporary files
7+
/tmp/
8+
*.tmp
9+
*.log
10+
*.out
11+
*.err
12+
13+
# Ignore OS files
14+
.DS_Store
15+
Thumbs.db
16+
17+
# Ignore IDE files
18+
.vscode/
19+
.idea/
20+
*.swp
21+
*.swo
22+
23+
# Ignore backup files
24+
*~
25+
*.bak

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Changelog
2+
3+
## [1.0.0] - 2024-07-16
4+
5+
### Added
6+
- Initial release of kernel patch validator
7+
- Full patch validation with 12+ checks
8+
- Quick sanity check for common errors
9+
- Interactive pre-send checklist
10+
- Complete documentation guides
11+
- Email response templates
12+
- Git aliases and configuration
13+
- GitHub Actions integration
14+
- Automatic installer script
15+
16+
### Features
17+
- Detects future date bugs (2025)
18+
- Validates Signed-off-by lines
19+
- Checks subject line format
20+
- Verifies changelog placement for v2+ patches
21+
- Validates Fixes: tag format
22+
- Checks Cc: stable format
23+
- Runs checkpatch.pl integration
24+
- Tests patch applies cleanly
25+
- Detects mixed changes (single purpose rule)
26+
- Analyzes commit message quality
27+
- Identifies novice patterns
28+
- Suggests proper maintainers
29+
30+
### Documentation
31+
- Complete contribution guide
32+
- Anti-patterns reference
33+
- Quick reference card
34+
- Installation instructions
35+
- Templates for commits and emails
36+
37+
### Templates
38+
- Perfect commit message format
39+
- Professional email responses
40+
- Cover letter structure
41+
42+
This validator was created after experiencing multiple patch rejections
43+
and learning from maintainer feedback. It embodies the lessons learned
44+
from real kernel development experience.

INSTALL.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
# Quick installer for kernel patch validator
3+
4+
echo "Installing Kernel Patch Validator..."
5+
6+
# Add to PATH
7+
if ! grep -q "kernel-patch-validator/scripts" ~/.bashrc; then
8+
echo 'export PATH="$HOME/kernel-patch-validator/scripts:$PATH"' >> ~/.bashrc
9+
echo "✓ Added to PATH"
10+
fi
11+
12+
# Add git aliases
13+
if ! grep -q "gitconfig.kernel" ~/.gitconfig; then
14+
echo "[include]" >> ~/.gitconfig
15+
echo " path = ~/.gitconfig.kernel" >> ~/.gitconfig
16+
cp ~/.gitconfig.kernel.bak ~/.gitconfig.kernel 2>/dev/null || true
17+
echo "✓ Added git aliases"
18+
fi
19+
20+
# Create symlinks for easy access
21+
ln -sf ~/kernel-patch-validator/scripts/validate-patch.sh ~/bin/kvalidate 2>/dev/null || true
22+
ln -sf ~/kernel-patch-validator/scripts/quick-check.sh ~/bin/kcheck 2>/dev/null || true
23+
ln -sf ~/kernel-patch-validator/scripts/pre-send-checklist.sh ~/bin/kchecklist 2>/dev/null || true
24+
25+
echo ""
26+
echo "Installation complete!"
27+
echo ""
28+
echo "Available commands:"
29+
echo " kvalidate <patch> - Full validation"
30+
echo " kcheck <patch> - Quick sanity check"
31+
echo " kchecklist - Interactive pre-send checklist"
32+
echo ""
33+
echo "Git aliases added:"
34+
echo " git validate <patch> - Run validator"
35+
echo " git precheck <patch> - Quick check"
36+
echo " git fp - Format patch"
37+
echo " git se - Send email"
38+
echo ""
39+
echo "Restart your shell or run: source ~/.bashrc"

LICENSE

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
GPL-2.0 License
2+
3+
Copyright (C) 2024 Ignacio Peña
4+
5+
This program is free software; you can redistribute it and/or modify
6+
it under the terms of the GNU General Public License as published by
7+
the Free Software Foundation; either version 2 of the License, or
8+
(at your option) any later version.
9+
10+
This program is distributed in the hope that it will be useful,
11+
but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
GNU General Public License for more details.
14+
15+
You should have received a copy of the GNU General Public License along
16+
with this program; if not, write to the Free Software Foundation, Inc.,
17+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

README.md

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
# Kernel Patch Validator
2+
3+
[![License: GPL v2](https://img.shields.io/badge/License-GPL%20v2-blue.svg)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
4+
[![GitHub Issues](https://img.shields.io/github/issues/ipenas-cl/kernel-patch-validator)](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

Comments
 (0)