ungoogled-software / ungoogled-chromium

Google Chromium, sans integration with Google
BSD 3-Clause "New" or "Revised" License
20.21k stars 818 forks source link

Static build of ungoogled-chromium #929

Closed sxiii closed 4 years ago

sxiii commented 4 years ago

Is your feature request related to a problem? Please describe. I have a specialized Linux distro that needs stuff to be compiled from the source code.

Describe the solution you'd like The distro I use has specific versions of libraries etc. etc. So I wonder - if there is a way to build ungoogled-chromium as a static binary file? To distribute to my specific OS.

Describe alternatives you've considered Running something in docker -> but it doesn't fully work on my distro.

mbakke commented 4 years ago

Not quite what you are asking, but if you have a spare computer you can install GNU Guix and use guix pack --relocatable ungoogled-chromium to get a distro-independent tarball containing ungoogled-chromium and all its dependencies. The tarball can be unpacked anywhere and will be approximately 1.5 GiB in size.

You can likely also just install Guix directly and then use guix install ungoogled-chromium, as Guix has no dependencies other than the Linux kernel and works entirely isolated from the host distro.

sxiii commented 4 years ago

Wow thanks a lot @mbakke; this sound as a good solution. I am trying it right now in a virtualbox. By the way, it builds version 74 of ungoogled chromium; is there a way to build a newer one?

sxiii commented 4 years ago

Now it has to do something with ungoogled-chromium default fonts...

[sw@t490s guix-ugch]$ ./bin/chromium --no-sandbox

(process:3700): Gtk-WARNING **: 16:28:21.498: Locale not supported by C library.
    Using the fallback 'C' locale.
Gtk-Message: 16:28:21.503: Failed to load module "canberra-gtk-module"
Gtk-Message: 16:28:21.503: Failed to load module "canberra-gtk-module"
[3721:3721:0208/162821.677023:ERROR:vaapi_wrapper.cc(335)] vaInitialize failed: unknown libva error
[3721:3721:0208/162821.719006:ERROR:sandbox_linux.cc(368)] InitializeSandbox() called with multiple threads in process gpu-process.
[3700:3700:0208/162821.718777:FATAL:platform_font_skia.cc(83)] Check failed: InitDefaultFont(). Could not find the default font
#0 0x56545edf53b9 base::debug::CollectStackTrace()

Received signal 6
#0 0x56545edf53b9 base::debug::CollectStackTrace()
  r8: 0000000000000000  r9: 00007ffd54c2a950 r10: 0000000000000008 r11: 0000000000000246
 r12: 00007ffd54c2b3a0 r13: 00007fb1029f3840 r14: 000000000000007f r15: 00007ffd54c2abc0
  di: 0000000000000002  si: 00007ffd54c2a950  bp: 00007ffd54c2ab90  bx: 00007ffd54c2b810
  dx: 0000000000000000  ax: 0000000000000000  cx: 00007fb102874b10  sp: 00007ffd54c2a9c8
  ip: 00007fb102874b10 efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
 trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.
sxiii commented 4 years ago

UPDATE: tried to include font-gnu-freefont-ttf by issuing guix install font-gnu-freefont-ttf, then added this package into "relocatable pack", tested again and the same error persists anyway.

ADD: this guix pack --relocatable -S /bin=bin -S /etc=etc ungoogled-chromium gont-gnu-freefont-ttf gs-fonts font-dejavu does not help either.

sxiii commented 4 years ago

Trying to install this package: https://guix.gnu.org/packages/ungoogled-chromium-79.0.3945.130-0.e2fae99/ but without success...

mbakke commented 4 years ago

Unfortunately including more fonts in the pack won't make Chromium aware of them. That's because fonts on GNU/Linux do not have a composable search path like FONT_DIRECTORY where applications can look for fonts. That would be too easy!

To make the packed fonts visible, try including fontconfig in the pack, and then on the target machine create ~/.config/fontconfig/fonts.conf:

 <?xml version="1.0"?>
 <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
 <fontconfig>
 <dir>/home/me/the-chromium-pack/share/fonts</dir>
 </fontconfig>

You might need to do -S /share=share so that the font directory is easily accessible. Then with this file in place, run ./bin/fc-cache -frv: that will make all fonts found on the specified location available to any application.

Hope this works & good luck!

Edit: fixed typo

Eloston commented 4 years ago

The closest we have to a static build is ungoogled-chromium-portablelinux. Otherwise you're free to use other solutions like the one @mbakke proposed.

Closing this issue. Feel free to continue discussing.

sxiii commented 4 years ago

@mbakke trying to run guix pack --relocatable -S /bin=bin -S /etc=etc -S /share=share ungoogled-chromium font-gnu-freefont-ttf gs-fonts font-dejavu fontconfig on the GUIX VM now. After I'll test I will update this message.

UPDATE: HEY! Thanks @mbakke that magically worked! Also what's strange; after I rebooted (actually, the GUIX VM just was off, and today I turned it on again); the ungoogled chromium is now at version 79! Cool. The result archive weight somewhere less 500 mb.

I will now try to move the package to the server where it actually should work and I'll report if it succeeds. Thanks again for your help!

sxiii commented 4 years ago

Seems I still get some font errors (when I've tried on the server), I don't know if they are warning-level or error-level; but here is the log:

/bin/chromium --no-sandbox --headless                                               
Fontconfig error: "/home/s/.config/fontconfig/fonts.conf", line 1: XML or text declaration not at start of entity
[0210/121354.553695:FATAL:platform_font_skia.cc(97)] Check failed: InitDefaultFont(). Could not find the default font
#0 0x55ac7c6fb349 base::debug::CollectStackTrace()
Task trace:
#0 0x55ac7c1aa6a9 headless::HeadlessShell::OnStart()
#1 0x55ac7c1aa6a9 headless::HeadlessShell::OnStart()

Received signal 6
#0 0x55ac7c6fb349 base::debug::CollectStackTrace()
  r8: 0000000000000000  r9: 00007ffffd1e2e40 r10: 0000000000000008 r11: 0000000000000246
 r12: 00007ffffd1e4090 r13: 0000000000000075 r14: 00007ffffd1e4260 r15: 00007ffffd1e30c0
  di: 0000000000000002  si: 00007ffffd1e2e40  bp: 00007ffffd1e3080  bx: 0000000000000006
  dx: 0000000000000000  ax: 0000000000000000  cx: 00007f4979e6c7fa  sp: 00007ffffd1e2eb8
  ip: 00007f4979e6c7fa efl: 0000000000000246 cgf: 002b000000000033 erf: 0000000000000000
 trp: 0000000000000000 msk: 0000000000000000 cr2: 0000000000000000
[end of stack trace]
Calling _exit(1). Core file will not be generated.
[0210/121354.606467:ERROR:vaapi_wrapper.cc(403)] Could not get a valid VA display
mbakke commented 4 years ago

Hmm, try removing the first two lines of ~/.config/fontconfig/fonts.conf and run ./bin/fc-cache -frv again.

sxiii commented 4 years ago

Thanks @mbakke actually the problem was that I had a SPACE before the <?xml; after I removed it everything went fine. So I was able to use ungoogled-chromium to actually screenshot a webpage (that was my goal) on a "kinda-unsupported" platform! I used this (in case somebody would need it):

./gowitness-linux-amd64 --chrome-path ./ugch/bin/chromium --chrome-time-budget 10 single --url 'http://distrowatch.com'

Or, another way, directly from chrome:

./bin/chromium --headless --no-sandbox --no-default-browser-check --no-first-run --no-experiments --disable-gpu --window-size=1920,1080 --hide-scrollbars --screenshot http://distrowatch.com

It magically works. Thanks @mbakke for all your support! You're the hero!

NB: This is very helpful for guix.

mbakke commented 4 years ago

Awesome, glad it worked @sxiii. Thanks for the updates and kind words! :-)