[r27]: / trunk / wharfie / Makefile  Maximize  Restore  History

Download this file

124 lines (109 with data), 3.9 kB

  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
# Copyright 2017 Ingo Hornberger <ingo_@gmx.net>
#
# This software is licensed under the MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this
# software and associated documentation files (the "Software"), to deal in the Software
# without restriction, including without limitation the rights to use, copy, modify,
# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to the following
# conditions:
#
# The above copyright notice and this permission notice shall be included in all copies
# or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
# PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
# OR OTHER DEALINGS IN THE SOFTWARE.
#
################################################################################

QEMU_IMAGE:=qemu/qwharfie.qcow
QEMU_OUTPUT:=qemu/qwharfie.output.raw
QEMU_CACHE:=qemu/qwharfie.cache.qcow
QEMU_ALL:=${QEMU_IMAGE} ${QEMU_OUTPUT} ${QEMU_CACHE}

QEMU_OUTPUT_SIZE?=2G
QEMU_CACHE_SIZE?=20G

help:
	@echo "usage: make <target>"
	@echo "targets:"
	@echo "- help: print this message"
	@echo "- qemu: build qemu image"
	@echo "- install: install wharfie on linux host"
	@echo "- clean: delete qemu image"
	@echo "- test: run a test build on all Wharfiles in the 'tests/' directory."
	@echo "        these tests are running with and without qemu."
	@echo
	@echo "Note: To control the size of the qemu output and cache images, you"
	@echo "      can pass the parameters QEMU_CACHE_SIZE and QEMU_OUTPUT_SIZE."
	@echo "e.g.: make QEMU_OUTPUT_SIZE=1G QEMU_CACHE_SIZE=10G qemu"

#
# Build qemu image.
# This can be used on windows, as well as linux.
# By default Wharfie uses qemu, as soon as it is available.
#
qemu: ${QEMU_ALL}

#
# Build a bootable Qemu image with Wharfie
#
${QEMU_IMAGE}:
	cd qemu; \
	../wharfie.py --no-qemu --no-proc

#
# Create an empty output image, which can be copied to a build folder.
# In fact this is just an empty file, where the qemu VM can write a raw
# tar archive to.
#
${QEMU_OUTPUT}:
	qemu-img create -f raw $@ ${QEMU_OUTPUT_SIZE}

#
# Create an empty ext3 cache partition, which can be copied into a build folder
# to cache intermediate files.
#
${QEMU_CACHE}:
# create raw image
	qemu-img create -f raw $@.raw ${QEMU_CACHE_SIZE}
# create partitions
	( \
	    echo o; \
	    echo n; \
	    echo p; \
	    echo 1; \
	    echo; \
	    echo; \
	    echo w; \
	) | sudo fdisk $@.raw
# create ext3 filesystem in partition
	l=$$(sudo /sbin/kpartx -l $@.raw | sed -n '/loop/ s,.*/dev/\(loop[0-9]\+\).*,\1, p;q;') && \
	sudo /sbin/kpartx -as $@.raw && \
	sudo mkfs.ext3 /dev/mapper/$${l}p1 && \
	sudo /sbin/kpartx -ds $@.raw
# convert raw image to qcow
	qemu-img convert -O qcow2 $@.raw $@
	rm -f $@.raw

#
# Remove the qemu image and intermediate build files
#
clean:
	cd qemu; \
	../wharfie.py --clean
	rm ${QEMU_IMAGE}
	rm ${QEMU_OUTPUT}
	rm ${QEMU_CACHE}

#
# Run a test on all Wharfiles in the subdirectory "test/"
# The test depends on qemu, as they are running with and without qemu
#
TEST_IMAGES=$(addsuffix .test.tar, $(wildcard tests/*))
TEST_IMAGES_QEMU=$(addsuffix .qemu.test.tar, $(wildcard tests/*))

test: ${QEMU_ALL} ${TEST_IMAGES_QEMU}


%.test.tar:
	cd $*; \
	../../wharfie.py --clean; \
	../../wharfie.py --no-qemu && cp result.tar ../$$(basename $@)

%.qemu.test.tar:
	cd $*; \
	../../wharfie.py --clean; \
	../../wharfie.py && cp result.tar ../$$(basename $@)