snapcast icon indicating copy to clipboard operation
snapcast copied to clipboard

snapserver install MACOS commands fail - error 64

Open claypole opened this issue 3 years ago • 7 comments

The snapserver Install fails

This appears to be when it attempts to install snapweb (a fairly new component looking at the changlog) when it runs the following from Makefile:

for file in etc/snapweb/.; do install -g wheel -o root -m 644 $${file} -Dt "/usr/share/snapserver/snapweb/"; done

It appears that the -Dt options are not valid and probably not required on MACOS.

Linux describes the syntax and install options as:

install [OPTION]... [-T] SOURCE DEST install [OPTION]... SOURCE... DIRECTORY install [OPTION]... -t DIRECTORY SOURCE... install [OPTION]... -d DIRECTORY...

-D create all leading components of DEST except the last, then copy SOURCE to DEST

-t, --target-directory=DIRECTORY copy all SOURCE arguments into DIRECTORY

On MACOS, it appears to handle these variants via the syntax without the need for these install options, as follows:

 install [OPTION]... Sourcefile1 Destinationfile2
 install [OPTION]... file1 ... fileN directory
 install -d [-v] [-g group] [-m mode]
            [-o owner] directory ...

The 3 variants above install either a single SOURCE file to DEST target or copy multiple SOURCE files to the destination. In the last variant, each DIRECTORY (and any missing parent directories) is created.

Therefore In theory, the same command, removing -Dt, will action as per variant 2 above:

for file in etc/snapweb/.; do install -g wheel -o root -m 644 $${file} "/usr/share/snapserver/snapweb/"; done

...will copy all of the files in ${file} into "/usr/share/snapserver/snapweb/"

I have not tried this yet, but keen to get feedback on whether this makes sense and if I have missed anything?

Steps to Reproduce

  1. make TARGET=MACOS (works)
  2. sudo make install TARGET=MACOS (fails)
  3. Output: echo macOS macOS install -s -g wheel -o root snapserver /usr/local/bin/snapserver install -g wheel -o root snapserver.1 /usr/local/share/man/man1/snapserver.1 install -g wheel -o root etc/snapserver.plist /Library/LaunchAgents/de.badaix.snapcast.snapserver.plist install -g wheel -o root etc/snapserver.conf /etc/snapserver.co usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 file2 install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 ... fileN directory install -d [-v] [-g group] [-m mode] [-o owner] directory ... usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 file2 install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 ... fileN directory install -d [-v] [-g group] [-m mode] [-o owner] directory ... usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 file2 install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 ... fileN directory install -d [-v] [-g group] [-m mode] [-o owner] directory ... usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 file2 install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 ... fileN directory install -d [-v] [-g group] [-m mode] [-o owner] directory ... usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 file2 install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 ... fileN directory install -d [-v] [-g group] [-m mode] [-o owner] directory ... usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 file2 install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 ... fileN directory install -d [-v] [-g group] [-m mode] [-o owner] directory ... usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 file2 install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 ... fileN directory install -d [-v] [-g group] [-m mode] [-o owner] directory ... usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 file2 install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 ... fileN directory install -d [-v] [-g group] [-m mode] [-o owner] directory ... usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 file2 install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 ... fileN directory install -d [-v] [-g group] [-m mode] [-o owner] directory ... usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 file2 install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 ... fileN directory install -d [-v] [-g group] [-m mode] [-o owner] directory ... usage: install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 file2 install [-bCcpSsv] [-B suffix] [-f flags] [-g group] [-m mode] [-o owner] file1 ... fileN directory install -d [-v] [-g group] [-m mode] [-o owner] directory ... make: *** [install] Error 64

Environment details MACOS Snapcast master branch

claypole avatar Nov 15 '20 02:11 claypole

Attempted to run without -Dt and it fails with the error "/usr/share/snapserver/snapweb does not exist". Is there another option required to create the missing directories?

claypole avatar Nov 15 '20 18:11 claypole

I was able to get this to build to install by:

  • Changing /usr/share to /usr/local/share in Makefile, as MACOS does not allow you to change/create files or directories in /usr/local
  • Creating the /usr/local/share/snapserver, snapweb and 3rdparty-tools manually before running the install

However, I am not sure this has worked, as I cannot access snapweb at the moment.

claypole avatar Nov 16 '20 03:11 claypole

maybe your snapweb is not accessible, because you're using the default doc_root = /usr/share/snapserver/snapweb in your snapserver.conf?

This is bad:

Creating the /usr/local/share/snapserver, snapweb and 3rdparty-tools manually before running the install

Can you try to figure out the necessary command line options? -d sounds promising:

-d Create directories. Missing parent directories are created as required.

(this is from the FreeBSD man page. Could be the same for MacOS)

badaix avatar Nov 17 '20 15:11 badaix

I managed to get it working, thanks.

I had already luckily already spotted and updated doc_root in snapserver.conf.

Unfortunately -d tries to turn every file into a directory, so that didn't work. The only way it works currently is to manually create the directories (bad I know). I was getting something like "/ doesn't exist" in the browser when trying to open snapweb, so I updated the permissions on the directories I created, and restarted snapcast, which is what I think might have finally got it to work.

I uninstalled everything and started again, to be sure, which appears to be working. These were the actions:

Run "make TARGET=MACOS" in ./snapcast/server

Open "./snapcast/snapserver/Makefile" and make the following edits: - Remove "-Dt" from the install commands in the MACOS target install script, as these are not valid options in MacOS (3 lines). - Replace “ /usr/share/” with “/usr/local/share” - because you cannot update /usr/share on MacOS for security reasons (even with sudo).

I also updated the MACOS uninstall script for good measure: - Replace "rm -rf /usr/share/snapserver" with "rm -rf /usr/local/share/snapserver"

Unfortunately, without -Dt, it doesn’t create the missing directories in /usr/local/share, and I haven’t yet been able to work out what the right option is. I am sure there is one, or it might require another command in the install to create the directories first?

Manually create the missing directories: - sudo mkdir /usr/local/share/snapserver /usr/local/share/snapserver/snapweb /usr/local/share/snapserver/snapweb/3rd-party
- sudo chown -R root:wheel /usr/local/share/snapserver - sudo chmod -R 755 /usr/local/share/snapserver

Now you can run make install, and hopefully it will work!

  • sudo make install TARGET=MACOS

Update snapserver.conf dest for doc_root:

  • Replace "doc_root = /usr/share/snapserver/snapweb" with "doc_root = /usr/local/share/snapserver/snapweb"

It would be great if the source can be updated with these changes, though of course the directory solution is a hack at the moment. Main thing is that it is working, so I can keep experimenting.

Thanks for your help.

claypole avatar Nov 19 '20 23:11 claypole

Thanks for elaborating this. Will not be straight forward to fix this (without having macos, but when I find some time I can setup a FreeBSD VM, which behaves similar). Also the default config must be patched with some sed text replacements.

badaix avatar Dec 30 '20 09:12 badaix

I've found similar issues installing on FreeBSD 12.3.
The destination used doesn't match FreeBSD layout, it should be within the /usr/local/ directory tree. The install command behaviour/parameters are different and it doesn't seem to want to create the destination directories.

install: illegal option -- -
usage: install [-bCcpSsUv] [-f flags] [-g group] [-m mode] [-o owner]
               [-M log] [-D dest] [-h hash] [-T tags]
               [-B suffix] [-l linkflags] [-N dbdir]
               file1 file2
       install [-bCcpSsUv] [-f flags] [-g group] [-m mode] [-o owner]
               [-M log] [-D dest] [-h hash] [-T tags]
               [-B suffix] [-l linkflags] [-N dbdir]
               file1 ... fileN directory
       install -dU [-vU] [-g group] [-m mode] [-N dbdir] [-o owner]
               [-M log] [-D dest] [-h hash] [-T tags]
               directory ...

Original install command install -g wheel -o root -m 644 etc/index.html -Dt /usr/share/snapserver/

-t does not exist for FreeBSD, although it does not complain.
-D does something to do with logging. From the man page - " This option does not affect where the actual files are installed".

I eventually realised the 3rd form of the command is JUST for creating directories and they have to be done separately to copying the files.

Once installed, I also had issue that the service requires user snapserver which is not created automatically. I created the user using pw (adduser on FreeBSD is interactive only) as below and then I could start the server daemonized.

pw user add -n snapserver -c "Snapcast Server" -d /var/lib/snapserver/ -s /usr/sbin/nologin

The makefile calls '../debian/snapserver.postinst configure ' for other platforms. Maybe this can be extended to handle FreeBSD?

jonahquark81 avatar Sep 11 '22 08:09 jonahquark81

These install issues are resolved on FreeBSD by switching to the newer cmake build process.

jonahquark81 avatar Sep 11 '22 14:09 jonahquark81