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

How to pack the application as RPM/deb format under the ARM64 environment #3901

Closed
BSoD-Ultimate opened this issue May 17, 2019 · 17 comments
Closed
Labels

Comments

@BSoD-Ultimate
Copy link

BSoD-Ultimate commented May 17, 2019

  • Version: 20.34.0
  • Target: aarch64

The company I worked is running a project developing a client program based on Electron. The customer requires us to deploy the client on computers having ARM64 architecture. Now we package the client on an aarch64-based server running openSUSE.
So far, there are no problems when packaging the client into an AppImage. However, we found out that the customer's computer only accepts programs installed as rpm/deb format due to unknown security reasons. We added rpm and deb in the linux section in the electron-builder configuration, attempting to package the client into an rpm/deb package on the same aarch64-based computer. The packaging procedure failed as follows:

  • downloading               path=/home/test/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86 url=https://github.com/electron-userland/electron-builder-binaries/releases/download/fpm-1.9.3-2.3.1-linux-x86/fpm-1.9.3-2.3.1-linux-x86.7z
  • downloading               parts=1 size=4.6 MB url=https://github.com/electron-userland/electron-builder-binaries/releases/download/fpm-1.9.3-2.3.1-linux-x86/fpm-1.9.3-2.3.1-linux-x86.7z
  • downloaded                duration=28.855s url=https://github.com/electron-userland/electron-builder-binaries/releases/download/fpm-1.9.3-2.3.1-linux-x86/fpm-1.9.3-2.3.1-linux-x86.7z

 ERROR  `electron-builder` says...

Error: Exit code: 1. Command failed: /home/test/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/fpm -s dir -t rpm --architecture arm64 --name cocall --force --after-install /tmp/t-VCbTzj/0-after-install --after-remove /tmp/t-VCbTzj/1-after-remove --description desc --version 5.1.15 --package /home/test/project/output/client-5.1.15.arm64.rpm ..........................
/home/test/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin/ruby: line 6: /home/test/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin.real/ruby: cannot execute binary file: Exec format error
/home/test/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin/ruby: line 6: /home/test/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin.real/ruby: Success

/home/test/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin/ruby: line 6: /home/test/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin.real/ruby: cannot execute binary file: Exec format error
/home/test/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin/ruby: line 6: /home/test/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin.real/ruby: Success

Obviously, electron-builder downloaded the package fpm compiled into the wrong format. I could not find the ARM64 version of the fpm package in the release page of https://github.com/electron-userland/electron-builder-binaries/ . So what should I do to build our project into an rpm/deb package under the ARM64 condition? Can we get the source of the fpm project then manually compile it for the electron-builder's use?

NOTE: The project contains some native code which cannot be re-written in JS. So compiling the application on the computer that uses the architecture required is the most convenient way. Cross-compiling is more difficult.

@guoxiaoqiao
Copy link

I have same problem.

Screenshot from 2019-06-04 10-13-49

@nashaofu
Copy link

nashaofu commented Jun 4, 2019

@BSoD-Ultimate
Copy link
Author

I've found a solution which can partially solve this problem.

electron-builder checks a system variable naming USE_SYSTEM_FPM when attempting to acquire the fpm tool, which is used to generate rpm and deb package. When this environment variable is set to true, electron-builder will attempt to launch fpm provided by the system. for example, fpm may locate in /usr/bin/fpm. the code relates to this mechanism lies here:
https://github.com/electron-userland/electron-builder/blob/master/packages/app-builder-lib/src/targets/tools.ts

You can get fpm using other ways the Linux system provides. You have to install packages which make ruby and gem command usable. Since I use openSUSE as the building environment, YaST is written in Ruby, and it's an essential module in openSUSE. I could install fpm simply running the command gem install fpm.
After the installation, a soft link might have to be created to help electron-builder find fpm. In my environment, I created the link by running the following command

sudo ln -s /usr/bin/fpm/fpm.ruby2.5 /usr/bin/fpm

Then, before the packaging procedure, just set the environment variable by running

export USE_SYSTEM_FPM="true"

and the packaging procedure runs with no error.

I could only say the problem is partially but not fully solved. fpm could not generate a usable deb package which can be successfully installed in Debian when packaging under openSUSE environment. see this issue:
jordansissel/fpm#737

However, if you use Debian, it's all fine.

@nashaofu
Copy link

nashaofu commented Jun 7, 2019

Build successfully using the following commands before building.

 sudo apt-get update
 sudo apt-get install --no-install-recommends -y gcc-multilib g++-multilib
 sudo apt-get install --no-install-recommends -y rpm

my travis-ci configuration

dist: trusty
sudo: required

language: node_js
node_js:
  - '10'

matrix:
  include:
    - os: linux
      before_install: # 为了支持打包rpm格式的包
        - sudo apt-get update
        - sudo apt-get install --no-install-recommends -y gcc-multilib g++-multilib
        - sudo apt-get install --no-install-recommends -y rpm
    - os: osx

cache:
  directories:
    - node_modules

install:
  - yarn install

script:
  - yarn lint
  - yarn build
  - yarn release

branches:
  only:
    - master

@stale
Copy link

stale bot commented Aug 6, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@saifeiLee
Copy link

I've found a solution which can partially solve this problem.

electron-builder checks a system variable naming USE_SYSTEM_FPM when attempting to acquire the fpm tool, which is used to generate rpm and deb package. When this environment variable is set to true, electron-builder will attempt to launch fpm provided by the system. for example, fpm may locate in /usr/bin/fpm. the code relates to this mechanism lies here:
https://github.com/electron-userland/electron-builder/blob/master/packages/app-builder-lib/src/targets/tools.ts

You can get fpm using other ways the Linux system provides. You have to install packages which make ruby and gem command usable. Since I use openSUSE as the building environment, YaST is written in Ruby, and it's an essential module in openSUSE. I could install fpm simply running the command gem install fpm.
After the installation, a soft link might have to be created to help electron-builder find fpm. In my environment, I created the link by running the following command

sudo ln -s /usr/bin/fpm/fpm.ruby2.5 /usr/bin/fpm

Then, before the packaging procedure, just set the environment variable by running

export USE_SYSTEM_FPM="true"

and the packaging procedure runs with no error.

I could only say the problem is partially but not fully solved. fpm could not generate a usable deb package which can be successfully installed in Debian when packaging under openSUSE environment. see this issue:
jordansissel/fpm#737

However, if you use Debian, it's all fine.

Thanks for your solution.
I got another quesion:
I got an arm64 deb package. But It cannot be installed. Seems like it has broken.

image

Any suggestion will be welcome! Thanks in advance.

@BelinChung
Copy link

@saifeiLee YES, The same with me! The deb package cannot be installed after use system fpm to package.

Chinese: 目前正在兼容 Arm64 架构下的 UOS 系统,这个问题应该是最后一步了,关注进度、一起解决这个问题。

@saifeiLee
Copy link

@saifeiLee YES, The same with me! The deb package cannot be installed after use system fpm to package.

Chinese: 目前正在兼容 Arm64 架构下的 UOS 系统,这个问题应该是最后一步了,关注进度、一起解决这个问题。

How can I access the latest progress about this problem? Thank you.

Chinese: 请问我如何获取最新进度呢?感谢🙏

@BelinChung
Copy link

BelinChung commented Oct 30, 2020

@saifeiLee This seems to be a problem with the latest fpm version, I am trying to downgrade fpm.
link: https://zhuanlan.zhihu.com/p/163856786

@BelinChung
Copy link

@saifeiLee After I downgraded the fpm to v1.9.3, it worked for me! The package can be installed now!

@fanlion
Copy link

fanlion commented Feb 19, 2021

@saifeiLee YES, The same with me! The deb package cannot be installed after use system fpm to package.

Chinese: 目前正在兼容 Arm64 架构下的 UOS 系统,这个问题应该是最后一步了,关注进度、一起解决这个问题。

Chinese: 我也在处理UOS,你有解决这个问题吗

@Danbuth
Copy link

Danbuth commented Apr 12, 2021

I have the same problem,with arm64 UOS in use electron-builder to package a deb app.

/root/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin/ruby:?6: /root/.cache/electron-builder/fpm/fpm-1.9.3-2.3.1-linux-x86/lib/ruby/bin.real/ruby

@wangwen666
Copy link

@saifeiLee YES, The same with me! The deb package cannot be installed after use system fpm to package.

Chinese: 目前正在兼容 Arm64 架构下的 UOS 系统,这个问题应该是最后一步了,关注进度、一起解决这个问题。

请问您解决了arm64下linux打包成deb的方式吗?

@mmaietta
Copy link
Collaborator

I think easiest way to resolve this would be someone to contribute to the electron-builder-binaries repo an arm64 ruby binary. Electron builder would then download and use an arch-specific bin. Develar could then perform a release of it and I can promptly update electron-builder

@BloodlustLR
Copy link

@saifeiLee After I downgraded the fpm to v1.9.3, it worked for me! The package can be installed now!

I also package and install my application successfully on UOS.However, The application I installed can't run when i double click it.

@famingyuan
Copy link

I've found a solution which can partially solve this problem.

electron-builder checks a system variable naming USE_SYSTEM_FPM when attempting to acquire the fpm tool, which is used to generate rpm and deb package. When this environment variable is set to true, electron-builder will attempt to launch fpm provided by the system. for example, fpm may locate in /usr/bin/fpm. the code relates to this mechanism lies here: https://github.com/electron-userland/electron-builder/blob/master/packages/app-builder-lib/src/targets/tools.ts

You can get fpm using other ways the Linux system provides. You have to install packages which make ruby and gem command usable. Since I use openSUSE as the building environment, YaST is written in Ruby, and it's an essential module in openSUSE. I could install fpm simply running the command gem install fpm. After the installation, a soft link might have to be created to help electron-builder find fpm. In my environment, I created the link by running the following command

sudo ln -s /usr/bin/fpm/fpm.ruby2.5 /usr/bin/fpm

Then, before the packaging procedure, just set the environment variable by running

export USE_SYSTEM_FPM="true"

and the packaging procedure runs with no error.

I could only say the problem is partially but not fully solved. fpm could not generate a usable deb package which can be successfully installed in Debian when packaging under openSUSE environment. see this issue: jordansissel/fpm#737

However, if you use Debian, it's all fine.

@BSoD-Ultimate thanks, it works for me on ubuntu 20.04 arm64.

@daic11
Copy link

daic11 commented Sep 11, 2024

Hello! The main problem was with fpm package that require electron during build
It downloads it automatically x86 version and their repo don't include aarm64.

I am very thankful to this topics:
th-ch/youtube-music#85
jordansissel/fpm#1801 (comment)

The main repo of aarm64 build, my hero!
https://github.com/jgresham/fpm-arm-binary

Main longread explanation how it works:
signalapp/Signal-Desktop#6063 (comment)

So, the solution is to build fpm by yourself and build any electron apps for aarm64 after.

// First install podman and run
podman run -it --platform=linux/arm64 ubuntu:20.04 bash

// Update vm
sudo apt update
sudo apt install -y curl git build-essential rpm

// Build aarm64 fpm
git clone https://github.com/jgresham/fpm-arm-binary
cd fpm-arm-binary/
chmod +x compile-script.sh
./compile-script.sh

// Make fpm usable by fpm command
sudo mv fpm-arm64-exe /usr/local/bin/fpm
sudo chmod +x /usr/local/bin/fpm
which fpm
fpm --version

// Install node with npm and pnpm
curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -
sudo npm install -g npm@latest
npm install -g pnpm

// Build Youtube Music, Simple Note, Signal-Desktop, Discord, etc. Anything on Electron
export USE_SYSTEM_FPM=true
git clone https://github.com/th-ch/youtube-music
cd youtube-music
pnpm install --frozen-lockfile
pnpm dist:linux:rpm-arm64

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

No branches or pull requests

13 participants