Files
mixer-tools/Makefile
T
Kevin C. Wells f5a79eb090 Rewrite the DNF conf generation
Previously, mixer used m4 to generate the dnf conf (.yum.conf), and only
did so if the file did not already exist, so as to not overwrite people's
custom conf files. However, this meant that the check if a "[local]"
section was needed only ran if the file didn't exist. If a mix had already
been built, this check was skipped, and the local section was never inserted.

This patch removes the use of the yum.conf.in file and m4, instead using an
embedded template. Additionally, if the file already exists but the local
section is needed, mixer will now check the file to see if it has the necessary
local section. If not, the section will be appended to the file.

Signed-off-by: Kevin C. Wells <kevin.c.wells@intel.com>
2018-03-22 10:45:45 -07:00

103 lines
3.1 KiB
Makefile

# Makefile used to create packages for mixer-tools. It doesn't assume
# that the code is inside a GOPATH, and always copy the files into a
# new workspace to get the work done. Go tools doesn't reliably work
# with symbolic links.
#
# For historical purposes, it also works in a development environment
# when the repository is already inside a GOPATH.
include Makefile.bats
.NOTPARALLEL:
GO_PACKAGE_PREFIX := github.com/clearlinux/mixer-tools
.PHONY: gopath
# Strictly speaking we should check if it the directory is inside an
# actual GOPATH, but the directory structure matching is likely enough.
ifeq (,$(findstring ${GO_PACKAGE_PREFIX},${CURDIR}))
LOCAL_GOPATH := ${CURDIR}/.gopath
export GOPATH := ${LOCAL_GOPATH}
gopath:
@rm -rf ${LOCAL_GOPATH}/src
@mkdir -p ${LOCAL_GOPATH}/src/${GO_PACKAGE_PREFIX}
@cp -af * ${LOCAL_GOPATH}/src/${GO_PACKAGE_PREFIX}
@echo "Prepared a local GOPATH=${GOPATH}"
else
LOCAL_GOPATH :=
GOPATH ?= ${HOME}/go
gopath:
@echo "Code already in existing GOPATH=${GOPATH}"
endif
.PHONY: build install clean check
.DEFAULT_GOAL := build
build: gopath
go install ${GO_PACKAGE_PREFIX}/mixer
go install ${GO_PACKAGE_PREFIX}/mixer-completion
install: gopath
test -d $(DESTDIR)/usr/bin || install -D -d -m 00755 $(DESTDIR)/usr/bin;
install -m 00755 $(GOPATH)/bin/mixer $(DESTDIR)/usr/bin/.
$(GOPATH)/bin/mixer-completion bash --path $(DESTDIR)/usr/share/bash-completion/completions/mixer
$(GOPATH)/bin/mixer-completion zsh --path $(DESTDIR)/usr/share/zsh/site-functions/_mixer
install -m 00755 pack-maker.sh $(DESTDIR)/usr/bin/mixer-pack-maker.sh
install -m 00755 superpack-maker.sh $(DESTDIR)/usr/bin/mixer-superpack-maker.sh
check: gopath
go test -cover ${GO_PACKAGE_PREFIX}/...
# TODO: when Go 1.10 comes out we will have support for passing multiple packages
# to coverprofile, so there will be no need to pass an individual package.
# At that time we can merge this target into check and run it against all
# packages every time.
.PHONY: checkcoverage
checkcoverage: gopath
ifeq (,${PKG})
$(error PKG is not set, try make PKG=swupd checkcoverage)
else
go test -cover ${GO_PACKAGE_PREFIX}/${PKG} -coverprofile=coverage.out
go tool cover -html=coverage.out
endif
.PHONY: lint
lint: gopath
@gometalinter.v2 --deadline=10m --tests --vendor --disable-all \
--enable=misspell \
--enable=vet \
--enable=ineffassign \
--enable=gofmt \
$${CYCLO_MAX:+--enable=gocyclo --cyclo-over=$${CYCLO_MAX}} \
--enable=golint \
--enable=deadcode \
--enable=varcheck \
--enable=structcheck \
--enable=unused \
--enable=vetshadow \
--enable=errcheck \
./...
clean:
ifeq (,${LOCAL_GOPATH})
go clean -i -x
else
rm -rf ${LOCAL_GOPATH}
endif
rm -f mixer-tools-*.tar.gz
release:
@if [ ! -d .git ]; then \
echo "Release needs to be used from a git repository"; \
exit 1; \
fi
@VERSION=$$(grep -e 'const Version' builder/builder.go | cut -d '"' -f 2) ; \
if [ -z "$$VERSION" ]; then \
echo "Couldn't extract version number from the source code"; \
exit 1; \
fi; \
git archive --format=tar.gz --verbose -o mixer-tools-$$VERSION.tar.gz HEAD --prefix=mixer-tools-$$VERSION/