Skip to content

Commit 2c8b6d8

Browse files
authored
Merge pull request #38 from nyrahul/lk-tags
Summary View of distributions
2 parents b845e16 + b6f7434 commit 2c8b6d8

File tree

6 files changed

+205
-98
lines changed

6 files changed

+205
-98
lines changed

README.md

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,42 @@
11
<!-- THIS IS AN AUTO-GENERATED FILE by ./tools/gendoc.sh. DO NOT EDIT MANUALLY -->
22
# Linux Kernel Configs for Popular Distros
33
![CI status](https://github.com/nyrahul/linux-kernel-configs/actions/workflows/ci-verify.yml/badge.svg)
4+
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/nyrahul/linux-kernel-configs?tab=readme-ov-file#contributions-welcome)
45

56
There is often a need to check a kernel config and other OS configuration to make a dev/design decision. The question often pops-up, does the popular distributions support the kernel config that the implementation expects? This is an attempt to answer that.
67

78
**My specific use-case**:
8-
[KubeArmor](https://github.com/kubearmor/kubearmor) leverages LSMs (Linux Security Modules) and eBPF for in-kernel policy controls. We had to refer to kernel configs for making design/dev decisions regarding whether we can depend on a certain kernel primitive. The boot configs part of this repo helped in making an informed choice.
9+
[KubeArmor](https://kubearmor.io/) leverages LSMs (Linux Security Modules) and eBPF for in-kernel policy controls. We had to refer to kernel configs for making design/dev decisions regarding whether we can depend on a certain kernel primitive. The boot configs part of this repo helped in making an informed choice.
910

1011
> Note: The lists below are sorted based on kernel version number.
1112
13+
14+
## Distribution Summary
15+
16+
Total Distros: 65
17+
18+
<table>
19+
<tr><th> Kernel Major </th><th>Kernel Arch</th></tr>
20+
<tr><td>
21+
22+
| Kernel Major Ver | Count |
23+
|:----------------:|:-------:|
24+
| >= 6.0 |17|
25+
| >= 5.0 && < 6.0 |28|
26+
| >= 4.0 && < 5.0: |17|
27+
| < 4.0 |3|
28+
29+
</td><td>
30+
31+
| Kernel Arch | Count |
32+
|:-----------:|:-------:|
33+
| x86 |60|
34+
| arm |4|
35+
| powerpc |1|
36+
| unknown |0|
37+
38+
</td></tr></table>
39+
1240
<details><summary><h2>Distribution Details</h2></summary><p>
1341

1442
| Distro | Arch | Kernel | Kernel Config | hostnamectl | os-release |
@@ -663,17 +691,18 @@ There is often a need to check a kernel config and other OS configuration to mak
663691
<details>
664692
<summary>Adding a new distro</summary>
665693

666-
Use following command to create a Distro/Kernel specific folder with the corresponding markdowns:
694+
ssh/login to the target Linux machine and run:
667695
```
668-
curl -s https://raw.githubusercontent.com/nyrahul/linux-kernel-configs/main/lk-config-get.sh | bash -s
696+
curl -s https://lkc.rjed.in/ | bash -s
669697
```
670698
if `curl` is not available, use `wget` ...
671699
```
672-
wget -q -O- https://raw.githubusercontent.com/nyrahul/linux-kernel-configs/main/lk-config-get.sh | bash -s
700+
wget -q -O- https://lkc.rjed.in/ | bash -s
673701
```
702+
This will create a folder with the name of the distro.
674703

675-
1. Copy the folder to your github fork
676-
2. Run `make`
704+
1. Copy the folder to your `linux-kernel-configs` git repo.
705+
2. Run `make`. This will update the `README.md` file with the distro you added.
677706
3. Raise a PR
678707

679708
</details>
@@ -687,7 +716,7 @@ Composition means a set of kernel configuration options shown in the context of
687716
To create a new composition:
688717
1. Create a new composition file. Use [tools/compositions/lsm.yaml](tools/compositions/lsm.yaml) as ref.
689718
2. Do a `make`
690-
3. Check if the composition is reflected in the [README.md](README.md)
719+
3. Check if the composition is reflected in the [README.md](README.md).
691720
4. Raise a PR with the changes
692721

693722
</details>

tools/common.sh

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
#!/usr/bin/env bash
2+
3+
YQ=`dirname $0`/yq # Use yq.exe on windows
4+
TMP_OSREL=temporary_osrel.txt
5+
TMP_HOSTCTL=temporary_hostnamectl.txt
6+
TMP_BOOTCFG=temporary_bootconfig.txt
7+
8+
statusline()
9+
{
10+
ORANGE="\033[0;33m"
11+
RED="\033[0;31m"
12+
GREEN="\033[0;32m"
13+
CYAN="\033[0;36m"
14+
NC="\033[0m" # No Color
15+
16+
status=$1
17+
shift
18+
[[ $status == AOK ]] || [[ $status == "0" ]] &&
19+
{
20+
printf "[${GREEN}OK${NC}] $*\n"
21+
return
22+
}
23+
[[ $status == WARN ]] &&
24+
{
25+
printf "[${ORANGE}WARN${NC}] $*\n"
26+
return
27+
}
28+
[[ $status == WAIT ]] &&
29+
{
30+
printf "[${CYAN}..${NC}] $*\r"
31+
return
32+
}
33+
printf "[${RED}FAIL${NC}] $*\n"
34+
exit 1
35+
}
36+
37+
getDistro()
38+
{
39+
if [ -f "$TMP_OSREL" ]; then
40+
. $TMP_OSREL
41+
DISTRO_NAME=$PRETTY_NAME
42+
return
43+
fi
44+
DISTRO_NAME=`grep "Operating System:" $TMP_HOSTCTL | sed 's/.*: //g'`
45+
}
46+
47+
getArchKrnVer()
48+
{
49+
STR=`grep "^#.* Linux.*Kernel Configuration" $TMP_BOOTCFG | head -1 | awk '{print $2,$3}'`
50+
ARCH=${STR/ */}
51+
ARCH=${ARCH/*\//}
52+
KRNVER=${STR/* /}
53+
# KRNVER=${KRNVER/-*/}
54+
}
55+
56+
forEveryPlatform()
57+
{
58+
[[ "$1" == "" ]] && statusline ERR "invalid use of forEveryPlatform"
59+
while read line; do
60+
rm -f $TMP_OSREL $TMP_HOSTCTL $TMP_BOOTCFG
61+
line=`echo $line | sed 's/|/\//g'`
62+
PLATFORM="$line"
63+
PLATFORM_PATH="${line// /%20}"
64+
BOOTCONFIG="$line/bootconfig.md"
65+
[[ ! -f "$BOOTCONFIG" ]] && continue
66+
awk '/\`\`\`/,/\`\`\`/' "$BOOTCONFIG" | grep -v "\`\`\`" > $TMP_BOOTCFG
67+
68+
HOSTNAMECTL="$line/hostnamectl.md"
69+
[[ -f "$HOSTNAMECTL" ]] && awk '/\`\`\`/,/\`\`\`/' "$HOSTNAMECTL" | grep -v "\`\`\`" > $TMP_HOSTCTL
70+
OSREL="$line/os-release.md"
71+
[[ -f "$OSREL" ]] && awk '/\`\`\`/,/\`\`\`/' "$OSREL" | grep -v "\`\`\`" > $TMP_OSREL
72+
[[ ! -f "$TMP_OSREL" ]] && [[ ! -f "$TMP_HOSTCTL" ]] &&
73+
statusline WARN "neither os-release nor hostnamectl found for [$PLATFORM]" && continue
74+
75+
getDistro
76+
getArchKrnVer
77+
$1
78+
done < <(find . -mindepth 2 -maxdepth 2 -type d | \grep ".*/.*/[0-9]\..*" | sed 's/\//|/g' | sort -k3 -t'|' -Vr)
79+
#done < <(find . -mindepth 2 -maxdepth 2 -type d | sort)
80+
}
81+
82+
cleanup()
83+
{
84+
rm -f $TMP_OSREL $TMP_HOSTCTL $TMP_BOOTCFG
85+
statusline AOK "done with processing"
86+
}
87+
88+
export LC_ALL=en_US.UTF-8

tools/footer.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,18 @@
44
<details>
55
<summary>Adding a new distro</summary>
66

7-
Use following command to create a Distro/Kernel specific folder with the corresponding markdowns:
7+
ssh/login to the target Linux machine and run:
88
```
9-
curl -s https://raw.githubusercontent.com/nyrahul/linux-kernel-configs/main/lk-config-get.sh | bash -s
9+
curl -s https://lkc.rjed.in/ | bash -s
1010
```
1111
if `curl` is not available, use `wget` ...
1212
```
13-
wget -q -O- https://raw.githubusercontent.com/nyrahul/linux-kernel-configs/main/lk-config-get.sh | bash -s
13+
wget -q -O- https://lkc.rjed.in/ | bash -s
1414
```
15+
This will create a folder with the name of the distro.
1516

16-
1. Copy the folder to your github fork
17-
2. Run `make`
17+
1. Copy the folder to your `linux-kernel-configs` git repo.
18+
2. Run `make`. This will update the `README.md` file with the distro you added.
1819
3. Raise a PR
1920

2021
</details>
@@ -28,7 +29,7 @@ Composition means a set of kernel configuration options shown in the context of
2829
To create a new composition:
2930
1. Create a new composition file. Use [tools/compositions/lsm.yaml](tools/compositions/lsm.yaml) as ref.
3031
2. Do a `make`
31-
3. Check if the composition is reflected in the [README.md](README.md)
32+
3. Check if the composition is reflected in the [README.md](README.md).
3233
4. Raise a PR with the changes
3334

3435
</details>

tools/gendoc.sh

Lines changed: 3 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,11 @@
11
#!/usr/bin/env bash
22

3-
YQ=`dirname $0`/yq # Use yq.exe on windows
43
HDR_MD=`dirname $0`/header.md
54
FTR_MD=`dirname $0`/footer.md
65
YAMLS="$*"
7-
TMP_OSREL=temporary_osrel.txt
8-
TMP_HOSTCTL=temporary_hostnamectl.txt
9-
TMP_BOOTCFG=temporary_bootconfig.txt
106
MD="README.md"
117

12-
statusline()
13-
{
14-
ORANGE="\033[0;33m"
15-
RED="\033[0;31m"
16-
GREEN="\033[0;32m"
17-
CYAN="\033[0;36m"
18-
NC="\033[0m" # No Color
19-
20-
status=$1
21-
shift
22-
[[ $status == AOK ]] || [[ $status == "0" ]] &&
23-
{
24-
printf "[${GREEN}OK${NC}] $*\n"
25-
return
26-
}
27-
[[ $status == WARN ]] &&
28-
{
29-
printf "[${ORANGE}WARN${NC}] $*\n"
30-
return
31-
}
32-
[[ $status == WAIT ]] &&
33-
{
34-
printf "[${CYAN}..${NC}] $*\r"
35-
return
36-
}
37-
printf "[${RED}FAIL${NC}] $*\n"
38-
exit 1
39-
}
8+
. `dirname $0`/common.sh
409

4110
prerequisites()
4211
{
@@ -97,25 +66,6 @@ forEveryComposition()
9766
echo "$colstr" >> "$MD"
9867
}
9968

100-
getDistro()
101-
{
102-
if [ -f "$TMP_OSREL" ]; then
103-
. $TMP_OSREL
104-
DISTRO_NAME=$PRETTY_NAME
105-
return
106-
fi
107-
DISTRO_NAME=`grep "Operating System:" $TMP_HOSTCTL | sed 's/.*: //g'`
108-
}
109-
110-
getArchKrnVer()
111-
{
112-
STR=`grep "^#.* Linux.*Kernel Configuration" $TMP_BOOTCFG | head -1 | awk '{print $2,$3}'`
113-
ARCH=${STR/ */}
114-
ARCH=${ARCH/*\//}
115-
KRNVER=${STR/* /}
116-
# KRNVER=${KRNVER/-*/}
117-
}
118-
11969
addCommonEntry()
12070
{
12171
hoststr="NotAvailable"
@@ -127,32 +77,6 @@ addCommonEntry()
12777
EOF
12878
}
12979

130-
forEveryPlatform()
131-
{
132-
[[ "$1" == "" ]] && statusline ERR "invalid use of forEveryPlatform"
133-
while read line; do
134-
rm -f $TMP_OSREL $TMP_HOSTCTL $TMP_BOOTCFG
135-
line=`echo $line | sed 's/|/\//g'`
136-
PLATFORM="$line"
137-
PLATFORM_PATH="${line// /%20}"
138-
BOOTCONFIG="$line/bootconfig.md"
139-
[[ ! -f "$BOOTCONFIG" ]] && continue
140-
awk '/\`\`\`/,/\`\`\`/' "$BOOTCONFIG" | grep -v "\`\`\`" > $TMP_BOOTCFG
141-
142-
HOSTNAMECTL="$line/hostnamectl.md"
143-
[[ -f "$HOSTNAMECTL" ]] && awk '/\`\`\`/,/\`\`\`/' "$HOSTNAMECTL" | grep -v "\`\`\`" > $TMP_HOSTCTL
144-
OSREL="$line/os-release.md"
145-
[[ -f "$OSREL" ]] && awk '/\`\`\`/,/\`\`\`/' "$OSREL" | grep -v "\`\`\`" > $TMP_OSREL
146-
[[ ! -f "$TMP_OSREL" ]] && [[ ! -f "$TMP_HOSTCTL" ]] &&
147-
statusline WARN "neither os-release nor hostnamectl found for [$PLATFORM]" && continue
148-
149-
getDistro
150-
getArchKrnVer
151-
$1
152-
done < <(find . -mindepth 2 -maxdepth 2 -type d | \grep ".*/.*/[0-9]\..*" | sed 's/\//|/g' | sort -k3 -t'|' -Vr)
153-
#done < <(find . -mindepth 2 -maxdepth 2 -type d | sort)
154-
}
155-
15680
forEveryConfig()
15781
{
15882
for YAML in `echo $YAMLS`; do
@@ -182,12 +106,6 @@ EOF
182106
done
183107
}
184108

185-
cleanup()
186-
{
187-
rm -f $TMP_OSREL $TMP_HOSTCTL $TMP_BOOTCFG
188-
statusline AOK "done with processing"
189-
}
190-
191109
main()
192110
{
193111
trap cleanup EXIT
@@ -197,6 +115,8 @@ main()
197115
<!-- THIS IS AN AUTO-GENERATED FILE by $0. DO NOT EDIT MANUALLY -->
198116
`cat $HDR_MD`
199117
118+
`tools/summary.sh`
119+
200120
<details><summary><h2>Distribution Details</h2></summary><p>
201121
202122
| Distro | Arch | Kernel | Kernel Config | hostnamectl | os-release |
@@ -217,5 +137,4 @@ EOF
217137
EOF
218138
}
219139

220-
export LC_ALL=en_US.UTF-8
221140
main

tools/header.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# Linux Kernel Configs for Popular Distros
22
![CI status](https://github.com/nyrahul/linux-kernel-configs/actions/workflows/ci-verify.yml/badge.svg)
3+
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/nyrahul/linux-kernel-configs?tab=readme-ov-file#contributions-welcome)
34

45
There is often a need to check a kernel config and other OS configuration to make a dev/design decision. The question often pops-up, does the popular distributions support the kernel config that the implementation expects? This is an attempt to answer that.
56

67
**My specific use-case**:
7-
[KubeArmor](https://github.com/kubearmor/kubearmor) leverages LSMs (Linux Security Modules) and eBPF for in-kernel policy controls. We had to refer to kernel configs for making design/dev decisions regarding whether we can depend on a certain kernel primitive. The boot configs part of this repo helped in making an informed choice.
8+
[KubeArmor](https://kubearmor.io/) leverages LSMs (Linux Security Modules) and eBPF for in-kernel policy controls. We had to refer to kernel configs for making design/dev decisions regarding whether we can depend on a certain kernel primitive. The boot configs part of this repo helped in making an informed choice.
89

910
> Note: The lists below are sorted based on kernel version number.

0 commit comments

Comments
 (0)