rules 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #!/usr/bin/make -f
  2. # originally from https://raw.githubusercontent.com/junland/hello-deb/master/debian/rules
  3. export DH_OPTIONS
  4. ##
  5. # From git-lfs/git-lfs repo:
  6. # Looks like dh_golang doesn't set diffrent archs, so you have to do them semi-manually.
  7. ##
  8. ## This if-structure is decided on what is passed by the -a flag by dpkg-buildpackage command.
  9. ifeq ($(DEB_HOST_ARCH), i386)
  10. export GOARCH := 386
  11. else ifeq ($(DEB_HOST_ARCH), amd64)
  12. export GOARCH := amd64
  13. else ifeq ($(DEB_HOST_ARCH), armhf)
  14. export GOARCH := arm
  15. # May need to set GOARM as well if your going to target ARM. But for now this works.
  16. else ifeq ($(DEB_HOST_ARCH), arm64)
  17. export GOARCH := arm64
  18. endif
  19. # Or add your arch that your targeting, these are just examples.
  20. # Directory where compiled binary is placed + debian setup files.
  21. # Note: If your doing building thru git, you may want to add obj-* to .gitignore
  22. BUILD_DIR := obj-$(DEB_HOST_GNU_TYPE)
  23. # Required: Put the url (without http://) of your git repo.
  24. export DH_GOPKG := notabug.org/themusicgod1/cp
  25. # Required: Put the name of your git repo below.
  26. GIT_REPO_NAME := notabug-themusicgod1-cp
  27. export PATH := $(CURDIR)/$(BUILD_DIR)/bin:$(PATH)
  28. ##
  29. # From git-lfs/git-lfs repo:
  30. # by-default, dh_golang only copies *.go and other source - this upsets a bunch of vendor test routines
  31. ##
  32. export DH_GOLANG_INSTALL_ALL := 1
  33. %:
  34. dh $@ --buildsystem=golang --with=golang
  35. override_dh_clean:
  36. rm -f debian/debhelper.log
  37. dh_clean
  38. override_dh_auto_build:
  39. dh_auto_build -- -ldflags "-s -w"
  40. ##
  41. # From git-lfs/git-lfs repo:
  42. # dh_golang doesn't do anything here in deb 8, and it's needed in both
  43. ##
  44. if [ "$(DEB_HOST_GNU_TYPE)" != "$(DEB_BUILD_GNU_TYPE)" ]; then\
  45. cp -rf $(BUILD_DIR)/bin/*/* $(BUILD_DIR)/bin/; \
  46. cp -rf $(BUILD_DIR)/pkg/*/* $(BUILD_DIR)/pkg/; \
  47. fi
  48. override_dh_strip:
  49. ##
  50. # From git-lfs/git-lfs repo:
  51. # strip disabled as golang upstream doesn't support it and it makes go crash.
  52. # See https://launchpad.net/bugs/1200255.
  53. ##
  54. override_dh_golang:
  55. ##
  56. # From git-lfs/git-lfs repo:
  57. # The dh_golang is used to add the Built-using field to the deb. This is only for reference.
  58. # As of https://anonscm.debian.org/cgit/collab-maint/dh-golang.git/commit/script/dh_golang?id=7c3fbec6ea92294477fa8910264fe9bd823f21c3
  59. # dh_golang errors out because the go compiler used was not installed via a package. Therefore the step is skipped
  60. ##