Skip to content

Commit

Permalink
ci: fix more nix build issues
Browse files Browse the repository at this point in the history
  • Loading branch information
yakimant committed Jun 25, 2024
1 parent 77c282f commit e36a528
Show file tree
Hide file tree
Showing 11 changed files with 156 additions and 59 deletions.
2 changes: 1 addition & 1 deletion AppRun
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export GST_PLUGIN_PATH="${APPDIR}/usr/lib/gstreamer-1.0"
export GST_PLUGIN_PATH_1_0="${APPDIR}/usr/lib/gstreamer-1.0"
export GST_PLUGIN_SYSTEM_PATH="${APPDIR}/usr/lib/gstreamer-1.0"
export GST_PLUGIN_SYSTEM_PATH_1_0="${APPDIR}/usr/lib/gstreamer-1.0"
export LD_LIBRARY_PATH="${APPDIR}/usr/lib/:${LD_LIBRARY_PATH}"
export LD_LIBRARY_PATH="${APPDIR}/usr/lib/:${APPDIR}/usr/lib/nss:${LD_LIBRARY_PATH}"
export QT_QPA_PLATFORM="xcb"

DEFAULT_LANG=en_US.UTF-8
Expand Down
61 changes: 22 additions & 39 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ status-go-clean:
echo -e "\033[92mCleaning:\033[39m status-go"
rm -f $(STATUSGO)

STATUSKEYCARDGO := vendor/status-keycard-go/build/libkeycard/libkeycard.$(LIBSTATUS_EXT)
export STATUSKEYCARDGO := vendor/status-keycard-go/build/libkeycard/libkeycard.$(LIBSTATUS_EXT)
export STATUSKEYCARDGO_LIBDIR := "$(shell pwd)/$(shell dirname "$(STATUSKEYCARDGO)")"

status-keycard-go: $(STATUSKEYCARDGO)
Expand All @@ -456,7 +456,7 @@ $(QRCODEGEN): | deps
+ cd vendor/QR-Code-generator/c && \
$(MAKE) $(QRCODEGEN_MAKE_PARAMS) $(HANDLE_OUTPUT)

FLEETS_FILE := ./fleets.json
export FLEETS_FILE := ./fleets.json
$(FLEETS_FILE):
echo -e $(BUILD_MSG) "Getting latest $(FLEETS_FILE)"
curl -s https://fleets.status.im/ > $(FLEETS_FILE)
Expand Down Expand Up @@ -591,7 +591,7 @@ STATUS_CLIENT_TARBALL ?= pkg/Status.tar.gz
STATUS_CLIENT_TARBALL_FULL ?= $(shell realpath $(STATUS_CLIENT_TARBALL))

ifeq ($(detected_OS),Linux)
FCITX5_QT := vendor/fcitx5-qt/build/qt5/platforminputcontext/libfcitx5platforminputcontextplugin.so
export FCITX5_QT := vendor/fcitx5-qt/build/qt5/platforminputcontext/libfcitx5platforminputcontextplugin.so
FCITX5_QT_CMAKE_PARAMS := -DCMAKE_BUILD_TYPE=Release -DBUILD_ONLY_PLUGIN=ON -DENABLE_QT4=OFF -DENABLE_QT5=ON
FCITX5_QT_BUILD_CMD := cmake --build . --config Release $(HANDLE_OUTPUT)
endif
Expand All @@ -608,54 +608,37 @@ $(FCITX5_QT): | check-qt-dir deps

PRODUCTION_PARAMETERS ?= -d:production

export APP_DIR := tmp/linux/dist

$(STATUS_CLIENT_APPIMAGE): override RESOURCES_LAYOUT := $(PRODUCTION_PARAMETERS)
$(STATUS_CLIENT_APPIMAGE): nim_status_client $(APPIMAGE_TOOL) nim-status.desktop $(FCITX5_QT)
rm -rf pkg/*.AppImage
rm -rf tmp/linux/dist
mkdir -p tmp/linux/dist/usr/bin
mkdir -p tmp/linux/dist/usr/lib
mkdir -p tmp/linux/dist/usr/qml

# General Files
cp bin/nim_status_client tmp/linux/dist/usr/bin
cp nim-status.desktop tmp/linux/dist/.
cp status.png tmp/linux/dist/status.png
cp status.png tmp/linux/dist/usr/.
cp -R resources.rcc tmp/linux/dist/usr/.
cp -R $(FLEETS_FILE) tmp/linux/dist/usr/.
mkdir -p tmp/linux/dist/usr/i18n
cp bin/i18n/* tmp/linux/dist/usr/i18n
mkdir -p tmp/linux/dist/usr/bin/StatusQ
cp bin/StatusQ/* tmp/linux/dist/usr/bin/StatusQ

# Libraries
ifndef IN_NIX_SHELL
cp -r /usr/lib/x86_64-linux-gnu/nss tmp/linux/dist/usr/lib/
cp -P /usr/lib/x86_64-linux-gnu/libgst* tmp/linux/dist/usr/lib/
cp -r /usr/lib/x86_64-linux-gnu/gstreamer-1.0 tmp/linux/dist/usr/lib/
cp -r /usr/lib/x86_64-linux-gnu/gstreamer1.0 tmp/linux/dist/usr/lib/
endif
cp vendor/status-go/build/bin/libstatus.so tmp/linux/dist/usr/lib/
cp vendor/status-go/build/bin/libstatus.so.0 tmp/linux/dist/usr/lib/
cp $(STATUSKEYCARDGO) tmp/linux/dist/usr/lib/
chmod -R u+w tmp || true

scripts/init_app_dir.sh

echo -e $(BUILD_MSG) "AppImage"

linuxdeployqt tmp/linux/dist/nim-status.desktop -no-copy-copyright-files -qmldir=ui -qmlimport=$(QT5_QMLDIR) -bundle-non-qt-libs
ifdef IN_NIX_SHELL
patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 tmp/linux/dist/usr/bin/nim_status_client
endif
linuxdeployqt $(APP_DIR)/nim-status.desktop \
-no-copy-copyright-files \
-qmldir=ui -qmlimport=$(QT5_QMLDIR) \
-bundle-non-qt-libs \
-exclude-libs=libgmodule-2.0.so.0,libgthread-2.0.so.0 \
-verbose=1 \
-executable=$(APP_DIR)/usr/libexec/QtWebEngineProcess

# Qt plugins
cp $(FCITX5_QT) tmp/linux/dist/usr/plugins/platforminputcontexts/
scripts/fix_app_dir.sh

rm tmp/linux/dist/AppRun
cp AppRun tmp/linux/dist/.
rm $(APP_DIR)/AppRun
cp AppRun $(APP_DIR)/.

mkdir -p pkg
$(APPIMAGE_TOOL) tmp/linux/dist $(STATUS_CLIENT_APPIMAGE)
$(APPIMAGE_TOOL) $(APP_DIR) $(STATUS_CLIENT_APPIMAGE)

# Fix rpath and interpreter for AppImage
ifdef IN_NIX_SHELL
patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 $(STATUS_CLIENT_APPIMAGE)
patchelf --remove-rpath $(STATUS_CLIENT_APPIMAGE)
endif

# if LINUX_GPG_PRIVATE_KEY_FILE is not set then we don't generate a signature
Expand Down
File renamed without changes.
7 changes: 4 additions & 3 deletions nix/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ in rec {
};
});

# Copyied from bootstrap121 from 0e2a36815d2310886458ac1aab14350160e6b12a
# autoPatchelfHook is disabled
# Copyied from bootstrap121 from 020300a756e75ea9ce86a8ab5ee259c31e28ed43
# - autoPatchelfHook is disabled
# - development/compilers/go/print-hashes.sh 1.21.11
# TODO: compile, not binary
# Binary is used because of initial complexity of both package override and copy from newer nixpkgs
go_1_20 = callPackage ./pkgs/go/bootstrap120.nix { };
go_1_21 = callPackage ./pkgs/go/bootstrap121.nix { };

# Fix for linuxdeployqt running ldd from nix with system shell
# ERROR: findDependencyInfo: "/bin/sh: /nix/store/HASH-glibc-2.31-74/lib/libc.so.6: version `GLIBC_2.33' not found (required by /bin/sh)\n/bin/sh: /nix/store/0c7c96gikmzv87i7lv3vq5s1cmfjd6zf-glibc-2.31-74/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/sh)"
Expand Down
1 change: 1 addition & 0 deletions nix/pkgs/go/binary.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ let
"armv6l" = "armv6l";
"armv7l" = "armv6l";
"powerpc64le" = "ppc64le";
"riscv64" = "riscv64";
}.${platform.parsed.cpu.name} or (throw "Unsupported CPU ${platform.parsed.cpu.name}");

toGoPlatform = platform: "${toGoKernel platform}-${toGoCPU platform}";
Expand Down
15 changes: 0 additions & 15 deletions nix/pkgs/go/bootstrap120.nix

This file was deleted.

22 changes: 22 additions & 0 deletions nix/pkgs/go/bootstrap121.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{ callPackage }:
callPackage ./binary.nix {
version = "1.21.11";
hashes = {
# Use `print-hashes.sh ${version}` to generate the list below
darwin-amd64 = "a3efff72f7aba31c85b53ebfd3985d0e3157a87b0e69e178161ba7097c197885";
darwin-arm64 = "0142f5ac9f9a1bf19b826ee08a8c7955a745f7a2e62d36e0566d29fcac4d88e0";
linux-386 = "8b00cbc2519c2d052177bf2c8472bf06578d3b0182eeb3406a1d7d4e5d4c59ef";
linux-amd64 = "54a87a9325155b98c85bc04dc50298ddd682489eb47f486f2e6cb0707554abf0";
linux-arm64 = "715d9a7ff72e4e0e3378c48318c52c6e4dd32a47c4136f3c08846f89b2ee2241";
linux-armv6l = "a62bff8297816a387a36bbda2889dd0dbcf0f8ce03bc62162ecd6918d6acecb5";
linux-loong64 = "19c738e3670efb6581a91d7d93e719080ccf710684938d015ab3e7ca044715be";
linux-mips = "4240bd1a4ca8ab664ead554b418bd1b1f319b063258763ade44f81a4dd018e61";
linux-mips64 = "6245001da9e2c39698f97543019f9faf4813f0564e471ec654f4698e0b9f19eb";
linux-mips64le = "d10166bb6ea6538e24f01ac9bcbbbaee5657d07b9edc11a82cbf569355a36534";
linux-mipsle = "8ab7e1af86845aa39bc93e1ae7e58f79a0b8df59783129c3b73aa0379f693c4a";
linux-ppc64 = "2939e56894877c51eb9c579f55588b80c77f38481240042512307ad1db5b3dd8";
linux-ppc64le = "6f5e18187abc4ff1c3173afbe38ef29f84b6d1ee7173f40075a4134863b209a5";
linux-riscv64 = "3ee5f9aac2f252838d88bb4cf93560c567814889c74d87ad8a04be16aa5e1b21";
linux-s390x = "489c363d5da2d3d5709419bda61856582c5ebdc7874ca7ecdebf67d736d329e6";
};
}
18 changes: 18 additions & 0 deletions scripts/check_app_dir.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -e pipefail

echo 'GLIBC highest version:'
find "${APP_DIR}" -type f -exec objdump -T {} \; 2>&1 | grep -v GLIBCXX | grep GLIBC | sed 's/.*GLIBC_\([.0-9]*\).*/\1/g' | sort -uV | tail -1

echo 'GLIBCXX highest version'
find "${APP_DIR}" -type f -exec objdump -T {} \; 2>&1 | grep GLIBCXX | sed 's/.*GLIBCXX_\([.0-9]*\).*/\1/g' | sort -uV | tail -1

echo 'Unresolved libraries:'
find "${APP_DIR}" -type f -exec ldd {} \; 2>&1 | grep -v 'you do not have execution permission' | grep -v 'not a dynamic executable' | grep -v ' => ' | grep -v 'ld-linux-x86-64.so.2' | grep -q 'linux-vdso.so.1' | wc -l

echo 'Rpaths not starting with $ORIGIN:'
find "${APP_DIR}" -type f -exec patchelf --print-rpath {} \; 2>&1 | grep -v 'not an ELF executable' | grep -v 'missing ELF header' | grep -v '^\$ORIGIN' | wc -l

echo 'Interpreters not default system(/lib64/ld-linux-x86-64.so.2):'
find "${APP_DIR}" -type f -exec patchelf --print-interpreter {} \; 2>&1 | grep -v 'not an ELF executable' | grep -v 'cannot find section' | grep -v 'missing ELF header' | grep -v '/lib64/ld-linux-x86-64.so.2' | wc -l
28 changes: 28 additions & 0 deletions scripts/fix_app_dir.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash

set -e pipefail

# Fix rpath and interpreter not fixed by linuxdeployqt
if [[ ! -z "${IN_NIX_SHELL}" ]]; then
patchelf --set-rpath '$ORIGIN/../../lib' \
"${APP_DIR}/usr/plugins/platforminputcontexts/libfcitx5platforminputcontextplugin.so" \
"${APP_DIR}/usr/bin/StatusQ/libStatusQ.so"

patchelf --set-rpath '$ORIGIN' \
"${APP_DIR}/usr/lib/libcom_err.so.3" \
"${APP_DIR}/usr/lib/libstatus.so"

patchelf --set-rpath '$ORIGIN/../' \
"${APP_DIR}"/usr/lib/gstreamer-1.0/* \
"${APP_DIR}"/usr/lib/nss/*.so

patchelf --set-rpath '$ORIGIN/../../' "${APP_DIR}"/usr/lib/gstreamer1.0/gstreamer-1.0/*

patchelf --set-rpath '$ORIGIN/../lib' "${APP_DIR}/usr/libexec/QtWebEngineProcess"

patchelf --set-interpreter /lib64/ld-linux-x86-64.so.2 \
"${APP_DIR}/usr/bin/nim_status_client" \
"${APP_DIR}/usr/libexec/QtWebEngineProcess" \
"${APP_DIR}/usr/lib/libQt5Core.so.5" \
"${APP_DIR}"/usr/lib/gstreamer1.0/gstreamer-1.0/*
fi
48 changes: 48 additions & 0 deletions scripts/init_app_dir.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env bash

set -e pipefail

rm -rf "${APP_DIR}"

mkdir -p "${APP_DIR}/usr/bin"
mkdir -p "${APP_DIR}/usr/lib"
mkdir -p "${APP_DIR}/usr/qml"
mkdir -p "${APP_DIR}/usr/i18n"
mkdir -p "${APP_DIR}/usr/bin/StatusQ"
mkdir -p "${APP_DIR}/usr/plugins/platforminputcontexts/"

cp bin/nim_status_client "${APP_DIR}/usr/bin"
cp bin/StatusQ/* "${APP_DIR}/usr/bin/StatusQ"

cp nim-status.desktop "${APP_DIR}/."
cp status.png "${APP_DIR}/status.png"
cp status.png "${APP_DIR}/usr/"
cp -R resources.rcc "${APP_DIR}/usr/"
cp -R "${FLEETS_FILE}" "${APP_DIR}/usr/"
cp bin/i18n/* "${APP_DIR}/usr/i18n"

cp vendor/status-go/build/bin/libstatus.so "${APP_DIR}/usr/lib/"
cp vendor/status-go/build/bin/libstatus.so.0 "${APP_DIR}/usr/lib/"
cp "${STATUSKEYCARDGO}" "${APP_DIR}/usr/lib/"
cp "${FCITX5_QT}" "${APP_DIR}/usr/plugins/platforminputcontexts/"

# Copy dependencies, which linuxdeployqt can't manage from nix store or system (FHS)
if [[ -z "${IN_NIX_SHELL}" ]]; then
cp -r /usr/lib/x86_64-linux-gnu/nss "${APP_DIR}/usr/lib/"
cp -P /usr/lib/x86_64-linux-gnu/libgst* "${APP_DIR}/usr/lib/"
cp -r /usr/lib/x86_64-linux-gnu/gstreamer-1.0 "${APP_DIR}/usr/lib/"
cp -r /usr/lib/x86_64-linux-gnu/gstreamer1.0 "${APP_DIR}/usr/lib/"
else
mkdir -p "${APP_DIR}"/usr/lib/{gstreamer1.0,gstreamer-1.0,nss}
mkdir -p "${APP_DIR}"/usr/libexec

echo "${GST_PLUGIN_SYSTEM_PATH_1_0}" | tr ':' '\n' | sort -u | xargs -I {} find {} -name "*.so" | xargs -I {} cp {} "${APP_DIR}/usr/lib/gstreamer-1.0/"
cp -r "${GSTREAMER_PATH}/libexec/gstreamer-1.0" "${APP_DIR}/usr/lib/gstreamer1.0/"
cp "${LIBKRB5_PATH}/lib/libcom_err.so.3" "${APP_DIR}/usr/lib/libcom_err.so.3"
cp "${NSS_PATH}"/lib/{libfreebl3,libfreeblpriv3,libnssckbi,libnssdbm3,libsoftokn3}.{chk,so} "${APP_DIR}/usr/lib/nss/" || true
cp "${QTWEBENGINE_PATH}/libexec/QtWebEngineProcess" "${APP_DIR}/usr/libexec/QtWebEngineProcess"
cp "${QTWEBENGINE_PATH}"/resources/* "${APP_DIR}/usr/libexec/"
cp -r "${QTWEBENGINE_PATH}/translations/qtwebengine_locales" "${APP_DIR}/usr/libexec/"

chmod -R u+w "${APP_DIR}/usr"
fi
13 changes: 12 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,18 @@ in pkgs.mkShell {
QTDIR = qtCustom;
# TODO: still needed?
# https://github.com/NixOS/nixpkgs/pull/109649
QT_INSTALL_PLUGINS = "${qtCustom}/${pkgs.qt515.qtbase.qtPluginPrefix}";
QT_INSTALL_PLUGINS = "${qtCustom}/${pkgs.qt515_8.qtbase.qtPluginPrefix}";

shellHook = ''
export MAKEFLAGS="-j$NIX_BUILD_CORES"
export PATH="${pkgs.lddWrapped}/bin:$PATH"
'';

LIBKRB5_PATH = pkgs.libkrb5;
QTWEBENGINE_PATH = pkgs.qt515_8.qtwebengine.out;
GSTREAMER_PATH = pkgs.gst_all_1.gstreamer;
NSS_PATH = pkgs.nss;

# Used for linuxdeployqt
# TODO:check which deps are needed
LD_LIBRARY_PATH = with pkgs; lib.makeLibraryPath (
Expand All @@ -69,6 +75,8 @@ in pkgs.mkShell {
libpng
libpulseaudio
libxkbcommon
openexr
openssl
p11-kit
zlib
] ++ (with xorg; [
Expand All @@ -84,6 +92,9 @@ in pkgs.mkShell {
xcbutilwm
]) ++ (with gst_all_1; [
gst-plugins-base
gst-plugins-good
gst-plugins-bad
gst-plugins-ugly
gstreamer
]));
}

0 comments on commit e36a528

Please sign in to comment.