Gentoo Archives: gentoo-commits

From: Thomas Deutschmann <whissi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/genkernel:master commit in: /, doc/
Date: Mon, 29 Jul 2019 20:10:33
Message-Id: 1564430427.94d32a155ef3e5cd59f852a032e5887b74306d81.whissi@gentoo
1 commit: 94d32a155ef3e5cd59f852a032e5887b74306d81
2 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jul 28 22:06:33 2019 +0000
4 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org>
5 CommitDate: Mon Jul 29 20:00:27 2019 +0000
6 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=94d32a15
7
8 Add --kernel-append-localversion option
9
10 Now that we moved $ARCH value to kernel's LOCALVERSION setting,
11 you cannot easily change LOCALVERSION anymore without losing
12 $ARCH information.
13
14 This can be annoying when you just want to build a new revision
15 which should have its own kernel binary, initramfs and modules
16 directory because you would have to remember to include default
17 value.
18
19 The new option will allow you to just append to genkernel's
20 KERNEL_LOCALVERSION value. This way you can just call genkernel
21 with --kernel-append-localversion=-rN option to build and test
22 a new revision.
23
24 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org>
25
26 doc/genkernel.8.txt | 6 +++++
27 gen_cmdline.sh | 6 +++++
28 gen_determineargs.sh | 63 ++++++++++++++++++++++++++++++++++------------------
29 3 files changed, 53 insertions(+), 22 deletions(-)
30
31 diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt
32 index 35762a2..1b36729 100644
33 --- a/doc/genkernel.8.txt
34 +++ b/doc/genkernel.8.txt
35 @@ -124,6 +124,12 @@ KERNEL CONFIGURATION
36 *--*[*no-*]*virtio*::
37 Adds, or skip adding VirtIO support to kernel configuration.
38
39 +*--kernel-append-localversion*=<...>::
40 + Appends value to genkernel's *KERNEL_LOCALVERSION* option (see below).
41 + The idea is to use this option to allow to easily build a new revision
42 + with own kernel binary, initramfs and modules directory without losing
43 + default *KERNEL_LOCALVERSION* value.
44 +
45 *--kernel-localversion*=<...>::
46 Set kernel option *LOCALVERSION*. Use special value *UNSET* to
47 unset any already set *LOCALVERSION*. The following placeholders are
48
49 diff --git a/gen_cmdline.sh b/gen_cmdline.sh
50 index 6fbf309..dcf479b 100755
51 --- a/gen_cmdline.sh
52 +++ b/gen_cmdline.sh
53 @@ -71,6 +71,8 @@ longusage() {
54 echo " --no-static Do not build a static (monolithic kernel)"
55 echo " Kernel settings"
56 echo " --kerneldir=<dir> Location of the kernel sources"
57 + echo " --kernel-append-localversion=<...>"
58 + echo " Appends value to genkernel's KERNEL_LOCALVERSION option"
59 echo " --kernel-config=<file|default>"
60 echo " Kernel configuration file to use for compilation; Use"
61 echo " 'default' to explicitly start from scratch using"
62 @@ -648,6 +650,10 @@ parse_cmdline() {
63 CMD_KERNEL_DIR="${*#*=}"
64 print_info 3 "CMD_KERNEL_DIR: ${CMD_KERNEL_DIR}"
65 ;;
66 + --kernel-append-localversion=*)
67 + CMD_KERNEL_APPEND_LOCALVERSION="${*#*=}"
68 + print_info 3 "CMD_KERNEL_APPEND_LOCALVERSION: ${CMD_KERNEL_APPEND_LOCALVERSION}"
69 + ;;
70 --kernel-config=*)
71 CMD_KERNEL_CONFIG="${*#*=}"
72 print_info 3 "CMD_KERNEL_CONFIG: ${CMD_KERNEL_CONFIG}"
73
74 diff --git a/gen_determineargs.sh b/gen_determineargs.sh
75 index df0934d..f4b3cf7 100755
76 --- a/gen_determineargs.sh
77 +++ b/gen_determineargs.sh
78 @@ -290,6 +290,7 @@ determine_real_args() {
79 set_config_with_override STRING CROSS_COMPILE CMD_CROSS_COMPILE
80 set_config_with_override STRING BOOTDIR CMD_BOOTDIR "/boot"
81 set_config_with_override STRING KERNEL_OUTPUTDIR CMD_KERNEL_OUTPUTDIR "${KERNEL_DIR}"
82 + set_config_with_override STRING KERNEL_APPEND_LOCALVERSION CMD_KERNEL_APPEND_LOCALVERSION
83 set_config_with_override STRING KERNEL_LOCALVERSION CMD_KERNEL_LOCALVERSION "-%%ARCH%%"
84 set_config_with_override STRING MODPROBEDIR CMD_MODPROBEDIR "/etc/modprobe.d"
85
86 @@ -630,6 +631,46 @@ determine_real_args() {
87 need_tar=yes
88 fi
89
90 + # We always need to populate KERNEL_LOCALVERSION to be able to warn
91 + # if user changed value but didn't rebuild kernel
92 + local valid_localversion_pattern='^[A-Za-z0-9_.-]{1,}$'
93 +
94 + if [ -n "${KERNEL_LOCALVERSION}" ]
95 + then
96 + case "${KERNEL_LOCALVERSION}" in
97 + UNSET)
98 + ;;
99 + *)
100 + KERNEL_LOCALVERSION=$(arch_replace "${KERNEL_LOCALVERSION}")
101 + if [ -z "${KERNEL_LOCALVERSION}" ]
102 + then
103 + # We somehow lost value...
104 + gen_die "Internal error: Variable 'KERNEL_LOCALVERSION' is empty!"
105 + fi
106 +
107 + if [[ ! "${KERNEL_LOCALVERSION}" =~ ${valid_localversion_pattern} ]]
108 + then
109 + gen_die "--kernel-localversion value '${KERNEL_LOCALVERSION}' does not match '${valid_localversion_pattern}' regex!"
110 + fi
111 + ;;
112 + esac
113 + fi
114 +
115 + if [ -n "${KERNEL_APPEND_LOCALVERSION}" ]
116 + then
117 + if [[ ! "${KERNEL_APPEND_LOCALVERSION}" =~ ${valid_localversion_pattern} ]]
118 + then
119 + gen_die "--kernel-append-localversion value '${KERNEL_APPEND_LOCALVERSION}' does not match '${valid_localversion_pattern}' regex!"
120 + fi
121 +
122 + if [[ "${KERNEL_LOCALVERSION}" == "UNSET" ]]
123 + then
124 + gen_die "Cannot append '${KERNEL_APPEND_LOCALVERSION}' to KERNEL_LOCALVERSION you want to unset!"
125 + else
126 + KERNEL_LOCALVERSION+="${KERNEL_APPEND_LOCALVERSION}"
127 + fi
128 + fi
129 +
130 if isTrue "${BUILD_KERNEL}"
131 then
132 if [ "${KERNEL_DIR}" != "${KERNEL_OUTPUTDIR}" -a ! -d "${KERNEL_OUTPUTDIR}" ]
133 @@ -637,28 +678,6 @@ determine_real_args() {
134 print_warning 3 "Set --kernel-outputdir '${KERNEL_OUTPUTDIR}' does not exist; Will try to create ..."
135 mkdir -p "${KERNEL_OUTPUTDIR}" || gen_die "Failed to create '${KERNEL_OUTPUTDIR}'!"
136 fi
137 -
138 - if [ -n "${KERNEL_LOCALVERSION}" ]
139 - then
140 - case "${KERNEL_LOCALVERSION}" in
141 - UNSET)
142 - ;;
143 - *)
144 - KERNEL_LOCALVERSION=$(arch_replace "${KERNEL_LOCALVERSION}")
145 - if [ -z "${KERNEL_LOCALVERSION}" ]
146 - then
147 - # We somehow lost value...
148 - gen_die "Internal error: Variable 'KERNEL_LOCALVERSION' is empty!"
149 - fi
150 -
151 - local valid_localversion_pattern='^[A-Za-z0-9_.-]{1,}$'
152 - if [[ ! "${KERNEL_LOCALVERSION}" =~ ${valid_localversion_pattern} ]]
153 - then
154 - gen_die "--kernel-localversion value '${KERNEL_LOCALVERSION}' does not match '${valid_localversion_pattern}' regex!"
155 - fi
156 - ;;
157 - esac
158 - fi
159 fi
160
161 if ! isTrue "${BUILD_RAMDISK}"