Skip to content

Commit

Permalink
Makefile stub for contrail's packages
Browse files Browse the repository at this point in the history
This is a makefile that automates building of all the packages in
contrail-packages repo and will be used as single source of truth
for both CI and dev-env. It will also allow building of packages after
merge from contrail-packaging.

Change-Id: I03a70723833621266435483474fbcffcd22f3bda
Partial-Bug: 1752195
  • Loading branch information
wurbanski committed Mar 8, 2018
1 parent f4967bd commit 81b258c
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions Makefile
@@ -0,0 +1,53 @@
MKFILE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
SB_TOP := $(MKFILE_DIR:/tools/packages/=)

SPEC_DIR := $(MKFILE_DIR)rpm
SPEC_FILES := $(wildcard $(SPEC_DIR)/*/*.spec)
PACKAGES := $(patsubst %.spec,rpm-%,$(notdir $(SPEC_FILES)))
DEPENDENCIES := $(patsubst %.spec,dep-%,$(notdir $(SPEC_FILES)))

DEBUGINFO := TRUE
SCONSOPT := production
SRCVER := $(shell cat $(SB_TOP)/controller/src/base/version.info)
KVERS := $(shell rpm -q --qf "%{VERSION}-%{RELEASE}.%{ARCH}" kernel-devel)
BUILDTAG := $(shell date +%m%d%Y%H%M)

RPMBUILD_FLAGS := -bb --define "_sbtop $(SB_TOP)"
RPMBUILD_FLAGS += --define "_opt $(SCONSOPT)"
RPMBUILD_FLAGS += --define "_kVers $(KVERS)"
RPMBUILD_FLAGS += --define "_srcVer $(SRCVER)"
RPMBUILD_FLAGS += --define "_buildTag $(BUILDTAG)"

SCONSFLAGS := -j$(shell nproc)

export BUILD_ONLY := TRUE
export SCONSFLAGS := $(SCONSFLAGS)

all: dep rpm
@echo $(PACKAGES)
@echo $(DEPENDENCIES)

.PHONY: all rpm dep

dep: $(DEPENDENCIES)
rpm: $(PACKAGES)

dep-%:
$(eval SPECFILE = $(filter %/$(patsubst dep-%,%.spec,$@), $(SPEC_FILES)))
$(info Installing dependencies for $(SPECFILE)...)
@yum-builddep -y $(SPECFILE) >/dev/null
$(info DONE)

rpm-%:
$(eval SPECFILE = $(filter %/$(patsubst rpm-%,%.spec,$@), $(SPEC_FILES)))
@rpmbuild $(RPMBUILD_FLAGS) $(SPECFILE)

list:
@echo $(patsubst rpm-%,%,$(PACKAGES))

info:
@echo SPEC_FILES=$(SPEC_FILES)
@echo SRCVER=$(SRCVER)
@echo KVERS=$(KVERS)
@echo SCONSOPT=$(SCONSOPT)
@echo BUILDTAG=$(BUILDTAG)

0 comments on commit 81b258c

Please sign in to comment.