Blob Blame History Raw
# Make mock usable.   The only standard target is mockbuild which
# doesn't do what you typically want.

BRANCH := $(shell git branch | sed -e 's/^\* f*//' -e 's/master/devel/' )
#MOCKCFG = fedora-devel-x86_64
MOCKCFG = fedora-$(BRANCH)-i386

# Order that dependent libraries need to be built and installed.

comma := ,
empty :=
space := $(empty) $(empty)

ORDER = \
	glib-java \
	cairo-java \
	libgtk-java \
	libgconf-java \
	libvte-java libgnome-java \
	libglade-java \
	frysk

MOCK_WORDS := $(subst -, , $(MOCKCFG))
MOCK_OS := $(word 1,$(MOCK_WORDS))
MOCK_RELEASE := $(word 2,$(MOCK_WORDS))
MOCK_ARCH := $(word 3,$(MOCK_WORDS))
MOCK_RESULTS := results.$(MOCKCFG)

ARCH := $(if $(findstring i386,$(MOCK_ARCH)),i686,$(MOCK_ARCH))

# --offline?
NO_CLEAN := --no-clean --no-cleanup-after
MOCK := mock $(MOCKARGS) -r $(MOCKCFG) --resultdir=$(MOCK_RESULTS)

SOURCES := *.spec *.patch

SPEC_FILE = $(shell fedpkg gimmespec)
# VERREL is very slow
VERREL = $(shell fedpkg verrel)
RPM = $(VERREL).$(ARCH).rpm

help:
	@echo "Mock targets"
	@echo ""
	@echo "  init: Initialize the $(MOCKCFG) chroot (if needed)"
	@echo "  local|build: Build, logs in $(MOCK_RESULTS)"
	@echo "  shell: Start a shell in the chroot"
	@echo "  deploy: Build/Deploy $(ARCH) package"
	@echo ""
	@echo "  clean: Purge the $(ARCH) chroot tree"
	@echo "  scrub: Completely remove Purge the chroot tree"
	@echo ""
	@echo "  update: Run yum update in the chroot"
	@echo "  orphanskill: Kill any stray processes from the build"
	@echo "  installdeps: Install dependencies for this package"
	@echo ""
	@echo "Use MOCKARGS= for extra arguments"
.PHONY:: help

init:
	$(MOCK) -q --chroot pwd \
	|| $(MOCK) --init
.PHONY:: init

local build $(MOCK_RESULTS)/$(RPM): init $(SOURCES)
	rm -f $(MOCK_RESULTS)/*.src.rpm
	$(MOCK) $(NO_CLEAN) --buildsrpm --spec $(SPEC_FILE) --source $(PWD)
	$(MOCK) $(NO_CLEAN) --rebuild $(MOCK_RESULTS)/*.src.rpm
.PHONY:: local build

# rpmspec -q --queryformat '%{NAME}-%{VERSION}-%{RELEASE}\n' $(SPEC_FILE)
deploy: $(MOCK_RESULTS)/$(RPM)
	$(MOCK) -q --chroot 'rm -f /tmp/*.rpm'
	for rpm in $(MOCK_RESULTS)/*.rpm ; do \
		case $$rpm in \
		*.src.rpm | *-debuginfo-* ) ;; \
		* ) $(MOCK) -q --copyin $$rpm /tmp ;; \
		esac ; \
	done
	$(MOCK) -q --chroot "rpm -Uvh --force /tmp/*.rpm" 
.PHONY:: deploy

world gnome:
	set -e ; \
	for d in $(ORDER) ; do \
		pushd ../$$d ; \
			$(MAKE) -f $(PWD)/Makefile deploy ; \
		popd ; \
	done
.PHONY:: world

usable: init
	$(MOCK) install vi less emacs automake-docs
.PHONY:: usable

clog prep:
	fedpkg $@
.PHONY:: clog prep


clean shell install update remove orphanskill scrub copyin copyout:
	$(MOCK) --$@ $(ARGS) $(PACKAGE)
	rm -rf $(MOCK_RESULTS)
.PHONY:: clean shell install update remove orphanskill scrub copyin copyout