53 lines
2.4 KiB
Makefile
53 lines
2.4 KiB
Makefile
NAME = codit
|
|
VERSION = $(shell awk '$$1 == "Version:" { print $$2; }' rpm/codit.spec)
|
|
WORKDIR = $(abspath ..)
|
|
PKGDIR = $(abspath .)
|
|
RPM_TOPDIR = $(PKGDIR)/RPM
|
|
DEB_OUTDIR = $(PKGDIR)/DEB
|
|
##DEB_PACKAGER_IMAGE = codit-packager:deb
|
|
##DEB_PACKAGER_BASE_IMAGE = debian:stable
|
|
##DEB_DOCKER_FILE = Dockerfile.deb
|
|
DEB_PACKAGER_IMAGE = codit-packager:deb12
|
|
DEB_PACKAGER_BASE_IMAGE = debian:12
|
|
DEB_DOCKERFILE = Dockerfile.deb12
|
|
PLATFORM = linux/386
|
|
|
|
CODIT_TAR = $(RPM_TOPDIR)/SOURCES/$(NAME)-$(VERSION).tar.gz
|
|
REPOKIT_TAR = $(RPM_TOPDIR)/SOURCES/repokit.tar.gz
|
|
GIT2GO_TAR = $(RPM_TOPDIR)/SOURCES/git2go.tar.gz
|
|
|
|
all: rpm
|
|
|
|
$(RPM_TOPDIR):
|
|
rm -rf "$(RPM_TOPDIR)/BUILD" "$(RPM_TOPDIR)/BUILDROOT" "$(RPM_TOPDIR)/SOURCES" "$(RPM_TOPDIR)/SPECS" "$(RPM_TOPDIR)/SRPMS" "$(RPM_TOPDIR)/RPMS"
|
|
mkdir -p "$(RPM_TOPDIR)/BUILD" "$(RPM_TOPDIR)/BUILDROOT" "$(RPM_TOPDIR)/SOURCES" "$(RPM_TOPDIR)/SPECS" "$(RPM_TOPDIR)/SRPMS" "$(RPM_TOPDIR)/RPMS"
|
|
|
|
$(CODIT_TAR): $(RPM_TOPDIR)
|
|
cd "$(WORKDIR)" && { git ls-files -z; find packaging -type f ! -path 'packaging/RPM/*' ! -path 'packaging/DEB/*' ! -path 'packaging/tmp/*' -print0; } | tar --null -T - --transform 's,^,$(NAME)-$(VERSION)/,' -czf "$@"
|
|
|
|
$(REPOKIT_TAR): $(RPM_TOPDIR)
|
|
cd $(RPM_TOPDIR)/SOURCES && rm -rf repokit && git clone https://code.miflux.com/hyung-hwan/repokit && cd repokit && git archive --format=tar.gz --prefix=repokit/ --output=$@ HEAD && cd .. && rm -rf repokit
|
|
|
|
$(GIT2GO_TAR): $(RPM_TOPDIR)
|
|
cd $(RPM_TOPDIR)/SOURCES && rm -rf git2go && git clone https://code.miflux.com/hyung-hwan/git2go && cd git2go && git archive --format=tar.gz --prefix=git2go/ --output=$@ HEAD && cd .. && rm -rf git2go
|
|
|
|
rpm: $(CODIT_TAR) $(REPOKIT_TAR) $(GIT2GO_TAR)
|
|
rpmbuild $(RPMBUILD_EXTRA_ARGS) --define "_topdir $(RPM_TOPDIR)" -ba rpm/codit.spec
|
|
|
|
deb-image:
|
|
if ! docker image inspect "$(DEB_PACKAGER_IMAGE)" >/dev/null 2>&1; then \
|
|
docker build --platform $(PLATFORM) -f "$(PKGDIR)/docker/$(DEB_DOCKERFILE)" --build-arg BASE_IMAGE="$(DEB_PACKAGER_BASE_IMAGE)" -t "$(DEB_PACKAGER_IMAGE)" "$(WORKDIR)"; \
|
|
fi
|
|
|
|
deb-image-rebuild:
|
|
docker build --platform $(PLATFORM) -f "$(PKGDIR)/docker/$(DEB_DOCKERFILE)" --build-arg BASE_IMAGE="$(DEB_PACKAGER_BASE_IMAGE)" -t "$(DEB_PACKAGER_IMAGE)" "$(WORKDIR)"
|
|
|
|
deb-docker: deb-image
|
|
mkdir -p "$(DEB_OUTDIR)"
|
|
CODIT_DEB_IMAGE="$(DEB_PACKAGER_IMAGE)" ./scripts/build-deb-in-docker.sh
|
|
|
|
clean:
|
|
rm -rf "$(RPM_TOPDIR)" "$(DEB_OUTDIR)" tmp
|
|
|
|
.PHONY: all rpm deb-image deb-image-rebuild deb-docker clean
|