Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Building the new sway 1.0 alpha from source
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
AnukWolf
n00b
n00b


Joined: 14 Oct 2018
Posts: 5

PostPosted: Sun Oct 14, 2018 1:51 pm    Post subject: Building the new sway 1.0 alpha from source Reply with quote

Hey everyone!

First of all, I'm really really new to Gentoo, so pardon my missing experience :D
Coming from Arch to Gentoo to find a more thought-out, well made distro and I really like it so far.

On Arch, I had the newest 1.0 alpha 6 version of sway installed via AUR.
It worked really well and I'd like to replicate this setup on Gentoo as well, if possible.

I already informed myself a bit about ebuilds and how they're written, and to me it seems like,
since the newest sway-9999 in Gentoo reps isn't exactly pointing to the much newer v1.0-alpha6 source,
I'll have to write my own ebuilds for that.

For now, I also looked into what packages I can source straight from the stable/testing repositories, and which ones are still missing.
I'm running a Gentoo 17.0 amd64 install straight from the handbook, if that's of any interest.

swaywm/sway dependencies:

  • dev-util/meson
  • dev-libs/wayland
  • dev-libs/libinput >= 1.6.0
  • x11-libs/pango
  • x11-libs/cairo
  • x11-libs/gdk-pixbuf *
  • sys-libs/pam **
  • sys-apps/dbus >= 1.10 ***
  • app-text/scdoc (requires ~amd64)
  • sys-libs/libcap

    Not found:
  • wlroots
  • xwayland
  • pcre
  • json-c >= 0.13 (only found 0.12)

swaywm/wlroots dependencies:

  • dev-util/meson
  • dev-libs/wayland
  • dev-libs/wayland-protocols
  • x11-libs/libdrm
  • dev-libs/libinput
  • x11-libs/libxkbcommon
  • sys-fs/udev
  • x11-libs/pixman
  • sys-apps/systemd or sys-auth/elogind (optional, for logind support)
  • sys-libs/libcap (optional, for capability support)

    Not found/not sure:
  • EGL
  • GLESv2 (apparently EGL and GLESv2 are built into mesa?)
  • GBM (also mesa?)


Doesn't look too bad to me. I just don't know where to find xwayland, pcre and the newer json-c from.

I'd like to seek help here on how to proceed, asking if it is possible and what's the best way to do it.
If it works well, of course I'd love to contribute something in the end and also have learned more about how everything works :)

Best regards, Anuk.
_________________
Running default/linux/amd64/17.0 (stable) on
Xeon E3 1230v3, MSI H87-G43 Gaming, 16GB DDR3-1600, ASUS R9 280X DC2T, ASUS Xonar DX Soundcard
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 30905
Location: here

PostPosted: Sun Oct 14, 2018 3:20 pm    Post subject: Reply with quote

At first welcome to gentoo forum!

Quote:
I already informed myself a bit about ebuilds and how they're written, and to me it seems like,
since the newest sway-9999 in Gentoo reps isn't exactly pointing to the much newer v1.0-alpha6 source,
I'll have to write my own ebuilds for that.

You right because in ebuild there is
Code:
EGIT_REPO_URI="https://github.com/swaywm/sway.git"
EGIT_BRANCH="0.15"

then 9999 ebuild point to 0.15 branch.

Quote:
Doesn't look too bad to me. I just don't know where to find xwayland, pcre and the newer json-c from.

xwayland -> x11-base/xorg-server with wayland use flag active (x11-base/xorg-server[wayland])
pcre -> dev-libs/libpcre or dev-libs/libpcre2
json-c -> dev-libs/json-c, 0.12 is latest stable but in tree there is also masked version 0.13.1-r1 (install eix to search packages)
egl, gles2, gbm -> media-libs/mesa with use flags gles2 egl

Quote:
I'd like to seek help here on how to proceed, asking if it is possible and what's the best way to do it.

I think first step is create your local overlay and put sway-9999 ebuild on it.
From here you can try to modify the ebuild for version 1.0-alpha.6.

https://wiki.gentoo.org/wiki/Basic_guide_to_write_Gentoo_Ebuilds
https://devmanual.gentoo.org/ebuild-writing/index.html
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
AnukWolf
n00b
n00b


Joined: 14 Oct 2018
Posts: 5

PostPosted: Sun Oct 14, 2018 10:03 pm    Post subject: Reply with quote

First of all, thank you very much for the quick, and really helpful reply!
I created a local repository and wrote my first ebuild file,
hope it's not too bad :)
Code:
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6

inherit git-r3

DESCRIPTION="A modular Wayland compositor library"
HOMEPAGE="https://github.com/swaywm/wlroots"

EGIT_REPO_URI="https://github.com/swaywm/wlroots.git"

LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64"
IUSE="X -systemd -elogind"
REQUIRED_USE="?? ( systemd elogind )"

RDEPEND="dev-libs/wayland
   dev-libs/wayland-protocols
   x11-libs/libdrm
   dev-libs/libinput
   x11-libs/libxkbcommon
   x11-libs/pixman
   virtual/opengl
   virtual/libudev
   media-libs/mesa[wayland,gbm,gles2,egl]
   
   X? (
      x11-libs/libX11
      x11-libs/libxcb[xkb]
      x11-libs/xcb-util-image
      x11-libs/xcb-util-wm
      x11-libs/libXfixes
   )

   systemd? ( sys-apps/systemd )
   elogind? ( sys-auth/elogind )"

DEPEND="${RDEPEND}
   dev-util/meson
   dev-util/ninja"

src_compile() {
   meson build
   ninja -C build
}

src_install() {
   ninja -C build install
}


I tried to merge it but I got errors somewhere around package 39/53, which is sys-devel/llvm-6.0.1.
Guess I gotta fix those first before testing the actual ebuild.

edit: According to build log it's a "internal compiler error: segmentation fault". I read in another thread that it might either be due to faulty memory modules, or due to "-j9" make flag. I'm currently recompiling llvm using -j1 and see if it helps.
_________________
Running default/linux/amd64/17.0 (stable) on
Xeon E3 1230v3, MSI H87-G43 Gaming, 16GB DDR3-1600, ASUS R9 280X DC2T, ASUS Xonar DX Soundcard
Back to top
View user's profile Send private message
AnukWolf
n00b
n00b


Joined: 14 Oct 2018
Posts: 5

PostPosted: Sun Oct 14, 2018 11:47 pm    Post subject: Reply with quote

Almost there!
wlroots requires a
Code:
sudo ninja -C build install

and of course omitting that in the ebuild leads to this error.

However, I just read that installing the build in src_install() directly to the live system is the
actual reason of this vialoation error. I don't know how to fix this though.
Apparently, the meson build system (in wlroot's meson.build file) defines whether files shall be installed or not,
and decides on the path automatically.. It would be easier if I could append the correct path to ninja in src_install().

I will look into how to install those files using the EAPI functions tomorrow.
If anyone has an idea how to do this, please let me know :)
_________________
Running default/linux/amd64/17.0 (stable) on
Xeon E3 1230v3, MSI H87-G43 Gaming, 16GB DDR3-1600, ASUS R9 280X DC2T, ASUS Xonar DX Soundcard
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21624

PostPosted: Mon Oct 15, 2018 12:03 am    Post subject: Reply with quote

[Edit: when I began writing, the last line quoted from AnukWolf in my post was the last line in his post. His discovery of sandbox rules was edited in while I was composing.]

You may be able to delegate some of this work to helper functions from an eclass. I am not familiar with meson, so I cannot say what helpers are available for this tool. Read /usr/portage/eclass/meson.eclass to see what is provided, and inherit meson if you want to make it available in your ebuild.
AnukWolf wrote:
Code:
IUSE="X -systemd -elogind"
- is not necessary here. Use:
Code:
IUSE="X systemd elogind"
AnukWolf wrote:
Almost there!
wlroots requires a
Code:
sudo ninja -C build install
No, it does not. Did you decide this based on the linked error text or did you encounter documentation which told you to use this solution? From the linked error, the problem is that it tried to install to a system directory instead of installing to the package staging area. This is deliberately blocked. The package must copy its files to a temporary area so that Portage can collect a list of what is installed. Portage will then handle copying the temporary area to the live filesystem.

The src_install provided by meson.eclass looks like it handles this correctly. You can probably remove your src_install, add inherit meson, and rely on the default provided by the eclass.
AnukWolf wrote:
Is it "good practice" to put sudo (or some other su command) into ebuilds or is there a more elegant way?
That is never correct practice. Portage will run phases as root when that is required.
Back to top
View user's profile Send private message
AnukWolf
n00b
n00b


Joined: 14 Oct 2018
Posts: 5

PostPosted: Mon Oct 15, 2018 7:40 am    Post subject: Reply with quote

Hu wrote:
[Edit: when I began writing, the last line quoted from AnukWolf in my post was the last line in his post. His discovery of sandbox rules was edited in while I was composing.]

This happens when you don't expect someone to reply so quickly. Sorry :)

Hu wrote:

You may be able to delegate some of this work to helper functions from an eclass. I am not familiar with meson, so I cannot say what helpers are available for this tool. Read /usr/portage/eclass/meson.eclass to see what is provided, and inherit meson if you want to make it available in your ebuild.

Thanks, I didn't know there were these kind of functions for other build tools as well.
Looks like it could work this way. Now I can also look for other ebuilds using this eclass to see how they did it.

Hu wrote:

No, it does not. Did you decide this based on the linked error text or did you encounter documentation which told you to use this solution? From the linked error, the problem is that it tried to install to a system directory instead of installing to the package staging area. This is deliberately blocked. The package must copy its files to a temporary area so that Portage can collect a list of what is installed. Portage will then handle copying the temporary area to the live filesystem.

Yeah I tried to use the build functions stated on their github page first. It makes sense that this is blocked, I'll keep that in mind.

Hu wrote:

The src_install provided by meson.eclass looks like it handles this correctly. You can probably remove your src_install, add inherit meson, and rely on the default provided by the eclass.

Alright, perfect. I'll try that out later!
_________________
Running default/linux/amd64/17.0 (stable) on
Xeon E3 1230v3, MSI H87-G43 Gaming, 16GB DDR3-1600, ASUS R9 280X DC2T, ASUS Xonar DX Soundcard
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 30905
Location: here

PostPosted: Mon Oct 15, 2018 7:53 am    Post subject: Reply with quote

AnukWolf wrote:
Thanks, I didn't know there were these kind of functions for other build tools as well.
Looks like it could work this way. Now I can also look for other ebuilds using this eclass to see how they did it.

See also eclasses reference
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
AnukWolf
n00b
n00b


Joined: 14 Oct 2018
Posts: 5

PostPosted: Tue Oct 16, 2018 10:31 am    Post subject: Reply with quote

Hey everyone. I made really good progress, but a new strange problem came up.
I implemented a sway ebuild and a wlroots ebuild.

Emerged them successfully, but when running sway it just froze the display. Everything else is still working, I can do stuff via ssh,
I can push the power button (acpi scripts) but I can't use the display anymore, not even switch ttys (I guess I can but the display doesnt show it).
Reconnecting doesn't help either.

This sounds like a hardware or kernel config issue at first, however, I upgraded the kernel to 4.18, and enabled all flags needed for AMDGPU to work.
Then I emerged weston (the reference wayland compositor) and it works beautifully (although XDG_RUNTIME_DIR isnt set but thats easy).

I also tried running glxinfo on weston but it doesnt find a display.
I heard that sway needs OpenGLES, however weston can run with the pixman renderer.
I'm starting to think that its an OpenGL issue here, perhaps due to missing dependencies (or wrong use flags).

I'll try to re-emerge mesa and closely look at its output, I might be able to find something.

Best regards, Anuk
_________________
Running default/linux/amd64/17.0 (stable) on
Xeon E3 1230v3, MSI H87-G43 Gaming, 16GB DDR3-1600, ASUS R9 280X DC2T, ASUS Xonar DX Soundcard
Back to top
View user's profile Send private message
josephg
l33t
l33t


Joined: 10 Jan 2016
Posts: 783
Location: usually offline

PostPosted: Tue Oct 16, 2018 11:03 pm    Post subject: Reply with quote

When I last tried sway, I did an emerge sway and it pulled in all the required dependencies prompting me for useflags where required. It might help if you install sway from the gentoo repo, even if you don't want to use that version. That process itself might resolve your dependency issues. Once you have sway working from the repo, you could upgrade to the latest bleeding edge hopefully working as all dependencies are already installed.
_________________
"Growth for the sake of growth is the ideology of the cancer cell." Edward Abbey
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21624

PostPosted: Wed Oct 17, 2018 1:28 am    Post subject: Reply with quote

josephg wrote:
It might help if you install sway from the gentoo repo, even if you don't want to use that version.
This could be more easily accomplished by using emerge --onlydeps on the Gentoo package to ask Portage to install all required dependencies, but not install the named package. The user could then install the overlay package, without the need to remove the unwanted Gentoo version first.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum