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

Automate copying third-party dlls for make install DESTDIR=... #1492

Closed
jimklimov opened this issue Jul 13, 2022 · 4 comments
Closed

Automate copying third-party dlls for make install DESTDIR=... #1492

jimklimov opened this issue Jul 13, 2022 · 4 comments
Labels
CI Entries related to continuous integration infrastructure (historically also recipes like Makefiles) Windows

Comments

@jimklimov
Copy link
Member

jimklimov commented Jul 13, 2022

We want to bundle third-party libraries with NUT to make a single usable package for WIN32 builds.
Recursive ldd may be an option - see build-mingw-nut.sh for a single-walk PoC, but this should become part of make package kind of call.

@jimklimov jimklimov added Windows CI Entries related to continuous integration infrastructure (historically also recipes like Makefiles) labels Jul 13, 2022
@jimklimov
Copy link
Member Author

It seems that not all mingw environments ship an ldd easily usable for this, and the system Linux ldd does not walk Windows PE (exe/dll) files :)

However, ARCH-dependent mingw builds of objdump may be used (recursively) to inspect available DLLs (and so copy out those present in the build environment), as automated by https://osdn.net/users/keith/pf/mingw-ldd/scm/blobs/master/mingw32-ldd.sh / https://osdn.net/users/keith/pf/mingw-ldd/wiki/FrontPage (note the script aims to be very portable but currently depends on bash syntax a bit with type -p CMDNAME vs command -v CMDNAME):

$ x86_64-w64-mingw32-ldd  nut/scripts/Windows/nut_install/bin/netxml-ups.exe
nut/scripts/Windows/nut_install/bin/netxml-ups.exe
 +- ADVAPI32.dll
 +- KERNEL32.dll
 +- msvcrt.dll
 +- WS2_32.dll
 +- libneon-27.dll
     +- KERNEL32.dll
     +- msvcrt.dll
     +- WS2_32.dll
     +- libxml2-2.dll
         +- KERNEL32.dll
         +- msvcrt.dll
         +- WS2_32.dll
         +- liblzma-5.dll
             +- KERNEL32.dll
             +- msvcrt.dll

executed AFTER placing the custom-built DLLs into the nut_install/bin dir.

Before preparing that location, we see just the top level (which we can iterate using files from MinGW bin and lib dirs if present):

$ x86_64-w64-mingw32-ldd  nut/scripts/Windows/nut_build/drivers/.libs/netxml-ups.exe
nut/scripts/Windows/nut_build/drivers/.libs/netxml-ups.exe
 +- ADVAPI32.dll
 +- KERNEL32.dll
 +- msvcrt.dll
 +- WS2_32.dll
 +- libneon-27.dll

@jimklimov
Copy link
Member Author

UPDATE: It seems the system objdump in Ubuntu 20.10 and Debian 11 (used among CI testbeds for cross-mingw experiments) can read PE files, even on a system where mingw bits are not installed:

$ which objdump ;  objdump -x nut/scripts/Windows/nut_install/bin/netxml-ups.exe  | grep -i 'dll name'
/usr/bin/objdump
        DLL Name: ADVAPI32.dll
        DLL Name: KERNEL32.dll
        DLL Name: msvcrt.dll
        DLL Name: WS2_32.dll
        DLL Name: libneon-27.dll

so this is a viable way forward.

@jimklimov jimklimov moved this from Todo to In Progress in NUT for Windows Aug 9, 2022
jimklimov added a commit to jimklimov/nut that referenced this issue Aug 9, 2022
… of DLLs needed by NUT binaries into the nut_install tree [networkupstools#1492]
@jimklimov
Copy link
Member Author

Now build-mingw-nut.sh does a recursive walk to fetch many (open-source third-party) DLLs from mingw build environment.

In the end they are dumped to bin dir (for drivers and tools), with links added later into sbin dir per needs of system daemons, because run-time DLLs must be near EXE (if not in system paths).

Further packaging for Windows was not yet explored => #1485

Repository owner moved this from In Progress to Done in NUT for Windows Aug 11, 2022
jimklimov added a commit to jimklimov/nut that referenced this issue Aug 17, 2022
jimklimov added a commit to jimklimov/nut that referenced this issue Aug 17, 2022
jimklimov added a commit to jimklimov/nut that referenced this issue Aug 17, 2022
…talled (others too technically... but unlikely a valid situation) [networkupstools#1492]
@jimklimov
Copy link
Member Author

With #1581 in place, make DESTDIR='/tmp/nut_install' install-win-bundle is a thing!

jimklimov added a commit to jimklimov/nut that referenced this issue Aug 18, 2022
jimklimov added a commit to jimklimov/nut that referenced this issue Aug 18, 2022
jimklimov added a commit to jimklimov/nut that referenced this issue Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI Entries related to continuous integration infrastructure (historically also recipes like Makefiles) Windows
Projects
Status: Done
Development

No branches or pull requests

1 participant