commit 659e58f
chld
·
2025-12-20 21:08:33 +0000 UTC
parent b73ff04
update
4 files changed,
+328,
-3
+310,
-0
1@@ -0,0 +1,310 @@
2+diff --git a/lib/Makefile b/lib/Makefile
3+index 30337431d10e..ca4853a86f86 100644
4+--- a/lib/Makefile
5++++ b/lib/Makefile
6+@@ -336,7 +336,7 @@ $(obj)/oid_registry_data.c: $(srctree)/include/linux/oid_registry.h \
7+ $(call cmd,build_OID_registry)
8+
9+ quiet_cmd_build_OID_registry = GEN $@
10+- cmd_build_OID_registry = perl $(src)/build_OID_registry $< $@
11++ cmd_build_OID_registry = $(CONFIG_SHELL) $(src)/build_OID_registry <$< >$@
12+
13+ clean-files += oid_registry_data.c
14+
15+diff --git a/lib/build_OID_registry b/lib/build_OID_registry
16+index 8267e8d71338..80aab4b069e9 100755
17+--- a/lib/build_OID_registry
18++++ b/lib/build_OID_registry
19+@@ -1,4 +1,4 @@
20+-#!/usr/bin/perl -w
21++#!/bin/sh
22+ # SPDX-License-Identifier: GPL-2.0-or-later
23+ #
24+ # Build a static ASN.1 Object Identified (OID) registry
25+@@ -7,202 +7,93 @@
26+ # Written by David Howells (dhowells@redhat.com)
27+ #
28+
29+-use strict;
30+-use Cwd qw(abs_path);
31+-
32+-my @names = ();
33+-my @oids = ();
34+-
35+-if ($#ARGV != 1) {
36+- print STDERR "Format: ", $0, " <in-h-file> <out-c-file>\n";
37+- exit(2);
38+-}
39+-
40+-my $abs_srctree = abs_path($ENV{'srctree'});
41+-
42+-#
43+-# Open the file to read from
44+-#
45+-open IN_FILE, "<$ARGV[0]" || die;
46+-while (<IN_FILE>) {
47+- chomp;
48+- if (m!\s+OID_([a-zA-z][a-zA-Z0-9_]+),\s+/[*]\s+([012][.0-9]*)\s+[*]/!) {
49+- push @names, $1;
50+- push @oids, $2;
51+- }
52+-}
53+-close IN_FILE || die;
54+-
55+ #
56+-# Open the files to write into
57++# Read OID lines and determine the lengths of the encoded data arrays.
58+ #
59+-open C_FILE, ">$ARGV[1]" or die;
60+-print C_FILE "/*\n";
61+-my $scriptname = $0;
62+-$scriptname =~ s#^\Q$abs_srctree/\E##;
63+-print C_FILE " * Automatically generated by ", $scriptname, ". Do not edit\n";
64+-print C_FILE " */\n";
65+-
66+-#
67+-# Split the data up into separate lists and also determine the lengths of the
68+-# encoded data arrays.
69+-#
70+-my @indices = ();
71+-my @lengths = ();
72+-my $total_length = 0;
73+-
74+-for (my $i = 0; $i <= $#names; $i++) {
75+- my $name = $names[$i];
76+- my $oid = $oids[$i];
77+-
78+- my @components = split(/[.]/, $oid);
79+-
80+- # Determine the encoded length of this OID
81+- my $size = $#components;
82+- for (my $loop = 2; $loop <= $#components; $loop++) {
83+- my $c = $components[$loop];
84+-
85+- # We will base128 encode the number
86+- my $tmp = ($c == 0) ? 0 : int(log($c)/log(2));
87+- $tmp = int($tmp / 7);
88+- $size += $tmp;
89+- }
90+- push @lengths, $size;
91+- push @indices, $total_length;
92+- $total_length += $size;
93+-}
94++set -f -- # use "$@" array for data
95++total_length=0 IFS='.'
96++while IFS=' ' read -r line; do
97++ if [ "${line#OID_[a-z]}" != "$line" ]; then
98++ name="${line#*_}" name="${name%,*}" oid="${line#*/* }" oid="${oid% */}"
99++ # shellcheck disable=SC2086
100++ size="$(set -- $oid; printf '%u' "$(($# - 1))")"
101++ for c in $oid; do
102++ # We will base128 encode the number
103++ : "$((size += c ? $(awk "BEGIN{print int(log($c)/log(2)/7)}") : 0))"
104++ done
105++ set -- "$@" "$name:$oid:$total_length"
106++ : "$((total_length += size))"
107++ fi
108++done
109+
110+ #
111+ # Emit the look-up-by-OID index table
112+ #
113+-print C_FILE "\n";
114+-if ($total_length <= 255) {
115+- print C_FILE "static const unsigned char oid_index[OID__NR + 1] = {\n";
116+-} else {
117+- print C_FILE "static const unsigned short oid_index[OID__NR + 1] = {\n";
118+-}
119+-for (my $i = 0; $i <= $#names; $i++) {
120+- print C_FILE "\t[OID_", $names[$i], "] = ", $indices[$i], ",\n"
121+-}
122+-print C_FILE "\t[OID__NR] = ", $total_length, "\n";
123+-print C_FILE "};\n";
124+-
125+-#
126+-# Encode the OIDs
127+-#
128+-my @encoded_oids = ();
129+-
130+-for (my $i = 0; $i <= $#names; $i++) {
131+- my @octets = ();
132+-
133+- my @components = split(/[.]/, $oids[$i]);
134+-
135+- push @octets, $components[0] * 40 + $components[1];
136+-
137+- for (my $loop = 2; $loop <= $#components; $loop++) {
138+- my $c = $components[$loop];
139+-
140+- # Base128 encode the number
141+- my $tmp = ($c == 0) ? 0 : int(log($c)/log(2));
142+- $tmp = int($tmp / 7);
143+-
144+- for (; $tmp > 0; $tmp--) {
145+- push @octets, (($c >> $tmp * 7) & 0x7f) | 0x80;
146+- }
147+- push @octets, $c & 0x7f;
148+- }
149+-
150+- push @encoded_oids, \@octets;
151+-}
152+-
153+-#
154+-# Create a hash value for each OID
155+-#
156+-my @hash_values = ();
157+-for (my $i = 0; $i <= $#names; $i++) {
158+- my @octets = @{$encoded_oids[$i]};
159+-
160+- my $hash = $#octets;
161+- foreach (@octets) {
162+- $hash += $_ * 33;
163+- }
164+-
165+- $hash = ($hash >> 24) ^ ($hash >> 16) ^ ($hash >> 8) ^ ($hash);
166+-
167+- push @hash_values, $hash & 0xff;
168+-}
169+-
170+-#
171+-# Emit the OID data
172+-#
173+-print C_FILE "\n";
174+-print C_FILE "static const unsigned char oid_data[", $total_length, "] = {\n";
175+-for (my $i = 0; $i <= $#names; $i++) {
176+- my @octets = @{$encoded_oids[$i]};
177+- print C_FILE "\t";
178+- print C_FILE $_, ", " foreach (@octets);
179+- print C_FILE "\t// ", $names[$i];
180+- print C_FILE "\n";
181+-}
182+-print C_FILE "};\n";
183+-
184+-#
185+-# Build the search index table (ordered by length then hash then content)
186+-#
187+-my @index_table = ( 0 .. $#names );
188+-
189+-@index_table = sort {
190+- my @octets_a = @{$encoded_oids[$a]};
191+- my @octets_b = @{$encoded_oids[$b]};
192+-
193+- return $hash_values[$a] <=> $hash_values[$b]
194+- if ($hash_values[$a] != $hash_values[$b]);
195+- return $#octets_a <=> $#octets_b
196+- if ($#octets_a != $#octets_b);
197+- for (my $i = $#octets_a; $i >= 0; $i--) {
198+- return $octets_a[$i] <=> $octets_b[$i]
199+- if ($octets_a[$i] != $octets_b[$i]);
200+- }
201+- return 0;
202+-
203+-} @index_table;
204+-
205+-#
206+-# Emit the search index and hash value table
207+-#
208+-print C_FILE "\n";
209+-print C_FILE "static const struct {\n";
210+-print C_FILE "\tunsigned char hash;\n";
211+-if ($#names <= 255) {
212+- print C_FILE "\tenum OID oid : 8;\n";
213+-} else {
214+- print C_FILE "\tenum OID oid : 16;\n";
215+-}
216+-print C_FILE "} oid_search_table[OID__NR] = {\n";
217+-for (my $i = 0; $i <= $#names; $i++) {
218+- my @octets = @{$encoded_oids[$index_table[$i]]};
219+- printf(C_FILE "\t[%3u] = { %3u, OID_%-35s }, // ",
220+- $i,
221+- $hash_values[$index_table[$i]],
222+- $names[$index_table[$i]]);
223+- printf C_FILE "%02x", $_ foreach (@octets);
224+- print C_FILE "\n";
225+-}
226+-print C_FILE "};\n";
227+-
228+-#
229+-# Emit the OID debugging name table
230+-#
231+-#print C_FILE "\n";
232+-#print C_FILE "const char *const oid_name_table[OID__NR + 1] = {\n";
233+-#
234+-#for (my $i = 0; $i <= $#names; $i++) {
235+-# print C_FILE "\t\"", $names[$i], "\",\n"
236+-#}
237+-#print C_FILE "\t\"Unknown-OID\"\n";
238+-#print C_FILE "};\n";
239+-
240+-#
241+-# Polish off
242+-#
243+-close C_FILE or die;
244++printf '/*\n * Automatically generated by %s. Do not edit\n */\n\n' "$0"
245++if [ "$total_length" -le 255 ]; then
246++ printf 'static const unsigned char oid_index[OID__NR + 1] = {\n'
247++else
248++ printf 'static const unsigned short oid_index[OID__NR + 1] = {\n'
249++fi
250++for i do
251++ printf '\t[OID_%s] = %u,\n' "${i%%:*}" "${i##*:}"
252++done
253++printf '\t[OID__NR] = %u\n};\n\n' "$total_length"
254++
255++#
256++# Encode the OIDs and emit the OID data
257++#
258++printf 'static const unsigned char oid_data[%u] = {\n' "$total_length"
259++for i do
260++ IFS='.' j=0 i="${i%:*}"
261++ for c in ${i##*:}; do
262++ case "$((j += 1))" in
263++ 1) o="$((c * 40))";;
264++ 2) : "$((o += c))";;
265++ *)
266++ # Base128 encode the number
267++ tmp="$((c ? $(awk "BEGIN{print int(log($c)/log(2)/7)+1}") : 1))"
268++ while [ "$((tmp -= 1))" -gt 0 ]; do
269++ o="$o.$((c >> tmp * 7 & 127 | 128))"
270++ done
271++ o="$o.$((c & 127))"
272++ esac
273++ done
274++
275++ set -- "$@" "${i%:*}:$o"
276++ shift
277++
278++ printf '\t'
279++ printf '%s, ' $o
280++ printf '\t// %s\n' "${i%:*}"
281++done
282++printf '};\n\n'
283++
284++printf 'static const struct {\n\tunsigned char hash;\n'
285++printf '\tenum OID oid : %u;\n} oid_search_table[OID__NR] = {' \
286++ "$(($# <= 255 ? 8 : 16))"
287++
288++#
289++# Create a hash value for each OID and build and emit the search index and hash
290++# value table (ordered by length then hash then content)
291++#
292++i=-1
293++for j do
294++ IFS='.'
295++ # shellcheck disable=SC2086
296++ count="$(set -- ${j##*:}; printf '%u' "$(($# - 1))")"
297++ hash="$count"
298++ set -- # use as array for reversing octet set
299++ for k in ${j##*:}; do
300++ : "$((hash += k * 33))"
301++ set -- "$k" "$@"
302++ done
303++ hash="$((hash >> 24 ^ hash >> 16 ^ hash >> 8 ^ hash & 255))"
304++ IFS=':'
305++ printf '%u:%s:%s:%u:%s\n' "$hash" "${j##*:}" "${j%%:*}" "$count" "$*"
306++done | sort -nt: -k1,1 -k4,4 -k5 | while IFS=':' read -r num octets name _; do
307++ printf '\n\t[%3u] = { %3u, OID_%-35s }, // ' "$((i += 1))" "$num" "$name"
308++ # shellcheck disable=SC2086
309++ printf '%02x' $octets
310++done
311++printf '\n};\n'
+5,
-0
1@@ -9,3 +9,8 @@ sh ./util/kiss-mount $m .
2 sh ./setup-rootfs
3 sh ./setup-apk
4 sh ./setup-userland
5+
6+# unmount /mnt as it finished
7+sh ./util/kiss-mount $m .
8+
9+echo && echo "mwakat linux is ready."
+0,
-1
1@@ -4,5 +4,4 @@
2
3 echo "WARNING: $0 assumes you have already run setup-distro!"
4 # unmount $m so nothing is messed up during tar
5-sh ./util/kiss-mount $m .
6 tar -cvJf mwakat-rootfs.tar.xz $m/*
+13,
-2
1@@ -28,6 +28,17 @@ _inc '
2 # fix tools
3 _inc '
4 apk fix musl
5- apk add openssl
6- apk del openssl
7+ apk add musl-dev
8+ apk del musl-dev
9+ apk add openssl openssl-dev
10+ apk del openssl openssl-dev
11 '
12+
13+# further remove traces of KISS
14+rm -rf /mnt/root/.cache
15+rm -rf /mnt/usr/share/doc
16+
17+# copy KISS no-perl.patch for the linux kernel
18+mkdir -p /mnt/usr
19+mkdir /mnt/usr/src
20+cp ./rootfs/no-perl.patch /mnt/usr/src/no-perl.patch