oxen-io / session-desktop

Session Desktop - Onion routing based messenger
https://getsession.org
GNU General Public License v3.0
1.56k stars 196 forks source link

[Feature Request] ARM64 #1635

Open FatBirdie opened 3 years ago

FatBirdie commented 3 years ago

Hi Would love to see an AppImage made for Arm64 so Session could be run on Raspberry, Pine etc. I'm not sure if interest for this is very low or non existent, but if you have a need for it please give this a thumbs up.

Cheers!

ryouko-dev commented 3 years ago

As someone that has primarily ARM devices due to not being able to afford something better, this would be a huge quality of life improvement.

To my knowledge, this would be required to get it to run on a PinePhone as well since they use an Allwinner A64 SoC. The PinePhone would need additional support through proper UI scaling but that's already been mentioned in issue #1304.

BugInACode commented 3 years ago

Has any progress for this to be added as a feature been made? I own a pinephone and would really appreciate support for arm64 - either being able to build from source or as an AppImage.

Happy to help debug/contribute too.

Bilb commented 3 years ago

Hey,

I cannot test this all the way as I only have a remove raspi 4 without a display, but I get a Gtk-WARNING **: 03:01:32.435: cannot open display:

so I guess it almost start. Maybe the screen not present is the only left issue? Here is what I did:

in package.json change the build-release command to

    "build-release": "cross-env SIGNAL_ENV=production electron-builder --config.extraMetadata.environment=production --publish=never --config.directories.output=release --arm64",

(just add the --arm64 at the end in fact)

then run

yarn icon-gen
yarn build-release

it should build you a file release/session-desktop-linux-arm64-1.6.6.AppImage

see the arm64 in its name. upload that to your raspberry. try to start it, complains about missing libz.so

looks like the library is installed on raspi with the version number /usr/lib/aarch64-linux-gnu/libz.so.1 so you just need to sudo ln -s /usr/lib/aarch64-linux-gnu/libz.so.1 /usr/lib/aarch64-linux-gnu/libz.so and then ./session-desktop-linux-arm64-1.6.6.AppImage

At this point, it just asks on my side for a screen. What do you get?

BugInACode commented 3 years ago

@Bilb Thanks for the response, unfortunately I could not run yarn icon-gen and got the following error. Searching online I could not find what exit code 127 was relating to.

mobian@mobian:~/session-desktop$ yarn icon-gen
yarn run v1.22.10
$ electron-icon-maker --input=images/session/session_icon_1024.png --output=./build
/bin/sh: 1: electron-icon-maker: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Can you confirm I should be building this on the pinephone, or should I do this on another linux machine (amd64) and then transfer the AppImage across?

FatBirdie commented 3 years ago

Never used Yarn before, getting this error, both on my PI and my x64: $ yarn icon-gen 00h00m00s 0/0: : ERROR: [Errno 2] No such file or directory: 'icon-gen'

Bilb commented 3 years ago

@Bilb Thanks for the response, unfortunately I could not run yarn icon-gen and got the following error. Searching online I could not find what exit code 127 was relating to.

mobian@mobian:~/session-desktop$ yarn icon-gen
yarn run v1.22.10
$ electron-icon-maker --input=images/session/session_icon_1024.png --output=./build
/bin/sh: 1: electron-icon-maker: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Can you confirm I should be building this on the pinephone, or should I do this on another linux machine (amd64) and then transfer the AppImage across?

I tried on my x64 so I would recommend doing the same.

About your error. Did you run yarn install --frozen before?

Bilb commented 3 years ago

Never used Yarn before, getting this error, both on my PI and my x64: $ yarn icon-gen 00h00m00s 0/0: : ERROR: [Errno 2] No such file or directory: 'icon-gen'

what is the yarn package installed? it's not supposed to be a binary you installed from your repository but an npm global binary

Before trying to build a release you should first follow those steps as seen in the Building.md file

sudo apt-get install python2
# install nvm by following their github README
nvm install # install the current node version used in this project
nvm use # use the current node version used in this project
npm install -g yarn # install yarn globally for this node version
yarn install --frozen-lockfile # install all dependecies of this project
yarn grunt # transpile and assemble files

then which yarn should return something like ~/.nvm/versions/node/v14.17.1/bin/yarn

Only then you can try to do what I am taking about in this comment

BugInACode commented 3 years ago

@Bilb

About your error. Did you run yarn install --frozen before?

I decided to clone the repo and begin from scratch on my x64, when I run this I got this output

However I decided to continue building and created the AppImage. I moved it to the pinephone and executed ./session-desktop-linux-1.6.7.AppImage (on the pinephone, not through ssh) and got the following output, unsure whether the two are related.

EDIT: I changed the outputs to be uploaded to the pastebin so the thread is tidy

Bilb commented 3 years ago

In thr first output, you get an error here import sys; print "%s.%s.%s" % sys.version_info[:3]; this looks very much like a python3 as default error.

Can you tell me what's returned by which python & python --version ?

BugInACode commented 3 years ago

Ah yes, my mistake I thought it was changed to python2 after installing.

$ which python
/home/aquarius/anaconda3/bin/python
$ python --version
Python 3.7.6

I have two python binaries python2 and python2.7, does it matter which one is used? There is a symbolic link between them

Bilb commented 3 years ago

you should be able to overide your default python temporary just with this command alias python=/usr/bin/python2.7 (or wherever python is installed locally)

and rerun your command yarn install --frozen

BugInACode commented 3 years ago

Just reran yarn install --frozen-lockfile and did not produce any errors. yarn icon-gen and yarn build-release also completed successfully, however I still get an error after running the AppImage on the pinephone. The cause seems different to the one I mentioned earlier but seems like it produced the same error. This is the output

Bilb commented 3 years ago

before build-release you also need to compile .ts and .tsx files to js. with yarn grunt

BugInACode commented 3 years ago

yarn grunt had no errors but the AppImage being run on the pinephone did not change as per my last response.

peepo5 commented 3 years ago

maybe just compile on amd64 PC with electron-builder config like

electron-builder build --linux ... --arm64 --armv7l

BugInACode commented 3 years ago

When I try to install electron-builder using yarn add electron-builder [--dev] I am unable to as there is a conflict between some modules. If using nvm v10.19.0 there is an error of

error builder-util-runtime@8.7.7: The engine "node" is incompatible with this module. Expected version ">=12.0.0". Got "10.19.0"
error Found incompatible module.

and if nvm v12.0.0 is used then the following error is produced

error session-desktop@1.6.7: The engine "node" is incompatible with this module. Expected version "^10.19.0". Got "12.0.0"
error Found incompatible module.

As with FatBirdie this too my first time using these commands and I am unsure how to move forward from here.

As with the error log from my previous comment, I am not sure where the error is coming from as on lines 6-9 it appears that in the home/mobian/.config/Session folder there is only one (empty) folder named Dictionaries/. Is this what should be expected?

BugInACode commented 3 years ago

@Bilb @peepopoggers I have taken this a few steps back and attempted to build the AppImage for my x64 and was able to run it. I have then proceeded to create the AppImage for my own raspberry pi but I am unable to execute the AppImage as I get the error below.

I followed the below steps in order, can you let me know if I'm building correctly?

On x64

git clone <repo>
cd session-desktop/
nano package.json    # add --arm64 to the end of the build release line
alias python='/usr/bin/python2'
nvm use 10.19.0
npm install -g yarn    # make sure yarn is up to date
yarn install --frozen-lockfile
yarn generate
yarn build-release

Instead of yarn generate I have also tried yarn icon-gen then yarn grunt individually I then copy the AppImage via USB from my x64 to the Raspberry Pi

On Raspberry Pi

pi@raspberrypi:~ $ ./session-desktop-linux-arm64-1.6.7.AppImage 
bash: ./session-desktop-linux-arm64-1.6.7.AppImage: cannot execute binary file: Exec format error
pi@raspberrypi:~ $ sudo !!
sudo ./session-desktop-linux-arm64-1.6.7.AppImage 
./session-desktop-linux-arm64-1.6.7.AppImage: 2: ./session-desktop-linux-arm64-1.6.7.AppImage: Syntax error: "(" unexpected

I've also tried [sudo] chmod [a]+x session-desktop-linux-arm64-1.6.7.AppImage and it returns the same errors.

As I have an external monitor if I can replicate your AppImage for my Raspberry Pi I can also check whether the build was successful before moving back to the pinephone.

Bilb commented 3 years ago

can you try to rebuild on your computer after having removed in package.json the

    "afterPack": "./build/afterPackHook.js"

(and the , right before it). Does that Syntax error: "(" unexpected still happens?

BugInACode commented 3 years ago

No it does not remove the error EDIT: I assume you also meant follow all the steps I took previously and that they are correct

BugInACode commented 3 years ago

Just tried to see if the latest updates fixed this and I can only get so far as to run yarn install --frozen-lockfile and run in to the error

[1/6] Validating package.json... error session-desktop@1.7.3: The engine "node" is incompatible with this module. Expected version "^14.16.0". Got "10.19.0" error Found incompatible module. info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

Any updates on when this will work? The main reason I dont use my pinephone daily yet is because I dont have a secure messaging platform working yet and would really like this to work.

necro-nemesis commented 3 years ago

nvm install 14.16.0 probably giving it what it wants? The instructions I'm guessing are old and it's no longer looking for 10.19.0. Confirm it's installed with nvm --version.

BugInACode commented 3 years ago

@necro-nemesis changing the version to 14.16.0 did allow it to attempt to build yarn install --frozen-lockfile to execute but it failed giving this error. Unfortunately I'm not familiar with this language and am unable to debug it.

necro-nemesis commented 3 years ago

It's having a problem building sqlite3 or .. better-sqlite3 and archiving it. Try installing git-lfs sudo apt install git-lfs and build again. You may need to delete your node modules and yarn clean cache.

BugInACode commented 3 years ago

I was able to build the AppImage for the pinephone, but when I tried opening it I got this error, again not sure how to proceed but it does look like it's almost complete

necro-nemesis commented 3 years ago

You're further ahead than I am at this point. I'm trying to build on a Pi4 to see if it's feasible. Possibly someone working on Session development could throw us a bone?

necro-nemesis commented 3 years ago

One thing I discovered poking around is the annoying network timeout warnings has a an option yarn install --frozen-lockfile --network-timeout 600000

BugInACode commented 3 years ago

I don't think the timeout was a problem for me, I have been building on an x64 system if that makes any difference. Hopefully the devs pull through then!

necro-nemesis commented 3 years ago

timeout was an issue for me and that fixed the option. I've the added challenge on trying to build on 32bit but if the objective is to use on Raspberry Pi OS then I'm limited there. Not sure of the merit in supporting this build but at this point it's just the challenge to see if it will build.

The Linux build instructions could use some attention like listing current dependencies. The correct version to build on etc. I was even looking over the github Actions CI Ubuntu build to see what was there that could be missing. That's where I picked up on the timeout option.

Bilb commented 3 years ago

nvm install 14.16.0 probably giving it what it wants? The instructions I'm guessing are old and it's no longer looking for 10.19.0. Confirm it's installed with nvm --version.

nvm install without version specified, on linux should look for the .nvmrc file containing the right version of nvm to install.

Bilb commented 3 years ago

Could you send me the full logs of the furthest you got ?

BugInACode commented 3 years ago

@Bilb I was able to successfully build and move it to the pinephone, this is what the pinephone returned when I tried ./session-desktop-linux-arm64-1.7.3.AppImage

Bilb commented 3 years ago

@Bilb I was able to successfully build and move it to the pinephone, this is what the pinephone returned when I tried ./session-desktop-linux-arm64-1.7.3.AppImage

Well yes, but i am pretty sure an issue happened during the build and somehow you still got a binary out. I expect some logs to be helpful in the build process.

BugInACode commented 3 years ago

I'm currently in class right now, when it finishes I will rebuild and send thru all the logs

BugInACode commented 3 years ago

I have recloned the repo to start from scratch, here is the full log of the build. I tried the new build just to be sure and it gave the same error output as before.

necro-nemesis commented 3 years ago

I don't see an error being reported anywhere in the build process. Looks like it built all 4 packages. At line 219 it reports building a deb. Have you tried installing and running it? sudo dpkg -i session-desktop-linux-arm64-1.7.3.deb from that folder.

BugInACode commented 3 years ago

I was able to install session on the pinephone using the deb file but it returned the same error (I had to run session-desktop in the terminal) as when I tried the AppImage. It did show up as an application tho, with an icon, it just fails to load. Keeping in mind this was using git-lfs during build, and the error seems related to it...

necro-nemesis commented 3 years ago

FWIW I was able to build and tar better-sqlite3 separately. If you go to the folder where it is built you will see a download script that is the script to build that specific package. It downloads the source as a zip. Unzips it. builds it and and packages three files as a tar.gz. At least in my case it would build a tar that wasn't corrupt which is what it's building, a corrupt tar.gz, when it builds it during the normal process. Like I say you're ahead of me building on 64 bit so I don't have any more I can add to the state you're at atm.

BugInACode commented 3 years ago

It seems like even if the dependency of better-sqlite3 is already built it attempts to rebuild it before building each type of release, saving me from fishing for the line would you happen to know what file/line it's rebuilding and I can go ahead and build separately?

So it looks like rebuilding is actually a bug of yarn. I've got exams coming up so I'll have to post pone chasing it up until after then. Apparently this is a common bug of npm/yarn, if someone else has the time they're welcome to look for a workaround.

necro-nemesis commented 3 years ago

It seems like even if the dependency of better-sqlite3 is already built it attempts to rebuild it before building each type of release, ~saving me from fishing for the line would you happen to know what file/line it's rebuilding and I can go ahead and build separately?~

So it looks like rebuilding is actually a bug of yarn. I've got exams coming up so I'll have to post pone chasing it up until after then. Apparently this is a common bug of npm/yarn, if someone else has the time they're welcome to look for a workaround.

I have nothing to add since this was posted. I played around with building a bit more but made no additional headway.

BugInACode commented 3 years ago

I was procrastinating the other day and never got around to adding anything to this thread but I think there is a problem with dependencies - better-sqlite3 has a dependency of node-gyp and that requires python3 during building... I think when this dependency is added it conflicts with the session-desktop build but I am not 100% sure, I was planning on doing some more digging but so far adding better-sqlite3 + node-gyp does not even let me build. The error occurs during the yarn install stage

necro-nemesis commented 3 years ago

If the docs aren't up to par to cover building it I'm not into playing "Guess My Dependency" to build a package for people that may want one. Seemed like a noble endeavor but I'm not a masochist. Appreciate your effort.

BugInACode commented 2 years ago

Since better-sqlite3 merged pre-built binaries for arm64 I thought I'd give this build another shot but I get this error, is this related to session? If so what can I do to overcome it? I've already tried copying playwright.config.ts into the ts/ folder but still comes up with the same error.

EDIT: I went ahead with the build and it doesn't complain about better-sqlite3, instead it complains about missing module protobufjs/minimal I'll see if I can add the module in and edit this comments with results

EDIT2: Okay so I tried running npm install protobufjs before the yarn install --frozen-lockfile line but when I try and run the installed app on the pinephone I still get the error it can't find the module protobufjs/minimal... not sure where to find the minimal package either. @necro-nemesis @Bilb can either of you chime in here?

necro-nemesis commented 2 years ago

I haven't tried building it since the last round we worked on it and am involved with other development that comes with less unanswered questions to resolve.

Bilb commented 2 years ago

@BugInACode that playwright.config.ts is actually nothing important for dev and only used for integration tests which are a WIP. You can safely delete it and your build should go further.

You should also be able to fix this issue by changing rootDir in tsconfig.json from "./ts" to "./"

BugInACode commented 2 years ago

@Bilb I did both of what you said but it still complains about protobufjs/minimal. Is this package a dependency? I pasted log output in my previous post

BugInACode commented 2 years ago

@Bilb I'd like to document my progress so far in this new comment but also request some further guidance. I have made enough progress that the app tries to start but instead creates a pop-up and in the terminal prints the same error where the pop-up seems to mention the Cannot read property 'prepare' of undefined ... but as soon as it appears it closes itself (i've even tried filming it with a camera and all I can make out is it's to do with that error).

Aside from the error here is what I did to get to this stage:

On x64

git clone <repo>
cd session-desktop/
vim package.json

# add --arm64 to the end of the build release line, change the URL for
# better-sqlite3 to https://github.com/JoshuaWise/better-sqlite3
# finally in the dependencies section add "protobufjs": "^6.11.2", (i added it to the corresponding alphabetical location)

alias python='/usr/bin/python2'
nvm install
nvm use
npm install -g yarn    # make sure yarn is up to date
yarn install --frozen-lockfile # got error of frozen file not updated, fixed by deleting yarn.lock then rerun
yarn generate
yarn build-release

Sent the .deb file to the pinephone

On pinephone

sudo dpkg -i <session>.deb
session-desktop
Bilb commented 2 years ago

Looking at your logs, your first issue is Migration without cipher change failed which happens when trying to open the database and migrate it. Could be a few things and the error {} doesn't help much. Could you make sure your ~/.config/Session* folders are empty before trying to start the app?

Bilb commented 2 years ago

I've just reread your instructions, and sadly updating in package.json dependency of better-sqlite3 to https://github.com/JoshuaWise/better-sqlite3 is going to break the build.

We use a modified better-sqlite3 build better-sqlite3 can be build with and without sqlcipher. By default, and so the one from JoshuaWise, it is built without sqlcipher. sqlcipher adds a way to have an encrypted database instead of a plaintext one.

the build we get from Signal at https://github.com/signalapp/better-sqlite3 has sqlcipher enabled and this is what you need to get with an arm64 flavor.

Those binaries are fetched using git lfs from signal and from there https://github.com/signalapp/better-sqlite3/blob/better-sqlcipher/deps/sqlite3.tar.gz. You can find that file locally on your build machine, and extract it, but I assume it doesn't contain an arm64 build, which is probably your issue.

Maybe you can find more info from signal-desktop issues?

Bilb commented 2 years ago

About protobufjs/minimal, it's my bad. in package.json, the protobufjs dep should be in the dependencies section and not the devDependencies

zpeterg commented 2 years ago

@BugInACode , thanks for posting your summary. I had found a similar set of steps for building on the Pinephone (except protobufjs seems to already be in the package.json now). I ran into the same "prepare of undefined" error in running it with yarn - yarn start-prod.

@Bilb , I suppose the solution would be to make a fork of better-sqlite3 that rebases the signalapp changes onto the latest better-sqlite3. Any idea how realistic that would be to do?