Update Makefile plumbing and associated misc things
This commit is contained in:
55
Makefile
55
Makefile
@@ -21,21 +21,22 @@ SHELL = /bin/bash
|
|||||||
|
|
||||||
SVERSION := $(shell git describe --match '[0-9]*\.[0-9]*\.[0-9]*' --tags --dirty --always)
|
SVERSION := $(shell git describe --match '[0-9]*\.[0-9]*\.[0-9]*' --tags --dirty --always)
|
||||||
VERSION := $(shell git describe --match '[0-9]*\.[0-9]*\.[0-9]*' --tags --abbrev=0)
|
VERSION := $(shell git describe --match '[0-9]*\.[0-9]*\.[0-9]*' --tags --abbrev=0)
|
||||||
PROGRAM := $(shell basename --suffix=-$(VERSION) $(notdir $(CURDIR)))
|
PROGRAM := $(shell echo $(notdir $(CURDIR)) | cut -f1 -d"-")
|
||||||
|
OLDGOLANG := $(shell go version | grep -E 'go1.3|go1.4')
|
||||||
ifeq ($(VERSION),$(SVERSION))
|
ifeq ($(VERSION),$(SVERSION))
|
||||||
RELEASE = 1
|
RELEASE = 1
|
||||||
else
|
else
|
||||||
RELEASE = untagged
|
RELEASE = untagged
|
||||||
endif
|
endif
|
||||||
ARCH = $(shell arch)
|
ARCH = $(shell arch)
|
||||||
SPEC = rpmbuild/SPECS/mgmt.spec
|
SPEC = rpmbuild/SPECS/$(PROGRAM).spec
|
||||||
SOURCE = rpmbuild/SOURCES/mgmt-$(VERSION).tar.bz2
|
SOURCE = rpmbuild/SOURCES/$(PROGRAM)-$(VERSION).tar.bz2
|
||||||
SRPM = rpmbuild/SRPMS/mgmt-$(VERSION)-$(RELEASE).src.rpm
|
SRPM = rpmbuild/SRPMS/$(PROGRAM)-$(VERSION)-$(RELEASE).src.rpm
|
||||||
SRPM_BASE = mgmt-$(VERSION)-$(RELEASE).src.rpm
|
SRPM_BASE = $(PROGRAM)-$(VERSION)-$(RELEASE).src.rpm
|
||||||
RPM = rpmbuild/RPMS/mgmt-$(VERSION)-$(RELEASE).$(ARCH).rpm
|
RPM = rpmbuild/RPMS/$(PROGRAM)-$(VERSION)-$(RELEASE).$(ARCH).rpm
|
||||||
USERNAME := $(shell cat ~/.config/copr 2>/dev/null | grep username | awk -F '=' '{print $$2}' | tr -d ' ')
|
USERNAME := $(shell cat ~/.config/copr 2>/dev/null | grep username | awk -F '=' '{print $$2}' | tr -d ' ')
|
||||||
SERVER = 'dl.fedoraproject.org'
|
SERVER = 'dl.fedoraproject.org'
|
||||||
REMOTE_PATH = 'pub/alt/$(USERNAME)/mgmt'
|
REMOTE_PATH = 'pub/alt/$(USERNAME)/$(PROGRAM)'
|
||||||
|
|
||||||
all: docs
|
all: docs
|
||||||
|
|
||||||
@@ -59,20 +60,20 @@ run:
|
|||||||
race:
|
race:
|
||||||
find -maxdepth 1 -type f -name '*.go' -not -name '*_test.go' | xargs go run -race -ldflags "-X main.program=$(PROGRAM) -X main.version=$(SVERSION)"
|
find -maxdepth 1 -type f -name '*.go' -not -name '*_test.go' | xargs go run -race -ldflags "-X main.program=$(PROGRAM) -X main.version=$(SVERSION)"
|
||||||
|
|
||||||
build: mgmt
|
build: $(PROGRAM)
|
||||||
|
|
||||||
mgmt: main.go
|
$(PROGRAM): main.go
|
||||||
@echo "Building: $(PROGRAM), version: $(SVERSION)."
|
@echo "Building: $(PROGRAM), version: $(SVERSION)..."
|
||||||
go generate
|
go generate
|
||||||
# avoid equals sign in old golang versions eg in: -X foo=bar
|
ifneq ($(OLDGOLANG),)
|
||||||
if go version | grep -qE 'go1.3|go1.4'; then \
|
@# avoid equals sign in old golang versions eg in: -X foo=bar
|
||||||
go build -ldflags "-X main.program $(PROGRAM) -X main.version $(SVERSION)" -o mgmt; \
|
go build -ldflags "-X main.program $(PROGRAM) -X main.version $(SVERSION)" -o $(PROGRAM);
|
||||||
else \
|
else
|
||||||
go build -ldflags "-X main.program=$(PROGRAM) -X main.version=$(SVERSION)" -o mgmt; \
|
go build -ldflags "-X main.program=$(PROGRAM) -X main.version=$(SVERSION)" -o $(PROGRAM);
|
||||||
fi
|
endif
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
[ ! -e mgmt ] || rm mgmt
|
[ ! -e $(PROGRAM) ] || rm $(PROGRAM)
|
||||||
rm -f *_stringer.go # generated by `go generate`
|
rm -f *_stringer.go # generated by `go generate`
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@@ -82,10 +83,10 @@ format:
|
|||||||
find -type f -name '*.go' -not -path './old/*' -not -path './tmp/*' -exec gofmt -w {} \;
|
find -type f -name '*.go' -not -path './old/*' -not -path './tmp/*' -exec gofmt -w {} \;
|
||||||
find -type f -name '*.yaml' -not -path './old/*' -not -path './tmp/*' -not -path './omv.yaml' -exec ruby -e "require 'yaml'; x=YAML.load_file('{}').to_yaml.each_line.map(&:rstrip).join(10.chr)+10.chr; File.open('{}', 'w').write x" \;
|
find -type f -name '*.yaml' -not -path './old/*' -not -path './tmp/*' -not -path './omv.yaml' -exec ruby -e "require 'yaml'; x=YAML.load_file('{}').to_yaml.each_line.map(&:rstrip).join(10.chr)+10.chr; File.open('{}', 'w').write x" \;
|
||||||
|
|
||||||
docs: mgmt-documentation.pdf
|
docs: $(PROGRAM)-documentation.pdf
|
||||||
|
|
||||||
mgmt-documentation.pdf: DOCUMENTATION.md
|
$(PROGRAM)-documentation.pdf: DOCUMENTATION.md
|
||||||
pandoc DOCUMENTATION.md -o 'mgmt-documentation.pdf'
|
pandoc DOCUMENTATION.md -o '$(PROGRAM)-documentation.pdf'
|
||||||
|
|
||||||
#
|
#
|
||||||
# build aliases
|
# build aliases
|
||||||
@@ -116,21 +117,21 @@ upload: upload-sources upload-srpms upload-rpms
|
|||||||
$(RPM): $(SPEC) $(SOURCE)
|
$(RPM): $(SPEC) $(SOURCE)
|
||||||
@echo Running rpmbuild -bb...
|
@echo Running rpmbuild -bb...
|
||||||
rpmbuild --define '_topdir $(shell pwd)/rpmbuild' -bb $(SPEC) && \
|
rpmbuild --define '_topdir $(shell pwd)/rpmbuild' -bb $(SPEC) && \
|
||||||
mv rpmbuild/RPMS/$(ARCH)/mgmt-$(VERSION)-$(RELEASE).*.rpm $(RPM)
|
mv rpmbuild/RPMS/$(ARCH)/$(PROGRAM)-$(VERSION)-$(RELEASE).*.rpm $(RPM)
|
||||||
|
|
||||||
$(SRPM): $(SPEC) $(SOURCE)
|
$(SRPM): $(SPEC) $(SOURCE)
|
||||||
@echo Running rpmbuild -bs...
|
@echo Running rpmbuild -bs...
|
||||||
rpmbuild --define '_topdir $(shell pwd)/rpmbuild' -bs $(SPEC)
|
rpmbuild --define '_topdir $(shell pwd)/rpmbuild' -bs $(SPEC)
|
||||||
# renaming is not needed because we aren't using the dist variable
|
# renaming is not needed because we aren't using the dist variable
|
||||||
#mv rpmbuild/SRPMS/mgmt-$(VERSION)-$(RELEASE).*.src.rpm $(SRPM)
|
#mv rpmbuild/SRPMS/$(PROGRAM)-$(VERSION)-$(RELEASE).*.src.rpm $(SRPM)
|
||||||
|
|
||||||
#
|
#
|
||||||
# spec
|
# spec
|
||||||
#
|
#
|
||||||
$(SPEC): rpmbuild/ mgmt.spec.in
|
$(SPEC): rpmbuild/ spec.in
|
||||||
@echo Running templater...
|
@echo Running templater...
|
||||||
#cat mgmt.spec.in > $(SPEC)
|
#cat spec.in > $(SPEC)
|
||||||
sed -e s/__VERSION__/$(VERSION)/ -e s/__RELEASE__/$(RELEASE)/ < mgmt.spec.in > $(SPEC)
|
sed -e s/__PROGRAM__/$(PROGRAM)/ -e s/__VERSION__/$(VERSION)/ -e s/__RELEASE__/$(RELEASE)/ < spec.in > $(SPEC)
|
||||||
# append a changelog to the .spec file
|
# append a changelog to the .spec file
|
||||||
git log --format="* %cd %aN <%aE>%n- (%h) %s%d%n" --date=local | sed -r 's/[0-9]+:[0-9]+:[0-9]+ //' >> $(SPEC)
|
git log --format="* %cd %aN <%aE>%n- (%h) %s%d%n" --date=local | sed -r 's/[0-9]+:[0-9]+:[0-9]+ //' >> $(SPEC)
|
||||||
|
|
||||||
@@ -140,7 +141,7 @@ $(SPEC): rpmbuild/ mgmt.spec.in
|
|||||||
$(SOURCE): rpmbuild/
|
$(SOURCE): rpmbuild/
|
||||||
@echo Running git archive...
|
@echo Running git archive...
|
||||||
# use HEAD if tag doesn't exist yet, so that development is easier...
|
# use HEAD if tag doesn't exist yet, so that development is easier...
|
||||||
git archive --prefix=mgmt-$(VERSION)/ -o $(SOURCE) $(VERSION) 2> /dev/null || (echo 'Warning: $(VERSION) does not exist. Using HEAD instead.' && git archive --prefix=mgmt-$(VERSION)/ -o $(SOURCE) HEAD)
|
git archive --prefix=$(PROGRAM)-$(VERSION)/ -o $(SOURCE) $(VERSION) 2> /dev/null || (echo 'Warning: $(VERSION) does not exist. Using HEAD instead.' && git archive --prefix=$(PROGRAM)-$(VERSION)/ -o $(SOURCE) HEAD)
|
||||||
# TODO: if git archive had a --submodules flag this would easier!
|
# TODO: if git archive had a --submodules flag this would easier!
|
||||||
@echo Running git archive submodules...
|
@echo Running git archive submodules...
|
||||||
# i thought i would need --ignore-zeros, but it doesn't seem necessary!
|
# i thought i would need --ignore-zeros, but it doesn't seem necessary!
|
||||||
@@ -149,7 +150,7 @@ $(SOURCE): rpmbuild/
|
|||||||
temp="$${temp#\'}"; \
|
temp="$${temp#\'}"; \
|
||||||
path=$$temp; \
|
path=$$temp; \
|
||||||
[ "$$path" = "" ] && continue; \
|
[ "$$path" = "" ] && continue; \
|
||||||
(cd $$path && git archive --prefix=mgmt-$(VERSION)/$$path/ HEAD > $$p/rpmbuild/tmp.tar && tar --concatenate --file=$$p/$(SOURCE) $$p/rpmbuild/tmp.tar && rm $$p/rpmbuild/tmp.tar); \
|
(cd $$path && git archive --prefix=$(PROGRAM)-$(VERSION)/$$path/ HEAD > $$p/rpmbuild/tmp.tar && tar --concatenate --file=$$p/$(SOURCE) $$p/rpmbuild/tmp.tar && rm $$p/rpmbuild/tmp.tar); \
|
||||||
done
|
done
|
||||||
|
|
||||||
# TODO: ensure that each sub directory exists
|
# TODO: ensure that each sub directory exists
|
||||||
|
|||||||
1
misc/example.conf
Normal file
1
misc/example.conf
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# example mgmt configuration file, currently has no options at the moment!
|
||||||
@@ -34,7 +34,7 @@ fi
|
|||||||
[ -x build ] && ./build
|
[ -x build ] && ./build
|
||||||
mkdir -p ~/bin/
|
mkdir -p ~/bin/
|
||||||
cp bin/etcd ~/bin/
|
cp bin/etcd ~/bin/
|
||||||
cd -
|
cd - >/dev/null
|
||||||
rm -rf etcd # clean up to avoid failing on upstream gofmt errors
|
rm -rf etcd # clean up to avoid failing on upstream gofmt errors
|
||||||
|
|
||||||
go get ./... # get all the go dependencies
|
go get ./... # get all the go dependencies
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
# example mgmt configuration file, currently has not options at the moment!
|
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
%global project_version __VERSION__
|
%global project_version __VERSION__
|
||||||
%define debug_package %{nil}
|
%define debug_package %{nil}
|
||||||
|
|
||||||
Name: mgmt
|
Name: __PROGRAM__
|
||||||
Version: __VERSION__
|
Version: __VERSION__
|
||||||
Release: __RELEASE__
|
Release: __RELEASE__
|
||||||
Summary: A next generation config management prototype!
|
Summary: A next generation config management prototype!
|
||||||
License: AGPLv3+
|
License: AGPLv3+
|
||||||
URL: https://github.com/purpleidea/mgmt
|
URL: https://github.com/purpleidea/mgmt
|
||||||
Source0: https://dl.fedoraproject.org/pub/alt/purpleidea/mgmt/SOURCES/mgmt-%{project_version}.tar.bz2
|
Source0: https://dl.fedoraproject.org/pub/alt/purpleidea/__PROGRAM__/SOURCES/__PROGRAM__-%{project_version}.tar.bz2
|
||||||
|
|
||||||
# graphviz should really be a "suggests", since technically it's optional
|
# graphviz should really be a "suggests", since technically it's optional
|
||||||
Requires: graphviz
|
Requires: graphviz
|
||||||
@@ -38,26 +38,26 @@ make build
|
|||||||
%install
|
%install
|
||||||
rm -rf %{buildroot}
|
rm -rf %{buildroot}
|
||||||
# _datadir is typically /usr/share/
|
# _datadir is typically /usr/share/
|
||||||
install -d -m 0755 %{buildroot}/%{_datadir}/mgmt/
|
install -d -m 0755 %{buildroot}/%{_datadir}/__PROGRAM__/
|
||||||
cp -a AUTHORS COPYING COPYRIGHT DOCUMENTATION.md README.md THANKS examples/ %{buildroot}/%{_datadir}/mgmt/
|
cp -a AUTHORS COPYING COPYRIGHT DOCUMENTATION.md README.md THANKS examples/ %{buildroot}/%{_datadir}/__PROGRAM__/
|
||||||
|
|
||||||
# install the binary
|
# install the binary
|
||||||
mkdir -p %{buildroot}/%{_bindir}
|
mkdir -p %{buildroot}/%{_bindir}
|
||||||
install -m 0755 mgmt %{buildroot}/%{_bindir}/mgmt
|
install -m 0755 __PROGRAM__ %{buildroot}/%{_bindir}/__PROGRAM__
|
||||||
|
|
||||||
# profile.d bash completion
|
# profile.d bash completion
|
||||||
mkdir -p %{buildroot}%{_sysconfdir}/profile.d
|
mkdir -p %{buildroot}%{_sysconfdir}/profile.d
|
||||||
install misc/mgmt.bashrc -m 0755 %{buildroot}%{_sysconfdir}/profile.d/mgmt.sh
|
install misc/bashrc.sh -m 0755 %{buildroot}%{_sysconfdir}/profile.d/__PROGRAM__.sh
|
||||||
|
|
||||||
# etc dir
|
# etc dir
|
||||||
mkdir -p %{buildroot}%{_sysconfdir}/mgmt/
|
mkdir -p %{buildroot}%{_sysconfdir}/__PROGRAM__/
|
||||||
install -m 0644 misc/mgmt.conf.example %{buildroot}%{_sysconfdir}/mgmt/mgmt.conf
|
install -m 0644 misc/example.conf %{buildroot}%{_sysconfdir}/__PROGRAM__/__PROGRAM__.conf
|
||||||
|
|
||||||
%files
|
%files
|
||||||
%attr(0755, root, root) %{_sysconfdir}/profile.d/mgmt.sh
|
%attr(0755, root, root) %{_sysconfdir}/profile.d/__PROGRAM__.sh
|
||||||
%{_datadir}/mgmt/*
|
%{_datadir}/__PROGRAM__/*
|
||||||
%{_bindir}/mgmt
|
%{_bindir}/__PROGRAM__
|
||||||
%{_sysconfdir}/mgmt/*
|
%{_sysconfdir}/__PROGRAM__/*
|
||||||
|
|
||||||
# this changelog is auto-generated by git log
|
# this changelog is auto-generated by git log
|
||||||
%changelog
|
%changelog
|
||||||
Reference in New Issue
Block a user