Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimal Haiku implementation #1538

Merged
merged 1 commit into from
Feb 5, 2025
Merged

Conversation

mmuman
Copy link
Contributor

@mmuman mmuman commented Feb 4, 2025

This is a first try at supporting Haiku, with the minimum to compile.

Copie d'écran_20250204_114510

@@ -1088,6 +1090,74 @@ elseif(SunOS)
src/util/platform/FFPlatform_unix.c
src/util/binary_linux.c
)
elseif(Haiku)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does Haiku support OpenGL, pulseaudio or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenGL yes, we have our own audio framework (MediaKit)… I wanted to have something that compiles before expanding to these.

continue;
#ifdef IFF_RUNNING
if (!(ifa->ifa_flags & IFF_RUNNING))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can we know if it's running then?

Copy link
Contributor Author

@mmuman mmuman Feb 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK this is not really used in most drivers on Linux anyway, it's here for BSD compatibility.

I'll add our own extra flags that I missed (IFF_LINK,…CONFIGURING…).

I suppose I could fake it when UP & LINK…

@CarterLi
Copy link
Member

CarterLi commented Feb 4, 2025

Thanks for your interest. Can we set up a CI to ensure it won't be broken unexpectedly?

@mmuman
Copy link
Contributor Author

mmuman commented Feb 4, 2025

I'm not sure we can get it into the GitHub CI stuff, since we build the cross-compiler from our own build system only to generate the image…
We do have our own buildbots but they generate the official packages.

@mmuman
Copy link
Contributor Author

mmuman commented Feb 4, 2025

Thanks for your interest. Can we set up a CI to ensure it won't be broken unexpectedly?

So I asked around, we have:

@mmuman mmuman force-pushed the haiku-port branch 2 times, most recently from 28fc078 to 1a1a728 Compare February 4, 2025 21:48
@mmuman
Copy link
Contributor Author

mmuman commented Feb 4, 2025

  • fixed boot time
  • patch "BePC" as "i386" architecture
  • add proper config dir.

@mmuman
Copy link
Contributor Author

mmuman commented Feb 4, 2025

  • fixed OS in version info
  • we have a non-standard path for /etc/resolv.conf

@mmuman
Copy link
Contributor Author

mmuman commented Feb 4, 2025

  • added font support

@mmuman
Copy link
Contributor Author

mmuman commented Feb 4, 2025

I think I picked all the low-hanging fruits, maybe we can get this in already?

@mmuman
Copy link
Contributor Author

mmuman commented Feb 5, 2025

For the record, the JSON output: ff.json

@CarterLi
Copy link
Member

CarterLi commented Feb 5, 2025

The IFF_ string prefix in localip_linux.c should be removed. I'm ok with others.

@mmuman
Copy link
Contributor Author

mmuman commented Feb 5, 2025

Oh right, missed that!

@CarterLi CarterLi merged commit 01f400c into fastfetch-cli:dev Feb 5, 2025
@CarterLi
Copy link
Member

CarterLi commented Feb 5, 2025

Thanks for your contribution. I wonder how the output is comparing to neofetch's

@mmuman
Copy link
Contributor Author

mmuman commented Feb 5, 2025

Much fancier:
Copie d'écran_20250205_021115

@mmuman mmuman deleted the haiku-port branch February 5, 2025 01:13
@CarterLi
Copy link
Member

CarterLi commented Feb 5, 2025

src/detection/os/os_uname.c

This file doesn't exist. Does your code really compile?

@Begasus
Copy link

Begasus commented Feb 5, 2025

src/detection/os/os_uname.c

This file doesn't exist. Does your code really compile?

That should be os_haiku.c, I think @mmuman used the nightly version for this, on R1B5 64bit I still need to apply a seperate patch for pipe2 and memmem.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1a8b39d..9435569 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1607,6 +1607,7 @@ elseif(Haiku)
     target_link_libraries(libfastfetch
         PRIVATE "network"
         PRIVATE "be"
+        PRIVATE "gnu"
     )
 endif()
 
diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c
index 63d3951..02d3bf8 100644
--- a/src/common/processing_linux.c
+++ b/src/common/processing_linux.c
@@ -34,7 +34,7 @@ enum { FF_PIPE_BUFSIZ = 8192 };
 
 static inline int ffPipe2(int *fds, int flags)
 {
-    #ifdef __APPLE__
+    #if defined(__APPLE__) || defined(__HAIKU__)
         if(pipe(fds) == -1)
             return -1;
         fcntl(fds[0], F_SETFL, fcntl(fds[0], F_GETFL) | flags);
-- 

fastfetch

CarterLi added a commit that referenced this pull request Feb 5, 2025
@CarterLi
Copy link
Member

CarterLi commented Feb 5, 2025

@Begasus Please test the newest commit

Some issue I found from your screenshot

  1. Seems the monitor name isn't available on current version
  2. The terminal name is wrong. I think ffProcessGetInfoLinux and ffProcessGetBasicInfoLinux in processing_linux.c lack a proper implementation for Haiku
  3. The ifa name in Haiku is a device path?
  4. fastfetch should report R1B5 instead of 1

@Begasus
Copy link

Begasus commented Feb 5, 2025

Thanks so far! Looks promising (mind you I'm no developer, @mmuman is the real one :)

No patching with master checkout:

fastfetch_2

@mmuman
Copy link
Contributor Author

mmuman commented Feb 5, 2025

src/detection/os/os_uname.c

This file doesn't exist. Does your code really compile?

Oops, thought I replaced it with the haiku one, that was a test.

@mmuman
Copy link
Contributor Author

mmuman commented Feb 5, 2025

1. Seems the monitor name isn't available on current version

The code is there but the API returns an error, so either it's not implemented at all, or at least on VESA mode.

2. The terminal name is wrong. I think ffProcessGetInfoLinux and ffProcessGetBasicInfoLinux in `processing_linux.c` lack a proper implementation for Haiku

That can probably be fixed.

3. The ifa name in Haiku is a device path?

For most network interfaces yes, for historical reasons.

4. fastfetch should report `R1B5` instead of `1`

Yes, I didn't find an easy way to find that yet, we'd have to dig the resources in the kernel file or something.

@Begasus
Copy link

Begasus commented Feb 5, 2025

Quick check on a 32bit laptop :)

fastfetch_32bit

PS, is there some color switch mode? Terminal with white background doesn show the logo too wel.

@CarterLi
Copy link
Member

CarterLi commented Feb 5, 2025

--bright-color false may help. If the terminal reports $COLORFGBG, fastfetch will detect whether the terminal is in light mode and set --bright-color false by default

Alternatively, we may set

FF_COLOR_FG_WHITE,
to FF_COLOR_FG_DEFAULT, so that fastfetch will use black color in light mode.

@Begasus
Copy link

Begasus commented Feb 5, 2025

to FF_COLOR_FG_DEFAULT, so that fastfetch will use black color in light mode.

That worked, --bright-color false didn't do the trick.

fastfetch_whitebg

Comment on lines +9 to +12
if (!(options->disabled & FF_PACKAGES_FLAG_PKG_BIT))
result->pkg = ffPackagesGetNumElements(FASTFETCH_TARGET_DIR_ROOT "/system/packages", false);
if (!(options->disabled & FF_PACKAGES_FLAG_PKGSRC_BIT))
result->pkgsrc = ffPackagesGetNumElements(FASTFETCH_TARGET_DIR_ROOT "/boot/home/config/packages", false);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usage of pkg and pkgsrc here doesn't really make sense. These are the same kind of packages (Haiku packages, "hpkg"), but rather system packages and user packages, respectively.

I see that there is such a distinction already for other packaging systems (e.g. for flatpak here). So I think it would make sense to add haikuSystem and haikuUser there as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I just used that because I wasn't sure how it was categorized, but that'd be better.
Ideally we'd query the Package Kit because some packages could be disabled.

@mmuman
Copy link
Contributor Author

mmuman commented Feb 15, 2025

Hmm the newest commits fail to build on 32bit…

@Begasus
Copy link

Begasus commented Feb 15, 2025

437006f still builds here on R1B5 32bit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants