<commit_before>.PHONY: deb

date=$(shell date +'%Y%m%d')
revision=$(shell git rev-parse --short HEAD)
package=yaml-parse
build_dir=output

deb:
	# Build main binary
	go build -v -ldflags="-X main.BuildMetadata=${date}.${revision}" \
		-o ../bin/${package} ../cmd/${package}/main.go
	$(eval version := $(shell ../bin/${package} --version | perl -pe 's/Version: //'))
	@echo ${version}
	# Create deb dir structure
	mkdir -p ${build_dir}/${package}/DEBIAN
	mkdir -p ${build_dir}/${package}/usr/bin
	# Copy debian files
	cp ./debian-control ${build_dir}/${package}/DEBIAN/control
	perl -i -pe 's/VERSION/${version}/' ${build_dir}/${package}/DEBIAN/control
	perl -i -pe 's/PACKAGE/${package}/' ${build_dir}/${package}/DEBIAN/control
	perl -i -pe 's/DESCRIPTION/${package}/' ${build_dir}/${package}/DEBIAN/control
	cp ./debian-postinst ${build_dir}/${package}/DEBIAN/postinst
	chmod 755 ${build_dir}/${package}/DEBIAN/postinst
	# Copy main binary
	cp ../bin/${package} ${build_dir}/${package}/usr/bin
	cd ${build_dir} && dpkg-deb --build ${package} ${package}_${version}_amd64.deb
	@echo Output: ${build_dir}/${package}_${version}_amd64.deb<commit_msg>Add .dev identifier to package when not built from master<commit_after>.PHONY: FORCE

date=$(shell date +'%Y%m%d')
# Get commit hash
revision=$(shell git rev-parse --short HEAD)
# Check if we are in the master branch, if not add .dev to the revision
dev=$(shell git rev-parse --abbrev-ref HEAD | grep master > /dev/null || echo .dev)
build_dir=output

package=yaml-parse

deb: ../bin/${package}
	$(eval version := $(shell ../bin/${package} --version | perl -pe 's/Version: //'))
	@echo version: ${version}
	# Create deb dir structure
	mkdir -p ${build_dir}/${package}/DEBIAN
	mkdir -p ${build_dir}/${package}/usr/bin
	# Copy debian files
	cp ./debian-control ${build_dir}/${package}/DEBIAN/control
	cp ./debian-postinst ${build_dir}/${package}/DEBIAN/postinst
	chmod 755 ${build_dir}/${package}/DEBIAN/postinst
	# Update control file
	perl -i -pe 's/VERSION/${version}/' ${build_dir}/${package}/DEBIAN/control
	perl -i -pe 's/PACKAGE/${package}/' ${build_dir}/${package}/DEBIAN/control
	perl -i -pe 's/DESCRIPTION/${package}/' ${build_dir}/${package}/DEBIAN/control
	# Copy main binary
	cp ../bin/${package} ${build_dir}/${package}/usr/bin
	cd ${build_dir} && dpkg-deb --build ${package} ${package}_${version}_amd64.deb
	@echo Output: ${build_dir}/${package}_${version}_amd64.deb

../bin/$(package): FORCE
	# Clean up
	-rm ${PWD}/../bin/${package}
	# Build main binary
	go build -v -ldflags="-X main.BuildMetadata=${date}.${revision}${dev}" -o ../bin/${package} ../cmd/${package}/main.go

FORCE:
{'fraction_non_alphanumeric': 0.2078758046194623, 'fraction_numerical': 0.005301022340022719, 'mean_word_length': 4.326612903225806, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4395912', 'n_tokens_mistral': 965, 'n_tokens_neox': 933, 'n_words': 220}