Skip to content
This repository has been archived by the owner on May 27, 2019. It is now read-only.

Homebrew formula for native binary #173

Closed
zsau opened this issue Oct 5, 2017 · 26 comments
Closed

Homebrew formula for native binary #173

zsau opened this issue Oct 5, 2017 · 26 comments

Comments

@zsau
Copy link
Contributor

zsau commented Oct 5, 2017

It would be nice to be able to install the native binary via Homebrew, for easy updating.

@crapp
Copy link

crapp commented Oct 14, 2017

Please also consider supporting macports https://www.macports.org

@maximbaz
Copy link
Member

Would anyone want to volunteer helping with any of these suggestions? :)

I will be happy to advise on any questions, but since I don't have a Mac and since it is a community project, if any of these ideas ever get implemented, the implementation will come from the community.

I'll keep this ticket open for a while, hoping that it will draw attention of other Mac users, but if nobody wants to help I'll have to close it.

@crapp
Copy link

crapp commented Oct 14, 2017

I will have a look if I can write a port file for macports. I have done this in the past so that shouldn't be the problem. I am not so sure about the installation process. The binary has to be copied for every supported browser in a specific directory. I think I'd rather install the binary to the default system location (/opt/local/bin) and create symlinks. I'll give it a try next weekend...

@maximbaz
Copy link
Member

That would be awesome!

It isn't normally needed to copy the binary, we usually put one binary in one place (like in /usr/bin on linux) and let different browsers know where to find the binary. Browsers will not look in $PATH, they use what is declared in the host.json file, right here.

I recommend checking out installation instructions in AUR package, the build() function there takes care of compiling a binary, and the package() function takes care of placing various files to the correct location on the system.

Another source of truth would of course be our own install.sh that we ship together with the release.

@zsau
Copy link
Contributor Author

zsau commented Nov 12, 2017

I'm working on a brew formula, but Homebrew doesn't allow installing files outside the package sandbox. So my plan is to install both the native binary and the install.sh file (as browserpass-setup or such) and instruct the user to run the latter upon installation. The host manifest files would be initially installed to $HOMEBREW_PREFIX/share/browserpass/, for the setup script to copy from.

For that to work, I'll need the brew formula to do a search-and-replace on install.sh to tell it where to find the native binary and the host manifest files. That would be awkward as-is since the script assumes both will be found in the same place, $DIR. @maximbaz, would you consider changing install.sh to use two separate vars for the binary dir and the manifest dir, so those locations can be easily swapped out? I can make a pull request if you like, though it's a pretty trivial change.

@maximbaz
Copy link
Member

I recommend not using install.sh for this, the script is really only for manual installations. Have a look at AUR package that I mentioned above, specifically package function.

@maximbaz
Copy link
Member

Or "package sandbox" means only the folder with the binary? In which case, yeah I see what you mean... Sounds sensible, but let me also think about it and I'll get back to you. There are simply a few other requests for install.sh, I want to make sure they will not break what you are doing here in future.

@maximbaz
Copy link
Member

@zsau I wouldn't like automated packages to depend on install.sh, first because it will change in the future in one or another way and I don't want to worry about potential backwards compatibility issues, but also since it's a package, it should just know how to configure browserpass as much as possible without my manual intervention.

I'm not familiar much with brew, but in this example I see some system calls. Can you use them to copy the json files to correct locations, or better yet, use symlinks?

I imagine the brew install the following files:

/usr
    /bin/browserpass
    /share/browserpass/*.json

and then you can do the following:

mkdir -p /Library/Google/Chrome/NativeMessagingHosts
ln -s /usr/share/browserpass/chrome-host.json /Library/Google/Chrome/NativeMessagingHosts/$APP_NAME.json

... (the same for other files and browsers)

That's essentially what aur package is doing, except that it keeps track of these files and automatically removes them upon uninstallation of browserpass. If there is a way to define commands to run on removal, you can also cleanup these files.

@zsau
Copy link
Contributor Author

zsau commented Nov 13, 2017

I'd prefer that too, but apparently it's not possible: https://discourse.brew.sh/t/installing-files-to-library/1284.

@maximbaz
Copy link
Member

I'm curious how it will know what system call is going to do? 🙂 Could you actually try to see if what that person mentioned (about sandbox not allowing) is actually true?

If this is indeed impossible, yes please go ahead and extend the install.sh to how ever you need it to be. I'll keep in mind to ping you in case it will change, so that you have time to adapt the brew formula if needed.

@zsau
Copy link
Contributor Author

zsau commented Nov 13, 2017

Any attempt to write to paths outside the sandbox results in a permission error.

@zsau
Copy link
Contributor Author

zsau commented Nov 13, 2017

About install.sh, would you accept a change that makes it do something similar to the AUR package, installing the actual JSON files to someplace like $PREFIX/share/browserpass/ and symlinking to them from the browser's NativeMessagingHosts dir?

@maximbaz
Copy link
Member

I'm not sure about symlinking, because I'm not sure how people use the script, i.e. if it is possible that someone will start having broken symlinks because they delete their "installation dir" after they install the app...

Let's keep copying the files, but do your change to separate binary dir and manifests dir.

@zsau
Copy link
Contributor Author

zsau commented Nov 13, 2017

The manifest already acts like a symlink, in that the JSON file references a binary at a specific path (which must exist for the plugin to work). Also I doubt many people blindly delete dirs in $PREFIX/share without knowing what uses them.

But it's not a big deal either way. If you still don't like the idea, I'll keep copying the JSON files and just add the binary/manifest dir distinction as discussed.

@maximbaz
Copy link
Member

I was more thinking like people might download release archive, unarchive the files, copy the binary to /usr/bin/browserpass, run install.sh and then delete the downloaded release archive. I also do something like this during development, e.g. compile things to generate manifests, run install.sh directly in the source repo, but later clean repo from autogenerated files (which removes json files).

@zsau
Copy link
Contributor Author

zsau commented Nov 13, 2017

The symlinks wouldn't be affected by doing that. I'm suggesting that install.sh copy the JSON files to $PREFIX/share/browserpass and then create symlinks pointing to those files inside the NativeMessagingHosts dir(s). That way if the JSON files need to be updated at any point, upgrading via homebrew wouldn't require re-running the install script.

@zsau
Copy link
Contributor Author

zsau commented Nov 13, 2017

On second thought, I'm not sure what I was thinking since the homebrew formula would need to copy the JSON files to the shared directory, so that part can't be done by install.sh. I'll keep the copying approach; sorry for the noise.

@maximbaz
Copy link
Member

maximbaz commented Nov 13, 2017

How about just printing commands for user to execute after installation is done? So you install binary and all json files to somewhere, rename what is possible to rename, and then print messages "now please copy-paste and run these commands".

I did something like this in a different aur package, just a bunch of prints after installation.

@zsau
Copy link
Contributor Author

zsau commented Nov 15, 2017

I considered doing that, but the script seems a little more user-friendly and less error-prone.

The Homebrew formula's pretty much ready, as soon as #190 makes it into a release.

@maximbaz
Copy link
Member

I was going to make a new release as soon as #188 is merged, is it okay to wait for it?

/cc @Weker01

@zsau
Copy link
Contributor Author

zsau commented Nov 15, 2017

No problem!

@maximbaz
Copy link
Member

@zsau 2.0.8 was just released, please test your formula and close this issue if everything is working fine 😉

@zsau
Copy link
Contributor Author

zsau commented Nov 25, 2017

Homebrew/homebrew-core#21039

Thanks for the help!

@zsau zsau closed this as completed Nov 25, 2017
@maximbaz
Copy link
Member

@zsau could you ping me when you manage to get the formula merged, in one place or another? I'd like to rewrite the installation section of the README and mention all available packages as a preferred way of installation (so far I'm only aware of existing packages for ArchLinux and NixOS).

@zsau
Copy link
Contributor Author

zsau commented Nov 26, 2017

Looks like it's not going to be accepted by Homebrew, and frankly I have no will to mess with a cask after wasting a bunch of time on the HB formula. I also just found out that gopass now has native messaging support built-in (already used by the add-on gopassbridge), so I'm even less inclined to put in more work on this. Sorry ;(

@maximbaz
Copy link
Member

It's a shame that homebrew aren't willing to accept this. Thanks for trying anyway 👍

Wow, good finding about built-in native messaging support in gopass, I'm very curious about it now 🙂

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants