netinvent / npbackup

A secure and efficient file backup solution that fits both system administrators (CLI) and end users (GUI)
GNU General Public License v3.0
141 stars 5 forks source link

Building on macOS #21

Closed kapitainsky closed 1 year ago

kapitainsky commented 1 year ago

Following https://github.com/netinvent/npbackup/blob/main/COMPILE_INSTRUCTIONS.md

So far so good - I can install all dependencies but it fails when compiling

python3 bin/compile.py --audience public
INFO: Building with default secret key
Cannot find restic source file.

The reason is that it does not recognize restic_0.15.2_darwin_amd64 as valid restic executable. I am guessing only linux/windows are in the code for arch?

restic_0.15.2_darwin_arm64 and restic_0.15.2_darwin_amd64 should be valid options here

deajan commented 1 year ago

I've tried to add support for darwin in https://github.com/netinvent/npbackup/commit/d1ada6d8d4f64ddcf2b9dce791a0134fec93a945 But this will be a long road, since I cannot test anything.

PS: What does python -c "import os; print(os.name)" output ?

kapitainsky commented 1 year ago

PS: What does python -c "import os; print(os.name)" output ?

posix

deajan commented 1 year ago

That's bad for me since I get the same output on Linux. What does python -c "import sys; print(sys.platform)" say ?

kapitainsky commented 1 year ago

I've tried to add support for darwin in d1ada6d But this will be a long road, since I cannot test anything.

I have cheated a bit and renamed restic_0.15.2_darwin_amd64 to restic_0.15.2_linux_amd64 - now compiling - it takes time as I do thin in VM

kapitainsky commented 1 year ago

It was a bit dependencies fight and also question of using right python - you can't system one as:

FATAL: Error, on macOS, for standalone mode, Apple Python is not supported due to being tied to specific OS releases, use e.g. CPython instead which is available from https://www.python.org/downloads/macos/ for download. With that, your program will work on macOS 10.9 or higher.

So it is needed to install python via brew. Also some extra deps are needed.

When/if I succeed I will document it.

kapitainsky commented 1 year ago

That's bad for me since I get the same output on Linux. What does python -c "import sys; print(sys.platform)" say ?

darwin

deajan commented 1 year ago

Thank you for the feedback. I've updated in https://github.com/netinvent/npbackup/commit/e09643cf0fbf21f0c004372f8f5e99904ee6385c the darwin detection. I'll happily update whatever will make MacOS compilation work ;)

Btw, does NPBackup work non compiled on MacOS ?

kapitainsky commented 1 year ago
Nuitka-Scons:INFO: Compiled 1 C files using ccache.
Nuitka-Scons:INFO: Cached C files (using ccache) with result 'cache miss': 1
Nuitka-Onefile:INFO: Keeping onefile build directory '/Users/db/Downloads/npbackup/BUILDS/public/linux/x64/npbackup.onefile-build'.
Nuitka:INFO: Keeping dist folder '/Users/db/Downloads/npbackup/BUILDS/public/linux/x64/npbackup.dist' for inspection, no need to use it.
Nuitka:INFO: Keeping build directory '/Users/db/Downloads/npbackup/BUILDS/public/linux/x64/npbackup.build'.
Nuitka:INFO: Created binary that runs on macOS 13.0 (x86_64) or higher.
Nuitka:INFO: Successfully created '/Users/db/Downloads/npbackup/BUILDS/public/linux/x64/npbackup.bin'.
COMPILE ERRORS False
SUCCESS: MADE public build for audience public
SUCCESS BUILDING

but as binary is in BUILDS/public/linux/x64/ I guess because I cheated with restic binary name.

Binary "works" but:

2023-06-11 13:59:59,735 :: INFO :: npbackup v2.2.0-P11-x64 2023060301 - GUI disabled - Copyright (C) 2022-2023 NetInvent
2023-06-11 13:59:59,735 :: CRITICAL :: Cannot load configuration file from /Users/db/Downloads/npbackup/BUILDS/public/linux/x64/npbackup.conf

I guess it might be related.

kapitainsky commented 1 year ago

Btw, does NPBackup work non compiled on MacOS ?

Not sure I understand this question:)

deajan commented 1 year ago

You can just launch NPBackup without compiling it, ie python bin/npbackup. Does that work ?

kapitainsky commented 1 year ago

You can just launch NPBackup without compiling it, ie python bin/npbackup. Does that work ?

db@dbs-Mac npbackup % /usr/local/bin/python3 bin/npbackup 
2023-06-11 14:11:19,805 :: INFO :: npbackup v2.2.0-P11-x64 2023060301 - GUI disabled - Copyright (C) 2022-2023 NetInvent
2023-06-11 14:11:19,805 :: CRITICAL :: Cannot load configuration file from /Users/db/Downloads/npbackup/bin/npbackup.conf
2023-06-11 14:11:19,814 :: ERROR :: No configuration file found. Please use --config-file "path" to specify one or copy a config file next to the NPBackup binary
kapitainsky commented 1 year ago

I've updated in e09643c the darwin detection.

it now detects darwin restic binary correctly - let's see

kapitainsky commented 1 year ago

Progress:

Nuitka:INFO: Created binary that runs on macOS 13.0 (x86_64) or higher.
Nuitka:INFO: Successfully created '/Users/db/Downloads/npbackup/BUILDS/public/darwin/x64/npbackup.bin'.
COMPILE ERRORS False
SUCCESS: MADE public build for audience public

but when trying to run:

db@dbs-Mac x64 % ./npbackup.bin                                                          
2023-06-11 14:24:44,869 :: INFO :: npbackup v2.2.0-P11-x64 2023060301 - GUI disabled - Copyright (C) 2022-2023 NetInvent
2023-06-11 14:24:44,888 :: INFO :: Handling random variables in configuration files
2023-06-11 14:24:44,888 :: INFO :: Updating config file
2023-06-11 14:24:44,897 :: ERROR :: Repo cannot be empty
2023-06-11 14:24:44,897 :: ERROR :: No password nor password command given. Repo password cannot be empty
2023-06-11 14:24:44,897 :: CRITICAL :: No backend available. Cannot continue

I do not worry about config part - it is not done. but why GUI disabled ???

kapitainsky commented 1 year ago

And after more fight (does not help I know nothing about python) with python/tk dependencies and macOS peculiarities I can report that it is working (at least compiles and starts):

image

Thank you for your compile instructions - definitely it was game changer - at least for me.

deajan commented 1 year ago

I was going to give you the gui-status parameter for npbackup executable, which would have told you something like tcl/tk missing probably, but I see that you did succeed building ;)

Congratulations !!

Would you mind making a PR on the build instructions file ? Might be a saver for next MacOS guy ;)

kapitainsky commented 1 year ago

I will update COMPILE_INSTRUCTIONS.md - but first will have to repeat all steps again. I have some notes - but expect some mess I have to clean.

kapitainsky commented 1 year ago

one thing - could you please add darwin example config inexamples? I guess the same as Linux - but it is something missing

deajan commented 1 year ago

I will update COMPILE_INSTRUCTIONS.md - but first will have to repeat all steps again. I have some notes - but expect some mess I have to clean.

Please use latest git master as compile.py might work without modifying restic binary names after latest commit

one thing - could you please add darwin example config in examples? I guess the same as Linux - but it is something missing

Like having the same file twice ?

kapitainsky commented 1 year ago

Please use latest git master as compile.py might work without modifying restic binary names after latest commit

I have used it - works fine.

kapitainsky commented 1 year ago

Like having the same file twice ?

At the moment we have in examples:

npbackup.linux.conf.dist
npbackup.windows.conf.dist

we need to add:

npbackup.darwin.conf.dist

I guess it will be the same as linux one - have not looked into details yet.