Skip to content

Commit

Permalink
Merge branch 'master' of gitlab.ricebook.net:platform/core
Browse files Browse the repository at this point in the history
  • Loading branch information
tonicmuroq committed Nov 9, 2016
2 parents 836c776 + 358d863 commit dbc2ac3
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 56 deletions.
6 changes: 6 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ stages:
- rpm
test:
stage: test
only:
- master
script:
- "make test"
build:
stage: build
only:
- master
script:
- make build
artifacts:
Expand All @@ -19,6 +23,8 @@ build:
expire_in: 1 week
rpm:
stage: rpm
only:
- master
script:
- "./make-rpm"
dependencies:
Expand Down
27 changes: 14 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@ python:
cd ./rpc/gen/; python -m grpc.tools.protoc -I. --python_out=. --grpc_python_out=. core.proto; mv core_pb2.py ../../devtools/

deps:
go get github.com/docker/docker
go get github.com/docker/engine-api
go get github.com/docker/go-units
go get github.com/docker/go-connections
go get github.com/coreos/etcd
go get github.com/Sirupsen/logrus
go get github.com/stretchr/testify
go get github.com/golang/protobuf/proto
go get github.com/codegangsta/cli
go get gopkg.in/yaml.v2
go get gopkg.in/libgit2/git2go.v23
go get golang.org/x/net/context
go get google.golang.org/grpc
go get github.com/docker/engine-api || echo "oops"
go get github.com/docker/go-units || echo "oops"
go get github.com/docker/go-connections || echo "oops"
go get github.com/docker/distribution || echo "oops"
go get github.com/Sirupsen/logrus || echo "oops"
go get github.com/stretchr/testify || echo "oops"
go get github.com/golang/protobuf/{proto,protoc-gen-go} || echo "oops"
go get github.com/codegangsta/cli || echo "oops"
go get gopkg.in/yaml.v2 || echo "oops"
go get gopkg.in/libgit2/git2go.v23 || echo "oops"
go get golang.org/x/net/context || echo "oops"
go get google.golang.org/grpc || echo "oops"
go get github.com/coreos/etcd || echo "oops"
go get github.com/docker/docker || echo "oops"

build:
go build -ldflags "$(GO_LDFLAGS)" -a -tags netgo -installsuffix netgo -o eru-core
Expand Down
53 changes: 17 additions & 36 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,50 +5,31 @@ Core
We use v0.23.4 because v0.24 sucks

```shell
$ wget https://github.com/libgit2/libgit2/archive/v0.23.4.zip
$ unzip v0.23.4.zip
cp devtools/libgit2.rb.patch /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula
git apply libgit2.rb.patch && git add libgit2.rb && git commit -m "patch libgit2 version for eru-core" && rm libgit2.rb.patch
cd -
```
Install dependencies: `libssh2`, `http-parser`, `cmake`, `libcurl`.

```shell
On Mac OSX:
$ brew install libssh2 http-parser cmake libcurl

On CentOS:
$ yum install libssh2-devel http-parser cmake libcurl-devel
```
Then install libgit2.

```shell
$ cmake . -DCMAKE_VERBOSE_MAKEFILE=ON -Wno-dev -DUSE_SSH=YES
$ make && make install
```
Note on Mac OSX may need to set CFLAGS="-std=c99".
Now libgit2 is installed under `/usr/local/lib` as default. We still need to set pkg-config and link dynamic libraries.
## setup dev environment

```shell
On Mac OSX:
$ cd /usr/local/lib/pkgconfig
$ ln -s /path/to/libgit2/pkgconfig/libgit2.pc libgit2.pc
$ cd /usr/local/lib
$ ln -s /path/to/libgit2/libgit2.23.dylib libgit2.23.dylib

On CentOS:
$ cd /usr/lib64/pkgconfig/
$ ln -s /usr/local/lib/pkgconfig/libgit2.pc libgit2.pc
$ cd /usr/lib64
$ ln -s /usr/local/lib/libgit2.so.23 libgit2.so.23
git config --global url."[email protected]:".insteadOf "https://gitlab.ricebook.net/"
go get gitlab.ricebook.net/platform/core.git
mv $GOPATH/src/gitlab.ricebook.net/platform/core.git $GOPATH/src/gitlab.ricebook.net/platform/core
cd $GOPATH/src/gitlab.ricebook.net/platform/core
make deps
make build
```

## setup dev environment
## Upgrade core on test/production server

```shell
$ git config --global url."[email protected]:".insteadOf "https://gitlab.ricebook.net/"
$ go get gitlab.ricebook.net/platform/core.git
$ mv $GOPATH/src/gitlab.ricebook.net/platform/core.git $GOPATH/src/gitlab.ricebook.net/platform/core
$ cd $GOPATH/src/gitlab.ricebook.net/platform/core && go install
$ ln -s $GOPATH/src/gitlab.ricebook.net/platform/core $MY_WORK_SPACE/eru-core2
$ make deps
make build
# test server
devtools/upgrade-eru-core.sh test eru-core
# prod server
devtools/upgrade-eru-core.sh
```

### GRPC
Expand Down
15 changes: 15 additions & 0 deletions devtools/libgit2.rb.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/Formula/libgit2.rb b/Formula/libgit2.rb
index b91f4ff..45205f1 100644
--- a/Formula/libgit2.rb
+++ b/Formula/libgit2.rb
@@ -1,8 +1,8 @@
class Libgit2 < Formula
desc "C library of Git core methods that is re-entrant and linkable"
homepage "https://libgit2.github.com/"
- url "https://github.com/libgit2/libgit2/archive/v0.24.2.tar.gz"
- sha256 "00f0a7403143fba69601accc80cacf49becc568b890ba232f300c1b2a37475e6"
+ url "https://github.com/libgit2/libgit2/archive/v0.23.4.tar.gz"
+ sha256 "c7f5e2d7381dbc4d7e878013d14f9993ae8a41bd23f032718e39ffba57894029"
head "https://github.com/libgit2/libgit2.git"

bottle do
22 changes: 15 additions & 7 deletions devtools/upgrade-eru-core.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
#!/bin/sh
#!/bin/bash

ssh [email protected] -t 'sudo yum --enablerepo=ricebook clean metadata'
ssh [email protected] -t 'sudo yum reinstall -y eru-core'
ssh [email protected] -t 'sudo systemctl daemon-reload'
ssh [email protected] -t 'sudo systemctl restart eru-core.service'
ssh [email protected] -t 'sudo git --work-tree=/opt/citadel --git-dir=/opt/citadel/.git pull'
ssh [email protected] -t 'sudo systemctl restart citadel'
if [ $1 == "test" ]; then
rsync -a /Users/timfeirg/gocode/src/gitlab.ricebook.net/platform/core sa-ricebook:~
ssh sa-ricebook -t 'sudo rm -rf /root/.go/src/gitlab.ricebook.net/platform/core'
ssh sa-ricebook -t 'sudo mv ~/core /root/.go/src/gitlab.ricebook.net/platform/core'
# ssh zzz1 -t 'sudo mv eru-core /usr/bin/eru-core'
# ssh zzz1 -t 'sudo systemctl restart eru-core.service'
else
ssh [email protected] -t 'sudo yum --enablerepo=ricebook clean metadata'
ssh [email protected] -t 'sudo yum reinstall -y eru-core'
ssh [email protected] -t 'sudo systemctl daemon-reload'
ssh [email protected] -t 'sudo systemctl restart eru-core.service'
ssh [email protected] -t 'sudo git --work-tree=/opt/citadel --git-dir=/opt/citadel/.git pull'
ssh [email protected] -t 'sudo systemctl restart citadel'
fi

0 comments on commit dbc2ac3

Please sign in to comment.