rules 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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 := gogs
  24. WHOAMI := hp
  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. mkdir -p debian/golang-$(GIT_REPO_NAME)/lib/systemd/system
  66. cp scripts/systemd/gogs.service debian/golang-$(GIT_REPO_NAME)/lib/systemd/system
  67. # outPlattform:=linux
  68. # outArch:=amd64
  69. # outPath:=output_$(outPlattform)_$(outArch)
  70. # mkdir -p $outPath
  71. # CGO_ENABLED=0 GOOS=$(outPlattform) GOARCH=$(outArch) go build -buildmode=pie ../gogs.go
  72. # chmod +x gogs
  73. # mv gogs $outPath/
  74. # cd ../scripts;
  75. mkdir -p debian/golang-$(GIT_REPO_NAME)/usr/bin
  76. cp obj-x86_64-linux-gnu/bin/gogs debian/golang-$(GIT_REPO_NAME)/usr/bin
  77. mkdir -p debian/golang-$(GIT_REPO_NAME)/usr/share/gogs
  78. cp -r conf/ debian/golang-$(GIT_REPO_NAME)/usr/share/gogs/conf/
  79. # cp -r custom/ debian/golang-$(GIT_REPO_NAME)-var/gogs/custom/
  80. # cp -r dockerfiles/ $outPath/dockerfiles/
  81. cp -r public/ debian/golang-$(GIT_REPO_NAME)/usr/share/gogs
  82. cp -r templates/ debian/golang-$(GIT_REPO_NAME)/usr/share/gogs/
  83. # cp cert.pem debian/golang-$(GIT_REPO_NAME)-var/gogs/
  84. cp CONTRIBUTING.md debian/golang-$(GIT_REPO_NAME)/usr/share/gogs/
  85. # cp scripts/gogs_supervisord.sh debian/golang-$(GIT_REPO_NAME)-var/gogs/
  86. # do we need to make key.pem?
  87. # cp key.pem debian/golang-$(GIT_REPO_NAME)-var/gogs/
  88. cp LICENSE debian/golang-$(GIT_REPO_NAME)/usr/share/gogs/
  89. cp README.md debian/golang-$(GIT_REPO_NAME)/usr/share/gogs/
  90. # cp scripts/start.sh debian/golang-$(GIT_REPO_NAME)-var/gogs/
  91. # cp wercker.yml debian/golang-$(GIT_REPO_NAME)-var/gogs/
  92. cp scripts/mysql.sql debian/golang-$(GIT_REPO_NAME)/usr/share/gogs/
  93. mkdir -p debian/golang-$(GIT_REPO_NAME)/var/lib/dpkg/info
  94. cp scripts/postinst/gogs.postinst debian/golang-$(GIT_REPO_NAME)/var/lib/dpkg/info
  95. # golang-notabug-themusicgod1-panicparse-dev
  96. # This is making a "fakeroot" so that when the deb is installed the binary will be placed in /usr/bin.
  97. # mkdir -p debian/golang-$(GIT_REPO_NAME)-dev/usr/bin
  98. # mkdir -p debian/golang-$(GIT_REPO_NAME)-dev/usr/share/gocode/src/notabug.org/$(WHOAMI)/$(REPO)
  99. # This is copying the binary and placing it in the fake root path.
  100. # cp $(BUILD_DIR)/bin/panicparse debian/golang-$(GIT_REPO_NAME)-dev/usr/bin/
  101. # cp $(BUILD_DIR)/bin/panic debian/golang-$(GIT_REPO_NAME)-dev/usr/bin/
  102. # cp $(BUILD_DIR)/bin/pp debian/golang-$(GIT_REPO_NAME)-dev/usr/bin/
  103. # cp -r $(BUILD_DIR)/src/notabug.org/themusicgod1/panicparse/stack debian/golang-$(GIT_REPO_NAME)-dev/usr/share/gocode/src/notabug.org/$(WHOAMI)/$(REPO)
  104. # #!/usr/bin/make -f
  105. #export DH_OPTIONS
  106. #%:
  107. # dh $@ --buildsystem=golang --with=golang