-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
Makefile-mock.rpmbuilder
125 lines (110 loc) · 4.57 KB
/
Makefile-mock.rpmbuilder
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
# This file is included from Makefile.fedora if USE_DIST_BUILD_TOOLS is defined
RPM_QUERY_FORMAT = "$(OUTPUT_DIR)/%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}.rpm\\n"
RPM_SRC_QUERY_FORMAT = "$(OUTPUT_DIR)/%{SOURCERPM}\n"
RPM_SOURCE_DIR ?= $(DIST_SRC)
ifneq (,$(wildcard $(RPM_PLUGIN_DIR)/mock/mock-$(DISTRIBUTION)-$(DIST_VER).cfg))
MOCK_CFG = mock-$(DISTRIBUTION)-$(DIST_VER).cfg
else
MOCK_CFG = mock-$(DISTRIBUTION).cfg
endif
# different locations of actual mock executable depending on distribution: on
# Fedora /usr/bin/mock is a (consolehelper) wrapper, which among other things,
# strips environment variables
MOCK ?= $(firstword $(wildcard /usr/libexec/mock/mock /usr/sbin/mock))
ifeq (,$(MOCK))
$(error package 'mock' must be installed)
endif
YUM ?= dnf
ifeq ($(shell rpm --eval %centos), 7)
YUM = yum
endif
MOCK_EXTRA_OPTS ?=
MOCK_EXTRA_OPTS += --$(YUM)
MOCK_EXTRA_OPTS += --isolation=nspawn
ifneq (,$(USE_QUBES_REPO_VERSION))
MOCK_EXTRA_OPTS += --enablerepo=qubes-current
ifeq (1,$(USE_QUBES_REPO_TESTING))
MOCK_EXTRA_OPTS += --enablerepo=qubes-current-testing
endif
endif
MOCK_ENV = DIST=$(DIST) \
PACKAGE_SET=$(PACKAGE_SET) \
RPM_PLUGIN_DIR=$(RPM_PLUGIN_DIR) \
USE_QUBES_REPO_VERSION=$(USE_QUBES_REPO_VERSION) \
BUILDER_REPO_DIR=$(BUILDER_REPO_DIR) \
CACHEDIR=$(CACHEDIR) \
CHROOT_DIR=$(CHROOT_DIR)
spec_pkg_name = $(shell cd $(ORIG_SRC) && [ -n "$(1)" ] && \
rpm -q $(RPM_QUERY_DEFINES) --qf '%{NAME}\n' --specfile $(1) | head -n 1)
# full name with version of base package - useful for src.rpm name build
spec_pkg_ver_name = $(shell cd $(ORIG_SRC) && [ -n "$(1)" ] && \
rpm -q $(RPM_QUERY_DEFINES) --qf '%{NAME}-%{VERSION}-%{RELEASE}\n' --specfile $(1) | head -n 1)
### Targets required by Makefile.generic to build packages
dist-prepare-chroot: $(CHROOT_DIR)/home/user/.prepared_mock
${Q}true
$(CHROOT_DIR)/home/user/.prepared_mock:
mkdir -p $(CHROOT_DIR)/home/user/qubes-src
sudo $(MOCK_ENV) $(MOCK) \
-v -r $(RPM_PLUGIN_DIR)/mock/$(MOCK_CFG) \
$(RPM_BUILD_DEFINES) \
$(MOCK_EXTRA_OPTS) \
--disablerepo=builder-local \
--init
touch $(CHROOT_DIR)/home/user/.prepared_mock
dist-build-dep:
$(RPM_PLUGIN_DIR)/scripts/update-local-repo.sh $(BUILDER_REPO_DIR)
rm -rf $(CHROOT_DIR)/$(DIST_SRC)/$(OUTPUT_DIR)/*
mkdir -p $(CHROOT_DIR)/$(DIST_SRC)/$(OUTPUT_DIR)
dist-src-package-build:
cd $(CHROOT_DIR)$(DIST_SRC); sudo $(MOCK_ENV) $(MOCK) \
-v -r $(RPM_PLUGIN_DIR)/mock/$(MOCK_CFG) \
--resultdir=$(CHROOT_DIR)/$(DIST_SRC)/$(OUTPUT_DIR) \
$(RPM_BUILD_DEFINES) \
$(MOCK_EXTRA_OPTS) \
--buildsrpm --spec $(PACKAGE) --sources $(CHROOT_DIR)$(RPM_SOURCE_DIR)
ifeq ($(suffix $(PACKAGE)),.rpm)
dist-package-build: srcrpm = $(PACKAGE)
else
dist-package-build: srcrpm = $(CHROOT_DIR)$(DIST_SRC)/$(OUTPUT_DIR)/$(call spec_pkg_ver_name,$(CHROOT_DIR)$(DIST_SRC)/$(PACKAGE)).src.rpm
dist-package-build: dist-src-package-build
endif
dist-package-build: buildinfo = $(notdir $(srcrpm:%.src.rpm=%.$(RPM_ARCH).buildinfo))
dist-package-build:
ifndef PACKAGE
$(error "PACKAGE need to be set!")
endif
ifdef INCREMENT_DEVEL_VERSIONS
mkdir -p $(ORIG_SRC)/$(OUTPUT_DIR)
echo $(devel_ver) > $(devel_ver_path)
endif
cd $(CHROOT_DIR)$(DIST_SRC); sudo $(MOCK_ENV) $(MOCK) \
--resultdir=$(CHROOT_DIR)/$(DIST_SRC)/$(OUTPUT_DIR) \
-v -r $(RPM_PLUGIN_DIR)/mock/$(MOCK_CFG) \
$(MOCK_EXTRA_OPTS) --no-cleanup-after \
$(RPM_BUILD_DEFINES) --rebuild $(srcrpm)
sudo $(MOCK_ENV) $(MOCK) \
'--plugin-option=bind_mount:dirs=[("$(RPM_PLUGIN_DIR)", "/builder-rpm")]' \
-q -r $(RPM_PLUGIN_DIR)/mock/$(MOCK_CFG) \
$(MOCK_EXTRA_OPTS) \
$(RPM_BUILD_DEFINES) --chroot \
'/builder-rpm/scripts/rpmbuildinfo /builddir/build/SRPMS/*.src.rpm' \
> $(CHROOT_DIR)/$(DIST_SRC)/$(OUTPUT_DIR)/$(buildinfo)
dist-copy-out: pkg_list_path = $(ORIG_SRC)/$(OUTPUT_DIR)/$(notdir $(PACKAGE)).list
dist-copy-out:
@echo "--> Done:" >&3
${Q}set -e;\
shopt -s nullglob; shopt -s globstar;\
mkdir -p "$(ORIG_SRC)/$(OUTPUT_DIR)";\
echo -n > $(pkg_list_path);\
for pkg in $(CHROOT_DIR)/$(DIST_SRC)/$(OUTPUT_DIR)/**/*.rpm \
$(CHROOT_DIR)/$(DIST_SRC)/$(OUTPUT_DIR)/*.buildinfo; do\
relative_path=`realpath --relative-to=$(CHROOT_DIR)/$(DIST_SRC) $$pkg`;\
echo " $(ORIG_SRC)/$$relative_path" >&3 ;\
echo "$$relative_path" >> $(pkg_list_path);\
done;\
mkdir -p $(BUILDER_REPO_DIR)/rpm;\
ln -f -t $(BUILDER_REPO_DIR)/rpm $(CHROOT_DIR)/$(DIST_SRC)/$(OUTPUT_DIR)/**/*.rpm;\
ln -f -t $(BUILDER_REPO_DIR)/rpm $(CHROOT_DIR)/$(DIST_SRC)/$(OUTPUT_DIR)/*.buildinfo;\
mv -t $(ORIG_SRC)/$(OUTPUT_DIR) $(CHROOT_DIR)/$(DIST_SRC)/$(OUTPUT_DIR)/**/*.rpm;\
mv $(CHROOT_DIR)/$(DIST_SRC)/$(OUTPUT_DIR)/*.buildinfo \
$(ORIG_SRC)/$(OUTPUT_DIR)/