NagiosEnterprises / ncpa

Nagios Cross-Platform Agent
Other
177 stars 95 forks source link

Issue Building with Windows #821

Open Stathogon opened 2 years ago

Stathogon commented 2 years ago

Hello, I try to build the dev-v3 Pakage for windows. But the Building-process is interrupted, bacause of a missing file/folder under agent\build. grafik I recognised the given file / folder in the master version. So do i have to merge them in some kind, is something missing or am i building it wrong. Its my first time and i followed this guide: https://github.com/NagiosEnterprises/ncpa/blob/dev-v3/BUILDING.rst

jomann09 commented 2 years ago

I haven't tried building v3 on windows in a while, it looks like it's trying to find the .nsi file in the wrong directory though if I had to guess, the windows build script probably needs to be adjusted with the new .nsi location.

Stathogon commented 2 years ago

Im trying to adjust the script, but also the ncpa.nsi file is heavily bugged for Windows. Eventhough i managed to get the build script working (not sure if it works in the end), the ncpa.nsi file also is quite bugged. All the Variables point to static folders which cant be found. after editing them out / change them to the right dirs the configs are also pointing to .\NCPA\etc which also is cleary a Linux term. I dont have any experience with NSIS and dont know what i have to change to get it working again. And yes the script is still not working correctly but that isnt the Problem at the moment. grafik edit: added Screenshot

Stathogon commented 2 years ago

So how do i continue from now on? I dont think im capable of resolving every issue there is with the scripts. Do i wait for updates or is there another thing i could do?

rdaunce commented 2 years ago

The issue is happening because NSIS process is looking for the build in a folder named NCPA. The build creates an architecture-specific folder, though. The windows build process on the V2 client renames the architecture-specific folder to NCPA after it builds. It looks like the V3 client build process was consolidated and the rename is no longer included.

I was able to resolve it by adding the following code to the bottom of https://github.com/NagiosEnterprises/ncpa/blob/dev-v3/agent/setup.py. You will also need to revert any path changes you made to the ncpa.nsi file.

if __SYSTEM__ == 'nt':
    if __ARCH__ == '32bit':
        os.rename(os.path.join('build', 'exe.win32-3.9'), os.path.join('build', 'NCPA'))
    elif __ARCH__ == '64bit':
        os.rename(os.path.join('build', 'exe.win-amd64-3.9'), os.path.join('build', 'NCPA'))
    else:
        print("unhandled architecture")
        sys.exit(1)
Stathogon commented 2 years ago

After all i cant get it working. I dont have much experience with nsis and i cant resolve the setup process in the build_windows.py file. I havent found much information what the nsi_store and the nsi file does. In the script it loads both files. The nsi_store one is not a problem and still located at the same location. The nsi one is declared in "/agent/build/ncpa.nsi" which doesnt exist. But i cant find a second instance of that file. Do i have to download/write another one? Or is there a Workaround i could use that would work with just one nsi file? It is used in Line 53 for reverence. kind regards

rdaunce commented 2 years ago

The nsi and nsi_store are just variables that hold file paths. nsi_store is the path to the file in the source control repository and nsi is the path to where it will be copied during the build. That file is a configuration file that NSIS uses to create an installer for the agent. You shouldn't have to change either of these variables. Line 52 is where the it copies the the ncpa.nsi file from the nsi_store file path to the nsi file path. Line 53 just starts the actual NSIS executable using the ncpa.nsi file found in the nsi path.

You shouldn't have to change or create anything, with the exception of the "agent/setup.py" change in my previous reply. Do you still have all of your path changes that you previously made to try to get it working? I would suggest stashing any of your changes and reverting back to the origin dev_v3 branch or cloning a new copy of it. Only add the code I posted to the end of the "agent/setup.py" file and retry the build.

Stathogon commented 2 years ago

After i "reseted" (deleted everything and redownloaded the dev build) and appended your lines i still get the error: "FileNotFoundError: [Errno 2] No such file or directory: 'C:\Users\jnagel\Documents\ncpa-dev-v3\agent\build\ncpa.nsi'" So there is still the Error. But in the original there isnt the path \agent\build. would the folder be created automatically? i have created the folder manually but the error stays the same.

Stathogon commented 2 years ago

Any updates / advices regarding this issue?