rules 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. REPO := clog
  24. WHOAMI := makenotabuggreatagain
  25. NOTABUG := notabug
  26. # Required: Put the url (without http://) of your git repo.
  27. export DH_GOPKG := notabug.org/$(WHOAMI)/$(REPO)
  28. # Required: Put the name of your git repo below.
  29. GIT_REPO_NAME := $(NOTABUG)-$(WHOAMI)-$(REPO)
  30. export PATH := $(CURDIR)/$(BUILD_DIR)/bin:$(PATH)
  31. ##
  32. # From git-lfs/git-lfs repo:
  33. # by-default, dh_golang only copies *.go and other source - this upsets a bunch of vendor test routines
  34. ##
  35. export DH_GOLANG_INSTALL_ALL := 1
  36. %:
  37. dh $@ --buildsystem=golang --with=golang
  38. override_dh_clean:
  39. rm -f debian/debhelper.log
  40. dh_clean
  41. override_dh_auto_build:
  42. dh_auto_build -- -ldflags "-s -w"
  43. ##
  44. # From git-lfs/git-lfs repo:
  45. # dh_golang doesn't do anything here in deb 8, and it's needed in both
  46. ##
  47. if [ "$(DEB_HOST_GNU_TYPE)" != "$(DEB_BUILD_GNU_TYPE)" ]; then\
  48. cp -rf $(BUILD_DIR)/bin/*/* $(BUILD_DIR)/bin/; \
  49. cp -rf $(BUILD_DIR)/pkg/*/* $(BUILD_DIR)/pkg/; \
  50. fi
  51. override_dh_strip:
  52. ##
  53. # From git-lfs/git-lfs repo:
  54. # strip disabled as golang upstream doesn't support it and it makes go crash.
  55. # See https://launchpad.net/bugs/1200255.
  56. ##
  57. #override_dh_golang:
  58. # ##
  59. # From git-lfs/git-lfs repo:
  60. # The dh_golang is used to add the Built-using field to the deb. This is only for reference.
  61. # As of https://anonscm.debian.org/cgit/collab-maint/dh-golang.git/commit/script/dh_golang?id=7c3fbec6ea92294477fa8910264fe9bd823f21c3
  62. # dh_golang errors out because the go compiler used was not installed via a package. Therefore the step is skipped
  63. ##
  64. #override_dh_auto_install:
  65. # golang-notabug-themusicgod1-panicparse-dev
  66. # This is making a "fakeroot" so that when the deb is installed the binary will be placed in /usr/bin.
  67. # mkdir -p debian/golang-$(GIT_REPO_NAME)-dev/usr/bin
  68. # mkdir -p debian/golang-$(GIT_REPO_NAME)-dev/usr/share/gocode/src/notabug.org/$(WHOAMI)/$(REPO)
  69. #
  70. # This is copying the binary and placing it in the fake root path.
  71. # cp $(BUILD_DIR)/bin/panicparse debian/golang-$(GIT_REPO_NAME)-dev/usr/bin/
  72. # cp $(BUILD_DIR)/bin/panic debian/golang-$(GIT_REPO_NAME)-dev/usr/bin/
  73. # cp $(BUILD_DIR)/bin/pp debian/golang-$(GIT_REPO_NAME)-dev/usr/bin/
  74. ## cp -r $(BUILD_DIR)/src/notabug.org/themusicgod1/panicparse/stack debian/golang-$(GIT_REPO_NAME)-dev/usr/share/gocode/src/notabug.org/$(WHOAMI)/$(REPO)
  75. #
  76. # #!/usr/bin/make -f
  77. #export DH_OPTIONS
  78. #%:
  79. # dh $@ --buildsystem=golang --with=golang