Prior to this patch, `make rpm` would produce rpms that have the latest tag as their versions. This was confusing, because one could never know which contents are in a locally built rpm. Change this so that the is version always based on the commit hash of HEAD. This is easy: the golang macros read a `%commit` macro when it exists and do this for us. To simplify more, only define `%_topdir` to ./rpmbuild and use rpmbuild's known directory structure (SPEC, SOURCES, RPMS, ...) otherwise, to make it easier to find build results. Build the specfile, tarball, source rpms, and rpms with `make rpm`, without separate sub-targets. We can reintroduce them if they're needed somewhere. Also remove the `check-working-directory` target. It should be clear from the output that only the currently-committed files are included, because the resulting tarball and rpms contain the commit hash. Without the check, one can work on the Makefile without having to commit all the time, for example ;)
70 lines
3.3 KiB
Makefile
70 lines
3.3 KiB
Makefile
PACKAGE_NAME = osbuild-composer
|
|
COMMIT=$(shell git rev-parse HEAD)
|
|
|
|
.PHONY: build
|
|
build:
|
|
go build -o osbuild-composer ./cmd/osbuild-composer/
|
|
go build -o osbuild-worker ./cmd/osbuild-worker/
|
|
go build -o osbuild-pipeline ./cmd/osbuild-pipeline/
|
|
go build -o osbuild-upload-azure ./cmd/osbuild-upload-azure/
|
|
go build -o osbuild-upload-aws ./cmd/osbuild-upload-aws/
|
|
go build -o osbuild-tests ./cmd/osbuild-tests/
|
|
go build -o osbuild-weldr-tests ./cmd/osbuild-weldr-tests/
|
|
go build -o osbuild-dnf-json-tests ./cmd/osbuild-dnf-json-tests/
|
|
|
|
.PHONY: install
|
|
install:
|
|
- mkdir -p /usr/libexec/osbuild-composer
|
|
cp osbuild-composer /usr/libexec/osbuild-composer/
|
|
cp osbuild-worker /usr/libexec/osbuild-composer/
|
|
cp dnf-json /usr/libexec/osbuild-composer/
|
|
- mkdir -p /usr/share/osbuild-composer/repositories
|
|
cp repositories/* /usr/share/osbuild-composer/repositories
|
|
- mkdir -p /etc/sysusers.d/
|
|
cp distribution/osbuild-composer.conf /etc/sysusers.d/
|
|
systemd-sysusers osbuild-composer.conf
|
|
- mkdir -p /etc/systemd/system/
|
|
cp distribution/*.service /etc/systemd/system/
|
|
cp distribution/*.socket /etc/systemd/system/
|
|
systemctl daemon-reload
|
|
|
|
.PHONY: ca
|
|
ca:
|
|
ifneq (/etc/osbuild-composer/ca-key.pem/etc/osbuild-composer/ca-crt.pem,$(wildcard /etc/osbuild-composer/ca-key.pem)$(wildcard /etc/osbuild-composer/ca-crt.pem))
|
|
@echo CA key or certificate file is missing, generating a new pair...
|
|
- mkdir -p /etc/osbuild-composer
|
|
openssl req -new -nodes -x509 -days 365 -keyout /etc/osbuild-composer/ca-key.pem -out /etc/osbuild-composer/ca-crt.pem -subj "/CN=osbuild.org"
|
|
else
|
|
@echo CA key and certificate files already exist, skipping...
|
|
endif
|
|
|
|
.PHONY: composer-key-pair
|
|
composer-key-pair: ca
|
|
openssl genrsa -out /etc/osbuild-composer/composer-key.pem 2048
|
|
openssl req -new -sha256 -key /etc/osbuild-composer/composer-key.pem -out /etc/osbuild-composer/composer-csr.pem -subj "/CN=localhost" # TODO: we need to generate certificates with another hostname
|
|
openssl x509 -req -in /etc/osbuild-composer/composer-csr.pem -CA /etc/osbuild-composer/ca-crt.pem -CAkey /etc/osbuild-composer/ca-key.pem -CAcreateserial -out /etc/osbuild-composer/composer-crt.pem
|
|
chown _osbuild-composer:_osbuild-composer /etc/osbuild-composer/composer-key.pem /etc/osbuild-composer/composer-csr.pem /etc/osbuild-composer/composer-crt.pem
|
|
|
|
.PHONY: worker-key-pair
|
|
worker-key-pair: ca
|
|
openssl genrsa -out /etc/osbuild-composer/worker-key.pem 2048
|
|
openssl req -new -sha256 -key /etc/osbuild-composer/worker-key.pem -out /etc/osbuild-composer/worker-csr.pem -subj "/CN=localhost"
|
|
openssl x509 -req -in /etc/osbuild-composer/worker-csr.pem -CA /etc/osbuild-composer/ca-crt.pem -CAkey /etc/osbuild-composer/ca-key.pem -CAcreateserial -out /etc/osbuild-composer/worker-crt.pem
|
|
|
|
.PHONY: rpm
|
|
rpm:
|
|
mkdir -p $(CURDIR)/rpmbuild/SPECS $(CURDIR)/rpmbuild/SOURCES
|
|
|
|
echo "%global commit $(COMMIT)" | cat - golang-github-osbuild-composer.spec \
|
|
> rpmbuild/SPECS/golang-github-osbuild-composer-$(COMMIT).spec
|
|
|
|
git archive --prefix=$(PACKAGE_NAME)-$(COMMIT)/ --format=tar.gz HEAD \
|
|
> rpmbuild/SOURCES/$(PACKAGE_NAME)-$(COMMIT).tar.gz
|
|
|
|
rpmbuild -bs \
|
|
--define "_topdir $(CURDIR)/rpmbuild" \
|
|
rpmbuild/SPECS/golang-github-$(PACKAGE_NAME)-$(COMMIT).spec
|
|
|
|
rpmbuild -bb \
|
|
--define "_topdir $(CURDIR)/rpmbuild" \
|
|
rpmbuild/SPECS/golang-github-$(PACKAGE_NAME)-$(COMMIT).spec
|