I've started putting together https://github.com/ericcurtin/asahi-centosstream-builder
ericcurtin opened this issue · 50 comments
The aim is to create an installer identical to this one, except CentOS Stream 9 based. I'll probably create another one after that which is also CentOS Stream 9 based but with the PREEMPT_RT patchset, to sort of replicate our new AutoSD distro https://autosd.sig.centos.org/AutoSD-9/
I'm trying to populate https://github.com/ericcurtin/asahi-centosstream-builder/tree/main/root-www to be like https://leifliddy.com/ and put everything in the one git repo for simplicity.
May I ask what were the manual edits to files and what were the more scripted steps you took to generate the necessary files in leifliddy.com ?
And if you'd rather do this in the https://github.com/leifliddy namespace and maintain that's fine with me too 😄
I don't want to take credit for this cool installer you created. I just want to create unofficial best-effort images for CentOS Stream 9 and AutoSD 9 for personal usage (although I'm sure a few others will end up using too).
I started with this file:
https://github.com/ericcurtin/asahi-centosstream-builder/blob/main/root-www/centosstream.sh
basically just replaced a few things with "https://raw.githubusercontent.com/ericcurtin/asahi-centosstream-builder/main/root-www"
The build.sh (with the mkosi stuff) script seemed to run fine for me too, but I'm not 100% sure what to do with the generated images.
I'm traveling at the moment, but I can definitely help you out next weekend.
To be fair, I haven't really documented much. I suppose it would be helpful to start doing that.
Ok, so for the moment I would recommend just getting familiar with the AsahiLinux installer.
Take a look at the following
curl https://alx.sh
https://de.mirror.asahilinux.org/
https://github.com/AsahiLinux/asahi-installer
*there's two submodules here, I substituted the artwork one for my own artwork (containing the Fedora logos). I can show you how to do that later (if needed)
If you're fine with just using the Asahi Linux artwork, then just use the latest pre-built installer here:
https://de.mirror.asahilinux.org/installer/installer-v0.3.9.tar.gz
Also, check out the osinstall.py
script.
https://raw.githubusercontent.com/AsahiLinux/asahi-installer/main/src/osinstall.py
You'll notice this line:
package = os.environ.get("REPO_BASE", ".") + "/os/" + package
So it's looking for the asahi zipped image at this location.
ie
https://www.leifliddy.com/os/asahi-base-20220714-1.zip
https://de.mirror.asahilinux.org/os/asahi-base-20220712-2.zip
Based on this designREPO_BASE
should ideally point to a webserver.
And of course, the asahi image name resolves to whatever package
is set to in installer_data.json
ie
https://raw.githubusercontent.com/ericcurtin/asahi-centosstream-builder/main/root-www/.config/installer_data.json
"name": "CentOSStream Minimal (CentOSStream Linux ARM)",
...
"package": "asahi-base-20220714-1.zip",
Simply rename the the asahi-base.zip
file that this project (or rather your project) creates to that name.
I didn't alter anything in the Asahi-Linux installer except for the artwork and simply followed the way they did it.
The only files you should need to customize (besides the asahi image) are:
1. installer_data.json
2. centosstream.sh
See what you can figure out and let me know if you get stuck on anything.
Ok thanks for the info, moving here:
First issue I hit is here:
Asahi Fedora 36 - aarch64 276 kB/s | 274 kB 00:00
CentOS Stream 9-stream - BaseOS 3.3 MB/s | 4.5 MB 00:01
CentOS Stream 9-stream - AppStream 8.2 MB/s | 12 MB 00:01
CentOS Stream 9-stream - CRB 518 kB/s | 3.2 MB 00:06
No match for argument: btrfs-progs
No match for argument: iwd
No match for argument: systemd-networkd
No match for argument: zram-generator-defaults
Error: Unable to find a match: btrfs-progs iwd systemd-networkd zram-generator-defaults
These packages don't seem to exist in CentOS Stream 9. Do you think we need them?
So this project formats the main partition as btrfs.
Yeah, that's going to be an issue for CentOS as I believe they removed support for it. You'll need to modify a few things then. I can send you the changes you'll need to make later. It's pretty easy though. This project originally formatted the main partition as ext4. So if you look back far enough in the history, you'll see it.
Would need wifi working... Yeah ext4 would be fine... I did ask the maintainer if we could add iwd to EPEL 9... So we can see there...
Do you think systemd-networkd and zram-generator-defaults are needed?
Gotta mess around with some spec files, have the sources?:
Asahi Fedora 36 - aarch64 248 kB/s | 274 kB 00:01
CentOS Stream 9-stream - BaseOS 2.8 MB/s | 4.5 MB 00:01
CentOS Stream 9-stream - AppStream 6.1 MB/s | 12 MB 00:01
CentOS Stream 9-stream - CRB 525 kB/s | 3.2 MB 00:06
Error:
Problem 1: conflicting requests
- nothing provides python(abi) = 3.10 needed by asahi-fwextract-0.4pre2-2.fc36.noarch
Problem 2: conflicting requests
- nothing provides btrfs-progs needed by asahi-scripts-20220714-1.fc36.noarch
Problem 3: conflicting requests
- nothing provides python3dist(construct) needed by m1n1-tools-1.1.2-1.fc36.noarch
(try to add '--skip-broken' to skip uninstallable packages)
‣ (Unmounting API VFS)
‣ (Unmounting Package Cache)
Asahi Fedora 36 - aarch64 248 kB/s | 274 kB 00:01
CentOS Stream 9-stream - BaseOS 2.8 MB/s | 4.5 MB 00:01
CentOS Stream 9-stream - AppStream 6.1 MB/s | 12 MB 00:01
CentOS Stream 9-stream - CRB 525 kB/s | 3.2 MB 00:06
Error:
Problem 1: conflicting requests
- nothing provides python(abi) = 3.10 needed by asahi-fwextract-0.4pre2-2.fc36.noarch
Problem 2: conflicting requests
- nothing provides btrfs-progs needed by asahi-scripts-20220714-1.fc36.noarch
Problem 3: conflicting requests
- nothing provides python3dist(construct) needed by m1n1-tools-1.1.2-1.fc36.noarch
(try to add '--skip-broken' to skip uninstallable packages)
‣ (Unmounting API VFS)
‣ (Unmounting Package Cache)
‣ (Unmounting image)
centos 9 has python 3.9, I wonder could I reuse your package if we reduced the version required a notch 🤔
>ext4 would be fine
Sure, that's completely up to you. You could also format the partition as xfs
if you wanted to.
> I did ask the maintainer if we could add iwd to EPEL 9
> Do you think systemd-networkd and zram-generator-defaults are needed?
Again, that's really up to you and whatever you think is best for a CentOS install. I chose iwd
+ systemd-networkd
as the initial network configuration was pretty straight forward as you could easily connect to a wifi network with a single command -- and to be honest, I like the minimalistic aspect of that combination. However, I'm sure NetworkManager
would work just as well.
The zram-generator
question is quite interesting though. As the asahi linux installer only carves out a single Linux partition -- you won't be able to create/use a dedicated swap partition. Therefore it might be beneficial to create a compressed block device in memory to use for swapping aka zram
(assuming that centos 9 supports it). That's the default in Fedora now. Fedora no longer creates an actual swap partition by default any longer.
>centos 9 has python 3.9, I wonder could I reuse your package if we reduced the version required a notch
That shouldn't be an issue at all. I can create RPM's that are compatible with CentOS 9 if you want.
That would be super helpful
Does CentOS 9 not have a gcc-aarch64-linux-gnu
cross-compiler rpm?
Sadly it doesn't, in RHIVOS, AutoSD, CentOS Stream, RHEL, Fedora (and all other variants) we don't cross compile for alternate architectures, because too many build scripts assume the host CPU architecture is the target architecture and it's just a huge headache to fix that for 1000's of packages.
So although we have cross-compiler packages in Fedora, it's not really used to build Fedora packages. So that's probably why it's not in EPEL atm.
Some other distros do cross-compiling I guess. Most Red Hat developers I know create some kind of aarch64 container/vm, use a rpi4 or some other machine like an M1, etc.
Ok no worries. I can just spin up a Rocky Linux 9 podman container on the M1 air when I get back next weekend and build the rpm's then. It doesn't look like there is a CentOS 9 podman container...
In any case you could always rebuild them on a CentOS 9 system if you wanted to.
In the meantime, I'll work on converting the F36 SRPM's to EL9 (shouldn't be too hard).
Also, if you could choose between formatting the root partition with ext4 or xfs, which one would you choose? I need to test out the xfs module on the m1 mac to ensure that it works properly. It's not listed here (like f2fs), so that's a good sign ; )
https://github.com/AsahiLinux/docs/wiki/Broken-Software
There's a podman container for it alright, it's just the version tag it not so obvious (I forget it all the time too), but rocky should also be fine:
sudo podman run -it centos:stream9 bash
Personally, I'd like ext4 as default, but I'm biased as the Automotive variant of our OS uses that by default (at least as of today). And that's what I tend to use. ext4 is less work for us anyway right? 😄
Even though a tiny part of me says both as it could change to xfs, hard to rule it out.
It's fine, we can do it later.
If you wanted to use xfs, we'd need to add the xfs grub module here:
https://github.com/leifliddy/asahi-scripts/blob/main/update-grub
https://github.com/leifliddy/asahi-fedora-builder/blob/main/mkosi.skeleton/image.creation/update-grub
we'd also need to modify the first-boot
script here so that it resizes the xfs partition.
https://github.com/leifliddy/asahi-scripts/blob/main/first-boot
I need to redo this script to support ext4 anyway. I need to add logic to first determine the filesystem type of the root partiton -- and then expand it accordingly. Along with a couple other changes.
Ok, so I've created this repo for el9
https://www.leifliddy.com/asahi-linux/el9/aarch64/
That python3-build packages is needed to build the asahi-fwextract package. I'll touch up that python3-build SRPM later. Just want to get the initial versions of these packages built. I'll do the asahi-scripts one next after I rework that first-boot script....
Ok, I made a few changes to https://github.com/leifliddy/asahi-scripts
and implemented better logic. Both ext4 and btrfs partitions are now supported.
However, I haven't yet tested out the changes yet.
I uploaded an el9
version with those changes here:
https://www.leifliddy.com/asahi-linux/el9/aarch64/
I'll create an el9 version of this project and see if i can build an image. I'll just copy the Fedora m1n1, update-m1n1, and uboot-asahi
rpm's into that el9
repo for now.
Ok, so I created a test el9 project here.
https://github.com/leifliddy/asahi-el9-builder
But, it fails on this.
Total 2.2 MB/s | 431 MB 03:12
Asahi Fedora 9-stream - aarch64 2.2 kB/s | 648 B 00:00
Importing GPG key 0x8A3CBE19:
Userid : "Leif Liddy <leif.linux@gmail.com>"
Fingerprint: 4903 CDA9 945C 643A C3B7 0628 55EC C2DE 8A3C BE19
From : https://leifliddy.com/asahi-linux/RPM-GPG-KEY-asahi
Key imported successfully
CentOS Stream 9-stream - BaseOS 0.0 B/s | 0 B 00:00
Curl error (37): Couldn't read a file:// file for file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial [Couldn't open file /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial]
I tried including that gpg in the mkosi skeleton directory, but that didn't work either.
It might related to this issue
k3s-io/k3s#5588
Looks like I'll have to try building this on a Centos9 VM...
nevermind, I changed the gpgkey entry to this
gpgkey=https://leifliddy.com/asahi-linux/RPM-GPG-KEY-centosofficial
and it worked. Not the best solution though. Does CentOS publish this key anywhere?
Ok so this project is now building a centos 9 image
https://github.com/leifliddy/asahi-el9-builder
Maybe you can incorporate some of these changes into your project.
Please let me know if this works for you.
You know...I bet it's looking for that centos gpg key on the host filesystem. I'll test that theory out tomorrow.
Are these the ones you are looking for?
Got some btrfs complaints, but seemed to build ok:
### Updating GRUB...
UUID: b0982627-9ee2-4524-97b6-54810f224b73
Generating GRUB image...
Generating grub configuration file ...
/usr/libexec/os-probes/50mounted-tests: line 88: btrfs: command not found
/usr/libexec/os-probes/50mounted-tests: line 89: btrfs: command not found
/usr/libexec/os-probes/50mounted-tests: line 90: btrfs: command not found
done
Interesting, so mkosi
is looking on the host system for the rpm-gpg keys.
So I copied that Centos gpg key to /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
on my host Fedora system.
Then I modified the gpgkey
entries in
https://github.com/leifliddy/asahi-el9-builder/blob/main/mkosi.skeleton/etc/yum.repos.d/centos.repo
to
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
and that somehow worked. Not sure if that's the intended behavior or not. It seems like it should be looking within the mkosi build directory for that.
>Are these the ones you are looking for?
I was looking for a location where you could pull in the key via curl (which is what yum/dnf uses)
>Got some btrfs complaints, but seemed to build ok:
Yeah those errors are harmless. It can't run through all of the probe tests as btrfs-progs
isn't installed.
I wanted to leave the dust settle on this before I do my first test install. I was actively using the Fedora partition also. Should I give it a test install @leifliddy ? Are you confident?
>Should I give it a test install @leifliddy?
Sure
>Are you confident?
I have no idea it's going to work, but it should.
Just make sure to pull in the latest changes from (I corrected a typo yesterday)
https://github.com/leifliddy/asahi-el9-builder
I'll be back home Sunday night, I can sort out any issues then.
I'll also build out the el9 rpms for the kernel, uboot-asahi, and m1n1
Not sure if this will be of interest to you or not but I'll throw it out there anyway.
So I created this project to quickly build out an environment in which to build centos9 rpm's.
https://github.com/leifliddy/podman-rpmbuild-centos9
You basically just run that script-podman.py
script as a normal user (or as root if really want to)
script-podman.py --help
will show you the supported args and is pretty self-explanatory.
Everyone's got their own method to accomplish something like this -- and I happen to like this approach : )
I'll fine-tune things once I start actually using it....
That's kinda neat. We do have this service called copr also, when you put your spec and related content into it, you can kind of tick whatever platforms and cpu architectures you want to build for and it will host the yum repo also.
But this is also neat. https://copr.fedorainfracloud.org/
Cool, I'll check that out later.
Ok, I finished creating the rest of the packages.
Everything "should" work now.
I created this project to test out the packages and create a bootable centos9 usb drive. So far so good....
https://github.com/leifliddy/asahi-centos-usb
bluetooth is working
[root@centosstream ~]# bluetoothctl
Agent registered
[CHG] Controller B0:BE:83:1E:43:FE Pairable: yes
..and so is the zram
disk
[root@centosstream ~]# swapon
NAME TYPE SIZE USED PRIO
/dev/zram0 partition 7.4G 0B 100
You'll have to figure out how you want to configure the wifi interface and modify the mkosi
config accordingly. Also, I'm hoping that I can hand the centos stuff off to you once we get things working. Maintaining two sets of packages is a bit tedious...
Wow, thanks. Sounds good!
I created a centos installer config to test things out:
https://www.leifliddy.com/centos.sh
Haven't tested it yet though. If you try it out let me know.
Will get to it within the next day or two
Damn there's a minor issue with this image. Going to sort it out now.
Yup, it's the most trivial of errors as well.
I just resolved it here:
https://github.com/leifliddy/asahi-el9-builder/commit/95156a1d0c8eb6cfa8c46b4f76e94d907377d2df
update -- this wasn't the issue
Thanks very much, again
I'll sort this out later tonight.
It's working now. I redesigned and standardized a few things -- like update-grub
so they can used interchangeably between fedora, centos, and usb installs.
Also, I added iwd
and systemd-networkd
to this image -- simply because I'm familiar with how to use them.
Let me know if you try it out.
I'll try it out again in the next day or two, thanks very much again
It looks you have your site setup...nice!
I would make the following adjustments though.
modify this https://ecurtin.fedorapeople.org/centos.sh and change
export VERSION_FLAG=https://ecurtin.fedorapeople.org/installer/latest-centos
to
export VERSION_FLAG=https://ecurtin.fedorapeople.org/installer/latest
then delete these:
https://ecurtin.fedorapeople.org/installer/latest-centos
https://ecurtin.fedorapeople.org/installer/installer-v0.4.1.tar.gz
# you're using the /.centos directory
https://ecurtin.fedorapeople.org/.config/
and then rename this:
https://ecurtin.fedorapeople.org/installer/installer-v0.4.1-centos.tar.gz
to:
https://ecurtin.fedorapeople.org/installer/installer-v0.4.1.tar.gz
Or however you want, these are just suggestions. I only put the -centos
on files to differentiate them from the fedora files. But you can do whatever you want.
Thanks for reviewing I will make your suggested settings. One question, how exactly did you build all your kernel rpms? What make commands, etc. did you use?
So I've made the Fedora SRPM compatible with centos.
[leif.liddy@black SOURCES]$ ls -ltr | tail -2
-rw-r--r--. 1 leif.liddy leif.liddy 192339 Jul 25 12:03 kernel-aarch64-rhel.config
-rw-rw-r--. 1 leif.liddy leif.liddy 192321 Jul 25 12:08 kernel-aarch64-fedora.config
I'll show you how create this SRPM from scratch later if you want.
But why don't you try building it first.
So you should be able to take this kernel SRPM and build it on centos:
https://www.leifliddy.com/asahi-linux/36/source/SRPMS/kernel-5.19.0-rc7.asahi2.1.fc36.src.rpm
these are from my notes
# build aarch64 kernel on x86_64 system
rpmbuild -bb --target=aarch64 --with headers --without debuginfo --with vanilla --with cross kernel.spec
# build aarch64 kernel on macbook m1
rpmbuild -bb --target=aarch64 --with headers --without debuginfo --with vanilla kernel.spec
I can see that I've set some of these variables in the spec file.
%define with_headers 1
%define with_vanilla 1
%define with_debuginfo 0
But I need to ensure those are working right. In any case it doesn't hurt anything to provide arguments like --with headers
even if you might not technically need them.
I'm assuming you know to run dnf builddep kernel.spec
to install the build requires.
Oh...you'll also need to generate and sign your rpms with a gpg key and then add the public gpg key to your repo. I've scripted out the signing of rpms with python + salt, I can show you how to do that later if you want.
I'm actually gonna leave the -centos tags in because I am going to be preparing another installer with tag -autosd. Thanks for giving me the kernel rpm building tips.