How to create custom brew bottle - homebrew

I have a go application that I would like to distribute for a few developers. Is it possible with "bottles & taps"?
I have tried:
brew tap-new <name of tap>
This gives me a local repository:
Initialized empty Git repository in <local path>
I possible what to do then, I can't find any documentation for custom bottle?

It's vaguely documented right over here; your formula would probably define
bottle do
root_url "https://my-internal-server/"
sha256 "..." => :sierra
sha256 "..." => :el_capitan
sha256 "..." => :yosemite
end

Related

How to I set an ENV VAR in my WORKSPACE in Bazel

I am trying to use Bazel with Pybind, and it requires that I set the following variables:
"""Repository rule for Python autoconfiguration.
`python_configure` depends on the following environment variables:
* `PYTHON_BIN_PATH`: location of python binary.
* `PYTHON_LIB_PATH`: Location of python libraries.
"""
https://github.com/pybind/pybind11_bazel/blob/master/python_configure.bzl
I dont want to have to pass it in manually when building my libraries, how can i hardcode these env vars in my WORKSPACE?
To (always) set environmental variable for a repository rule consumption, you case use --repo_env command line option. And if you want to include those with every invocation in your workspace, you can set add these flags to your .bazelrc file therein.
Now the wisdom of doing that could be questioned. If it's actually a project (repo) and not build host configuration, it would probably make more sense, be more targeted and more explicit, if it was an attribute of the given rule which was then checked in with the rest of the build configuration.
And looking at the name, there may be another question about specifying python configuration (from outside the bazel build) instead of actually using correctly resolved python toolchain (but there I have to say have no background in what the given rule is about and what is it trying to accomplish to render judgment, this is just a general comment).
To address your comment... I don't what other factors make it "not accept" or what exactly does that actually look like, but if I have this mini-example:
.
├── BUILD
├── WORKSPACE
└── customrule.bzl
Where customrule.bzl reads:
def _run_me(repo_ctx):
repo_ctx.file(
"WORKSPACE",
'workspace(name = "{}")\n'.format(repo_ctx.name),
executable = False,
)
repo_ctx.file(
"BUILD",
'exports_files(["var.sh"], visibility=["//visibility:public"])',
executable = False,
)
repo_ctx.file(
"var.sh",
"echo {}\n".format(repo_ctx.os.environ.get("var1")),
executable = True,
)
wsrule = repository_rule(
implementation = _run_me,
environ = ["var1"],
)
The WORKSPACE is:
load(":customrule.bzl", "wsrule")
wsrule(
name = "extdep"
)
And BUILD:
sh_binary(
name = "tgt",
srcs = ["#extdep//:var.sh"],
)
Then I do get:
$ bazel run --repo_env var1=val1 tgt
val1
and:
$ bazel run --repo_env var1=val2 tgt
val2
I.e. this is a way to pass variables to a repo rule and it does (as such) work.
If you absolutely know, you must call a build with some variable set to certain value (which as mentioned above is itself a requirement that is worth closer examination) and you want these to be associated with the project / repo. You can always check in a build.sh or any such file that wraps your bazel call to be exactly what it must be. But again, this looks more likely to not be really entirely "The Right Thing" to do or want.

Not able to find curator.yml (elasticsearch-curator) in linux

Official site of elasticsearch says the default config file exists in /home/username/.curator/curator.yml
https://www.elastic.co/guide/en/elasticsearch/client/curator/current/command-line.html
But there is no such folder.
Also, I tried creating curator.yml and give path using --config option. But, it throws me error
curator --config ./curator.yml
Error: no such option: --config
Installation was done using apt
sudo apt-get update && sudo apt-get install elasticsearch-curator
Help me create a config file as I want to delete my log-indexes
Please note that the documentation does not say it that file exists after creation, it says:
If --config and CONFIG.YML are not provided, Curator will look in ~/.curator/curator.yml for the configuration file.
The file must be created by the end user.
Also, if you installed via:
sudo apt-get update && sudo apt-get install elasticsearch-curator
but did not add the official Elastic repository for Curator, then you installed an older version. Please check which version you are running with:
$ curator --version
curator, version 5.4.1
If you do not see the current version (5.4.1 at the time this answer was added), then you do not have the appropriate repository installed.
The official documentation provides an example client configuration file here.
There are also many examples of action files in the examples
Yes, one needs to create both the curator.yml as well as action.yml files.
Since I am on centos 7, I happened to install curator from RPM, and in its default /opt/elastic-curator' I could follow up this good blog (but badly formatted!) : https://anchormen.nl/blog/big-data-services/monitoring-aws-redshift-with-elasticsearch/ to ge the files as follows(you may modify according to your needs) :
curator.yml
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
client:
hosts:
- <host1>
- <host2, likewise upto hostN >
port: 9200
url_prefix:
use_ssl: False
certificate:
client_cert:
client_key:
ssl_no_validate: False
http_auth:
timeout: 30
master_only: False
logging:
loglevel: INFO
logfile: /var/log/curator.log
logformat: default
blacklist: []
and an action.yml as follows :
---
# Remember, leave a key empty if there is no value. None will be a string,
# not a Python "NoneType"
#
# Also remember that all examples have 'disable_action' set to True. If you
# want to use this action as a template, be sure to set this to False after
# copying it.
actions:
1:
action: rollover
description: Rollover the index associated with index 'name', which should be in the form of prefix-000001 (or similar),or prefix-YYYY.MM.DD-1.
options:
disable_action: False
name: redshift_metrics_daily
conditions:
max_age: 1d
extra_settings:
index.number_of_shards: 2
index.number_of_replicas: 1
2:
action: rollover
description: Rollover the index associated with index 'name' , which should be in the form of prefix-000001 (or similar), or prefix-YYYY.MM.DD-1.
options:
disable_action: False
name: redshift_query_metadata_daily
conditions:
max_age: 1d
extra_settings:
index.number_of_shards: 2
index.number_of_replicas: 1

Linking custom taps to existing bottles in bintray

As it usually happens sometimes you get stuck with older version of some software. But you still want to be able to install it seamlessly using homebrew. In my company we are stuck with old version of docker so I created my own tap from the old version of docker Formula.
class Docker191 < Formula
desc "Pack, ship and run any application as a lightweight container"
homepage "https://www.docker.com/"
url "https://github.com/docker/docker.git",
:tag => "v1.9.1",
:revision => "a34a1d598c6096ed8b5ce5219e77d68e5cd85462"
revision 1
head "https://github.com/docker/docker.git"
bottle do
cellar :any_skip_relocation
root_url "https://homebrew.bintray.com/bottles"
sha256 "fe02c921afd6863be441b85ae069e24b7c5b13e97615b47c994ea8064e082bf1" => :el_capitan
sha256 "8a3137f5d6155491e9c4833d80ca819d8bf6d31f38595be713baed06f5283c92" => :yosemite
sha256 "282f987005f81d9a82269827b66aa1044dfbd8645c23845d59e21aad93dc99e0" => :mavericks
end
option "without-completions", "Disable bash/zsh completions"
depends_on "go" => :build
conflicts_with "docker", :because => "Differing version of the same formula"
def install
ENV["AUTO_GOPATH"] = "1"
ENV["DOCKER_CLIENTONLY"] = "1"
system "hack/make.sh", "dynbinary"
build_version = build.head? ? File.read("VERSION").chomp : version
bin.install "bundles/#{build_version}/dynbinary/docker-#{build_version}" => "docker"
if build.with? "completions"
bash_completion.install "contrib/completion/bash/docker"
fish_completion.install "contrib/completion/fish/docker.fish"
zsh_completion.install "contrib/completion/zsh/_docker"
end
end
test do
system "#{bin}/docker", "--version"
end
end
It all builds fine from the source but I was wondering whether it is possible to pull the bottles already built and available in bintray instead of building from source.
I tried to do it by adding
root_url "https://homebrew.bintray.com/bottles"
But because my Formula name is Docker191 instead of just Docker it tries to pull from nonexistent path
==> Downloading https://homebrew.bintray.com/bottles/docker191-1.9.1_1.el_capitan.bottle.tar.gz
instead of
==> Downloading https://homebrew.bintray.com/bottles/docker-1.9.1_1.el_capitan.bottle.tar.gz
Is there a way to fix the bottle name as well? I cannot change the name of formula to Docker because I need multiple versions to be available.

How to escape # in Ant SCP task

I would like to ask you for some help. How can I use an scp task when my username contains an # sign?
I tried to escape the character in many ways but it isn't working. In the following example, my username is user#host.com
<scp file="test.txt" todir=""user#host.com":password#ftp.host.com:/" trust="true" sftp="true"/>
<scp file="test.txt" todir="'user#host.com':password#ftp.host.com:/" trust="true" sftp="true"/>
<scp file="test.txt" todir="user\#host.com:password#ftp.host.com:/" trust="true" sftp="true"/>
But the output is always the same:
neither password nor keyfile for user "user has been given. Can't authenticate.
Please, is there anyway to force the task to parse this string correctly? Thank you very much.
By the way, I don't know why but with my current provider it is impossible to create a username without appending the hostname.
I use the SCP task in my build.xml and it's form looks like this:
<scp file="package/ROOT.war" todir="user#example.com:~" trust="true" password="${password}"/>
Looking at the source of the SCP Task at the function parseUri(String uri) (line 370) it appears that the task can support a username with a # symbol. The restrictions appear to be with paths that have a : or # in them as seen by this comment:
// user:password#host:/path notation
// everything upto the last # before the last : is considered
// password. (so if the path contains an # and a : it will not work)
The code doesn't seem to support this comment (as pointed out by
martin clayton). You can also see the error you are referring which is triggered when the password or the keyfile is missing. Maybe the combination of a password in user:password#host:/path notation and a username with an # is causing problems?
Present ant version -1.9.4 operating system:-16.04 Ubuntu did not work.
Changed to 1.9.3 and pointed to /usr/bin/ant ssh was successful
observation:
16.04 and ant 1.9.3 is working
14.04 ant 1.9.4 is working

Trying to make curl requests in ruby

is there a ruby curl library that will allow me to duplicate this request:
curl -d '<hello xmlns="http://checkout.google.com/schema/2"/>' https://S_MERCHANT_ID:S_MERCHANT_KEY#sandbox.google.com/checkout/api/checkout/v2/request/Merchant/S_MERCHANT_ID
i have tried curb, but their PostField.content class is not cooperating with google's checkout api. here is the code from my curb request:
c = Curl::Easy.new("https://MY_ID:MY_KEY#sandbox.google.com/checkout/api/checkout/v2/request/Merchant/MY_ID_AGAIN")
c.http_auth_types = :basic
c.username = 'MY_ID'
c.password = 'MY_KEY'
# c.headers["data"] = '<?xml version="1.0" encoding="UTF-8"?><hello xmlns="http://checkout.google.com/schema/2"/>'
c.http_post(Curl::PostField.content('', '<?xml version="1.0" encoding="UTF-8"?><hello xmlns="http://checkout.google.com/schema/2"/>'))
c.perform
i HAVE managed to get it working using ruby's system command, but im not sure how to handle the response from it.
req = system("curl -d '<hello xmlns=\"http://checkout.google.com/schema/2\"/>' https://MY_ID:MY_KEY#sandbox.google.com/checkout/api/checkout/v2/request/Merchant/MY_ID")
I have been at it for 2 hours now. any help would be greatly appreciated, thanks!
You can use IO.popen to read from the child process:
IO.popen(['curl', '-o', '-', '-d', ..., err: [:child, :out]]) do |io|
response = io.read
end
This example combines standard out and standard error into one stream in the child process, and it forces curl to redirect output to standard out via -o. You would specify your other options in place of the ....
I always use Rest Client gem for such use cases, it is very simple in use and have all REST requests out-of-box with whole batch of tuning parameters.
Your code will look like something similar to this:
url = "sandbox.google.com/checkout/api/checkout/v2/request/Merchant/#{S_MERCHANT_ID}"
credentials = "#{S_MERCHANT_ID}:#{S_MERCHANT_KEY}"
RestClient.post "https://credentials##{url}", '<hello xmlns="http://checkout.google.com/schema/2"/>'
Alternatively, you can use a HTTP request library such as Typheous (https://github.com/typhoeus/typhoeus). Is there anything that binds you with "curl"?
I would have curl put the result in a file, and then open the file using ruby and read it ( File.open)
Or us httparty
I figured it out (YAAAAY!)
if anyone else is having this problem, here is the solution.
executable commands work fine in the command line, but if you are trying to render the output of an executable command from a controller in rails, make sure you use render :json instead of render :text to print the results.
for some reason the render :text was only outputting bits and pieces of my command's output (and driving me insane in the process).
For those of you trying to integrate with google checkout in rails, here is how you make http requests to google:
First step: add rest-client to your Gemfile. here is how to do it from the command line:
$ cd /path/to/your/rails/app
$ sudo nano Gemfile
Next, add the gem to your gemfile by placing the following somewhere in your Gemfile
$ gem "rest-client"
next, run bundle install
$ bundle install
restart your server. if apache2:
$ sudo service apache2 reload
if webrick:
$ rails s
then, in your controller (assuming you have rails set up and are able to access a controller from the browser) write the following code:
$ url = "https://YOUR_GOOGLE_CHECKOUT_MERCHANT_ID:YOUR_GOOGLE_CHECKOUT_KEY#sandbox.google.com/checkout/api/checkout/v2/request/Merchant/YOUR_GOOGLE_CHECKOUT_MERCHANT_ID"
$ req = RestClient.post(url, '<hello xmlns="http://checkout.google.com/schema/2"/>')
render :json => req
Please don't forget to replace YOUR_GOOGLE_MERCHANT_ID with your actual merchant id and YOUR_GOOGLE_CHECKOUT_KEY with your actual google checkout key
<?xml version="1.0" encoding="UTF-8"?>
<bye xmlns="http://checkout.google.com/schema/2" serial-number="1dfc3b90-1fa6-47ea-a585-4d5482b6c785" />
(answer courtesy of nexo)

Resources