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

Build from source & enable aarch64 build #55

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

proletarius101
Copy link
Contributor

@proletarius101 proletarius101 commented Mar 17, 2021

Fixes #16 #63

The update generated sources action is tested: https://github.com/proletarius101/com.bitwarden.desktop/actions/runs/3997870343/jobs/6859757368

bitwarden-cli should be handled in another PR to make this PR smaller.

@flathubbot
Copy link
Contributor

Started test build 41986

@proletarius101 proletarius101 mentioned this pull request Mar 17, 2021
@flathubbot
Copy link
Contributor

Build 41986 failed

@ghisvail ghisvail mentioned this pull request May 24, 2021
@baarkerlounger
Copy link

Is this blocked upstream?

bitwarden-git.json Outdated Show resolved Hide resolved
- --share=ipc
# TODO: add wayland socket when electron supports wayland
# https://github.com/electron/electron/issues/10915

Choose a reason for hiding this comment

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

Looks like this issue has been closed and Electron (~)supports Wayland since V12. Since Bitwarden is using V19 currently is it worth adding this now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It will be tackled in #99

@flathubbot
Copy link
Contributor

Started test build 19150

@flathubbot
Copy link
Contributor

Build 19150 failed

@flathubbot
Copy link
Contributor

Started test build 19151

@flathubbot
Copy link
Contributor

Build 19151 failed

@flathubbot
Copy link
Contributor

Started test build 19152

@flathubbot
Copy link
Contributor

Build 19152 failed

@flathubbot
Copy link
Contributor

Started test build 19157

@flathubbot
Copy link
Contributor

Started test build 19158

@flathubbot
Copy link
Contributor

Build 19157 failed

@flathubbot
Copy link
Contributor

Build 19158 failed

@flathubbot
Copy link
Contributor

Started test build 19164

@flathubbot
Copy link
Contributor

Build 19164 failed

@proletarius101 proletarius101 changed the title Build from source Build from source & enable aarch64 build Jan 25, 2023
@Newbytee
Copy link

What's blocking this from being merged?

@SethFalco
Copy link

The latest aarch64 release (1.7.0) doesn't work for me. I'm able to launch the app, but if I try to login, I just get a 400 with the error description: Auth Email header invalid.. I don't have this problem on any of my x86_64 devices or in browser.

Since the links above expired, I tried to build and install the branch directly on a device running postmarketOS.

Unfortunately, I ran into errors during build, though. 🤔

# Install git and flatpak-builder
sudo apk update
sudo apk add \
  flatpak-builder \
  git

# Clone the forked repo and switch to the relevent feature branch
git clone https://github.com/proletarius101/com.bitwarden.desktop.git
cd com.bitwarden.desktop
git submodule update --init --recursive
git switch build-from-source

# Install dependencies to build this flatpak
sudo flatpak install \
  org.freedesktop.Platform//22.08 \
  org.freedesktop.Sdk//22.08 \
  org.electronjs.Electron2.BaseApp//22.08 \
  org.freedesktop.Sdk.Extension.node16/aarch64/22.08 \
  org.freedesktop.Sdk.Extension.rust-stable/aarch64/22.08

# Build it
flatpak-builder build-dir com.bitwarden.desktop.yaml
npm verb stack Error: An unknown git error occurred
npm verb stack     at makeError (/usr/lib/sdk/node16/lib/node_modules/npm/node_modules/@npmcli/git/lib/make-error.js:28:13)
npm verb stack     at /usr/lib/sdk/node16/lib/node_modules/npm/node_modules/@npmcli/git/lib/spawn.js:37:26
npm verb stack     at processTicksAndRejections (node:internal/process/task_queues:96:5)
npm verb stack     at async /usr/lib/sdk/node16/lib/node_modules/npm/node_modules/pacote/lib/git.js:262:19
npm verb stack     at async Object.withTempDir (/usr/lib/sdk/node16/lib/node_modules/npm/node_modules/@npmcli/fs/lib/with-temp-dir.js:23:14)
npm verb cwd /run/build/bitwarden-desktop
npm verb Linux 6.3.0
npm verb node v16.20.0
npm verb npm  v8.19.4
npm ERR! code EMFILE
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno -24
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects clone file:///home/user/Documents/repos/flathub/com.bitwarden.desktop/.flatpak-builder/build/bitwarden-desktop-2/flatpak-node/git-packages/duo_web_sdk-29cad7338eff2cd909a361ecdd525458862938be /run/build/bitwarden-desktop/flatpak-node/npm-cache/_cacache/tmp/git-cloneF69E8B --recurse-submodules
npm verb exit -24

Any chance we could get a build from CI again so we can test this?

@flowftw
Copy link

flowftw commented Jun 17, 2023

Building on Asahi Linux on an M1 MacBook Air was successful. However running it afterwards resulted in the following error:

[2 zypak-helper] Wait found events, but sd-event found none
A JavaScript error occurred in the main process
Uncaught Exception:
Error: Cannot find module '@bitwarden/desktop-native-linux-arm64-musl'
Require stack:
- /app/bitwarden-desktop/resources/app.asar/node_modules/@bitwarden/desktop-native/index.js
- /app/bitwarden-desktop/resources/app.asar/main.js
- 
    at Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
    at n._resolveFilename (node:electron/js2c/browser_init:249:1105)
    at Module._load (node:internal/modules/cjs/loader:785:27)
    at c._load (node:electron/js2c/asar_bundle:5:13339)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/app/bitwarden-desktop/resources/app.asar/node_modules/@bitwarden/desktop-native/index.js:174:29)
    at Module._compile (node:internal/modules/cjs/loader:1120:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1175:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)
Gtk-Message: 21:08:17.269: Failed to load module "canberra-gtk-module"
Gtk-Message: 21:08:17.271: Failed to load module "canberra-gtk-module"
[2:0617/210817.283978:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
[2:0617/210817.284008:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
libGL error: MESA-LOADER: failed to open apple: /usr/lib/aarch64-linux-gnu/GL/default/lib/dri/apple_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/aarch64-linux-gnu/GL/default/lib/dri, suffix _dri)
libGL error: failed to load driver: apple
[39:0617/210817.356980:ERROR:viz_main_impl.cc(186)] Exiting GPU process due to errors during initialization
MESA-LOADER: failed to open apple: /usr/lib/aarch64-linux-gnu/GL/default/lib/dri/apple_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/aarch64-linux-gnu/GL/default/lib/dri, suffix _dri)

With the following patch I was able to build and run the flatpak.

diff --git a/com.bitwarden.desktop.yaml b/com.bitwarden.desktop.yaml
index 4d8359a..3dfe1a7 100644
--- a/com.bitwarden.desktop.yaml
+++ b/com.bitwarden.desktop.yaml
@@ -72,6 +72,7 @@ modules:
 
       # Flatpak doesn't support building against musl yet
       - sed -i -e "s,desktop_native.linux-x64-musl,desktop_native.linux-x64-gnu,g" -e "s,@bitwarden/desktop-native-linux-x64-musl,@bitwarden/desktop-native-linux-x64-gnu,g" apps/desktop/desktop_native/index.js
+      - sed -i -e "s,desktop_native.linux-arm64-musl,desktop_native.linux-arm64-gnu,g" -e "s,@bitwarden/desktop-native-linux-arm64-musl,@bitwarden/desktop-native-linux-arm64-gnu,g" apps/desktop/desktop_native/index.js
 
       - npm ci --offline
       - source /usr/lib/sdk/rust-stable/enable.sh; npm run --prefix=apps/desktop/desktop_native build

But I am not really sure if that breaks compatibility on other aarch64 platforms?

@jwillikers
Copy link

@proletarius101 Can you take care of those merge conflicts? I'd love to see this be merged in.

@proletarius101
Copy link
Contributor Author

@proletarius101 Can you take care of those merge conflicts? I'd love to see this be merged in.

I'd like to see it merged as well. But first I need the support of the maintainers of this repository. The only thing left to do after that is to update the version tags.

@jwillikers
Copy link

@proletarius101 Can you take care of those merge conflicts? I'd love to see this be merged in.

I'd like to see it merged as well. But first I need the support of the maintainers of this repository. The only thing left to do after that is to update the version tags.

Who are the maintainers?

Choose a reason for hiding this comment

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

why what this added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the original build script doesn't produce a desktop entry?

Comment on lines +53 to +56
i386:
env:
npm_config_arch: ia32
npm_config_target_arch: ia32

Choose a reason for hiding this comment

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

Suggested change
i386:
env:
npm_config_arch: ia32
npm_config_target_arch: ia32

Comment on lines +61 to +64
arm:
env:
npm_config_arch: armv7l
npm_config_target_arch: armv7l

Choose a reason for hiding this comment

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

Suggested change
arm:
env:
npm_config_arch: armv7l
npm_config_target_arch: armv7l

Comment on lines +147 to +150
i386:
env:
npm_config_arch: ia32
npm_config_target_arch: ia32

Choose a reason for hiding this comment

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

Suggested change
i386:
env:
npm_config_arch: ia32
npm_config_target_arch: ia32

Comment on lines +155 to +158
arm:
env:
npm_config_arch: armv7l
npm_config_target_arch: armv7l

Choose a reason for hiding this comment

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

Suggested change
arm:
env:
npm_config_arch: armv7l
npm_config_target_arch: armv7l

url-template: https://github.com/bitwarden/clients/releases/download/cli-v$version/bw-linux-$version.zip
tag-template: cli-v$version

# `node` binary with patches for `pkg`: https://www.npmjs.com/package/pkg#build

Choose a reason for hiding this comment

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

aren't these in the base app?

Choose a reason for hiding this comment

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

I'd remove the whole file. automerge is being phased out for that use case.

@@ -5,10 +5,13 @@ sdk: org.freedesktop.Sdk
base: org.electronjs.Electron2.BaseApp
base-version: '22.08'

Choose a reason for hiding this comment

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

23.08 is current now.

finish-args:
- --share=ipc
- --share=network
- --socket=wayland
- --socket=x11
- --device=dri
- --env=XDG_CURRENT_DESKTOP=Unity

Choose a reason for hiding this comment

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

why we are at it, why this?

@proletarius101
Copy link
Contributor Author

@hfiguiere Since you've done an extensive review, are you interested in merging this PR if the issues are addressed?

@Haui1112
Copy link

Haui1112 commented May 6, 2024

I tried to help and build this for arm but it fails due to "sdk not specified" but the sdk is specified.

@hfiguiere
Copy link

bot, build

@flathubbot
Copy link
Contributor

Queued test build for com.bitwarden.desktop.

@flathubbot
Copy link
Contributor

Started test build 119236

@hfiguiere
Copy link

@hfiguiere Since you've done an extensive review, are you interested in merging this PR if the issues are addressed?

Don't put the cart before the horse.

  1. I don't maintain that package
  2. There are review comment that are no addressed some marked at rsolved while they were not

@flathubbot
Copy link
Contributor

Build 119236 failed

finish-args:
- --share=ipc
- --share=network
- --socket=wayland
Copy link

Choose a reason for hiding this comment

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

I don't think removing wayland support is desirable, especially in this day and age, but maybe I'm misunderstanding what you're removing here?

Choose a reason for hiding this comment

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

it has both x11 ansd wayland which is wrong. So something must be changed anyway.

@Haui1112
Copy link

Haui1112 commented May 6, 2024

I built it and it succeeded. the bundle does not start on my arm device though. This is the error: any ideas?

�[1m�[47m�[31mA JavaScript error occurred in the main process
�[30mUncaught Exception:
Error: Cannot find module '@bitwarden/desktop-native-linux-arm64-musl'
Require stack:

  • /app/bitwarden-desktop/resources/app.asar/node_modules/@bitwarden/desktop-native/index.js
  • /app/bitwarden-desktop/resources/app.asar/main.js
  • at Module._resolveFilename (node:internal/modules/cjs/loader:940:15)
    at n._resolveFilename (node:electron/js2c/browser_init:249:1105)
    at Module._load (node:internal/modules/cjs/loader:785:27)
    at c._load (node:electron/js2c/asar_bundle:5:13339)
    at Module.require (node:internal/modules/cjs/loader:1012:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object. (/app/bitwarden-desktop/resources/app.asar/node_modules/@bitwarden/desktop-native/index.js:174:29)
    at Module._compile (node:internal/modules/cjs/loader:1120:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1175:10)
    at Module.load (node:internal/modules/cjs/loader:988:32)�[0m
    Gtk-Message: 20:08:07.946: Failed to load module "canberra-gtk-module"
    Gtk-Message: 20:08:07.949: Failed to load module "canberra-gtk-module"
    [2:0506/200807.982554:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
    [2:0506/200807.982746:ERROR:bus.cc(399)] Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory
    MESA: warning: Failed to set BO metadata with DRM_MSM_GEM_INFO: -22

@Newbytee
Copy link

Newbytee commented May 6, 2024

I built it and it succeeded. the bundle does not start on my arm device though. This is the error: any ideas?

It's missing @bitwarden/desktop-native-linux-arm64-musl, so it sounds like you're building outside of Flatpak — I assume you're using postmarketOS? Either way, building it outside of this Flatpak package is off-topic and is best discussed elsewhere.

@Haui1112
Copy link

Haui1112 commented May 6, 2024

I built it and it succeeded. the bundle does not start on my arm device though. This is the error: any ideas?

It's missing @bitwarden/desktop-native-linux-arm64-musl, so it sounds like you're building outside of Flatpak — I assume you're using postmarketOS? Either way, building it outside of this Flatpak package is off-topic and is best discussed elsewhere.

I am using qemu, flatpak-builder and flatpak build bundle on an x68_64 machine. The target device is a OP6 with pmOS indeed but I fail to understand why this happens and also why it would be bad to troubleshoot it since succeeding would help everyone using arm, no? And if it is indeed not possible to troubleshoot it here, can you point me somewhere? pmOS will likely tell me its a flatpak issue.

If you want to take a look at the file: https://files.giftedmc.com/6kaKnS17jzbE.flatpak

This is the command I used to build it:
flatpak-builder --arch=aarch64 --repo=myrepo _flatpak ~/Schreibtisch/com.bitwarden.desktop/com.bitwarden.desktop.yaml --install-deps-from=flathub --force-clean
flatpak build-bundle --arch=aarch64 myrepo app.flatpak com.bitwarden.desktop

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.

Build from source