1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
#!/usr/bin/make -f
export DH_GOLANG_INSTALL_ALL := 1
export DH_GOLANG_EXCLUDES := hub\d+ data\d+
# Make sure ancillary rules don't generate errors, since the following
# variable is only set while building:
ifneq (,$(SOURCE_DATE_EPOCH))
now := @$(SOURCE_DATE_EPOCH)
else
now := now
endif
# Upstream's Makefile would take care of this, but we're building via
# dh_auto_build in golang mode, instead of using make:
export BUILD_VERSION := v$(shell dpkg-parsechangelog -SVersion)
export BUILD_TAG := debian
export BUILD_CODENAME := $(shell perl -ne 'print $$1 if /^BUILD_CODENAME="(.+)"$$/' platform/unix_common.mk)
export BUILD_TIMESTAMP := $(shell TZ=Etc/UTC date +'%F_%T' -d $(now))
export set_cwversion := -X github.com/crowdsecurity/crowdsec/pkg/cwversion
export LD_FLAGS := -ldflags '-s -w \
$(set_cwversion).Version=$(BUILD_VERSION) \
$(set_cwversion).Tag=$(BUILD_TAG) \
$(set_cwversion).Codename=$(BUILD_CODENAME) \
$(set_cwversion).BuildDate=$(BUILD_TIMESTAMP) \
'
# Use 1 for a new upstream release, and bump it when an update of the
# hub files is desired while the upstream version doesn't change. See
# below for the generate_hub_tarball target:
export DATA_ID := 1
export HUB_ID := 1
export HUB_BRANCH := origin/v1.4.6
export HUB_DIR := ../hub
export U_VERSION := $(shell dpkg-parsechangelog -SVersion|sed 's/-.*//')
%:
dh $@ --builddirectory=_build --buildsystem=golang --with=golang
override_dh_auto_build:
dh_auto_build -- $(LD_FLAGS)
override_dh_install-arch:
dh_install -a
# Switch from Golang naming to upstream-desired naming:
mv debian/crowdsec/usr/bin/crowdsec-cli \
debian/crowdsec/usr/bin/cscli
# Adjust the hub branch according to the upstream version:
sed "s/\(.*hub_branch:\) master/\1 v$(U_VERSION)/" -i debian/crowdsec/etc/crowdsec/config.yaml
# Drop unit tests from the hub:
find debian/crowdsec/usr/share/crowdsec/hub -depth -name '.tests' -exec rm -rf '{}' ';'
# #1031328 (upstream #2125):
override_dh_install-indep: IDIR=debian/golang-github-crowdsecurity-crowdsec-dev/usr/share/gocode/src/github.com/crowdsecurity/crowdsec/pkg/cwhub
override_dh_install-indep:
dh_install -i
rm -f $(IDIR)/hubdir/.index.json
rm -f $(IDIR)/hubdir/collections/crowdsecurity/test_collection.yaml
rm -f $(IDIR)/hubdir/scenarios/crowdsecurity/barfoo_scenario.yaml
rm -f $(IDIR)/hubdir/scenarios/crowdsecurity/foobar_scenario.yaml
rm -f $(IDIR)/hubdir/collections/crowdsecurity/test_collection.yaml
rm -f $(IDIR)/hubdir/scenarios/crowdsecurity/barfoo_scenario.yaml
rm -f $(IDIR)/install/collections/test_collection.yaml
rm -f $(IDIR)/install/scenarios/barfoo_scenario.yaml
### Maintainer targets:
generate_hub_tarball:
cd $(HUB_DIR) && git archive --prefix hub$(HUB_ID)/ $(HUB_BRANCH) | gzip -9 > ../crowdsec_$(U_VERSION).orig-hub$(HUB_ID).tar.gz \
&& echo "Generated hub tarball from branch $(HUB_BRANCH), at commit `git show $(HUB_BRANCH) | awk '/^commit / {print $$2; quit}' | cut -b -10`"
extract_hub_tarball:
tar xf ../crowdsec_$(U_VERSION).orig-hub$(HUB_ID).tar.gz
extract_data_tarball:
tar xf ../crowdsec_$(U_VERSION).orig-data$(HUB_ID).tar.gz
|