Makefile 32.2 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#This file is part of lipck - the "linux install party customization kit".
#
# Copyright (C) 2014 trilader, Anwarias, Christopher Spinrath
#
# lipck 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 3 of the License, or
# (at your option) any later version.
#
# lipck 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 lipck.  If not, see <http://www.gnu.org/licenses/>.

$(info lipck Copyright (C) 2014 trilader, Anwarias, Christopher Spinrath)
$(info This program comes with ABSOLUTELY NO WARRANTY;)
$(info This is free software, and you are welcome to redistribute it)
$(info under certain conditions; cf. the COPYING file for details.)
$(info )

24
25
26
27
28
29
CONFIG_FILE_DEFAULTS=$(CURDIR)/config/Makefile.conf.defaults
CONFIG_FILE=$(CURDIR)/config/Makefile.conf

include $(CONFIG_FILE_DEFAULTS)
include $(CONFIG_FILE)

30
31
#read all offically config options from CONFIG_FILE_DEFAULTS
CONFIGURABLE=$(shell cat "$(CONFIG_FILE_DEFAULTS)" | grep -v "^\#" | cut -s -d"=" -f1)
32

33
34
35
36
37
38
ifndef ARCH
  ARCH=$(PRIMARY_ARCH)
endif

#some tools and targets need alternative architecture names,
#so lets infer them
39
40
41
define altarch =
$(if $(subst x86_64,,$1),$(if $(subst i686,,$1),$1,i386),amd64)
endef
42

43
44
45
46
47
48
49
50
#inverse function of altarch; required by targets containing
#the altarch string to depend on architecture specific stuff
#Since all unknown names are mapped to itself this function
#may be used to convert any name to the normal architecture name.
define to_arch =
$(if $(subst amd64,,$1),$(if $(subst i386,,$1),$1,i686),x86_64)
endef

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
#Some targets require the image partition to be mounted.
#Although, it is easy to detect this (and mount the partition)
#by depending on the phony target image_mount_if, make is unable
#to calculate the dependencies correctly. The reason is that some
#dependencies are located on the partition (which is not mounted
#when scanning for dependencies). Hence, make will rebuild all
#targets (after it mounted the partition) regardless of the state
#of these files.
#
#To solve this issue we call ensure_mount on phony targets invoked
#by the user. The actual target will serve as a wrapper which
#mounts the partition and then invokes the actual target renamed
#to <name>__ignore_mount. Note that both targets will be marked
#as phony, since the renaming makes no sense for files (and most
#probably this is a file on the partition anyway...) and the user
#will invoke a phony target anyway.
#
#tl;dr every target that requires the image partition to be mounted
#should be encapsulated in $(call ensure_mount,<target_name>).
#
#Finally, do not change _any_ whitespaces in the defintion of
#ensure_mount without knowing exactly what you are doing. This is
#dark magic!
define ensure_mount =
$(eval
.PHONY : $(strip $1) $(strip $1)__ignore_mount
$(strip $1): image_mount_if
	$(MAKE) $(strip $1)__ignore_mount
)$(strip $1)__ignore_mount
endef

82
83
84
85
86
87
88
89
90
91
92
#On the other hand, targets operating on the actual image file
#require that the partition is unmounted. So here we go with an
#"inverse" of ensure_mount:
define ensure_unmount =
$(eval
.PHONY : $(strip $1) $(strip $1)__ignore_mount
$(strip $1): image_umount_if
	$(MAKE) $(strip $1)__ignore_mount
)$(strip $1)__ignore_mount
endef

93
RSYNC=rsync -a --inplace --no-whole-file
94
XZ_LZMA_FLAGS=-T 0
95

96
define archdir =
97
$(WORKSPACE)/$(call to_arch,$1)
98
99
endef

100
101
IMAGE_DIR=$(WORKSPACE)/image_files

102
103
104
105
106
107
108
109
ARCH_DIR=$(call archdir,$(ARCH))
PRIMARY_ARCH_DIR=$(call archdir,$(PRIMARY_ARCH))
SECONDARY_ARCH_DIR=$(call archdir,$(SECONDARY_ARCH))
COMMON_DIR=$(WORKSPACE)/common

define gentargets =
$(PRIMARY_ARCH_DIR)$1 $(SECONDARY_ARCH_DIR)$1 : $(call archdir,%)$1
endef
110
111

ISO_IMAGE_DEST=/iso
112
ISO_IMAGE=$(ISO_IMAGE_DEST)/image.iso
113
114
115
116
117
ifneq (,$(findstring url-no-release,$(ISO_PATTERN_FLAGS)))
  ISO_URL=$(ISO_BASE_URL)/$(ISO_CHANNEL)
else
  ISO_URL=$(ISO_BASE_URL)/$(ISO_RELEASE)/$(ISO_CHANNEL)
endif
118
119
ISO_CONTENT=$(ISO_IMAGE_DEST)/content

120
IMAGE_PART_FILE=$(WORKSPACE)/image.img.part
121
GRUB_ASSEMBLE_DIR=$(WORKSPACE)/grub
122
123
124
125
126
#GRUB_INSTALL_DIR is passed to grub mbr, so it has to be relative!
#Moreover, it has to be kept in sync with /contrib/image/grub_early.cfg
#and should not conflict with the secure boot grub shipped with the iso
#(usually /boot/grub)
GRUB_INSTALL_DIR=/grub
127

128
129
130
ifneq (,$(findstring release-prefix,$(ISO_PATTERN_FLAGS)))
  ISO_PREFIX=$(ISO_RELEASE)-
else
131
132
133
  ISO_PREFIX=$(ISO_FLAVOR)-$(ISO_VERSION)-
endif

134
define getisoname =
135
$(ISO_PREFIX)desktop-$(call altarch,$1).iso
136
137
endef

Christopher Spinrath's avatar
Christopher Spinrath committed
138
139
GPARTED_BASE_URL=http://sourceforge.net/projects/gparted/files/gparted-live-stable/$(GPARTED_VERSION)/

140
141
#applies all patches in $1 to target directory $2
define patch_all =
142
$(foreach p,$(wildcard $1/*),echo "Applying \"$1\" to \"$2\":" && \
143
	cat "$p" | patch -d"$2" -p1 && echo "done." && ) true
144
145
endef

146
147
148
CASPER_SOURCE_DIR=$(ISO_CONTENT)/casper
INITRD_SOURCE=$(CASPER_SOURCE_DIR)/initrd.lz
SQUASHFS_SOURCE=$(CASPER_SOURCE_DIR)/filesystem.squashfs
149
APT_CACHE_DIR=$(WORKSPACE)/apt_cache
150

151
152
ROOTFS=/rootfs
INITRD=/initrd
153
INITRD_TARGET=/initrd.xz
154
155
156
157
STATE_DIR=/state
LXC_DIR=/lxc_container
CHECKSUMS=/rootfs.md5sums

158
159
REPO_ARCHIVE_DIR=$(IMAGE_DIR)/archives
REPO_DIST_DIR=$(REPO_ARCHIVE_DIR)/dists/$(ISO_RELEASE)/lip
160

christian's avatar
christian committed
161
162
163
default: help
	@exit 0

164
workspace: | $(WORKSPACE)
165

166
$(WORKSPACE) :
167
	mkdir -p "$(WORKSPACE)"
168

169
$(call gentargets,) : | $(WORKSPACE)
170
171
	mkdir -p "$(WORKSPACE)/$*"

172
$(call gentargets,$(STATE_DIR)) : | $(WORKSPACE)/%
173
174
175
176
177
	mkdir -p "$(WORKSPACE)/$*$(STATE_DIR)"

iso_download : $(ARCH_DIR)$(ISO_IMAGE)
$(call gentargets,$(ISO_IMAGE)) : | $(call archdir,%)
	mkdir -p "$(call archdir,$*)$(ISO_IMAGE_DEST)"
178
	wget -O "$(call archdir,$*)$(ISO_IMAGE_DEST)/$(call getisoname,$*)" -c "$(ISO_URL)/$(call getisoname,$*)"
179
	wget -O "$(call archdir,$*)$(ISO_IMAGE_DEST)/SHA256SUMS.temp" -c "$(ISO_URL)/SHA256SUMS"
180
	grep "$(call getisoname,$*)" "$(call archdir,$*)$(ISO_IMAGE_DEST)/SHA256SUMS.temp" > "$(call archdir,$*)$(ISO_IMAGE_DEST)/SHA256SUMS"
181
182
	$(RM) "$(call archdir,$*)$(ISO_IMAGE_DEST)/SHA256SUMS.temp"
	cd "$(call archdir,$*)$(ISO_IMAGE_DEST)" && sha256sum -c SHA256SUMS
183
	mv "$(call archdir,$*)$(ISO_IMAGE_DEST)/$(call getisoname,$*)" "$(call archdir,$*)$(ISO_IMAGE)"
184
185

iso_content : $(ARCH_DIR)$(STATE_DIR)/iso_extracted
186
$(call gentargets,$(STATE_DIR)/iso_extracted) : $(call archdir,%)$(ISO_IMAGE) | $(call archdir,%)$(STATE_DIR)
187
188
189
	mkdir -p "$(call archdir,$*)$(ISO_CONTENT)"
	7z x -o"$(call archdir,$*)$(ISO_CONTENT)" -aos "$(call archdir,$*)$(ISO_IMAGE)"
	touch "$(call archdir,$*)$(STATE_DIR)/iso_extracted"
190
191
192
193
194
195

iso_clean:
	$(RM) "$(ARCH_DIR)$(ISO_IMAGE)"
	$(RM) -r "$(ARCH_DIR)$(ISO_IMAGE_DEST)"
	$(RM) "$(ARCH_DIR)$(STATE_DIR)/iso_extracted"

196
197
198
199
iso_clean_both:
	$(MAKE) ARCH=$(PRIMARY_ARCH) iso_clean
	$(MAKE) ARCH=$(SECONDARY_ARCH) iso_clean

200
apt_cache $(APT_CACHE_DIR): |$(WORKSPACE)
201
	mkdir -p "$(APT_CACHE_DIR)"
202

Christopher Spinrath's avatar
Christopher Spinrath committed
203
204
205
apt_cache_clean:
	$(RM) -r "$(APT_CACHE_DIR)"

206
207
208
209
210
211
212
rootfs_unsquash : $(ARCH_DIR)$(STATE_DIR)/rootfs_extracted
$(call gentargets,$(STATE_DIR)/rootfs_extracted) : $(call archdir,%)$(STATE_DIR)/iso_extracted
	$(RM) -r "$(call archdir,$*)$(ROOTFS)"
	unsquashfs -f -d "$(call archdir,$*)$(ROOTFS)" "$(call archdir,$*)$(SQUASHFS_SOURCE)"
	touch "$(call archdir,$*)$(STATE_DIR)/rootfs_extracted"

rootfs_prepare : $(ARCH_DIR)$(STATE_DIR)/rootfs_prepared
213
$(call gentargets,$(STATE_DIR)/rootfs_prepared) : $(call archdir,%)$(STATE_DIR)/rootfs_extracted
214
	test -e /etc/resolv.conf
215
216
	test ! -e "$(call archdir,$*)$(ROOTFS)/usr/sbin/init.lxc"
	test ! -e "$(call archdir,$*)$(ROOTFS)/remaster/"
217
218
	if [ -e "$(call archdir,$*)$(ROOTFS)/etc/resolv.conf" ]; \
	then \
219
		cp -a --remove-destination "$(call archdir,$*)$(ROOTFS)/etc/resolv.conf" "$(call archdir,$*)$(ROOTFS)/etc/resolv.conf.bak"; \
220
	fi
221
222
223
	echo "#!/bin/bash" > "$(call archdir,$*)$(ROOTFS)/usr/sbin/init.lxc"
	echo "shift; exec \$$@" >> "$(call archdir,$*)$(ROOTFS)/usr/sbin/init.lxc"
	chmod +x "$(call archdir,$*)$(ROOTFS)/usr/sbin/init.lxc"
224
	cp -a --remove-destination /etc/resolv.conf "$(call archdir,$*)$(ROOTFS)/etc/resolv.conf"
225
226
	mkdir -p "$(call archdir,$*)$(ROOTFS)/remaster"
	cp -Lr "$(CURDIR)"/config/copy_to_rootfs_remaster_dir/* "$(call archdir,$*)$(ROOTFS)/remaster"
227
228
229
230
231
	echo "#!/bin/bash" > "$(call archdir,$*)$(ROOTFS)/remaster/remaster.proxy.sh"
	echo "export PATH; export TERM=$(TERM); export LIPCK_HAS_APT_CACHE=1" >> "$(call archdir,$*)$(ROOTFS)/remaster/remaster.proxy.sh"
	echo "test -n \"\$$1\" || exit 41" >> "$(call archdir,$*)$(ROOTFS)/remaster/remaster.proxy.sh"
	echo "exec \$$@" >> "$(call archdir,$*)$(ROOTFS)/remaster/remaster.proxy.sh"
	chmod +x "$(call archdir,$*)$(ROOTFS)/remaster/remaster.proxy.sh"
232
233
234
	touch "$(call archdir,$*)$(STATE_DIR)/rootfs_prepared"

rootfs_remaster : $(ARCH_DIR)$(STATE_DIR)/rootfs_remastered
235
236
$(call gentargets,$(STATE_DIR)/rootfs_remastered) : $(call archdir,%)$(STATE_DIR)/rootfs_extracted | $(APT_CACHE_DIR)
	$(MAKE) ARCH=$* rootfs_prepare
237
ifneq ($(strip $(APT_SOURCE_URL_OVERRIDE)),)
238
239
240
	#override apt sources list
	echo "deb $(APT_SOURCE_URL_OVERRIDE) $(ISO_RELEASE) main restricted universe multiverse" \
		> "$(call archdir,$*)$(ROOTFS)/etc/apt/sources.list"
241
242
243
244
	echo "deb $(APT_SOURCE_URL_OVERRIDE) $(ISO_RELEASE)-security main restricted universe multiverse" \
		>> "$(call archdir,$*)$(ROOTFS)/etc/apt/sources.list"
	echo "deb $(APT_SOURCE_URL_OVERRIDE) $(ISO_RELEASE)-updates main restricted universe multiverse" \
		>> "$(call archdir,$*)$(ROOTFS)/etc/apt/sources.list"
245
endif
246
247
	#set timezone
	echo -n "Europe/Berlin" > "$(call archdir,$*)$(ROOTFS)/etc/timezone"
248
249
	#install skel files (in particular kde defaults)
	cp -R "$(CURDIR)/contrib/rootfs/skel" "$(call archdir,$*)$(ROOTFS)/etc/"
250
251
252
253
254
	#install modprobe.d files
	cp "$(CURDIR)/contrib/rootfs/modprobe.d/"* "$(call archdir,$*)$(ROOTFS)/etc/modprobe.d/"
	#install sysctl.d files
	cp "$(CURDIR)/contrib/rootfs/sysctl.d/"* "$(call archdir,$*)$(ROOTFS)/etc/sysctl.d/"

255
	mkdir -p "$(call archdir,$*)$(LXC_DIR)"
256
	lxc-execute --name "lipck_remaster_$*" -P "$(call archdir,$*)$(LXC_DIR)" -f "$(CURDIR)/config/lxc_common.conf" \
257
258
	-s lxc.arch="$*" -s lxc.rootfs="$(call archdir,$*)$(ROOTFS)" \
	-s lxc.mount.entry="$(APT_CACHE_DIR) $(call archdir,$*)$(ROOTFS)/var/cache/apt/ none defaults,bind 0 0" \
259
260
	-s lxc.mount.entry="none $(call archdir,$*)$(ROOTFS)/tmp tmpfs defaults 0 0" \
	-s lxc.mount.entry="none $(call archdir,$*)$(ROOTFS)/run tmpfs defaults 0 0" \
261
	-- /bin/bash -l /remaster/remaster.proxy.sh /remaster/scripts/rootfs_remaster.sh
262
	$(MAKE) ARCH=$* rootfs_finalize
263
264
265

	#apply patches
	$(call patch_all,$(CURDIR)/patches/rootfs,$(call archdir,$*)$(ROOTFS))
266
	touch "$(call archdir,$*)$(STATE_DIR)/rootfs_remastered"
267

268
269
270
271
272
273
274
275
rootfs_console : $(call archdir,$(ARCH))$(STATE_DIR)/rootfs_extracted | $(APT_CACHE_DIR)
	$(MAKE) ARCH=$(ARCH) rootfs_prepare
	mkdir -p "$(call archdir,$(ARCH))$(LXC_DIR)"
	@echo
	@echo "==> LIPCK: Entering container... (exit with CTRL+D but _NOT_ with  CTRL+C!)"
	lxc-execute --name "lipck_remaster_$(ARCH)" -P "$(call archdir,$(ARCH))$(LXC_DIR)" -f "$(CURDIR)/config/lxc_common.conf" \
        -s lxc.arch="$(ARCH)" -s lxc.rootfs="$(call archdir,$(ARCH))$(ROOTFS)" \
        -s lxc.mount.entry="$(APT_CACHE_DIR) $(call archdir,$(ARCH))$(ROOTFS)/var/cache/apt/ none defaults,bind 0 0" \
276
277
        -s lxc.mount.entry="none $(call archdir,$(ARCH))$(ROOTFS)/tmp tmpfs defaults 0 0" \
        -s lxc.mount.entry="none $(call archdir,$(ARCH))$(ROOTFS)/run tmpfs defaults 0 0" \
278
        -- /bin/bash -l /remaster/remaster.proxy.sh /bin/bash -l || exit 0
279
280
281
	@echo
	@echo "==> LIPCK: Leaving container and cleaning up..."
	@echo
282
	$(MAKE) ARCH=$(ARCH) rootfs_finalize
283

284
rootfs_finalize : $(ARCH_DIR)$(STATE_DIR)/rootfs_finalized
285
$(call gentargets,$(STATE_DIR)/rootfs_finalized) : $(call archdir,%)$(STATE_DIR)/rootfs_prepared
286
287
288
289
	$(RM) "$(call archdir,$*)$(ROOTFS)/usr/sbin/init.lxc"
	$(RM) "$(call archdir,$*)$(ROOTFS)/etc/resolv.conf"
	if [ -e "$(call archdir,$*)$(ROOTFS)/etc/resolv.conf.bak" ]; then mv "$(call archdir,$*)$(ROOTFS)/etc/resolv.conf.bak" "$(call archdir,$*)$(ROOTFS)/etc/resolv.conf"; fi
	$(RM) -r "$(call archdir,$*)$(ROOTFS)/remaster"
290
291
	#clean up crash reports
	$(RM) -rf "$(call archdir,$*)$(ROOTFS)/var/crash/"*
292
	$(RM) "$(call archdir,$*)$(STATE_DIR)/rootfs_prepared"
293
	touch "$(call archdir,$*)$(STATE_DIR)/rootfs_finalized"
294
295
296
297

rootfs_clean:
	$(RM) -r "$(ARCH_DIR)$(ROOTFS)"
	$(RM) "$(ARCH_DIR)$(STATE_DIR)/rootfs_extracted"
298
	$(RM) "$(ARCH_DIR)$(STATE_DIR)/rootfs_prepared"
299
300
	$(RM) "$(ARCH_DIR)$(STATE_DIR)/rootfs_remastered"
	$(RM) "$(ARCH_DIR)$(STATE_DIR)/rootfs_finalized"
301
	$(RM) "$(ARCH_DIR)/filesystem.size"
302
	$(RM) "$(ARCH_DIR)/$(CHECKSUMS)"
303
	$(RM) -r $(ARCH_DIR)$(LXC_DIR)
304

305
306
307
308
rootfs_clean_both:
	$(MAKE) ARCH=$(PRIMARY_ARCH) rootfs_clean
	$(MAKE) ARCH=$(SECONDARY_ARCH) rootfs_clean

309
rootfs_checksums : $(ARCH_DIR)$(CHECKSUMS)
310
$(call gentargets,$(CHECKSUMS)) : $(call archdir,%)$(STATE_DIR)/rootfs_remastered
311
	cd "$(call archdir,$*)$(ROOTFS)" && find . -type f -print0 | sort -z | xargs -0 md5sum > "$(call archdir,$*)$(CHECKSUMS)"
312

313
rootfs_fssize: $(ARCH_DIR)/filesystem.size
314
$(call gentargets,/filesystem.size) : $(call archdir,%)$(STATE_DIR)/rootfs_remastered
315
316
	IN_BYTES=$$(du -sx --block-size=1 "$(call archdir,$*)$(ROOTFS)"|cut -f1) && \
	echo $$IN_BYTES > $(call archdir,$*)/filesystem.size
317

318
319
320
321
322
323
rootfs_deduplicate $(COMMON_DIR)$(STATE_DIR)/rootfs_deduplicated: $(PRIMARY_ARCH_DIR)$(CHECKSUMS) $(SECONDARY_ARCH_DIR)$(CHECKSUMS)
	mkdir -p "$(COMMON_DIR)$(STATE_DIR)"
	mkdir -p "$(COMMON_DIR)/lip-$(PRIMARY_ARCH)" "$(COMMON_DIR)/lip-$(SECONDARY_ARCH)" "$(COMMON_DIR)/lip-common"
	diff --old-line-format="" --new-line-format="" --unchanged-line-format="%L" \
	"$(PRIMARY_ARCH_DIR)$(CHECKSUMS)" "$(SECONDARY_ARCH_DIR)$(CHECKSUMS)" > "$(COMMON_DIR)$(CHECKSUMS)" || true
	cut -d" " -f3- "$(COMMON_DIR)$(CHECKSUMS)" > "$(COMMON_DIR)/common_files.list"
324
	@echo "Copying common files..."
325
	$(RSYNC) --files-from="$(COMMON_DIR)/common_files.list" "$(PRIMARY_ARCH_DIR)$(ROOTFS)/" "$(COMMON_DIR)/lip-common"
326
	@echo "Copying $(PRIMARY_ARCH) files..."
327
	$(RSYNC) "$(PRIMARY_ARCH_DIR)$(ROOTFS)/" "$(COMMON_DIR)/lip-$(PRIMARY_ARCH)"
328
	cd "$(COMMON_DIR)/lip-$(PRIMARY_ARCH)" && tr \\n \\0 < "$(COMMON_DIR)/common_files.list" | xargs -0 rm 
329
	@echo "Copying $(SECONDARY_ARCH) files..."
330
	$(RSYNC) "$(SECONDARY_ARCH_DIR)$(ROOTFS)/" "$(COMMON_DIR)/lip-$(SECONDARY_ARCH)"
331
	cd "$(COMMON_DIR)/lip-$(SECONDARY_ARCH)" && tr \\n \\0 < "$(COMMON_DIR)/common_files.list" | xargs -0 rm 
332
333
	touch "$(COMMON_DIR)$(STATE_DIR)/rootfs_deduplicated"

334
$(COMMON_DIR)/lip-%.squashfs : $(COMMON_DIR)$(STATE_DIR)/rootfs_deduplicated
Daniel Schulte's avatar
Daniel Schulte committed
335
	mksquashfs "$(COMMON_DIR)/lip-$*" "$(COMMON_DIR)/lip-$*.squashfs" -comp xz -noappend
336

337
rootfs_squash: $(COMMON_DIR)/lip-$(PRIMARY_ARCH).squashfs $(COMMON_DIR)/lip-$(SECONDARY_ARCH).squashfs $(COMMON_DIR)/lip-common.squashfs
338

339
340
341
rootfs_common_clean:
	$(RM) -r "$(COMMON_DIR)"

342
343
344
initrd_unpack : $(ARCH_DIR)$(STATE_DIR)/initrd_extracted
$(call gentargets,$(STATE_DIR)/initrd_extracted) : $(call archdir,%)$(STATE_DIR)/iso_extracted
	mkdir -p "$(call archdir,$*)$(INITRD)"
345
	cd "$(call archdir,$*)$(INITRD)" && lzma $(XZ_LZMA_FLAGS) -d < "$(call archdir,$*)$(INITRD_SOURCE)" | cpio -i
346
	touch "$(call archdir,$*)$(STATE_DIR)/initrd_extracted"
347
348
349
350
351
352
353

initrd_clean:
	$(RM) -r "$(ARCH_DIR)$(INITRD)"
	$(RM) "$(ARCH_DIR)$(INITRD_TARGET)"
	$(RM) "$(ARCH_DIR)$(STATE_DIR)/initrd_extracted"
	$(RM) "$(ARCH_DIR)$(STATE_DIR)/initrd_remastered"

354
355
356
357
initrd_clean_both:
	$(MAKE) ARCH=$(PRIMARY_ARCH) initrd_clean
	$(MAKE) ARCH=$(SECONDARY_ARCH) initrd_clean

358
initrd_remaster : $(ARCH_DIR)$(STATE_DIR)/initrd_remastered
359
$(call gentargets,$(STATE_DIR)/initrd_remastered) : $(call archdir,%)$(STATE_DIR)/initrd_extracted $(call archdir,%)$(STATE_DIR)/rootfs_remastered
360
361
362
	mkdir -p "$(call archdir,$*)$(INITRD)/lip"

	#nmtelekinese
363
364
365
366
367
	mkdir -p "$(call archdir,$*)$(INITRD)/lip/nm"
	cp "$(CURDIR)/contrib/initrd/nmtelekinese/nmtelekinese.desktop" "$(call archdir,$*)$(INITRD)/lip/nm"
	cp "$(CURDIR)/contrib/initrd/nmtelekinese/nmtelekinese.py" "$(call archdir,$*)$(INITRD)/lip/nm"
	cp "$(CURDIR)/contrib/initrd/nmtelekinese/26mopsmops" "$(call archdir,$*)$(INITRD)/scripts/casper-bottom/"
	chmod +x "$(call archdir,$*)$(INITRD)/scripts/casper-bottom/26mopsmops"
368
369
370
371

	#liphook
	cp "$(CURDIR)/contrib/initrd/initrd_hook/24liphook" "$(call archdir,$*)$(INITRD)/scripts/casper-bottom/"
	chmod +x "$(call archdir,$*)$(INITRD)/scripts/casper-bottom/24liphook"
372
373
374
375
376
377

	$(RM) "$(call archdir,$*)$(INITRD)/scripts/casper-bottom/ORDER"
	find "$(call archdir,$*)$(INITRD)/scripts/casper-bottom/" -type f \
		| xargs basename -a | grep -E "^[0-9]{2}" | sort | xargs -I{} \
		echo -e "/scripts/casper-bottom/{}\n[ -e /conf/param.conf ] && . /conf/param.conf" \
		>> "$(call archdir,$*)$(INITRD)/scripts/casper-bottom/ORDER"
378
379

	#install new kernel modules
380
	$(RM) -R "$(call archdir,$*)$(INITRD)/lib/modules/"*
381
382
	cp -a "$(call archdir,$*)$(ROOTFS)/lib/modules/$(shell basename $$(readlink -f "$(call archdir,$*)$(ROOTFS)/vmlinuz") | cut -d'-' -f2-)" \
		 "$(call archdir,$*)$(INITRD)/lib/modules"
383
384

	$(call patch_all,$(CURDIR)/patches/initrd,$(call archdir,$*)$(INITRD))
385
	touch "$(call archdir,$*)$(STATE_DIR)/initrd_remastered"
386

387
388
initrd_pack : $(ARCH_DIR)$(INITRD_TARGET)
$(call gentargets,$(INITRD_TARGET)) : $(call archdir,%)$(STATE_DIR)/initrd_remastered
389
390
	cd "$(call archdir,$*)$(INITRD)" && find | cpio -H newc -o | xz $(XZ_LZMA_FLAGS) --check=crc32 -z \
		> "$(call archdir,$*)$(INITRD_TARGET)"
391

392
$(call ensure_unmount,clean_really_all): iso_clean_both rootfs_clean_both rootfs_common_clean initrd_clean_both image_clean
393

394
$(call ensure_mount,image_git) $(IMAGE_DIR)/.git: |$(WORKSPACE)
395
	test ! -e "$(IMAGE_DIR)/.git"
396
397
398
399
400
	mkdir -p "$(IMAGE_DIR)"
	cd "$(IMAGE_DIR)" && git init
	cd "$(IMAGE_DIR)" && git remote add origin "$(IMAGE_GIT_URL)"
	cd "$(IMAGE_DIR)" && git fetch
	cd "$(IMAGE_DIR)" && git checkout -t "origin/$(IMAGE_GIT_BRANCH)"
401

402
$(call ensure_mount,image_git_pull): |$(IMAGE_DIR)/.git
403
	cd "$(IMAGE_DIR)" && $(SHELL) ./scripts/update_stick.sh "$(IMAGE_GIT_BRANCH)"
404
405
406

IMAGE_BINARIES= $(COMMON_DIR)/lip-$(PRIMARY_ARCH).squashfs $(COMMON_DIR)/lip-$(SECONDARY_ARCH).squashfs $(COMMON_DIR)/lip-common.squashfs \
$(PRIMARY_ARCH_DIR)$(INITRD_TARGET) $(SECONDARY_ARCH_DIR)$(INITRD_TARGET) \
407
$(PRIMARY_ARCH_DIR)$(STATE_DIR)/iso_extracted $(SECONDARY_ARCH_DIR)$(STATE_DIR)/iso_extracted \
Christopher Spinrath's avatar
Christopher Spinrath committed
408
409
$(PRIMARY_ARCH_DIR)/filesystem.size \
$(PRIMARY_ARCH_DIR)/gparted-live.iso $(SECONDARY_ARCH_DIR)/gparted-live.iso
410
$(call ensure_mount,image_binary_files) $(IMAGE_DIR)/.lipbinaries: image_git_pull $(IMAGE_BINARIES)
411
	$(RSYNC) "$(PRIMARY_ARCH_DIR)$(ISO_CONTENT)/dists" \
412
413
414
415
		 "$(PRIMARY_ARCH_DIR)$(ISO_CONTENT)/isolinux" \
		 "$(PRIMARY_ARCH_DIR)$(ISO_CONTENT)/pool" \
		 "$(PRIMARY_ARCH_DIR)$(ISO_CONTENT)/preseed" \
		 "$(PRIMARY_ARCH_DIR)$(ISO_CONTENT)/.disk" \
416
417
		 "$(IMAGE_DIR)/"
	$(RSYNC) "$(SECONDARY_ARCH_DIR)$(ISO_CONTENT)/.disk/casper-uuid-generic" "$(IMAGE_DIR)/.disk/casper-uuid-generic-$(SECONDARY_ARCH)"
418
	$(RSYNC) "$(PRIMARY_ARCH_DIR)$(ISO_CONTENT)/EFI/BOOT/BOOTx64.EFI" "$(IMAGE_DIR)/efi/boot/"
419
	$(RSYNC) "$(PRIMARY_ARCH_DIR)$(ISO_CONTENT)/EFI/BOOT/grubx64.efi" "$(IMAGE_DIR)/efi/boot/"
420
	mkdir -p "$(IMAGE_DIR)/casper"
421
422
423
424
425
426
	$(RSYNC) --progress "$(COMMON_DIR)/lip-common.squashfs" \
		 "$(COMMON_DIR)/lip-$(PRIMARY_ARCH).squashfs" \
		 "$(COMMON_DIR)/lip-$(SECONDARY_ARCH).squashfs" \
		 "$(PRIMARY_ARCH_DIR)$(ISO_CONTENT)/casper/filesystem.manifest" \
		 "$(PRIMARY_ARCH_DIR)$(ISO_CONTENT)/casper/filesystem.manifest-remove" \
		 "$(PRIMARY_ARCH_DIR)/filesystem.size" \
427
		 "$(IMAGE_DIR)/casper/"
428
429
	$(RSYNC) "$(PRIMARY_ARCH_DIR)$(INITRD_TARGET)" "$(IMAGE_DIR)/casper/initrd-$(PRIMARY_ARCH).lz"
	$(RSYNC) "$(SECONDARY_ARCH_DIR)$(INITRD_TARGET)" "$(IMAGE_DIR)/casper/initrd-$(SECONDARY_ARCH).lz"
430
431
	$(RSYNC) --progress "$(PRIMARY_ARCH_DIR)/gparted-live.iso" "$(IMAGE_DIR)/gparted-live-$(PRIMARY_ARCH).iso"
	$(RSYNC) --progress "$(SECONDARY_ARCH_DIR)/gparted-live.iso" "$(IMAGE_DIR)/gparted-live-$(SECONDARY_ARCH).iso"
432
433
	cd "$(PRIMARY_ARCH_DIR)$(ROOTFS)" && $(RSYNC) -L vmlinuz "$(IMAGE_DIR)/casper/vmlinuz-$(PRIMARY_ARCH)"
	cd "$(SECONDARY_ARCH_DIR)$(ROOTFS)" && $(RSYNC) -L vmlinuz "$(IMAGE_DIR)/casper/vmlinuz-$(SECONDARY_ARCH)"
434
	mkdir -p "$(IMAGE_DIR)/boot/grub/" #note: this must not be $$(GRUB_INSTALL_DIR)!
435
436
	$(RSYNC) "$(PRIMARY_ARCH_DIR)$(ISO_CONTENT)/boot/grub/x86_64-efi" \
		 "$(IMAGE_DIR)/boot/grub/"
437
	touch "$(IMAGE_DIR)/.lipbinaries"
438

439
$(call ensure_mount,image_remaster) $(IMAGE_DIR)/.remastered: $(IMAGE_DIR)/.lipbinaries
440
	$(call patch_all,$(CURDIR)/patches/iso/,$(IMAGE_DIR))
441
442
	awk -f $(CURDIR)/scripts/casper-remove-needed-packages-from-unistall-manifest.awk $(IMAGE_DIR)/casper/filesystem.manifest-remove > /tmp/fs.manifest
	mv /tmp/fs.manifest $(IMAGE_DIR)/casper/filesystem.manifest-remove
443
444
	touch "$(IMAGE_DIR)/.remastered"

445
$(call ensure_mount,image_content): image_git_pull $(IMAGE_DIR)/.remastered $(IMAGE_DIR)$(GRUB_INSTALL_DIR)/lipinfo.cfg $(IMAGE_DIR)$(GRUB_INSTALL_DIR)/.lipgrub
446
447
448
	@echo
	@echo "Image content is ready: $(IMAGE_DIR)"

449
$(call ensure_unmount,image_skel_file): $(IMAGE_PART_FILE)
450
451
452
453
454
455
456
$(IMAGE_PART_FILE):
	truncate -s "$(IMAGE_PART_SIZE)" "$@"
	mkfs.vfat -n "$(IMAGE_PART_LABEL)" "$@"

	@echo
	@echo "Image partition skeleton is ready: $@"

457
458
459
460
461
image_grub_memdisk: $(GRUB_ASSEMBLE_DIR)/memdisk.tar
$(GRUB_ASSEMBLE_DIR)/memdisk.tar:
	mkdir -p "$(GRUB_ASSEMBLE_DIR)"
	tar cvf "$@" -C "$(CURDIR)/contrib/image/" "grub_early.cfg"

462
image_grub_mkimage_efi: $(GRUB_ASSEMBLE_DIR)/grub.x86_64-efi
463
$(GRUB_ASSEMBLE_DIR)/grub.x86_64-efi $(GRUB_ASSEMBLE_DIR)/grub.i386-efi : $(GRUB_ASSEMBLE_DIR)/grub.%-efi : $(GRUB_ASSEMBLE_DIR)/memdisk.tar | $(WORKSPACE)
464
	mkdir -p "$(GRUB_ASSEMBLE_DIR)"
465
466
467
468
	echo "normal (memdisk)/grub_early.cfg" \
		> "$(GRUB_ASSEMBLE_DIR)/grub_pre_normal.cfg"
	grub-mkimage  \
		--memdisk "$(GRUB_ASSEMBLE_DIR)/memdisk.tar" \
469
		--output "$@" --format "$*-efi" \
470
471
		--config "$(GRUB_ASSEMBLE_DIR)/grub_pre_normal.cfg" \
		--prefix "/grub" \
472
473
474
475
476
		$(IMAGE_GRUB_EFI_MODULES)

image_grub_mkimage_mbr: $(GRUB_ASSEMBLE_DIR)/grub.i386-pc
$(GRUB_ASSEMBLE_DIR)/grub.i386-pc : | $(WORKSPACE)
	mkdir -p "$(GRUB_ASSEMBLE_DIR)"
477
	grub-mkimage --prefix "(hd0,msdos1)$(GRUB_INSTALL_DIR)" \
478
479
480
                --output "$@" --format "i386-pc" \
                $(IMAGE_GRUB_MBR_MODULES)

481
482
483
484
485
image_grub_mbr_template: $(GRUB_ASSEMBLE_DIR)/mbr.img
$(GRUB_ASSEMBLE_DIR)/mbr.img : $(GRUB_ASSEMBLE_DIR)/grub.i386-pc
	dd if=/usr/lib/grub/i386-pc/boot.img of="$@" bs=446 count=1
	dd if="$(GRUB_ASSEMBLE_DIR)/grub.i386-pc" of="$@" bs=512 seek=1

486
$(call ensure_mount,image_grub_install): $(IMAGE_DIR)$(GRUB_INSTALL_DIR)/.lipgrub
487
$(IMAGE_DIR)$(GRUB_INSTALL_DIR)/.lipgrub: $(GRUB_ASSEMBLE_DIR)/grub.x86_64-efi $(GRUB_ASSEMBLE_DIR)/grub.i386-efi
488
489
490
491
492
493
494
	mkdir -p "$(IMAGE_DIR)$(GRUB_INSTALL_DIR)"
	$(RSYNC) "/usr/lib/grub/x86_64-efi" "$(IMAGE_DIR)$(GRUB_INSTALL_DIR)/"
	$(RSYNC) "/usr/lib/grub/i386-efi" "$(IMAGE_DIR)$(GRUB_INSTALL_DIR)/"
	$(RSYNC) "/usr/lib/grub/i386-pc" "$(IMAGE_DIR)$(GRUB_INSTALL_DIR)/"
	$(RSYNC) "/usr/share/grub/themes" "$(IMAGE_DIR)$(GRUB_INSTALL_DIR)/"
	mkdir -p "$(IMAGE_DIR)$(GRUB_INSTALL_DIR)/fonts"
	$(RSYNC) "/usr/share/grub/unicode.pf2" "$(IMAGE_DIR)$(GRUB_INSTALL_DIR)/fonts/"
495
496
	#copy efi core files; note that the x64 binary is named grubx64-unsigned.efi because grubx64.efi
	#is occupied by the ubuntu secure boot grub.
497
	mkdir -p "$(IMAGE_DIR)/efi/boot"
498
	$(RSYNC) --no-p --no-g --no-o "$(GRUB_ASSEMBLE_DIR)/grub.x86_64-efi" "$(IMAGE_DIR)/efi/boot/grubx64-unsigned.efi"
499
	#our i386 efi bootloader shall be the default:
500
	$(RSYNC) --no-p --no-g --no-o "$(GRUB_ASSEMBLE_DIR)/grub.i386-efi" "$(IMAGE_DIR)/efi/boot/bootia32.efi"
501
	touch "$(IMAGE_DIR)$(GRUB_INSTALL_DIR)/.lipgrub"
502

503
$(call ensure_unmount,image_assemble): $(IMAGE_FILE)
504
505
$(IMAGE_FILE): $(IMAGE_PART_FILE) $(GRUB_ASSEMBLE_DIR)/mbr.img
	cp "$(GRUB_ASSEMBLE_DIR)/mbr.img" "$@"
506
	ddrescue --output-position=2048s --sparse "$(IMAGE_PART_FILE)" "$@"
507
508
	#sfdisk: start, as large as possible, FAT, bootable
	echo -e "label: dos\nunit: sectors\n2048,+,b,*"\
509
		| sfdisk "$@"
510

511
	@echo
512
	@echo "Image is ready: $@"
513

514
515
$(call ensure_unmount,image_deploy): $(IMAGE_FILE) $(IMAGE_FILE).sha1sum
$(call ensure_unmount,image_deploy_vmdk): $(IMAGE_FILE:.img=.vmdk) $(IMAGE_FILE:.img=.vmdk).sha1sum
516

517
$(call ensure_unmount,image_clean):
518
	$(RM) "$(IMAGE_PART_FILE)"
519
	$(RM) -r "$(GRUB_ASSEMBLE_DIR)"
520

521
$(call ensure_mount,image_grub_lipinfo) : $(IMAGE_DIR)$(GRUB_INSTALL_DIR)/lipinfo.cfg
522
523
524
525
526
527
528
529
$(IMAGE_DIR)$(GRUB_INSTALL_DIR)/lipinfo.cfg : | $(WORKSPACE)
	mkdir -p "$(IMAGE_DIR)$(GRUB_INSTALL_DIR)"
	echo "#This file was generated by lipck." > "$@"
	echo "#Feel free to edit it." >> "$@"
	echo "set lip_flavor=\"$$(echo "$(ISO_FLAVOR)" | sed "s/\(.\)\(.*\)/\u\1\2/")\"" >> "$@"
	echo "set lip_version=\"$(ISO_VERSION)\"" >> "$@"
	echo "set lip_release=\"$(ISO_RELEASE)\"" >> "$@"
	echo "set lip_extra_info=\"$(IMAGE_EXTRA_INFO)\"" >> "$@"
530

531
image_mount_if : $(IMAGE_PART_FILE)
532
	mkdir -p "$(IMAGE_DIR)"
533
	[ "$$(findmnt --target "$(IMAGE_DIR)" -f -n --output=target)" = "$(shell readlink -f "$(IMAGE_DIR)")" ] \
534
		|| mount "$(IMAGE_PART_FILE)" "$(IMAGE_DIR)"
535

536
537
image_umount_if :
	#if something is mounted then umount
538
	[ "$$(findmnt --target "$(IMAGE_DIR)" -f -n --output=target)" != "$(shell readlink -f "$(IMAGE_DIR)")" ] \
539
		|| umount -d "$(IMAGE_DIR)"
540

541
$(call ensure_mount,image) : image_content $(GRUB_ASSEMBLE_DIR)/mbr.img
Christopher Spinrath's avatar
Christopher Spinrath committed
542

543
544
545
546
547
548
#The following target is not used by lipck itself. It may be used to create
#an empty (only the bootloader will be installed) manually. In particular,
#it can be used to test the image creation process of lipck (it is not
#necessary to remaster an image to test this crucial base part).
multiboot :
	mkdir -p "$(WORKSPACE)/multiboot.work"
549
550
551
552
	$(MAKE) "IMAGE_DIR=$(WORKSPACE)/multiboot.work" "IMAGE_PART_FILE=$(WORKSPACE)/multiboot.part" \
		IMAGE_PART_LABEL=MultiBoot \
		image_grub_install \
		|| (umount -d "$(WORKSPACE)/multiboot.work" && exit 1)
553
554
	#since this is most likely a standalone image make the lipck grubx64 the
	#default bootloader for 64bit efi systems
555
556
	[ -e "$(WORKSPACE)/multiboot.work/efi/boot/bootx64.efi" ] \
		|| mv "$(WORKSPACE)/multiboot.work/efi/boot/"{grubx64-unsigned.efi,bootx64.efi} \
557
		|| (umount -d "$(WORKSPACE)/multiboot.work" && exit 1)
558
	$(MAKE) "IMAGE_PART_FILE=$(WORKSPACE)/multiboot.part" IMAGE_FILE=MultiBoot.img \
559
		"IMAGE_DIR=$(WORKSPACE)/multiboot.work" \
560
561
		image_assemble

Christopher Spinrath's avatar
Christopher Spinrath committed
562
563
564
565
gparted : $(call archdir,$(PRIMARY_ARCH))/gparted-live.iso $(call archdir,$(SECONDARY_ARCH))/gparted-live.iso
$(call gentargets,/gparted-live.iso) :
	wget -O "$@" "$(GPARTED_BASE_URL)/gparted-live-$(GPARTED_VERSION)-$(subst $(SECONDARY_ARCH),i686-pae,$(subst $(PRIMARY_ARCH),amd64,$*)).iso"

566
$(call ensure_mount,repo_packages) : $(REPO_ARCHIVE_DIR)/Packages.$(call altarch,$(ARCH))
567
568
$(REPO_ARCHIVE_DIR)/Packages.$(call altarch,$(PRIMARY_ARCH)) $(REPO_ARCHIVE_DIR)/Packages.$(call altarch,$(SECONDARY_ARCH)) : $(REPO_ARCHIVE_DIR)/Packages.% : $(call archdir,$*)$(STATE_DIR)/rootfs_remastered | $(IMAGE_DIR)
	$(MAKE) ARCH=$(call to_arch,$*) rootfs_prepare
569
	mkdir -p "$(call archdir,$*)$(ROOTFS)/cdrom"
570
571
572
573
	mkdir -p "$(call archdir,$*)$(LXC_DIR)"
	lxc-execute --name "lipck_remaster_$*" -P "$(call archdir,$*)$(LXC_DIR)" -f "$(CURDIR)/config/lxc_common.conf" \
        -s lxc.arch="$(call to_arch,$*)" -s lxc.rootfs="$(call archdir,$*)$(ROOTFS)" \
        -s lxc.mount.entry="none $(call archdir,$*)$(ROOTFS)/var/cache/apt/ tmpfs defaults 0 0" \
574
575
        -s lxc.mount.entry="none $(call archdir,$(ARCH))$(ROOTFS)/tmp tmpfs defaults 0 0" \
        -s lxc.mount.entry="none $(call archdir,$(ARCH))$(ROOTFS)/run tmpfs defaults 0 0" \
576
577
	-s lxc.mount.entry="$(IMAGE_DIR) $(call archdir,$*)$(ROOTFS)/cdrom none defaults,bind 0 0" \
        -- /bin/bash -l /remaster/remaster.proxy.sh \
578
	/remaster/scripts/repo_packages.sh "$*" "/cdrom"
579
	rmdir "$(call archdir,$*)$(ROOTFS)/cdrom"
580
581
	$(MAKE) ARCH=$(call to_arch,$*) rootfs_finalize

582
$(call ensure_mount,repo_package_info) : $(REPO_DIST_DIR)/binary-$(call altarch,$(ARCH))/Packages.bz2
583
$(REPO_DIST_DIR)/binary-$(call altarch,$(PRIMARY_ARCH))/Packages.bz2 $(REPO_DIST_DIR)/binary-$(call altarch,$(SECONDARY_ARCH))/Packages.bz2 : $(REPO_DIST_DIR)/binary-%/Packages.bz2 : $(REPO_ARCHIVE_DIR)/Packages.%
584
	mkdir -p "$(REPO_ARCHIVE_DIR)"
585
	mkdir -p "$(REPO_DIST_DIR)/binary-$*/"
586
587
588
589
590
591
592
593
594
595
596
597
598
	#info/release file
	echo "Archive: $(ISO_RELEASE)" > "$(REPO_DIST_DIR)/binary-$*/Release"
	echo "Version: $(shell echo $(ISO_VERSION) | cut -f-2 -d'.')" \
		>> "$(REPO_DIST_DIR)/binary-$*/Release"
	echo "Component: main" \
		>> "$(REPO_DIST_DIR)/binary-$*/Release"
	echo "Origin: Ubuntu" \
		>> "$(REPO_DIST_DIR)/binary-$*/Release"
	echo "Label: Ubuntu" \
		>> "$(REPO_DIST_DIR)/binary-$*/Release"
	echo "Architecture: $*" \
		>> "$(REPO_DIST_DIR)/binary-$*/Release"

599
	cd "$(REPO_ARCHIVE_DIR)" \
600
	&& cat Packages.noarch "Packages.$*" > "$(REPO_DIST_DIR)/binary-$*/Packages.bz2"
601

602
603
#The following rules requires none of its dependencies. However, it writes a timestamp to the metadata
#that should always be "newer" than the dependencies.
604
$(call ensure_mount,repo_metadata) : $(REPO_ARCHIVE_DIR)/Release
605
606
$(REPO_ARCHIVE_DIR)/Release : $(REPO_DIST_DIR)/binary-$(call altarch,$(PRIMARY_ARCH))/Packages.bz2 $(REPO_DIST_DIR)/binary-$(call altarch,$(SECONDARY_ARCH))/Packages.bz2
	mkdir -p "$(REPO_ARCHIVE_DIR)"
607
	touch "$(REPO_ARCHIVE_DIR)"/.aptignr
608
609
610
611
612
613
614
615
616
617
618
619

	echo "Origin: Ubuntu" > "$(REPO_ARCHIVE_DIR)"/Release
	echo "Label: LIP Ubuntu Extra Packages" \
		>> "$(REPO_ARCHIVE_DIR)"/Release
	echo "Suite: $(ISO_RELEASE)" \
		>> "$(REPO_ARCHIVE_DIR)"/Release
	echo "Version: $(shell echo $(ISO_VERSION) | cut -f-2 -d'.')" \
		>> "$(REPO_ARCHIVE_DIR)"/Release
	echo "Codename: $(ISO_RELEASE)" \
		>> "$(REPO_ARCHIVE_DIR)"/Release
	echo "Date: $$(LC_ALL=C date -u)" \
		>> "$(REPO_ARCHIVE_DIR)"/Release
620
	echo "Architectures: $(call altarch,$(PRIMARY_ARCH)) $(call altarch,$(SECONDARY_ARCH))" \
621
622
623
624
625
		>> "$(REPO_ARCHIVE_DIR)"/Release
	echo "Components: lip" \
		>> "$(REPO_ARCHIVE_DIR)"/Release
	echo "Description: Ubuntu $(ISO_RELEASE) $(shell echo $(ISO_VERSION) | cut -f-2 -d'.')" \
		>> "$(REPO_ARCHIVE_DIR)"/Release
626

627
628
629
630
$(call ensure_mount,repo_offline_repo_json) : $(IMAGE_DIR)/offline_repo.json
$(IMAGE_DIR)/offline_repo.json: | $(IMAGE_DIR)
	cp "$(CURDIR)/contrib/rootfs/offline_repo.json" "$(IMAGE_DIR)/"

631
632
633
repo_clean:
	$(RM) -r "$(REPO_DIST_DIR)"
	$(RM) -r "$(REPO_ARCHIVE_DIR)"
634
	$(RM) "$(IMAGE_DIR)/offline_repo.json"
635

636
$(call ensure_mount,repo): repo_packages repo_package_info repo_metadata $(IMAGE_DIR)/offline_repo.json
637

638
config $(CONFIG_FILE):
639
	@echo "Generating configuration $(CONFIG_FILE)"
640
	echo "#see $(CONFIG_FILE_DEFAULTS) for default values." > "$(CONFIG_FILE)"
641
	echo -e -n "$(foreach option,$(CONFIGURABLE),$(option)=$(strip $($(option)))\n)" >> "$(CONFIG_FILE)"
642

643
config_clean:
644
645
	$(RM) $(CONFIG_FILE)

646
647
648
%.vmdk : %.img
	vboxmanage convertfromraw --format vmdk "$<" "$@"

649
%.sha1sum : %
650
	(cd "$$(dirname "$<")" && sha1sum "$$(basename "$<")") > "$@"
651

652
help:
653
	@echo "Defaul Architecture: $(ARCH) ($(call altarch,$(ARCH)))"
654
655
656
	@echo "Workspace: $(WORKSPACE)"
	@echo "You may specify the Architecture by setting ARCH="
	@echo
657
658
659
	@echo "=== Example run of lipck ==="
	@echo "\$$ make WORKSPACE=/media/drivewithspace config #configure lipck"
	@echo "# make image #main remaster process (requires several cups of coffee)"
660
	@echo "# make repo #build offline repo"
661
	@echo "\$$ #copy mbr+partition to final destination"
662
	@echo "# make IMAGE_FILE=/somewhere/myfinalimage.img image_deploy"
663
	@echo "\$$ #(optionally) create a vmdk version. Note that IMAGE_FILE is still the raw .img file here!"
664
	@echo "# make IMAGE_FILE=/somewhere/myfinalimage.img image_deploy_vmdk"
665
	@echo
christian's avatar
christian committed
666
	@echo "There is a list of all phony targets available under \"make listall\""
667
668
	@echo "A list of all config options may be found in:"
	@echo "    $(CONFIG_FILE_DEFAULTS)"
669
670

listall:
671
672
	@echo "Available targets: "
	@echo -e "$(foreach t,$(COMMON_PHONY) $(ISO_PHONY) $(ROOTFS_PHONY) $(INITRD_PHONY) $(APT_CACHE_PHONY) $(IMAGE_PHONY),\n-$t)"
673

674
ISO_PHONY=iso_download iso_content iso_clean iso_clean_both
675
ROOTFS_PHONY=rootfs_unsquash rootfs_prepare rootfs_remaster rootfs_finalize rootfs_checksums rootfs_deduplicate rootfs_squash rootfs_console rootfs_clean rootfs_common_clean rootfs_clean_both
676
INITRD_PHONY=initrd_unpack initrd_remaster initrd_pack initrd_clean initrd_clean_both
Christopher Spinrath's avatar
Christopher Spinrath committed
677
APT_CACHE_PHONY=apt_cache apt_cache_clean
678
REPO_PHONY=repo repo_packages repo_package_info repo_metadata repo_clean repo_offline_repo_json
679
IMAGE_PHONY=image image_content image_skel_file image_assemble image_remaster image_git image_git_pull image_binary_files image_grub_lipinfo image_grub_mkimage_efi image_grub_mkimage_mbr image_grub_mbr_template image_grub_install image_umount image_mount_if image_clean
680
COMMON_PHONY=help workspace config multiboot config_clean clean_really_all
Christopher Spinrath's avatar
Christopher Spinrath committed
681

682
.PHONY : default $(COMMON_PHONY) $(ISO_PHONY) $(ROOTFS_PHONY) $(INITRD_PHONY) $(APT_CACHE_PHONY) $(IMAGE_PHONY) $(REPO_PHONY)