forked from AlmaLinux/leapp-data
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
148 lines (115 loc) · 5.4 KB
/
Copy pathMakefile
File metadata and controls
148 lines (115 loc) · 5.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# Parameters
DIST_NAME ?= cloudlinux
DIST_VERSION ?= 7
DIST_TARGET_VERSION := $(shell echo ${DIST_VERSION}+1 | bc)
GPG_KEY ?= RPM-GPG-KEY-CloudLinux RPM-GPG-KEY-AlmaLinux-$(DIST_TARGET_VERSION)
VENDORS = epel imunify kernelcare mariadb nginx-stable nginx-mainline postgresql alt-common
CLOUDLINUX_VENDORS = cloudlinux_ea4 cloudlinux_ea4_testing cloudlinux_testing
# Installation prefix
PREFIX?=/
# Variables
buildroot ?= build
_sysconfdir = /etc
# Directories
LEAPP_BUILD_DIR = $(buildroot)$(_sysconfdir)/leapp
VENDORS_DIR = $(LEAPP_BUILD_DIR)/files/vendors.d
VENDORS_GPG_DIR = $(VENDORS_DIR)/rpm-gpg
SOURCE_FILES_DIR = files/$(DIST_NAME)
TARGET_FILES_DIR = $(LEAPP_BUILD_DIR)/files
CLOUDLINUX_VENDORS_DIR = $(SOURCE_FILES_DIR)/vendors.d
GPG_DIR_RHEL = $(LEAPP_BUILD_DIR)/repos.d/system_upgrade/common/files/rpm-gpg/$(DIST_TARGET_VERSION)/
all: vendors core
core:
cp -arf files/$(DIST_NAME)/* $(buildroot)$(_sysconfdir)/leapp/files/
install -D files/$(DIST_NAME)/leapp_upgrade_repositories.repo.el${DIST_TARGET_VERSION} $(LEAPP_BUILD_DIR)/files/leapp_upgrade_repositories.repo
install -D files/$(DIST_NAME)/repomap.json.el${DIST_TARGET_VERSION} $(LEAPP_BUILD_DIR)/files/repomap.json
@for key in $(GPG_KEY); do \
install -D files/rpm-gpg/$${key} $(GPG_DIR_RHEL)/$${key}; \
done
# (oshyshatsky): can we just use common vendors.d?
@for vendor in $(CLOUDLINUX_VENDORS); do \
install -D $(CLOUDLINUX_VENDORS_DIR)/$${vendor}.repo.el$(DIST_TARGET_VERSION) \
$(VENDORS_DIR)/$${vendor}.repo; \
install -D $(CLOUDLINUX_VENDORS_DIR)/$${vendor}.gpg.el$(DIST_TARGET_VERSION) \
$(VENDORS_GPG_DIR)/$${vendor}.gpg; \
install -D $(CLOUDLINUX_VENDORS_DIR)/$${vendor}_map.json.el$(DIST_TARGET_VERSION) \
$(VENDORS_DIR)/$${vendor}_map.json; \
done
find $(LEAPP_BUILD_DIR) -name '*.el?' -delete
vendors:
mkdir -p $(VENDORS_DIR)
cp -rf vendors.d/* $(VENDORS_DIR)/
# expected to be almalinux here
bash tools/generate_epel_files.sh "almalinux" "$(DIST_VERSION)" "$(buildroot)$(_sysconfdir)/leapp/files"
@for vendor in $(VENDORS); do \
install -D $(VENDORS_DIR)/$${vendor}.repo.el$(DIST_TARGET_VERSION) \
$(VENDORS_DIR)/$${vendor}.repo; \
install -D $(VENDORS_GPG_DIR)/$${vendor}.gpg.el$(DIST_TARGET_VERSION) \
$(VENDORS_GPG_DIR)/$${vendor}.gpg; \
install -D $(VENDORS_DIR)/$${vendor}_map.json.el$(DIST_TARGET_VERSION) \
$(VENDORS_DIR)/$${vendor}_map.json; \
done
find $(LEAPP_BUILD_DIR) -name '*.el?' -delete
find $(VENDORS_DIR) -name '*.json' | xargs -n 1 python3 tools/repomap_check.py
test:
$(eval JSON_FILES := $(shell find $(buildroot) -path "./tests" -prune -o -name "*pes*.json*" -print0 | xargs -0 echo))
python3 tests/validate_json.py tests/pes-events-schema.json $(JSON_FILES)
python3 tests/validate_ids.py $(JSON_FILES)
# todo: disabled temporary
# python3 tests/check_debranding.py $(buildroot)$(_sysconfdir)/leapp/files/pes-events.json
install:
cp -ar $(buildroot)/* $(PREFIX)
clean:
rm -rf $(buildroot)
rpm:
echo "Add your files to index before running this command"
# see details here https://docs.oracle.com/en/operating-systems/oracle-linux/6/porting/ch10s01s03.html
git ls-files -z | xargs -0 tar \
-czvf ~/rpmbuild/SOURCES/$(shell rpm -q --queryformat="leapp-data-%{version}.tar.gz\n" --specfile leapp-data.spec) \
--transform 's,^,$(shell rpm -q -D "dist_name cloudlinux" --queryformat="%{NAME}-%{VERSION}\n" --specfile leapp-data.spec)/,'
rpmbuild -bb -D "dist_name cloudlinux" leapp-data.spec
# =============================================================================
# Workspace targets for local development and testing
# =============================================================================
SPEC_FILE := leapp-data.spec
VERSION := $(shell grep -m1 '^Version:' $(SPEC_FILE) | awk '{print $$2}')
RPMBUILD_DIR := $(CURDIR)/.rpmbuild
# install-deps: Install build and test dependencies
install-deps:
@echo "Installing build and test dependencies..."
dnf install -y rpm-build git rsync
rpmspec -q --buildrequires --define "dist_name $(DIST_NAME)" $(SPEC_FILE) | xargs dnf install -y
# sync-sources: Build and install data files to system paths for development
sync-sources: all
@echo "Syncing leapp-data to system paths..."
rsync -a --ignore-errors $(buildroot)/ /
@echo "Done. Files synced to /etc/leapp/"
# build-package: Build RPM using rpmbuild with local _topdir
build-package:
@echo "Building RPM package..."
@mkdir -p $(RPMBUILD_DIR)/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
@echo "-> Creating source tarball"
git ls-files -z | xargs -0 tar \
-czf $(RPMBUILD_DIR)/SOURCES/leapp-data-$(VERSION).tar.gz \
--transform 's,^,leapp-data-$(VERSION)/,'
@cp $(SPEC_FILE) $(RPMBUILD_DIR)/SPECS/
rpmbuild -bb \
--define "_topdir $(RPMBUILD_DIR)" \
--define "dist $$(rpm --eval '%{dist}').$$(date +%s)" \
--define "dist_name $(DIST_NAME)" \
$(RPMBUILD_DIR)/SPECS/$(SPEC_FILE)
@echo "Build complete! RPMs at: $(RPMBUILD_DIR)/RPMS/"
# install-package: Install built RPM package
install-package: build-package
@RPM_FILE=$$(ls -t $(RPMBUILD_DIR)/RPMS/noarch/leapp-data-*.rpm 2>/dev/null | head -1); \
if [ -z "$$RPM_FILE" ]; then \
echo "Error: No RPM found. Run 'make build-package' first."; \
exit 1; \
fi; \
echo "Installing $$RPM_FILE"; \
yum install -y $$RPM_FILE
# run-unit-tests: Run JSON validation tests
run-unit-tests: test
# run-integration-tests: No integration tests for data-only package
run-integration-tests:
@echo "No integration tests configured for leapp-data (data-only package)."