feat: only build packages that dont exist
Some checks failed
Build / build (pull_request) Failing after 1m2s
Some checks failed
Build / build (pull_request) Failing after 1m2s
- check the rpm repo to confirm if a package already exists
This commit is contained in:
parent
f7a6cd7d3c
commit
04eb148b70
37
Makefile
37
Makefile
@ -1,17 +1,23 @@
|
||||
# Variables
|
||||
ROOT_DIR := $(PWD)
|
||||
RPMS_DIR := $(ROOT_DIR)/rpms
|
||||
REPO_OPTIONS := --disablerepo=* --enablerepo=unkin
|
||||
|
||||
# Automatically find all package/version directories
|
||||
PACKAGES := $(shell find $(RPMS_DIR) -mindepth 2 -maxdepth 2 -type d | sed "s|$(RPMS_DIR)/||")
|
||||
|
||||
# Default target to build all packages and versions
|
||||
.PHONY: all list build buildall clean
|
||||
all: $(PACKAGES)
|
||||
.PHONY: all list cache build clean
|
||||
all: cache $(PACKAGES)
|
||||
|
||||
list:
|
||||
@echo "$(PACKAGES)"
|
||||
|
||||
cache:
|
||||
echo "Refreshing DNF cache..." && \
|
||||
dnf clean all && \
|
||||
dnf makecache
|
||||
|
||||
# Build specific package/version
|
||||
.PHONY: $(PACKAGES)
|
||||
$(PACKAGES):
|
||||
@ -26,17 +32,22 @@ build:
|
||||
@echo "Preparing to build $(PACKAGE_NAME) version $(PACKAGE_VERSION)"
|
||||
@cd $(RPMS_DIR)/$(PACKAGE_NAME) && \
|
||||
export PACKAGE_RELEASE=$$(cat $(PACKAGE_VERSION)/release) && \
|
||||
echo "Using PACKAGE_RELEASE=$${PACKAGE_RELEASE}" && \
|
||||
docker build \
|
||||
--build-arg PACKAGE_VERSION=$(PACKAGE_VERSION) \
|
||||
--build-arg PACKAGE_RELEASE=$${PACKAGE_RELEASE} \
|
||||
-t $$(echo $(PACKAGE_NAME)-builder \
|
||||
| tr '[:upper:]' '[:lower:]') . && \
|
||||
docker create --name $(PACKAGE_NAME)-$(PACKAGE_VERSION)-builder \
|
||||
$$(echo $(PACKAGE_NAME)-builder | tr '[:upper:]' '[:lower:]') && \
|
||||
docker start -a $(PACKAGE_NAME)-$(PACKAGE_VERSION)-builder && \
|
||||
docker cp $(PACKAGE_NAME)-$(PACKAGE_VERSION)-builder:/app/dist/. $(ROOT_DIR)/dist/$(PACKAGE_NAME)/ && \
|
||||
docker rm $(PACKAGE_NAME)-$(PACKAGE_VERSION)-builder
|
||||
export PACKAGE_FULL_NAME=$(PACKAGE_NAME)-$(PACKAGE_VERSION)-$$PACKAGE_RELEASE && \
|
||||
if dnf info $$PACKAGE_FULL_NAME $(REPO_OPTIONS) > /dev/null 2>&1; then \
|
||||
echo "Skipping build for $(PACKAGE_NAME) version $(PACKAGE_VERSION) (already exists in the repository)"; \
|
||||
else \
|
||||
echo "Building RPM for $(PACKAGE_NAME) version $(PACKAGE_VERSION)"; \
|
||||
docker build \
|
||||
--build-arg PACKAGE_VERSION=$(PACKAGE_VERSION) \
|
||||
--build-arg PACKAGE_RELEASE=$${PACKAGE_RELEASE} \
|
||||
-t $$(echo $(PACKAGE_NAME)-builder \
|
||||
| tr '[:upper:]' '[:lower:]') . && \
|
||||
docker create --name $(PACKAGE_NAME)-$(PACKAGE_VERSION)-builder \
|
||||
$$(echo $(PACKAGE_NAME)-builder | tr '[:upper:]' '[:lower:]') && \
|
||||
docker start -a $(PACKAGE_NAME)-$(PACKAGE_VERSION)-builder && \
|
||||
docker cp $(PACKAGE_NAME)-$(PACKAGE_VERSION)-builder:/app/dist/. $(ROOT_DIR)/dist/$(PACKAGE_NAME)/ && \
|
||||
docker rm $(PACKAGE_NAME)-$(PACKAGE_VERSION)-builder
|
||||
fi
|
||||
|
||||
# Clean target
|
||||
clean:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user