forked from QubesOS/qubes-builder-rpm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile-legacy.rpmbuilder
110 lines (96 loc) · 4.28 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
100
101
102
103
104
105
106
107
108
109
# 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 Y"
RPM_BUILD_DEFINES += --define "clamp_mtime_to_source_date_epoch Y"
RPM_BUILD_DEFINES += --define "use_source_date_epoch_as_buildtime Y"
RPM_QUERY_FORMAT = "$(OUTPUT_DIR)/%{ARCH}/%{NAME}-%{VERSION}-%{RELEASE}.%{ARCH}.rpm\\n"
ifdef REPO_PROXY
YUM_OPTS += --setopt=proxy=$(REPO_PROXY)
endif
YUM := dnf
YUM_BUILDDEP := dnf builddep --spec
YUM_BUILDDEP_SRPM := dnf builddep --srpm
ifeq (centos,$(DISTRIBUTION))
ifeq ($(subst centos,,$(DIST)),7)
YUM := yum
YUM_BUILDDEP := yum-builddep
YUM_BUILDDEP_SRPM := yum-builddep
endif
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
@if [ ! -r $(CHROOT_DIR)/proc/cpuinfo ]; then\
sudo mount -t proc proc $(CHROOT_DIR)/proc;\
fi
@if ! [ -d $(CHROOT_DIR)/tmp/qubes-packages-mirror-repo/rpm ]; then\
mkdir -p $(CHROOT_DIR)/tmp/qubes-packages-mirror-repo;\
sudo mount --bind $(BUILDER_REPO_DIR) $(CHROOT_DIR)/tmp/qubes-packages-mirror-repo;\
fi
@sudo cp $(RPM_PLUGIN_DIR)yum.conf $(CHROOT_DIR)/etc/yum.conf
$(CHROOT_DIR)/home/user/.prepared_base: $(RPM_PLUGIN_DIR)/prepare-chroot-builder $(RPM_PLUGIN_DIR)/$(BUILD_PKG_LIST)
@echo "-> Preparing $(DIST) build environment"
@sudo -E $(RPM_PLUGIN_DIR)/prepare-chroot-builder $(CHROOT_DIR) $(DIST) || exit 1
@touch $(CHROOT_DIR)/home/user/.prepared_base
.PHONY: refresh-update.dnf
refresh-update.yum:
ifndef PACKAGE
$(error "PACKAGE need to be set!")
endif
$(RPM_PLUGIN_DIR)/update-local-repo.sh $(DIST)
sudo $(CHROOT_ENV) chroot $(CHROOT_DIR) $(YUM) --disablerepo=* --enablerepo=qubes-builder-pkgs $(YUM_OPTS) clean all
sudo $(CHROOT_ENV) chroot $(CHROOT_DIR) sh -c 'cd $(DIST_SRC); $(YUM) $(YUM_OPTS) makecache'
sudo $(CHROOT_ENV) chroot $(CHROOT_DIR) sh -c 'cd $(DIST_SRC); $(YUM) $(YUM_OPTS) -y update'
.PHONY: refresh-update.dnf
refresh-update.dnf:
ifndef PACKAGE
$(error "PACKAGE need to be set!")
endif
$(RPM_PLUGIN_DIR)/update-local-repo.sh $(DIST)
sudo $(CHROOT_ENV) chroot $(CHROOT_DIR) sh -c 'cd $(DIST_SRC); $(YUM) $(YUM_OPTS) --refresh -y update'
dist-build-dep: refresh-update.$(YUM) dist-build-dep$(suffix $(PACKAGE))
dist-build-dep.spec:
sudo $(CHROOT_ENV) chroot $(CHROOT_DIR) bash -c 'cd $(DIST_SRC); $(YUM_BUILDDEP) $(YUM_OPTS) $(RPM_BUILD_EXTRA_DEFINES) -y $(PACKAGE)'
dist-build-dep.rpm:
sudo $(CHROOT_ENV) chroot $(CHROOT_DIR) bash -c 'cd $(DIST_SRC); \
rpm2cpio $(PACKAGE) | cpio --extract --to-stdout "*.spec" > $(PACKAGE).spec && \
$(YUM_BUILDDEP) $(YUM_OPTS) $(RPM_BUILD_EXTRA_DEFINES) -y $(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) --rebuild $(PACKAGE)' - $(RUN_AS_USER)
else
sudo chroot $(CHROOT_DIR) su -c 'cd $(DIST_SRC); env $(CHROOT_ENV) rpmbuild $(RPM_BUILD_DEFINES) -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
@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