Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
linux/scripts/diffconfig at master · sigma-random/linux · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
sigma-random
linux
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
More
items
Files
Expand file tree
master
Breadcrumbs
linux
/
scripts
/
diffconfig
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
executable file
·
129 lines (108 loc) · 3.56 KB
master
Breadcrumbs
linux
/
scripts
/
diffconfig
Copy path
Top
File metadata and controls
Code
Blame
executable file
·
129 lines (108 loc) · 3.56 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/python
#
# diffconfig - a tool to compare .config files.
#
# originally written in 2006 by Matt Mackall
# (at least, this was in his bloatwatch source code)
# last worked on 2008 by Tim Bird
#
import
sys
,
os
def
usage
():
print
"""Usage: diffconfig [-h] [-m] [<config1> <config2>]
Diffconfig is a simple utility for comparing two .config files.
Using standard diff to compare .config files often includes extraneous and
distracting information. This utility produces sorted output with only the
changes in configuration values between the two files.
Added and removed items are shown with a leading plus or minus, respectively.
Changed items show the old and new values on a single line.
If -m is specified, then output will be in "merge" style, which has the
changed and new values in kernel config option format.
If no config files are specified, .config and .config.old are used.
Example usage:
$ diffconfig .config config-with-some-changes
-EXT2_FS_XATTR n
-EXT2_FS_XIP n
CRAMFS n -> y
EXT2_FS y -> n
LOG_BUF_SHIFT 14 -> 16
PRINTK_TIME n -> y
"""
sys
.
exit
(
0
)
# returns a dictionary of name/value pairs for config items in the file
def
readconfig
(
config_file
):
d
=
{}
for
line
in
config_file
:
line
=
line
[:
-
1
]
if
line
[:
7
]
==
"CONFIG_"
:
name
,
val
=
line
[
7
:].
split
(
"="
,
1
)
d
[
name
]
=
val
if
line
[
-
11
:]
==
" is not set"
:
d
[
line
[
9
:
-
11
]]
=
"n"
return
d
def
print_config
(
op
,
config
,
value
,
new_value
):
global
merge_style
if
merge_style
:
if
new_value
:
if
new_value
==
"n"
:
print
"# CONFIG_%s is not set"
%
config
else
:
print
"CONFIG_%s=%s"
%
(
config
,
new_value
)
else
:
if
op
==
"-"
:
print
"-%s %s"
%
(
config
,
value
)
elif
op
==
"+"
:
print
"+%s %s"
%
(
config
,
new_value
)
else
:
print
" %s %s -> %s"
%
(
config
,
value
,
new_value
)
def
main
():
global
merge_style
# parse command line args
if
(
"-h"
in
sys
.
argv
or
"--help"
in
sys
.
argv
):
usage
()
merge_style
=
0
if
"-m"
in
sys
.
argv
:
merge_style
=
1
sys
.
argv
.
remove
(
"-m"
)
argc
=
len
(
sys
.
argv
)
if
not
(
argc
==
1
or
argc
==
3
):
print
"Error: incorrect number of arguments or unrecognized option"
usage
()
if
argc
==
1
:
# if no filenames given, assume .config and .config.old
build_dir
=
""
if
os
.
environ
.
has_key
(
"KBUILD_OUTPUT"
):
build_dir
=
os
.
environ
[
"KBUILD_OUTPUT"
]
+
"/"
configa_filename
=
build_dir
+
".config.old"
configb_filename
=
build_dir
+
".config"
else
:
configa_filename
=
sys
.
argv
[
1
]
configb_filename
=
sys
.
argv
[
2
]
a
=
readconfig
(
file
(
configa_filename
))
b
=
readconfig
(
file
(
configb_filename
))
# print items in a but not b (accumulate, sort and print)
old
=
[]
for
config
in
a
:
if
config
not
in
b
:
old
.
append
(
config
)
old
.
sort
()
for
config
in
old
:
print_config
(
"-"
,
config
,
a
[
config
],
None
)
del
a
[
config
]
# print items that changed (accumulate, sort, and print)
changed
=
[]
for
config
in
a
:
if
a
[
config
]
!=
b
[
config
]:
changed
.
append
(
config
)
else
:
del
b
[
config
]
changed
.
sort
()
for
config
in
changed
:
print_config
(
"->"
,
config
,
a
[
config
],
b
[
config
])
del
b
[
config
]
# now print items in b but not in a
# (items from b that were in a were removed above)
new
=
b
.
keys
()
new
.
sort
()
for
config
in
new
:
print_config
(
"+"
,
config
,
None
,
b
[
config
])
main
()
You can’t perform that action at this time.