Makefile 32.4 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

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 248 249 250 251 252
	#set timezone
	echo -n "Europe/Berlin" > "$(call archdir,$*)$(ROOTFS)/etc/timezone"
	#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/"

253
	mkdir -p "$(call archdir,$*)$(LXC_DIR)"
254
	lxc-execute --name "lipck_remaster_$*" -P "$(call archdir,$*)$(LXC_DIR)" -f "$(CURDIR)/config/lxc_common.conf" \
255 256
	-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" \
257 258
	-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" \
259
	-- /bin/bash -l /remaster/remaster.proxy.sh /remaster/scripts/rootfs_remaster.sh
260
	$(MAKE) ARCH=$* rootfs_finalize
261 262 263

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

266 267 268 269 270 271 272 273
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" \
274 275
        -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" \
276
        -- /bin/bash -l /remaster/remaster.proxy.sh /bin/bash -l || exit 0
277 278 279
	@echo
	@echo "==> LIPCK: Leaving container and cleaning up..."
	@echo
280
	$(MAKE) ARCH=$(ARCH) rootfs_finalize
281

282
rootfs_finalize : $(ARCH_DIR)$(STATE_DIR)/rootfs_finalized
283
$(call gentargets,$(STATE_DIR)/rootfs_finalized) : $(call archdir,%)$(STATE_DIR)/rootfs_prepared
284 285 286 287
	$(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"
288 289
	#clean up crash reports
	$(RM) -rf "$(call archdir,$*)$(ROOTFS)/var/crash/"*
290
	$(RM) "$(call archdir,$*)$(STATE_DIR)/rootfs_prepared"
291
	touch "$(call archdir,$*)$(STATE_DIR)/rootfs_finalized"
292 293 294 295

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

303 304 305 306
rootfs_clean_both:
	$(MAKE) ARCH=$(PRIMARY_ARCH) rootfs_clean
	$(MAKE) ARCH=$(SECONDARY_ARCH) rootfs_clean

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

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

316 317 318 319 320 321
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"
322
	@echo "Copying common files..."
323
	$(RSYNC) --files-from="$(COMMON_DIR)/common_files.list" "$(PRIMARY_ARCH_DIR)$(ROOTFS)/" "$(COMMON_DIR)/lip-common"
324
	@echo "Copying $(PRIMARY_ARCH) files..."
325
	$(RSYNC) "$(PRIMARY_ARCH_DIR)$(ROOTFS)/" "$(COMMON_DIR)/lip-$(PRIMARY_ARCH)"
326
	cd "$(COMMON_DIR)/lip-$(PRIMARY_ARCH)" && tr \\n \\0 < "$(COMMON_DIR)/common_files.list" | xargs -0 rm 
327
	@echo "Copying $(SECONDARY_ARCH) files..."
328
	$(RSYNC) "$(SECONDARY_ARCH_DIR)$(ROOTFS)/" "$(COMMON_DIR)/lip-$(SECONDARY_ARCH)"
329
	cd "$(COMMON_DIR)/lip-$(SECONDARY_ARCH)" && tr \\n \\0 < "$(COMMON_DIR)/common_files.list" | xargs -0 rm 
330 331
	touch "$(COMMON_DIR)$(STATE_DIR)/rootfs_deduplicated"

332
$(COMMON_DIR)/lip-%.squashfs : $(COMMON_DIR)$(STATE_DIR)/rootfs_deduplicated
333
	mksquashfs "$(COMMON_DIR)/lip-$*" "$(COMMON_DIR)/lip-$*.squashfs" -comp xz -noappend
334

335
rootfs_squash: $(COMMON_DIR)/lip-$(PRIMARY_ARCH).squashfs $(COMMON_DIR)/lip-$(SECONDARY_ARCH).squashfs $(COMMON_DIR)/lip-common.squashfs
336

337 338 339
rootfs_common_clean:
	$(RM) -r "$(COMMON_DIR)"

340 341 342
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)"
343
	cd "$(call archdir,$*)$(INITRD)" && lzma $(XZ_LZMA_FLAGS) -d < "$(call archdir,$*)$(INITRD_SOURCE)" | cpio -i
344
	touch "$(call archdir,$*)$(STATE_DIR)/initrd_extracted"
345 346 347 348 349 350 351

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"

352 353 354 355
initrd_clean_both:
	$(MAKE) ARCH=$(PRIMARY_ARCH) initrd_clean
	$(MAKE) ARCH=$(SECONDARY_ARCH) initrd_clean

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

	#nmtelekinese
361 362 363 364 365
	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"
366 367 368 369

	#liphook
	cp "$(CURDIR)/contrib/initrd/initrd_hook/24liphook" "$(call archdir,$*)$(INITRD)/scripts/casper-bottom/"
	chmod +x "$(call archdir,$*)$(INITRD)/scripts/casper-bottom/24liphook"
370 371 372 373 374 375
	
	#kdeconfig
	mkdir -p "$(call archdir,$*)$(INITRD)/lip/kde"
	cp "$(CURDIR)/contrib/initrd/kde-config/kde-config.tar.xz" "$(call archdir,$*)$(INITRD)/lip/kde/"
	cp "$(CURDIR)/contrib/initrd/kde-config/26kdeconfig" "$(call archdir,$*)$(INITRD)/scripts/casper-bottom/"
	chmod +x "$(call archdir,$*)$(INITRD)/scripts/casper-bottom/26kdeconfig"
376 377 378 379 380 381

	$(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"
382 383

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

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

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

396
$(call ensure_unmount,clean_really_all): iso_clean_both rootfs_clean_both rootfs_common_clean initrd_clean_both image_clean
397

398
$(call ensure_mount,image_git) $(IMAGE_DIR)/.git: |$(WORKSPACE)
399
	test ! -e "$(IMAGE_DIR)/.git"
400 401 402 403 404
	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)"
405

406
$(call ensure_mount,image_git_pull): |$(IMAGE_DIR)/.git
407
	cd "$(IMAGE_DIR)" && $(SHELL) ./scripts/update_stick.sh "$(IMAGE_GIT_BRANCH)"
408 409 410

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) \
411
$(PRIMARY_ARCH_DIR)$(STATE_DIR)/iso_extracted $(SECONDARY_ARCH_DIR)$(STATE_DIR)/iso_extracted \
Christopher Spinrath's avatar
Christopher Spinrath committed
412 413
$(PRIMARY_ARCH_DIR)/filesystem.size \
$(PRIMARY_ARCH_DIR)/gparted-live.iso $(SECONDARY_ARCH_DIR)/gparted-live.iso
414
$(call ensure_mount,image_binary_files) $(IMAGE_DIR)/.lipbinaries: image_git_pull $(IMAGE_BINARIES)
415
	$(RSYNC) "$(PRIMARY_ARCH_DIR)$(ISO_CONTENT)/dists" \
416 417 418 419
		 "$(PRIMARY_ARCH_DIR)$(ISO_CONTENT)/isolinux" \
		 "$(PRIMARY_ARCH_DIR)$(ISO_CONTENT)/pool" \
		 "$(PRIMARY_ARCH_DIR)$(ISO_CONTENT)/preseed" \
		 "$(PRIMARY_ARCH_DIR)$(ISO_CONTENT)/.disk" \
420 421
		 "$(IMAGE_DIR)/"
	$(RSYNC) "$(SECONDARY_ARCH_DIR)$(ISO_CONTENT)/.disk/casper-uuid-generic" "$(IMAGE_DIR)/.disk/casper-uuid-generic-$(SECONDARY_ARCH)"
422
	$(RSYNC) "$(PRIMARY_ARCH_DIR)$(ISO_CONTENT)/EFI/BOOT/BOOTx64.EFI" "$(IMAGE_DIR)/efi/boot/"
423
	$(RSYNC) "$(PRIMARY_ARCH_DIR)$(ISO_CONTENT)/EFI/BOOT/grubx64.efi" "$(IMAGE_DIR)/efi/boot/"
424
	mkdir -p "$(IMAGE_DIR)/casper"
425 426 427 428 429 430
	$(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" \
431
		 "$(IMAGE_DIR)/casper/"
432 433
	$(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"
434 435
	$(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"
436 437
	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)"
438
	mkdir -p "$(IMAGE_DIR)/boot/grub/" #note: this must not be $$(GRUB_INSTALL_DIR)!
439 440
	$(RSYNC) "$(PRIMARY_ARCH_DIR)$(ISO_CONTENT)/boot/grub/x86_64-efi" \
		 "$(IMAGE_DIR)/boot/grub/"
441
	touch "$(IMAGE_DIR)/.lipbinaries"
442

443
$(call ensure_mount,image_remaster) $(IMAGE_DIR)/.remastered: $(IMAGE_DIR)/.lipbinaries
444
	$(call patch_all,$(CURDIR)/patches/iso/,$(IMAGE_DIR))
445 446
	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
447 448
	touch "$(IMAGE_DIR)/.remastered"

449
$(call ensure_mount,image_content): image_git_pull $(IMAGE_DIR)/.remastered $(IMAGE_DIR)$(GRUB_INSTALL_DIR)/lipinfo.cfg $(IMAGE_DIR)$(GRUB_INSTALL_DIR)/.lipgrub
450 451 452
	@echo
	@echo "Image content is ready: $(IMAGE_DIR)"

453
$(call ensure_unmount,image_skel_file): $(IMAGE_PART_FILE)
454 455 456 457 458 459 460
$(IMAGE_PART_FILE):
	truncate -s "$(IMAGE_PART_SIZE)" "$@"
	mkfs.vfat -n "$(IMAGE_PART_LABEL)" "$@"

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

461 462 463 464 465
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"

466
image_grub_mkimage_efi: $(GRUB_ASSEMBLE_DIR)/grub.x86_64-efi
467
$(GRUB_ASSEMBLE_DIR)/grub.x86_64-efi $(GRUB_ASSEMBLE_DIR)/grub.i386-efi : $(GRUB_ASSEMBLE_DIR)/grub.%-efi : $(GRUB_ASSEMBLE_DIR)/memdisk.tar | $(WORKSPACE)
468
	mkdir -p "$(GRUB_ASSEMBLE_DIR)"
469 470 471 472
	echo "normal (memdisk)/grub_early.cfg" \
		> "$(GRUB_ASSEMBLE_DIR)/grub_pre_normal.cfg"
	grub-mkimage  \
		--memdisk "$(GRUB_ASSEMBLE_DIR)/memdisk.tar" \
473
		--output "$@" --format "$*-efi" \
474 475
		--config "$(GRUB_ASSEMBLE_DIR)/grub_pre_normal.cfg" \
		--prefix "/grub" \
476 477 478 479 480
		$(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)"
481
	grub-mkimage --prefix "(hd0,msdos1)$(GRUB_INSTALL_DIR)" \
482 483 484
                --output "$@" --format "i386-pc" \
                $(IMAGE_GRUB_MBR_MODULES)

485 486 487 488 489
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

490
$(call ensure_mount,image_grub_install): $(IMAGE_DIR)$(GRUB_INSTALL_DIR)/.lipgrub
491
$(IMAGE_DIR)$(GRUB_INSTALL_DIR)/.lipgrub: $(GRUB_ASSEMBLE_DIR)/grub.x86_64-efi $(GRUB_ASSEMBLE_DIR)/grub.i386-efi
492 493 494 495 496 497 498
	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/"
499 500
	#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.
501
	mkdir -p "$(IMAGE_DIR)/efi/boot"
502
	$(RSYNC) --no-p --no-g --no-o "$(GRUB_ASSEMBLE_DIR)/grub.x86_64-efi" "$(IMAGE_DIR)/efi/boot/grubx64-unsigned.efi"
503
	#our i386 efi bootloader shall be the default:
504
	$(RSYNC) --no-p --no-g --no-o "$(GRUB_ASSEMBLE_DIR)/grub.i386-efi" "$(IMAGE_DIR)/efi/boot/bootia32.efi"
505
	touch "$(IMAGE_DIR)$(GRUB_INSTALL_DIR)/.lipgrub"
506

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

515
	@echo
516
	@echo "Image is ready: $@"
517

518 519
$(call ensure_unmount,image_deploy): $(IMAGE_FILE) $(IMAGE_FILE).sha256sum
$(call ensure_unmount,image_deploy_vmdk): $(IMAGE_FILE:.img=.vmdk) $(IMAGE_FILE:.img=.vmdk).sha256sum
520

521
$(call ensure_unmount,image_clean):
522
	$(RM) "$(IMAGE_PART_FILE)"
523
	$(RM) -r "$(GRUB_ASSEMBLE_DIR)"
524

525
$(call ensure_mount,image_grub_lipinfo) : $(IMAGE_DIR)$(GRUB_INSTALL_DIR)/lipinfo.cfg
526 527 528 529 530 531 532 533
$(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)\"" >> "$@"
534

535
image_mount_if : $(IMAGE_PART_FILE)
536
	mkdir -p "$(IMAGE_DIR)"
537
	[ "$$(findmnt --target "$(IMAGE_DIR)" -f -n --output=target)" = "$(shell readlink -f "$(IMAGE_DIR)")" ] \
538
		|| mount "$(IMAGE_PART_FILE)" "$(IMAGE_DIR)"
539

540 541
image_umount_if :
	#if something is mounted then umount
542
	[ "$$(findmnt --target "$(IMAGE_DIR)" -f -n --output=target)" != "$(shell readlink -f "$(IMAGE_DIR)")" ] \
543
		|| umount -d "$(IMAGE_DIR)"
544

545
$(call ensure_mount,image) : image_content $(GRUB_ASSEMBLE_DIR)/mbr.img
546

547 548 549 550 551 552
#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"
553 554 555 556
	$(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)
557 558
	#since this is most likely a standalone image make the lipck grubx64 the
	#default bootloader for 64bit efi systems
559 560
	[ -e "$(WORKSPACE)/multiboot.work/efi/boot/bootx64.efi" ] \
		|| mv "$(WORKSPACE)/multiboot.work/efi/boot/"{grubx64-unsigned.efi,bootx64.efi} \
561
		|| (umount -d "$(WORKSPACE)/multiboot.work" && exit 1)
562
	$(MAKE) "IMAGE_PART_FILE=$(WORKSPACE)/multiboot.part" IMAGE_FILE=MultiBoot.img \
563
		"IMAGE_DIR=$(WORKSPACE)/multiboot.work" \
564 565
		image_assemble

Christopher Spinrath's avatar
Christopher Spinrath committed
566 567 568 569
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"

570
$(call ensure_mount,repo_packages) : $(REPO_ARCHIVE_DIR)/Packages.$(call altarch,$(ARCH))
571 572
$(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
573
	mkdir -p "$(call archdir,$*)$(ROOTFS)/cdrom"
574 575 576 577
	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" \
578 579
        -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" \
580 581
	-s lxc.mount.entry="$(IMAGE_DIR) $(call archdir,$*)$(ROOTFS)/cdrom none defaults,bind 0 0" \
        -- /bin/bash -l /remaster/remaster.proxy.sh \
582
	/remaster/scripts/repo_packages.sh "$*" "/cdrom"
583
	rmdir "$(call archdir,$*)$(ROOTFS)/cdrom"
584 585
	$(MAKE) ARCH=$(call to_arch,$*) rootfs_finalize

586 587
$(call ensure_mount,repo_package_info) : $(REPO_DIST_DIR)/binary-$(call altarch,$(ARCH))/Packages
$(REPO_DIST_DIR)/binary-$(call altarch,$(PRIMARY_ARCH))/Packages $(REPO_DIST_DIR)/binary-$(call altarch,$(SECONDARY_ARCH))/Packages : $(REPO_DIST_DIR)/binary-%/Packages : $(REPO_ARCHIVE_DIR)/Packages.%
588
	mkdir -p "$(REPO_ARCHIVE_DIR)"
589
	mkdir -p "$(REPO_DIST_DIR)/binary-$*/"
590 591 592 593 594 595 596 597 598 599 600 601 602
	#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"

603
	cd "$(REPO_ARCHIVE_DIR)" \
604
	&& cat Packages.noarch "Packages.$*" > "$(REPO_DIST_DIR)/binary-$*/Packages"
605

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

	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
624
	echo "Architectures: $(call altarch,$(PRIMARY_ARCH)) $(call altarch,$(SECONDARY_ARCH))" \
625 626 627 628 629
		>> "$(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
630

631
$(call ensure_mount,repo_offline_repo_json) : $(IMAGE_DIR)/offline_repo.json
632
$(IMAGE_DIR)/offline_repo.json: $(CURDIR)/contrib/rootfs/offline_repo.json | $(IMAGE_DIR)
633 634
	cp "$(CURDIR)/contrib/rootfs/offline_repo.json" "$(IMAGE_DIR)/"

635 636 637
repo_clean:
	$(RM) -r "$(REPO_DIST_DIR)"
	$(RM) -r "$(REPO_ARCHIVE_DIR)"
638
	$(RM) "$(IMAGE_DIR)/offline_repo.json"
639

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

642
config $(CONFIG_FILE):
643
	@echo "Generating configuration $(CONFIG_FILE)"
644
	echo "#see $(CONFIG_FILE_DEFAULTS) for default values." > "$(CONFIG_FILE)"
645
	echo -e -n "$(foreach option,$(CONFIGURABLE),$(option)=$(strip $($(option)))\n)" >> "$(CONFIG_FILE)"
646

647
config_clean:
648 649
	$(RM) $(CONFIG_FILE)

650 651 652
%.vmdk : %.img
	vboxmanage convertfromraw --format vmdk "$<" "$@"

653 654
%.sha256sum : %
	(cd "$$(dirname "$<")" && sha256sum "$$(basename "$<")") > "$@"
655

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

listall:
675 676
	@echo "Available targets: "
	@echo -e "$(foreach t,$(COMMON_PHONY) $(ISO_PHONY) $(ROOTFS_PHONY) $(INITRD_PHONY) $(APT_CACHE_PHONY) $(IMAGE_PHONY),\n-$t)"
677

678
ISO_PHONY=iso_download iso_content iso_clean iso_clean_both
679
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
680
INITRD_PHONY=initrd_unpack initrd_remaster initrd_pack initrd_clean initrd_clean_both
681
APT_CACHE_PHONY=apt_cache apt_cache_clean
682
REPO_PHONY=repo repo_packages repo_package_info repo_metadata repo_clean repo_offline_repo_json
683
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
684
COMMON_PHONY=help workspace config multiboot config_clean clean_really_all
685

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