-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathMakefile-legacy.rpmbuilder
99 lines (86 loc) · 4.31 KB
/
Makefile-legacy.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
# This file is included from Makefile.fedora if USE_DIST_BUILD_TOOLS is not defined
RPM_BUILD_DEFINES += --define "_rpmdir $(OUTPUT_DIR)/"
RPM_BUILD_DEFINES += --define "qubes_builder 1"
RPM_BUILD_DEFINES += --define "backend_vmm $(BACKEND_VMM)"
RPM_BUILD_DEFINES += --define "source_date_epoch_from_changelog 1"
RPM_BUILD_DEFINES += --define "clamp_mtime_to_source_date_epoch 1"
RPM_BUILD_DEFINES += --define "use_source_date_epoch_as_buildtime 1"
RPM_QUERY_FORMAT = "$(OUTPUT_DIR)/%{ARCH}/%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}.rpm\\n"
ifdef REPO_PROXY
YUM_OPTS += --setopt=proxy=$(REPO_PROXY)
endif
YUM_OPTS += --installroot=$(CHROOT_DIR)
YUM := dnf
YUM_BUILDDEP := dnf builddep --spec
YUM_BUILDDEP_SRPM := dnf builddep --srpm
ifeq (centos,$(DISTRIBUTION))
ifeq ($(subst centos,,$(DIST)),8)
YUM_BUILDDEP := dnf builddep --nobest --spec
YUM_BUILDDEP_SRPM := dnf builddep --srpm
endif
endif
### Targets required by Makefile.generic to build packages
dist-prepare-chroot: $(CHROOT_DIR)/home/user/.prepared_base
${Q}if [ ! -r $(CHROOT_DIR)/proc/cpuinfo ]; then\
sudo mount -t proc proc $(CHROOT_DIR)/proc;\
fi
${Q}if ! mountpoint -q $(CHROOT_DIR)/dev/shm; then\
sudo mkdir -p $(CHROOT_DIR)/dev/shm;\
sudo mount -t tmpfs tmpfs $(CHROOT_DIR)/dev/shm;\
fi
$(CHROOT_DIR)/home/user/.prepared_base: $(RPM_PLUGIN_DIR)/scripts/prepare-chroot-builder $(RPM_PLUGIN_DIR)/dnf/$(BUILD_PKG_LIST)
${Q}echo "-> Preparing $(DIST) build environment"
${Q}$(RPM_PLUGIN_DIR)/scripts/update-local-repo.sh $(BUILDER_REPO_DIR)
${Q}sudo -E $(RPM_PLUGIN_DIR)/scripts/prepare-chroot-builder $(CHROOT_DIR) $(DISTRIBUTION) $(DIST_VER) $(CACHEDIR) $(BUILDER_REPO_DIR) $(RPM_PLUGIN_DIR)/dnf/$(BUILD_PKG_LIST) || exit 1
${Q}touch $(CHROOT_DIR)/home/user/.prepared_base
.PHONY: refresh-update.dnf
refresh-update.dnf:
ifndef PACKAGE
$(error "PACKAGE need to be set!")
endif
$(RPM_PLUGIN_DIR)/scripts/update-local-repo.sh $(BUILDER_REPO_DIR)
sudo $(CHROOT_ENV) $(YUM) $(YUM_OPTS) --refresh -y update
dist-build-dep: refresh-update.$(YUM) dist-build-dep$(suffix $(PACKAGE))
# double parsing makes %-escaping tricky; the below is far from perfect (for
# example attributes in %files is mishandled), but works good enough to extract build deps
dist-build-dep.spec:
sudo $(CHROOT_ENV) chroot $(CHROOT_DIR) su -c 'cd "$(DIST_SRC)" && sed "s/\([^:]\)%%\([^{]\)/\1%%%%\2/" $(PACKAGE) > $(PACKAGE).tmp && rpmspec -P --define "_sourcedir $(DIST_SRC)" --define "debug_package %{nil}" $(RPM_QUERY_DEFINES) $(PACKAGE).tmp | sed "s/\([^%]\)%\([^%]\)/\1%%\2/g"> $(PACKAGE).parsed' - $(RUN_AS_USER)
sudo $(CHROOT_ENV) $(YUM_BUILDDEP) $(YUM_OPTS) $(RPM_BUILD_EXTRA_DEFINES) -y $(CHROOT_DIR)$(DIST_SRC)/$(PACKAGE).parsed
dist-build-dep.rpm:
sudo $(CHROOT_ENV) chroot $(CHROOT_DIR) bash -c 'cd $(DIST_SRC); \
rpm2cpio $(PACKAGE) | cpio --extract --to-stdout "*.spec" > $(PACKAGE).spec' && \
sudo $(YUM_BUILDDEP) $(YUM_OPTS) $(RPM_BUILD_EXTRA_DEFINES) -y $(CHROOT_DIR)$(DIST_SRC)/$(PACKAGE).spec
dist-package-build: RPM_SOURCE_DIR ?= $(DIST_SRC)
dist-package-build: RPM_BUILD_DEFINES += --define "_sourcedir $(RPM_SOURCE_DIR)"
dist-package-build:
ifndef PACKAGE
$(error "PACKAGE need to be set!")
endif
rm -rf $(CHROOT_DIR)/$(DIST_SRC)/$(OUTPUT_DIR)/*
ifdef INCREMENT_DEVEL_VERSIONS
mkdir -p $(ORIG_SRC)/$(OUTPUT_DIR)
echo $(devel_ver) > $(devel_ver_path)
endif
ifeq ($(suffix $(PACKAGE)),.rpm)
sudo chroot $(CHROOT_DIR) su -c 'cd $(DIST_SRC); env $(CHROOT_ENV) rpmbuild $(RPM_BUILD_DEFINES) --nodeps --rebuild $(PACKAGE)' - $(RUN_AS_USER)
else
sudo chroot $(CHROOT_DIR) su -c 'cd $(DIST_SRC); env $(CHROOT_ENV) rpmbuild $(RPM_BUILD_DEFINES) --nodeps -bb $(PACKAGE)' - $(RUN_AS_USER)
endif
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;\
mkdir -p $(ORIG_SRC)/$(OUTPUT_DIR);\
echo -n > $(pkg_list_path);\
for arch_chroot_dir in $(CHROOT_DIR)/$(DIST_SRC)/$(OUTPUT_DIR)/*; do\
arch_rpm_dir=$(ORIG_SRC)/$(OUTPUT_DIR)/`basename $$arch_chroot_dir`;\
mkdir -p $$arch_rpm_dir;\
for pkg in $$arch_chroot_dir/*; do\
echo " $$arch_rpm_dir/`basename $$pkg`" >&3 ;\
echo "$(OUTPUT_DIR)/`basename $$arch_chroot_dir`/`basename $$pkg`" >> $(pkg_list_path);\
done;\
mkdir -p $(BUILDER_REPO_DIR)/rpm;\
ln -f -t $(BUILDER_REPO_DIR)/rpm $$arch_chroot_dir/*;\
mv -t $$arch_rpm_dir $$arch_chroot_dir/*;\
done