I've built a binary locally...how do I now 'install' it system wide ?

polaris · · 457 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hi So I&#39;m playing with Grafana </p> <p><a href="http://docs.grafana.org/project/building_from_source/" rel="nofollow">http://docs.grafana.org/project/building_from_source/</a></p> <p>and I&#39;ve been folowing the build from source guide above as I couldn&#39;t find binaries for i386. This works well except that the binaries end up where i built them (under my home dir). My question is, what is the Go version of &#39;make install&#39; ? Is it possible to automatically install the bin in a system location and ideally get the init scripts and config scripts be created/put in the correct spots (e.g. /etc) or does it have to be done manually ? Thanks</p> <p>[Update- Solved] On the page above it details how to create a package via </p> <pre><code>go run build.go build package </code></pre> <p>and that installs things into the correct locations Thanks for the help and suggestions</p> <hr/>**评论:**<br/><br/>q1t: <pre><p>there is a &#39;go install&#39; which will install a binary under $GOPATH/bin, just place a $GOPATH/bin in your system&#39;s $PATH</p></pre>lakid74: <pre><p>no worries. It&#39;s not so much the &#39;put it the bin in a new location&#39; i&#39;m after it&#39;s more the systemd and etc files i&#39;m after so I can daemonise it Thanks</p></pre>icholy: <pre><p>I like supervisord</p></pre>bboozzoo: <pre><p>It&#39;s out of the scope of go tools. Use whatever method you would use for other software, eg. Makefile with an <code>install</code> target with suffice.</p> <p>For instance, docker has a Makefile but without an <code>install</code> target. In this case, in the spec for Fedora&#39;s packages, the binaries are just copied over to proper locations.</p></pre>lakid74: <pre><p>ah ok, got it thanks.</p></pre>CrankBot: <pre><p>Grafana probably has package build &amp; install scripts somewhere in the source tree... Seems there is not a &#34;go&#34; way to do it but you should be able to see what they did to take the executable and package it for RHEL &amp; Debian.</p></pre>lakid74: <pre><p>ok will have a look around, thanks for the input.</p></pre>BasicDesignAdvice: <pre><p>You could probably turn it into a package using fpm.</p></pre>lakid74: <pre><p>yes and this did what I was after. On the link above it details how to create the package using</p> <pre><code>go run build.go build package </code></pre> <p>and that did exactly what i wanted...thanks !</p></pre>[deleted]: <pre><p>Checking out the source, it looks like <code>build.go</code> has a number of options: <a href="https://github.com/grafana/grafana/blob/master/build.go" rel="nofollow">https://github.com/grafana/grafana/blob/master/build.go</a></p> <p>Try running with the <code>package</code> option (<code>go run build.go package</code>) and it looks like it&#39;ll build .deb and .rpms of it which you can then install whichever is appropriate for your distro.</p></pre>lakid74: <pre><p>Yep that&#39;s what I did and it all worked. Thanks !</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

457 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传