Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add generation of apiserver-builder executables, .deb and .rpm packages in . #150

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,23 @@
# See the License for the specific language governing permissions and
# limitations under the License.

NAME=apiserver-builder
VENDOR=kubernetes-incubator
VERSION=$(shell cat VERSION)
DESCRIPTION=apiserver-builder implements libraries and tools to quickly and easily build Kubernetes apiservers to support custom resource types.
MAINTAINER=The Kubernetes Authors
URL=https://github.com/$(VENDOR)/$(NAME)
LICENSE=Apache-2.0

BUILD_DIR=$(shell pwd)/build
DARWIN_AMD64_BUILD_BIN_DIR=$(BUILD_DIR)/darwin-amd64/bin
LINUX_AMD64_BUILD_BIN_DIR=$(BUILD_DIR)/linux-amd64/bin
LINUX_AMD64_BUILD_PKG_DIR=$(BUILD_DIR)/linux-amd64/pkg
WINDOWS_AMD64_BUILD_BIN_DIR=$(BUILD_DIR)/windows-amd64/bin

.PHONY: default
default: install

.PHONY: test
test:
go test ./pkg/... ./cmd/...
Expand All @@ -20,3 +37,70 @@ test:
install:
go install -v ./pkg/... ./cmd/...

.PHONY: clean
clean:
rm -rf $(BUILD_DIR)

.PHONY: build
build: clean build-darwin-amd64 build-linux-amd64 build-windows-amd64

.PHONY: build-darwin-amd64
build-darwin-amd64: build-apiregister-gen-darwin-amd64 build-apiserver-boot-darwin-amd64 build-apiserver-builder-release-darwin-amd64

.PHONY: build-apiregister-gen-darwin-amd64 build-apiserver-boot-darwin-amd64 build-apiserver-builder-release-darwin-amd64
build-apiregister-gen-darwin-amd64 build-apiserver-boot-darwin-amd64 build-apiserver-builder-release-darwin-amd64: build-%-darwin-amd64:
mkdir -p $(DARWIN_AMD64_BUILD_BIN_DIR)
GOOS=darwin GOARCH=amd64 go build -o $(DARWIN_AMD64_BUILD_BIN_DIR)/$* ./cmd/$*/main.go

.PHONY: build-linux-amd64
build-linux-amd64: build-apiregister-gen-linux-amd64 build-apiserver-boot-linux-amd64 build-apiserver-builder-release-linux-amd64

.PHONY: build-apiregister-gen-linux-amd64 build-apiserver-boot-linux-amd64 build-apiserver-builder-release-linux-amd64
build-apiregister-gen-linux-amd64 build-apiserver-boot-linux-amd64 build-apiserver-builder-release-linux-amd64: build-%-linux-amd64:
mkdir -p $(LINUX_AMD64_BUILD_BIN_DIR)
GOOS=linux GOARCH=amd64 go build -o $(LINUX_AMD64_BUILD_BIN_DIR)/$* ./cmd/$*/main.go
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may need to do something more than this. The tar release contains builds of the vendored code-generators + the vendored go packages.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look at the artifacts in the .tar.gz published in the release and the release cmd.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Understood (see the comment above). The idea is then to run apiserver-builder-release to build a .tar.gz and use this to create the packages. Do you have any idea why apiserver-boot fails when I run apiserver-builder-release (again, see the comment above).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. That is weird, the release command should set the GOPATH. Looking that the code, it looks like it might be just appending the GOPATH. Perhaps if your GOPATH is already set, it won't override it. What OS are you running this on? I have only run it from a Mac.

I am going to try a fix by removing the existing GOPATH env from the exec'ed command environment if it is preset.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am running this on a Mac with a GOPATH set. Since you're already on it, I won't open an issue for it then. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, that is odd. What shell are you using? I made some changes so it will prune the GOPATH from the environment when execing. Try running again now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your may revert your change to GOPATH handling. The error was due to glide being missing.


.PHONY: build-windows-amd64
build-darwin-amd64: build-apiregister-gen-windows-amd64 build-apiserver-boot-windows-amd64 build-apiserver-builder-release-windows-amd64

.PHONY: build-apiregister-gen-windows-amd64 build-apiserver-boot-windows-amd64 build-apiserver-builder-release-windows-amd64
build-apiregister-gen-windows-amd64 build-apiserver-boot-windows-amd64 build-apiserver-builder-release-windows-amd64: build-%-windows-amd64:
mkdir -p $(WINDOWS_AMD64_BUILD_BIN_DIR)
GOOS=linux GOARCH=amd64 go build -o $(WINDOWS_AMD64_BUILD_BIN_DIR)/$* ./cmd/$*/main.go

.PHONY: package
package: build package-linux-amd64

.PHONY: package-linux-amd64
package-linux-amd64: build-linux-amd64 package-linux-amd64-deb package-linux-amd64-rpm

.PHONY: package-linux-amd64-deb
package-linux-amd64-deb: ## Build a Debian package. Requires jordansissel/fpm.
mkdir -p $(LINUX_AMD64_BUILD_PKG_DIR)

fpm --name '$(NAME)' --version '$(VERSION)' \
--input-type dir \
--output-type deb \
--vendor '$(VENDOR)' \
--description '$(DESCRIPTION)' \
--url '$(URL)' \
--maintainer '$(MAINTAINER)' \
--license '$(LICENSE)' \
--package $(LINUX_AMD64_BUILD_PKG_DIR)/$(NAME)_$(VERSION)_amd64.deb \
$(LINUX_AMD64_BUILD_BIN_DIR)/=/usr/local/bin

.PHONY: package-linux-amd64-rpm
package-linux-amd64-rpm: ## Build a Debian package. Requires jordansissel/fpm and rpmbuild.
mkdir -p $(LINUX_AMD64_BUILD_PKG_DIR)

fpm --name '$(NAME)' --version '$(VERSION)' \
--input-type dir \
--output-type rpm \
--vendor '$(VENDOR)' \
--description '$(DESCRIPTION)' \
--url '$(URL)' \
--maintainer '$(MAINTAINER)' \
--license '$(LICENSE)' \
--rpm-os linux \
--package $(LINUX_AMD64_BUILD_PKG_DIR)/$(NAME)_$(VERSION)_amd64.rpm \
$(LINUX_AMD64_BUILD_BIN_DIR)/=/usr/local/bin
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.1-alpha.14