rules 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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/makenotabuggreatagain/barcode
  25. # Required: Put the name of your git repo below.
  26. GIT_REPO_NAME := barcode
  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. ##
  61. #override_dh_auto_install:
  62. # This is making a "fakeroot" so that when the deb is installed the binary will be placed in /usr/bin.
  63. #mkdir -p debian/golang-$(GIT_REPO_NAME)-dev/usr/bin
  64. # This is copying the binary and placing it in the fake root path.
  65. #cp $(BUILD_DIR)/bin/panicparse debian/golang-$(GIT_REPO_NAME)-dev/usr/bin/
  66. #cp $(BUILD_DIR)/bin/panic debian/golang-$(GIT_REPO_NAME)-dev/usr/bin/
  67. #cp $(BUILD_DIR)/bin/pp debian/golang-$(GIT_REPO_NAME)-dev/usr/bin/
  68. # #!/usr/bin/make -f
  69. #export DH_OPTIONS
  70. #%:
  71. # dh $@ --buildsystem=golang --with=golang