Skip to content

Commit

Permalink
Makefile simplify, add version target
Browse files Browse the repository at this point in the history
  • Loading branch information
xorel committed Nov 3, 2023
1 parent bc48571 commit f9b9077
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 47 deletions.
40 changes: 16 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,33 @@ include Makefile.config
# load possible overrides or non-free definitions
-include Makefile.local

#------------------------------------------------------------------------------
# All, alliases
#------------------------------------------------------------------------------
all: $(patsubst %, packer-%, $(DISTROS)) $(patsubst %, services-%, $(SERVICES))
@:
# all, aliases
all: $(patsubst %, packer-%, $(DISTROS)) $(patsubst %, packer-%, $(SERVICES))
distros: $(patsubst %, packer-%, $(DISTROS))
services: $(patsubst %, packer-%, $(SERVICES))

# allow individual distribution targets (e.g., "make debian11")
$(DISTROS): %: packer-% ;
$(SERVICES): %: services-% ;
$(SERVICES): %: packer-% ;

#------------------------------------------------------------------------------
# Packer stage
# - run packer build for given distro
#------------------------------------------------------------------------------
packer: $(patsubst %, packer-%, $(DISTROS))

packer-%: context-linux ${DIR_EXPORT}/%-${VERSION}-${RELEASE}.qcow2
packer-%: context-linux ${DIR_EXPORT}/%.qcow2
@${INFO} "Packer ${*} done"

${DIR_EXPORT}/%-${VERSION}-${RELEASE}.qcow2:
# run packer build for given distro or service
${DIR_EXPORT}/%.qcow2:
$(eval DISTRO_NAME := $(shell echo ${*} | sed 's/[0-9].*//'))
$(eval DISTRO_VER := $(shell echo ${*} | sed 's/[a-z]*//'))
packer/build.sh ${DISTRO_NAME} ${DISTRO_VER} ${@}

clean:
-rm -rf ${DIR_EXPORT}/*

#------------------------------------------------------------------------------
# context-linux
#------------------------------------------------------------------------------
context-linux: $(patsubst %, context-linux/out/%, $(LINUX_CONTEXT_PACKAGES))
@${INFO} "Generate context-linux done"

context-linux/out/%:
cd context-linux; ./generate-all.sh

#------------------------------------------------------------------------------
# help
#------------------------------------------------------------------------------
clean:
-rm -rf ${DIR_EXPORT}/*

help:
@echo 'Available distros:'
@echo ' $(DISTROS)'
Expand All @@ -51,9 +39,13 @@ help:
@echo ' $(SERVICES)'
@echo
@echo 'Usage examples:'
@echo ' make -- build all distros'
@echo ' make -- build all distros and services'
@echo ' make distros -- build all distros'
@echo ' make services -- build all services'
@echo
@echo ' make <distro> -- build just one distro'
@echo ' make context-linux -- build context linux packages'
@echo ' make context-windows -- TODO'

version:
@echo $(VERSION)-$(RELEASE)
34 changes: 11 additions & 23 deletions Makefile.config
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# context version definition
VERSION ?= 6.6.1
RELEASE ?= 1
VERSION := 6.6.1
RELEASE := 1

# log
VERBOSE ?= 1
PACKER_LOG ?= 0
PACKER_HEADLESS ?= true
VERBOSE := 1
PACKER_LOG := 0
PACKER_HEADLESS := true

DISTROS := alma8 alma9 \
alpine316 alpine317 \
Expand All @@ -22,17 +22,16 @@ DISTROS := alma8 alma9 \
SERVICES := service_OneKE service_wordpress

# default directories
DIR_BUILD ?= build
DIR_PACKER ?= $(DIR_BUILD)/packer
DIR_EXPORT ?= export
DIR_BUILD := build
DIR_EXPORT := export

# create them if not present
$(shell mkdir -p ${DIR_BUILD} ${DIR_PACKER} ${DIR_EXPORT})
$(shell mkdir -p ${DIR_BUILD} ${DIR_EXPORT})

# Don't delete exported
.SECONDARY: $(patsubst %, $(DIR_EXPORT)/%-$(VERSION)-$(RELEASE).qcow2, $(DISTROS))
# don't delete exported
.SECONDARY: $(patsubst %, $(DIR_EXPORT)/%.qcow2, $(DISTROS)) $(patsubst %, $(DIR_EXPORT)/%.qcow2, $(SERVICES))

.PHONY: context-linux packer help
.PHONY: context-linux help

# this needs to match context-linux/generate-all.sh products
LINUX_CONTEXT_PACKAGES := one-context_${VERSION}-${RELEASE}.deb \
Expand All @@ -49,17 +48,6 @@ LINUX_CONTEXT_PACKAGES := one-context_${VERSION}-${RELEASE}.deb \
LINUX_CONTEXT_PACKAGES_FULL := $(patsubst %, context-linux/out/%, $(LINUX_CONTEXT_PACKAGES))


# discover some binaries
QEMU_BINARY ?= $(shell \
for _qb in /usr/bin/qemu-system-x86_64 \
/usr/libexec/qemu-kvm \
/usr/bin/qemu-kvm; do \
\
if [ -e "$$_qb" ]; then \
echo $$_qb && exit; \
fi; \
done )

# logging func
INFO=sh -c 'if [ $(VERBOSE) = 1 ]; then echo [INFO] $$1; fi' INFO

Expand Down

0 comments on commit f9b9077

Please sign in to comment.