Version 0.5 -- fixed tty problems, added virt-p2v-unpack script.
[virt-p2v.git] / Makefile
1 # Makefile for virt-p2v
2 #
3 # Copyright (C) 2007 Red Hat Inc.
4 # Written by Richard W.M. Jones <rjones@redhat.com>
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 #
20 # $Id$
21
22 #----------------------------------------------------------------------
23 # General configuration
24
25 PACKAGE  := virt-p2v
26 VERSION  := 0.5
27
28 # i386 images also work on x86-64, so best to stick with i386.
29 ARCH     := i386
30
31 LANG     := en_US.UTF-8
32 KEYBOARD := us
33 TIMEZONE := US/Eastern
34
35 BASEREPO := http://download.fedora.redhat.com/pub/fedora/linux/releases/7/Fedora/$(ARCH)/os/
36
37 # Select a suitable HTTP proxy.
38 # The default assumes a local squid proxy.
39 export http_proxy := http://127.0.0.1:3128/
40 export ftp_proxy := http://127.0.0.1:3128/
41
42 LABEL    := $(PACKAGE)-$(VERSION)
43
44 #----------------------------------------------------------------------
45
46 all:
47         @echo "make build     Build the live CD ISO"
48         @echo "make boot [HDA=hda.img] [HDB=hdb.img] [ISO=livecd.iso]"
49         @echo "               Boot built/named ISO (uses qemu)"
50
51 # Build live CD.
52
53 build: checkroot livecd.ks
54         rm -f $(LABEL).iso
55         livecd-creator --config=livecd.ks --fslabel=$(LABEL)
56         ls -lhtr *.iso
57
58 livecd.ks: livecd.ks.in livecd-post.sh Makefile
59         rm -f $@
60         sed \
61           -e 's|@BASEREPO@|$(BASEREPO)|g' \
62           -e 's|@LANG@|$(LANG)|g' \
63           -e 's|@KEYBOARD@|$(KEYBOARD)|g' \
64           -e 's|@TIMEZONE@|$(TIMEZONE)|g' \
65           < $< | cat - livecd-post.sh > $@
66
67 livecd-post.sh: livecd-post.sh.in virt-p2v.sh inittab lvm.conf Makefile
68         rm -f $@
69         sed \
70           -e '/@VIRT-P2V.SH@/ r virt-p2v.sh' \
71           -e '/@VIRT-P2V.SH@/ d' \
72           -e '/@INITTAB@/ r inittab' \
73           -e '/@INITTAB@/ d' \
74           -e '/@LVM.CONF@/ r lvm.conf' \
75           -e '/@LVM.CONF@/ d' \
76           < $< > $@
77
78 # Run live CD under qemu.
79
80 QEMU    := qemu
81 ISO     := $(LABEL).iso
82 HDA     :=
83 HDB     :=
84
85 QEMU_ARGS := -m 512 -cdrom $(ISO) -boot d
86 ifneq ($(HDA),)
87 QEMU_ARGS += -hda $(HDA)
88 endif
89 ifneq ($(HDB),)
90 QEMU_ARGS += -hdb $(HDB)
91 endif
92
93 boot:
94         $(QEMU) $(QEMU_ARGS)
95
96 # Standard rules.
97
98 checkroot:
99         @if [ `id -u` -ne 0 ]; then \
100           echo "You must be root to perform this operation."; \
101           exit 1; \
102         fi
103
104 clean:
105         rm -f *~ core livecd.ks livecd-post.sh
106
107 # Manifest.
108
109 dist:
110         $(MAKE) check-manifest
111         rm -rf $(PACKAGE)-$(VERSION)
112         mkdir $(PACKAGE)-$(VERSION)
113         tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
114         tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
115         rm -rf $(PACKAGE)-$(VERSION)
116         ls -l $(PACKAGE)-$(VERSION).tar.gz
117
118 check-manifest:
119         @for d in `find -type d -name CVS | grep -v '^\./debian/'`; \
120         do \
121         b=`dirname $$d`/; \
122         awk -F/ '$$1 != "D" {print $$2}' $$d/Entries | \
123         sed -e "s|^|$$b|" -e "s|^\./||"; \
124         done | sort > .check-manifest; \
125         sort MANIFEST > .orig-manifest; \
126         diff -u .orig-manifest .check-manifest; rv=$$?; \
127         rm -f .orig-manifest .check-manifest; \
128         exit $$rv
129
130 .PHONY: build boot checkroot