forked from QubesOS/qubes-installer-qubes-os
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
161 lines (131 loc) · 5.24 KB
/
Makefile
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
149
150
151
152
153
154
155
156
157
158
159
160
161
#
# The Qubes OS Project, http://www.qubes-os.org
#
# Copyright (C) 2011 Tomasz Sterna <[email protected]>
# Copyright (C) 2019 Frédéric Pierret <[email protected]>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
#
DIST ?= fc32
DIST_VER = $(subst fc,,$(DIST))
INSTALLER_DIR ?= $(PWD)
ISO_INSTALLER ?= 1
INSTALLER_KICKSTART ?= $(INSTALLER_DIR)/conf/qubes-kickstart.cfg
ISO_LIVEUSB ?= 0
LIVE_KICKSTART ?= $(INSTALLER_DIR)/conf/liveusb.ks
CREATEREPO := $(shell which createrepo_c createrepo 2>/dev/null |head -1)
ifdef QUBES_RELEASE
ISO_VERSION := $(QUBES_RELEASE)
LORAX_OPTS += --isfinal
else
ISO_VERSION ?= $(shell date +%Y%m%d)
endif
ISO_NAME := Qubes-$(ISO_VERSION)-x86_64
ISO_VOLID := $(shell echo $(ISO_NAME) | tr a-z A-Z | tr -s -c [:alnum:]'\n' - | head -c 30)
BASE_DIR := $(INSTALLER_DIR)/work/$(ISO_VERSION)/x86_64
DNF := /usr/bin/dnf
DNF_ROOT := /tmp/dnfroot
DNF_REPO := $(DNF_ROOT)/etc/yum.repos.d/installer.repo
DNF_PACKAGES := $(DNF_ROOT)/tmp/packages.list
DNF_OPTS := -y --releasever=$(DIST_VER) --installroot=$(DNF_ROOT)
DNF_OPTS += --downloaddir=$(BASE_DIR)/os/Packages --downloadonly install
LORAX := /usr/sbin/lorax
LORAX_OPTS := --product "Qubes OS" --variant "qubes" --macboot --force --rootfs-size=4
LORAX_OPTS += --version "$(ISO_VERSION)" --release "Qubes OS $(ISO_VERSION)" --volid $(ISO_VOLID)
LORAX_OPTS += --workdir $(INSTALLER_DIR)/work/work/x86_64 --logfile $(INSTALLER_DIR)/work/logs/lorax-x86_64.log
LORAX_OPTS += --repo $(DNF_REPO) --skip-branding
MKISOFS := /usr/bin/xorriso -as mkisofs
# common mkisofs flags
MKISOFS_OPTS := -v -U -J --joliet-long -R -T -m repoview -m boot.iso
# x86 boot args
MKISOFS_OPTS += -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table
# efi boot args
MKISOFS_OPTS += -eltorito-alt-boot -e images/efiboot.img -no-emul-boot
help:
@echo "make iso <== \o/";\
echo; \
echo "make clean";\
echo; \
exit 0;
.PHONY: clean clean-repos iso iso-prepare iso-installer iso-liveusb
ifeq ($(ISO_INSTALLER),1)
iso: iso-installer
endif
ifeq ($(ISO_LIVEUSB),1)
iso: iso-liveusb
endif
iso-prepare:
rm -rf work && mkdir work
rm -rf $(DNF_ROOT)
# Update installer repo
$(CREATEREPO) -q -g ../../conf/comps-dom0.xml --update yum/qubes-dom0
# Destination directory for RPM
mkdir -p $(BASE_DIR)/os/Packages
# Copy Fedora key to DNF installroot
mkdir -p $(DNF_ROOT)/etc/pki/rpm-gpg
cp $(INSTALLER_DIR)/qubes-release/RPM-GPG-KEY-fedora-$(DIST_VER)-primary $(DNF_ROOT)/etc/pki/rpm-gpg
# Provide qubes-release/conf for Qubes keys
mkdir -p $(DNF_ROOT)/tmp/qubes-installer
ln -nsf $(INSTALLER_DIR) $(DNF_ROOT)/tmp/qubes-installer
# Legacy conf using this folder
ln -nsf $(INSTALLER_DIR) /tmp/qubes-installer
# Extract repos conf and packages from kickstart
mkdir -p $(DNF_ROOT)/etc/yum.repos.d
$(INSTALLER_DIR)/scripts/ksparser --ks $(INSTALLER_KICKSTART) --extract-repo-conf-to $(DNF_REPO) --extract-packages-to $(DNF_PACKAGES)
iso-installer-gather:
umask 022; $(DNF) $(DNF_OPTS) $(shell cat $(DNF_PACKAGES))
pushd $(BASE_DIR)/os/ && $(CREATEREPO) -q -g $(INSTALLER_DIR)/conf/comps-dom0.xml .
iso-installer-lorax:
$(LORAX) $(LORAX_OPTS) $(BASE_DIR)/os
iso-installer-mkisofs:
mkdir -p $(BASE_DIR)/iso/
chmod og+rX -R $(BASE_DIR)/os/
$(MKISOFS) $(MKISOFS_OPTS) -V $(ISO_VOLID) -o $(BASE_DIR)/iso/$(ISO_NAME).iso $(BASE_DIR)/os/
/usr/bin/isohybrid -u $(BASE_DIR)/iso/$(ISO_NAME).iso
/usr/bin/implantisomd5 $(BASE_DIR)/iso/$(ISO_NAME).iso
iso-installer: iso-prepare iso-installer-gather iso-installer-lorax iso-installer-mkisofs
# Move result files to known-named directories
mkdir -p build/ISO/qubes-x86_64/iso
mv $(BASE_DIR)/iso/$(ISO_NAME).iso build/ISO/qubes-x86_64/iso/
echo $(ISO_VERSION) > build/ISO/qubes-x86_64/iso/build_latest
rm -rf build/work
mv work build/work
chown --reference=Makefile -R build yum
rm -rf work
iso-liveusb: $(LIVE_KICKSTART) iso-prepare
pushd work && $(INSTALLER_DIR)/scripts/livecd-creator-qubes --debug --product='Qubes OS' --title="Qubes OS $(ISO_VERSION)" --fslabel="Qubes-$(ISO_VERSION)-x86_64-LIVE" --config $(LIVE_KICKSTART) && popd
# Move result files to known-named directories
mkdir -p build/ISO/qubes-x86_64/iso build/work
mv work/*.iso build/ISO/qubes-x86_64/iso/
chown --reference=Makefile -R build yum
rm -rf work
clean-repos:
@echo "--> Removing old rpms from the installer repos..."
@(cd yum && ./clean_repos.sh)
clean:
sudo rm -rf $(DNF_ROOT)
sudo rm -fr build/*
get-sources:
git submodule update --init --recursive
ifeq ($(ISO_LIVEUSB),1)
get-sources:
$(MAKE) -C livecd-tools get-sources
verify-sources:
$(MAKE) -C livecd-tools verify-sources
else
verify-sources:
@true
endif