From 6854f65aa4eaf5e9e2c549eaf885ddd2c724f342 Mon Sep 17 00:00:00 2001 From: Kiminuo Date: Sun, 12 Jun 2022 22:30:52 +0200 Subject: [PATCH] Add support for arm64 --- contrib/build.Dockerfile | 19 ++++++++----------- contrib/build_bin.sh | 31 +++++++++++++++++++++++++------ hwi.spec | 2 +- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/contrib/build.Dockerfile b/contrib/build.Dockerfile index 622926491..73d183464 100644 --- a/contrib/build.Dockerfile +++ b/contrib/build.Dockerfile @@ -41,17 +41,14 @@ ENV BUILD_DATE="Jan 1 2019" ENV BUILD_TIME="00:00:00" RUN eval "$(pyenv init --path)" && eval "$(pyenv virtualenv-init -)" && cat /opt/reproducible-python.diff | pyenv install -kp 3.9.7 -RUN dpkg --add-architecture i386 -RUN wget -nc https://dl.winehq.org/wine-builds/winehq.key -RUN apt-key add winehq.key -RUN echo "deb https://dl.winehq.org/wine-builds/debian/ stretch main" >> /etc/apt/sources.list -RUN apt-get update -RUN apt-get install --install-recommends -y \ - wine-stable-amd64 \ - wine-stable-i386 \ - wine-stable \ - winehq-stable \ - p7zip-full +RUN if [[ $(dpkg --print-architecture) == "amd64" ]]; then \ + dpkg --add-architecture i386; \ + wget -nc https://dl.winehq.org/wine-builds/winehq.key; \ + apt-key add winehq.key; \ + echo "deb https://dl.winehq.org/wine-builds/debian/ stretch main" >> /etc/apt/sources.list; \ + apt-get update; \ + apt-get install --install-recommends -y wine-stable-amd64 wine-stable-i386 wine-stable winehq-stable p7zip-full; \ + fi ENV LC_ALL=C.UTF-8 ENV LANG=C.UTF-8 diff --git a/contrib/build_bin.sh b/contrib/build_bin.sh index f060ef002..09237986d 100755 --- a/contrib/build_bin.sh +++ b/contrib/build_bin.sh @@ -3,13 +3,19 @@ set -ex +arch=`dpkg --print-architecture` + eval "$(pyenv init --path)" eval "$(pyenv virtualenv-init -)" pip install -U pip pip install poetry # Setup poetry and install the dependencies -poetry install -E qt +if [[ $arch == "amd64" ]]; then + poetry install -E qt +else + poetry install +fi # We also need to change the timestamps of all of the base library files lib_dir=`pyenv root`/versions/3.9.7/lib/python3.9 @@ -18,8 +24,12 @@ TZ=UTC find ${lib_dir} -name '*.py' -type f -execdir touch -t "201901010000.00" # Make the standalone binary export PYTHONHASHSEED=42 poetry run pyinstaller hwi.spec -poetry run contrib/generate-ui.sh -poetry run pyinstaller hwi-qt.spec + +if [[ $arch == "amd64" ]]; then + poetry run contrib/generate-ui.sh + poetry run pyinstaller hwi-qt.spec +fi + unset PYTHONHASHSEED # Make the final compressed package @@ -29,13 +39,22 @@ OS=`uname | tr '[:upper:]' '[:lower:]'` if [[ $OS == "darwin" ]]; then OS="mac" fi -target_tarfile="hwi-${VERSION}-${OS}-amd64.tar.gz" -tar -czf $target_tarfile hwi hwi-qt + +target_tarfile="hwi-${VERSION}-${OS}-${arch}.tar.gz" + +if [[ $arch == "amd64" ]]; then + tar -czf $target_tarfile hwi hwi-qt +else + tar -czf $target_tarfile hwi +fi # Copy the binaries to subdir for shasum target_dir="$target_tarfile.dir" mkdir $target_dir mv hwi $target_dir -mv hwi-qt $target_dir + +if [[ $arch == "amd64" ]]; then + mv hwi-qt $target_dir +fi popd diff --git a/hwi.spec b/hwi.spec index 1502458f8..6ad8d380c 100644 --- a/hwi.spec +++ b/hwi.spec @@ -13,7 +13,7 @@ def get_libusb_path(): prefix = proc.communicate()[0].rstrip().decode() return os.path.join(prefix, "lib", "libusb-1.0.dylib") if platform.system() == "Linux": - for lib_dir in ["/lib/x86_64-linux-gnu", "/usr/lib64", "/lib64" "/usr/lib", "/lib"]: + for lib_dir in ["/lib/x86_64-linux-gnu", "/lib/aarch64-linux-gnu", "/usr/lib64", "/lib64" "/usr/lib", "/lib"]: libusb_path = os.path.join(lib_dir, "libusb-1.0.so.0") if os.path.exists(libusb_path): return libusb_path