123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- #!/usr/bin/make -f
- # originally from https://raw.githubusercontent.com/junland/hello-deb/master/debian/rules
- export DH_OPTIONS
- ##
- # From git-lfs/git-lfs repo:
- # Looks like dh_golang doesn't set diffrent archs, so you have to do them semi-manually.
- ##
- ## This if-structure is decided on what is passed by the -a flag by dpkg-buildpackage command.
- ifeq ($(DEB_HOST_ARCH), i386)
- export GOARCH := 386
- else ifeq ($(DEB_HOST_ARCH), amd64)
- export GOARCH := amd64
- else ifeq ($(DEB_HOST_ARCH), armhf)
- export GOARCH := arm
- # May need to set GOARM as well if your going to target ARM. But for now this works.
- else ifeq ($(DEB_HOST_ARCH), arm64)
- export GOARCH := arm64
- endif
- # Or add your arch that your targeting, these are just examples.
- # Directory where compiled binary is placed + debian setup files.
- # Note: If your doing building thru git, you may want to add obj-* to .gitignore
- BUILD_DIR := obj-$(DEB_HOST_GNU_TYPE)
- REPO := gogs
- WHOAMI := hp
- NOTABUG := notabug
- # Required: Put the url (without http://) of your git repo.
- export DH_GOPKG := notabug.org/$(WHOAMI)/$(REPO)
- # Required: Put the name of your git repo below.
- GIT_REPO_NAME := $(NOTABUG)-$(WHOAMI)-$(REPO)
- export PATH := $(CURDIR)/$(BUILD_DIR)/bin:$(PATH)
- ##
- # From git-lfs/git-lfs repo:
- # by-default, dh_golang only copies *.go and other source - this upsets a bunch of vendor test routines
- ##
- export DH_GOLANG_INSTALL_ALL := 1
- %:
- dh $@ --buildsystem=golang --with=golang
- override_dh_clean:
- rm -f debian/debhelper.log
- dh_clean
- override_dh_auto_build:
- dh_auto_build -- -ldflags "-s -w"
- ##
- # From git-lfs/git-lfs repo:
- # dh_golang doesn't do anything here in deb 8, and it's needed in both
- ##
- if [ "$(DEB_HOST_GNU_TYPE)" != "$(DEB_BUILD_GNU_TYPE)" ]; then\
- cp -rf $(BUILD_DIR)/bin/*/* $(BUILD_DIR)/bin/; \
- cp -rf $(BUILD_DIR)/pkg/*/* $(BUILD_DIR)/pkg/; \
- fi
-
- override_dh_strip:
- ##
- # From git-lfs/git-lfs repo:
- # strip disabled as golang upstream doesn't support it and it makes go crash.
- # See https://launchpad.net/bugs/1200255.
- ##
- # override_dh_golang:
- ##
- # From git-lfs/git-lfs repo:
- # The dh_golang is used to add the Built-using field to the deb. This is only for reference.
- # As of https://anonscm.debian.org/cgit/collab-maint/dh-golang.git/commit/script/dh_golang?id=7c3fbec6ea92294477fa8910264fe9bd823f21c3
- # dh_golang errors out because the go compiler used was not installed via a package. Therefore the step is skipped
- ##
- override_dh_auto_install:
- mkdir -p debian/golang-$(GIT_REPO_NAME)/lib/systemd/system
- cp scripts/systemd/gogs.service debian/golang-$(GIT_REPO_NAME)/lib/systemd/system
- # outPlattform:=linux
- # outArch:=amd64
- # outPath:=output_$(outPlattform)_$(outArch)
- # mkdir -p $outPath
- # CGO_ENABLED=0 GOOS=$(outPlattform) GOARCH=$(outArch) go build -buildmode=pie ../gogs.go
- # chmod +x gogs
- # mv gogs $outPath/
- # cd ../scripts;
- mkdir -p debian/golang-$(GIT_REPO_NAME)/usr/bin
- cp obj-x86_64-linux-gnu/bin/gogs debian/golang-$(GIT_REPO_NAME)/usr/bin
- mkdir -p debian/golang-$(GIT_REPO_NAME)/usr/share/gogs
- cp -r conf/ debian/golang-$(GIT_REPO_NAME)/usr/share/gogs/conf/
- # cp -r custom/ debian/golang-$(GIT_REPO_NAME)-var/gogs/custom/
- # cp -r dockerfiles/ $outPath/dockerfiles/
- cp -r public/ debian/golang-$(GIT_REPO_NAME)/usr/share/gogs
- cp -r templates/ debian/golang-$(GIT_REPO_NAME)/usr/share/gogs/
- # cp cert.pem debian/golang-$(GIT_REPO_NAME)-var/gogs/
- cp CONTRIBUTING.md debian/golang-$(GIT_REPO_NAME)/usr/share/gogs/
- # cp scripts/gogs_supervisord.sh debian/golang-$(GIT_REPO_NAME)-var/gogs/
- # do we need to make key.pem?
- # cp key.pem debian/golang-$(GIT_REPO_NAME)-var/gogs/
- cp LICENSE debian/golang-$(GIT_REPO_NAME)/usr/share/gogs/
- cp README.md debian/golang-$(GIT_REPO_NAME)/usr/share/gogs/
- # cp scripts/start.sh debian/golang-$(GIT_REPO_NAME)-var/gogs/
- # cp wercker.yml debian/golang-$(GIT_REPO_NAME)-var/gogs/
- cp scripts/mysql.sql debian/golang-$(GIT_REPO_NAME)/usr/share/gogs/
- mkdir -p debian/golang-$(GIT_REPO_NAME)/var/lib/dpkg/info
- cp scripts/postinst/gogs.postinst debian/golang-$(GIT_REPO_NAME)/var/lib/dpkg/info
- # golang-notabug-themusicgod1-panicparse-dev
- # This is making a "fakeroot" so that when the deb is installed the binary will be placed in /usr/bin.
- # mkdir -p debian/golang-$(GIT_REPO_NAME)-dev/usr/bin
- # mkdir -p debian/golang-$(GIT_REPO_NAME)-dev/usr/share/gocode/src/notabug.org/$(WHOAMI)/$(REPO)
- # This is copying the binary and placing it in the fake root path.
- # cp $(BUILD_DIR)/bin/panicparse debian/golang-$(GIT_REPO_NAME)-dev/usr/bin/
- # cp $(BUILD_DIR)/bin/panic debian/golang-$(GIT_REPO_NAME)-dev/usr/bin/
- # cp $(BUILD_DIR)/bin/pp debian/golang-$(GIT_REPO_NAME)-dev/usr/bin/
- # cp -r $(BUILD_DIR)/src/notabug.org/themusicgod1/panicparse/stack debian/golang-$(GIT_REPO_NAME)-dev/usr/share/gocode/src/notabug.org/$(WHOAMI)/$(REPO)
- # #!/usr/bin/make -f
- #export DH_OPTIONS
- #%:
- # dh $@ --buildsystem=golang --with=golang
|