It's hard to overstate how awesome build.sh is. If you have some powerful desktop/laptop running virtually any modern POSIX OS, you can easily build for an embedded board like an RPi or Beagelboard, obscure retro targets, or standard systems all the same. The closest thing is maybe Yocto Linux, but a whole lot easier to use and understand.
idatum 6 days ago [-]
If you run older hardware you realize quickly how significant it is to be able to do cross builds with build.sh. I came across this post today that highlights this!
> How long would you imagine it might take to compile NetBSD 10 from source on real m68k hardware? Earlier this year I wanted to find out, so I set up a Macintosh to try it.
> The toolchain, OS and installation sets started on 16-March and finished on 10-May:
> build.sh started: Sat Mar 16 17:04:20 UTC 2024
> build.sh ended: Fri May 10 00:35:54 UTC 2024
> 4692724.22 real 3810544.56 user 700310.18 sys
kstrauser 6 days ago [-]
I misread that. It started on Mar 16 and ended on Mar 10? How did that OHHHHhhhh...
actionfromafar 6 days ago [-]
That's not so bad! :-D
dgfitz 6 days ago [-]
My yocto linux builds have a single entry point that is a build.sh. And they’re like 20 lines.
johnklos 6 days ago [-]
I've heard this about various Linux distros, but every time I've tried it has never been as simple as people say it should be.
I assume your twenty lines has customizations. How do you rebuild the OS and kernel the simplest way possible?
dgfitz 4 days ago [-]
The short answer to the last question is, blow away the cache and download dirs and run build.sh
My build.sh clones down 5 repos, inits the bitbake environment, and builds. This bit is 12-15 lines.
Because I have to work around work infrastructure, about 10 lines of build.sh make symlinks into bitbakes previously-cloned folder structure for things that should be native recipes, but cannot be. Really no magic at all, the symlinks piss me off.
theamk 6 days ago [-]
> NetBSD build system allows you to build the full OS from scratch, on pretty much any host POSIX platform, while targeting any hardware architecture supported by NetBSD. All without root privileges.
That seems fairly standard to me though? Yocto, buldroot, many other embedded-oriented systems provide that and more.
plorkyeran 6 days ago [-]
It's definitely what I would consider the basic expectations for a build system (why would you even need root to compile an OS?), but it's not something that most non-embedded-focused distributions deliver.
musicale 6 days ago [-]
> why would you even need root to compile an OS
Usually it's to make it easier dealing with file system ("disk") image files, which may require root privileges to mount and use with regular programs (though FUSE and similar subsystems can help.) In a mounted filesystem, root privileges may be required to set permission bits like setuid.
The NetBSD toolchain probably includes utilities to make it easy to copy data in and out of file system images, ideally concurrently and without corruption.
cperciva 5 days ago [-]
In addition to building filesystem images, a common use of root for operating system building is to chroot into a "clean" environment to avoid environmental corruption. (In general, chroot is reserved to uid 0 due to issues with setuid binaries -- on some systems chroot can be made available to non-root users by turning off setuid behaviour.)
Koshkin 5 days ago [-]
The option -U lets you build in the unprivileged mode.
deaddodo 5 days ago [-]
Yeah, I feel like anyone making this statement hasn't done any sort of wide cross-compilation in the past, let alone of an entire OS.
It should be a basic expectation, but most certainly isn't one in the real-world. Especially with stuff like GCC2 Haiku, which requires an old obscure GCC version for building ABI compatible images.
jmmv 5 days ago [-]
I didn't know about Yocto, but reading through its documentation, it looks far more complex than NetBSD's build.sh. And then, I read:
> If the machine you want to use Yocto Project on to build an image (Build Host) is not a native Linux system, you can still perform these steps by using CROss PlatformS (CROPS) and setting up a Poky container.
...
> With CROPS, which leverages Docker Containers, you can create a Yocto Project development environment that is operating system agnostic. You can set up a container in which you can develop using the Yocto Project on a Windows, Mac, or Linux machine.
... which is not close to what NetBSD's build system does, like at all.
As for buildroot: "Buildroot is designed to run on Linux systems." (a "red flag") and the list of host dependencies to install is pretty large, which is also different from NetBSD's build.
Plus Buildroot and "other embedded-oriented systems" are, well, something specifically designed to build embedded system images with Linux, not a "standard" Unix-like OS that happens to have a build system that works well for embedded. A big plus for BSD is its monorepo style of development: customizing and patching the system is trivial. With buildroot, well, you have Linux's hodgepodge style of development, so picking and choosing components is simple, but modifying any of them is hard.
So what NetBSD's build system offers doesn't "seem fairly standard" to me. Definitely not the "run on pretty much any host POSIX platform", which is not common. And when you involve Docker in the picture, I also say that other systems fail the test of "all without root".
jmclnx 6 days ago [-]
I just updated pkgsrc from 2024Q3 to 2024Q4 for amd64 and i386, very easy.
I never built NetBSD because I never had the need to do that. But from what I read its cross-compiling works very well.
plagiarist 5 days ago [-]
I really enjoyed reading this. And it is too relatable that they would detour from the project they want to work on to port the build over to Bazel.
6 days ago [-]
mikedesu 5 days ago [-]
[dead]
Rendered at 15:25:25 GMT+0000 (UTC) with Wasmer Edge.
https://zia.io/objects/c4b825f9-8c57-4b86-a108-af869dfbcb10
> How long would you imagine it might take to compile NetBSD 10 from source on real m68k hardware? Earlier this year I wanted to find out, so I set up a Macintosh to try it.
> The toolchain, OS and installation sets started on 16-March and finished on 10-May:
> build.sh started: Sat Mar 16 17:04:20 UTC 2024
> build.sh ended: Fri May 10 00:35:54 UTC 2024
> 4692724.22 real 3810544.56 user 700310.18 sys
I assume your twenty lines has customizations. How do you rebuild the OS and kernel the simplest way possible?
My build.sh clones down 5 repos, inits the bitbake environment, and builds. This bit is 12-15 lines.
Because I have to work around work infrastructure, about 10 lines of build.sh make symlinks into bitbakes previously-cloned folder structure for things that should be native recipes, but cannot be. Really no magic at all, the symlinks piss me off.
That seems fairly standard to me though? Yocto, buldroot, many other embedded-oriented systems provide that and more.
Usually it's to make it easier dealing with file system ("disk") image files, which may require root privileges to mount and use with regular programs (though FUSE and similar subsystems can help.) In a mounted filesystem, root privileges may be required to set permission bits like setuid.
The NetBSD toolchain probably includes utilities to make it easy to copy data in and out of file system images, ideally concurrently and without corruption.
It should be a basic expectation, but most certainly isn't one in the real-world. Especially with stuff like GCC2 Haiku, which requires an old obscure GCC version for building ABI compatible images.
> If the machine you want to use Yocto Project on to build an image (Build Host) is not a native Linux system, you can still perform these steps by using CROss PlatformS (CROPS) and setting up a Poky container. ... > With CROPS, which leverages Docker Containers, you can create a Yocto Project development environment that is operating system agnostic. You can set up a container in which you can develop using the Yocto Project on a Windows, Mac, or Linux machine.
... which is not close to what NetBSD's build system does, like at all.
As for buildroot: "Buildroot is designed to run on Linux systems." (a "red flag") and the list of host dependencies to install is pretty large, which is also different from NetBSD's build.
Plus Buildroot and "other embedded-oriented systems" are, well, something specifically designed to build embedded system images with Linux, not a "standard" Unix-like OS that happens to have a build system that works well for embedded. A big plus for BSD is its monorepo style of development: customizing and patching the system is trivial. With buildroot, well, you have Linux's hodgepodge style of development, so picking and choosing components is simple, but modifying any of them is hard.
So what NetBSD's build system offers doesn't "seem fairly standard" to me. Definitely not the "run on pretty much any host POSIX platform", which is not common. And when you involve Docker in the picture, I also say that other systems fail the test of "all without root".
I never built NetBSD because I never had the need to do that. But from what I read its cross-compiling works very well.