Closed perasmus closed 10 years ago
Hi perasmus,
I did consider it, but the homebrew philosophy is that packages should (mostly) be made available for UNIX tools that need to be ported to OSX (https://github.com/Homebrew/homebrew/wiki/Acceptable-Formulae).
One thing that could be possible though is using brew tap.
For now, there does not seem to be enough interest in clamp for me to invest time in this. I may reconsider if more people use it some day.
If someone is willing to do it i'd be very glad to merge it though !
If I have enough time I might look into that :) I'll keep you postet.
Great !! Let me know ;)
Hi again,
I did some tests today and created a (working) "formula" for clamp. There are some changes and steps which I'll describe here. It is possible to test this formula on your own hardware. Distributing it through homebrew would require some further steps. Maybe @jide will give it a try :)
We need to make some adjustments to the main clamp
file (the unix one) later. The reason is the use of »absolute paths«. I made some changes which resolve symlinks etc and functions alike the php __DIR__
variable (I'm actually using some php, since it is easier and it is required anyway...). Thus it works via the current install script and also if you change directories (like homebrew does).
#!/bin/bash
SCRIPT_DIR=$(php -r "exit(dirname(realpath('${0}')));")
start() {
php ${SCRIPT_DIR}/clamp.php start
}
stop() {
echo -en "\n"
php ${SCRIPT_DIR}/clamp.php stop
exit $?
}
if [ "$#" == "0" ]; then
trap stop SIGINT
start
while true; do read x; done
else
php ${SCRIPT_DIR}/clamp.php "$@"
fi
Now we have a »portable« clamp version. This will be needed later, since homebrew will download clamp freshly from the web.
Adding the formula to homebrew is also rather simple: brew create https://github.com/jide/clamp/archive/master.zip
This will open an editor for your recipe. The formula I came up with is rather simple
require "formula"
class Clamp < Formula
homepage "http://jide.github.io/clamp"
url "https://github.com/jide/clamp/archive/master.zip"
sha1 "b84fcd7809160e794d6ee1e8ddd71f68b3201481"
version "0.1"
depends_on "mariadb"
def install
prefix.install Dir["*"]
bin.install_symlink '../clamp'
end
end
this will place the recipe in /usr/local/Library/Formula/clamp.rb
Now we can install it via brew install clamp
We need to apply those changes mentioned at the start, or else clamp won't find its clamp.php
. The file ist located in /usr/local/Cellar/clamp/0.1/clamp
.
Enjoy!
2 additional things:
how to publish via homebrew is described here https://github.com/Homebrew/homebrew/blob/master/share/doc/homebrew/Formula-Cookbook.md#commit
the audit tool prefers tarballs, else it seems to be fine
brew audit
clamp:
* Use GitHub tarballs rather than zipballs (url is https://github.com/jide/clamp/archive/master.zip).
Error: 1 problems in 1 formulae
i think you could also use https://github.com/jide/clamp/archive/master.tar.gz
this would require another checksum.
Hey @perasmus,
Wow this rocks !
I don't have the time right now, but I'll come back as soon as I can. Thank you for taking the time to look into this :)
Hi @jide,
I will also have a look at two changes in the coming days:
clamp update
function should return "please use brew upgrade clamp
". or it could trigger this function. To check whether or not it is installed via homebrew could be made »quick and dirty« (»am I installed in a Folder called Cellar«)...I'll send you an updated version soon :)
All right:
--head
directive which complicates installation. The »updated« and »audited« formula now looks like this:require "formula"
class Clamp < Formula
homepage "http://jide.github.io/clamp"
url "https://github.com/jide/clamp/archive/master.tar.gz"
sha1 "9463c24929db98da54693403ba9d9773e7e40a50"
version "0.2"
depends_on "mariadb"
def install
prefix.install Dir["*"]
bin.install_symlink '../clamp'
end
end
this one passes the brew audit
tool. That means: tarball instead of zipball, no trailing whitespaces, file ends with a newline. If there is an updated CLAMP version the checksum and possibly the version need to be updated and committed to homebrew
.
includes/Clamp/UpdateCommand.php
could be changed to this:<?php
namespace Clamp;
use ConsoleKit;
class UpdateCommand extends \Clamp\Command
{
public function execute(array $args, array $options = array())
{
if ( strpos(__DIR__, "/Cellar/") )
exec('brew upgrade clamp');
else
exec('curl http://jide.github.io/clamp/install.sh | sh');
}
}
The /Cellar/
part in a path seems to be required by homebrew. Alternatively one could ask if INSTALL_RECEIPT.json
exist. Instead of the first exec one could also echo a message.
The changes made to the clamp
are the same as mentioned above. To have it all in one post, I'll repost it:
#!/bin/bash
SCRIPT_DIR=$(php -r "exit(dirname(realpath('${0}')));")
start() {
php ${SCRIPT_DIR}/clamp.php start
}
stop() {
echo -en "\n"
php ${SCRIPT_DIR}/clamp.php stop
exit $?
}
if [ "$#" == "0" ]; then
trap stop SIGINT
start
while true; do read x; done
else
php ${SCRIPT_DIR}/clamp.php "$@"
fi
Hi @perasmus,
This is awesome !
I still don't have time for the moment, but I just wanted to say hello :)
I am wondering if we should not embrace homebrew entirely and remove the update command completely, letting homebrew manage this for us instead.
I'll definitely have a look at this as soon as I can.
If you have time and you're willing to make a Pull Request that would really help, otherwise I'll update the code manually.
Thanks again for the awesome work !
Hi,
just a quick update: I made a fork and added the mentioned changes. No merge request right now, since I'd like to test it some more with 10.10 and 10.9 (the only two versions I have available right now). perasmus clamp fork
I also created a »tool« which automates some more or less annoying tasks when creating a formula (including creating and pushing a version tag to github, creating the checksum ...). You can also manually do these steps... If you want to take a look: perasmus clamp_forumla
Now if everything is stable enough the only missing part would be an official homebrew pull request. This step is described over here »homebrew pull request«...
best regards, perasmus
Hi again,
no bug, just a question. Is it possible to distribute CLAMP via homebrew? Since homebrew and mariadb are already required, installation would be even easier than it already is.