Kernel Builder script -- simple version

Here is a place for your projects which are not officially supported by the Porteus Team. For example: your own kernel patched with extra features; desktops not included in the standard ISO like Gnome; base modules that are different than the standard ISO, etc...
fulalas
DEV Team
DEV Team
Posts: 2050
Joined: 26 Oct 2016, 15:34
Distribution: Porteus
Location: Brazil

Kernel Builder script -- simple version

Post#1 by fulalas » 17 Dec 2021, 08:34

The idea is not to replace neko's application, but just to provide a straightforward non-UI approach that doesn't require updates when a new kernel is released.

https://www.mediafire.com/file/r1ui4kaf ... 206.tar.gz
(398 KB)

Usage:

Code: Select all

./kernel.sh [kernelVersionYouWantToCompile]
Example:

Code: Select all

./kernel.sh 5.12.14
It will download the kernel source code, AUFS path for the given kernel version, firmware, compile everything and generate:
  • vmlinuz
  • 000-kernel.xzm
  • 06-crippled_sources-[kernelVersion].xzm.
Typical output:

Code: Select all

Initial setup...
Downloading kernel source code...
Extracting kernel source code...
Copying .config file...
Downloading AUFS...
Patching AUFS...
Building kernel (this may take a while)...
Creating symlinks...
Downloading firmware...
Extracting firmware...
Adding firmware...
Blacklisting...
Copying cryptsetup...
Creating kernel xzm module...
Creating crippled xzm module...
Cleaning up...
All finished.

Files generated:
vmlinuz -> should go into boot/syslinux
000-kernel.xzm -> should go into porteus/base
06-crippled_sources-5.12.14.xzm -> should go into porteus/base
Tips:
1- If the script detects either the kernel source package or firmware package in the script folder it won't download them again.
2- All the temporary files will be created in /tmp/kernel-builder, and they should be deleted when the process finishes.
3- If you forget to run it as sudo it will ask for sudo pass.
4- You only need 3 files for this to work (they're all included in the package above):
  • kernel.sh (of course)
  • 64bit.config or 32bit.config (which contains kernel configuration)
  • cryptsetup (for handling encrypted save changes)
It should be able to build any version of the kernel that is still buildable nowadays, either 32 or 64 bit. I haven't tested with many different kernel versions so I can't guarantee much. It's still very experimental and any feedback is welcome.

Next version should include a way to log the output -- at the moment the script is swallowing all the output for a cleaner experience.

I would like to thank neko for his generous patience to teach me all the tricks that involve building Linux kernel. He's the man! :)

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Kernel builder script -- simple version

Post#2 by Ed_P » 17 Dec 2021, 17:17

:o
Ed

fulalas
DEV Team
DEV Team
Posts: 2050
Joined: 26 Oct 2016, 15:34
Distribution: Porteus
Location: Brazil

Kernel builder script -- simple version

Post#3 by fulalas » 17 Dec 2021, 20:53

It's failing to build (actually, link) 5.15.x with the following error:

Code: Select all

ld: fs/inode.o: in function `__ksymtab_update_time':
inode.c:(___ksymtab_gpl+update_time+0x0): undefined reference to `update_time'
ld: fs/aufs/i_op.o: in function `aufs_update_time':
i_op.c:(.text+0x19c): undefined reference to `update_time'
make: *** [Makefile:1183: vmlinux] Error 1
I reported the issue: https://github.com/sfjro/aufs5-standalone/issues/8

beny
Full of knowledge
Full of knowledge
Posts: 2086
Joined: 02 Jan 2011, 11:33
Location: italy

Kernel builder script -- simple version

Post#4 by beny » 17 Dec 2021, 22:39

hi,the issue of aufs patch is start with the 5.15.6 and also neko don't have the hint to solve this, but he have the overlay option,the 5.16-rc5 do not have issue with aufs, you can try to build it i have tried to download it via your script but no way... error

roadie
Full of knowledge
Full of knowledge
Posts: 400
Joined: 02 Jan 2011, 18:41
Distribution: Porteus 5.0-RC1
Location: In a hayfield

Kernel builder script -- simple version

Post#5 by roadie » 17 Dec 2021, 22:59

fulalas,

I just compiled the 5.15.8 kernel using the aufs5.15.5 patch.......no errors on patching and the kernel booted well.

https://github.com/sfjro/aufs5-standalone/branches

beny
Full of knowledge
Full of knowledge
Posts: 2086
Joined: 02 Jan 2011, 11:33
Location: italy

Kernel builder script -- simple version

Post#6 by beny » 17 Dec 2021, 23:39

hi i can confirm that aufs 5.15.5 work on 5.15.10 with roadie advice

fulalas
DEV Team
DEV Team
Posts: 2050
Joined: 26 Oct 2016, 15:34
Distribution: Porteus
Location: Brazil

Kernel builder script -- simple version

Post#7 by fulalas » 18 Dec 2021, 05:27

Yeah, confirmed. Working version now uploaded (first post).

In the future I'm going to add more specific verifications for these broken versions... Zzzzz :P

fulalas
DEV Team
DEV Team
Posts: 2050
Joined: 26 Oct 2016, 15:34
Distribution: Porteus
Location: Brazil

Kernel builder script -- simple version

Post#8 by fulalas » 24 Jan 2022, 11:34

Does anyone know why kernel is failing to build? No matter what version I'm trying, including 5.12.14 which I tested countless times during the development of this script!

That's the error output if I remove > /dev/null 2>&1 from the make olddefconfig command (line 88):

Code: Select all

  ...
  HOSTLD  scripts/kconfig/conf
make[1]: *** [scripts/kconfig/Makefile:63: olddefconfig] Segmentation fault
make: *** [Makefile:602: olddefconfig] Error 2
EDIT: never mind. It's something in our current developer base.

UrUtusUbU
Black ninja
Black ninja
Posts: 73
Joined: 21 Apr 2012, 00:19
Distribution: Hannah Montana Linux
Location: inmygrave

Kernel builder script -- simple version

Post#9 by UrUtusUbU » 04 Feb 2022, 22:30

in line 19 get i a error about a space,

code WITH ERROR

Code: Select all

	if [ ! -f 32bit.config]; then
code WITHOUT ERROR

Code: Select all

	if [ ! -f 32bit.config ]; then
ONLY put A SPACE AFTER config

Building kernel (this may take a while)...
iam building 5.15.8 at the moment no problems,
waiting the end...........
Building kernel (this may take a while)...

thanks

why use ausfs neither??

User avatar
Blaze
DEV Team
DEV Team
Posts: 3869
Joined: 28 Dec 2010, 11:31
Distribution: ⟰ Porteus current ☯ all DEs ☯
Location: ☭ Russian Federation, Lipetsk region, Dankov
Contact:

Kernel builder script -- simple version

Post#10 by Blaze » 05 Feb 2022, 06:19

I stuck on this

Code: Select all

Building kernel (this may take a while)...
   HOSTCC scripts/basic/fixdep
   HOSTCC scripts/kconfig/conf.o
   HOSTCC scripts/kconfig/confdata.o
   HOSTCC scripts/kconfig/expr.o
   LEX scripts/kconfig/lexer.lex.c
   YACC scripts/kconfig/parser.tab.[ch]
   HOSTCC scripts/kconfig/lexer.lex.o
   HOSTCC scripts/kconfig/menu.o
   HOSTCC scripts/kconfig/parser.tab.o
   HOSTCC scripts/kconfig/preprocess.o
   HOSTCC scripts/kconfig/symbol.o
   HOSTCC scripts/kconfig/util.o
   HOSTLD scripts/kconfig/conf
make[1]: *** [scripts/kconfig/Makefile:77: olddefconfig] Segmentation error
make: *** [Makefile:619: olddefconfig] Error 2
Fail to build kernel. 
Linux 6.6.11-porteus #1 SMP PREEMPT_DYNAMIC Sun Jan 14 12:07:37 MSK 2024 x86_64 Intel(R) Xeon(R) CPU E3-1270 v6 @ 3.80GHz GenuineIntel GNU/Linux
MS-7A12 » [AMD/ATI] Navi 23 [Radeon RX 6600] [1002:73ff] (rev c7) » Vengeance LPX 16GB DDR4 K2 3200MHz C16

UrUtusUbU
Black ninja
Black ninja
Posts: 73
Joined: 21 Apr 2012, 00:19
Distribution: Hannah Montana Linux
Location: inmygrave

Kernel builder script -- simple version

Post#11 by UrUtusUbU » 05 Feb 2022, 12:10

I at the end the same
Fail to build kernel.

beny
Full of knowledge
Full of knowledge
Posts: 2086
Joined: 02 Jan 2011, 11:33
Location: italy

Kernel builder script -- simple version

Post#12 by beny » 05 Feb 2022, 18:07

Code: Select all

  uest@porteus:~/Downloads/kernelbuild$ sh '/home/guest/Downloads/kernelbuild/kernel.sh' 5.15.20
glibtop(c=4231): [DEBUG] open.c:50 glibtop_open_l(): SIZEOF: 40 - 65648 - 248 - 65624 - 296 - 65624
glibtop(c=4231): [DEBUG] open.c:163 glibtop_open_l(): Calling sysdeps open function.
glibtop(c=4231): [DEBUG] init.c:229 glibtop_init_s(): init_s with features=0xfffffff and flags=0

gksu-run: gksu/|home|guest|Downloads|kernelbuild|kernel.sh '5.15.20' '|home|guest|Downloads|kernelbuild'/4231-0-porteus.example.net_TIME0
gksu-run: a05c78660723308b616860d084a073d5

Initial setup...
Downloading kernel source code...
Extracting kernel source code...
Copying .config file...
Downloading AUFS...
Patching AUFS...
Building kernel (this may take a while)...
Creating symlinks...
Downloading firmware...
Extracting firmware...
Adding firmware...
/home/guest/Downloads/kernelbuild/kernel.sh: line 119: [: too many arguments
Blacklisting...
Copying cryptsetup...
Creating kernel xzm module...
Creating crippled xzm module...
Cleaning up...
All finished.

Files generated:
vmlinuz -> should go into boot/syslinux
000-kernel.xzm -> should go into porteus/base
06-crippled_sources-5.15.20.xzm -> should go into porteus/base
guest@porteus:~/Downloads/kernelbuild$ 

                                                                                        

fulalas
DEV Team
DEV Team
Posts: 2050
Joined: 26 Oct 2016, 15:34
Distribution: Porteus
Location: Brazil

Kernel builder script -- simple version

Post#13 by fulalas » 06 Feb 2022, 01:46

@UrUtusUbU, thanks for the bug report. It's fixed now (first post).

@all, kernel will fail to build if you use wrong combination of devel module and core/xorg modules. EDIT: it seems there's something in the new core module that is breaking kernel build. I still don't know what :(

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

Kernel builder script -- simple version

Post#14 by Ed_P » 06 Feb 2022, 04:12

fulalas wrote:
06 Feb 2022, 01:46
@all, kernel will fail to build if you use wrong combination of devel module and core/xorg modules.
How does one know what devel mod goes with which core/xorg mods?
Ed

User avatar
Blaze
DEV Team
DEV Team
Posts: 3869
Joined: 28 Dec 2010, 11:31
Distribution: ⟰ Porteus current ☯ all DEs ☯
Location: ☭ Russian Federation, Lipetsk region, Dankov
Contact:

Kernel builder script -- simple version

Post#15 by Blaze » 06 Feb 2022, 10:07

Yep

Code: Select all

+ cat aufs/aufs5-base.patch aufs/aufs5-kbuild.patch aufs/aufs5-loopback.patch aufs/aufs5-mmap.patch aufs/aufs5-standalone.patch aufs/tmpfs-idr.patch aufs/vfs-ino.patch
+ cd linux-5.16.7
+ patch -p1
+ echo 'Building kernel (this may take a while)...'
Building kernel (this may take a while)...
++ nproc --all
+ cpuThreads=4
+ make olddefconfig
+ echo 'Fail to build kernel.'
Fail to build kernel.
+ exit 1
Linux 6.6.11-porteus #1 SMP PREEMPT_DYNAMIC Sun Jan 14 12:07:37 MSK 2024 x86_64 Intel(R) Xeon(R) CPU E3-1270 v6 @ 3.80GHz GenuineIntel GNU/Linux
MS-7A12 » [AMD/ATI] Navi 23 [Radeon RX 6600] [1002:73ff] (rev c7) » Vengeance LPX 16GB DDR4 K2 3200MHz C16

Post Reply