Rename 'update-iso.ml' as more happenin' 'iso-attach'.
[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.9
27
28 # i386 images also work on x86-64, so best to stick with i386.
29 ARCH     := i386
30
31 # Base repository.
32 BASE     := 8
33 BASEURL  := http://download.fedora.redhat.com/pub/fedora/linux/releases/$(BASE)/Everything/$(ARCH)/os/
34
35 LANG     := en_US.UTF-8
36 KEYBOARD := us
37 TIMEZONE := US/Eastern
38
39 # Select a suitable HTTP proxy.
40 # The default assumes a local squid proxy.
41 export http_proxy := http://127.0.0.1:3128/
42 export ftp_proxy := http://127.0.0.1:3128/
43
44 LABEL    := $(PACKAGE)-$(VERSION)
45
46 ISO      := $(LABEL).iso
47
48 #----------------------------------------------------------------------
49
50 all:
51         @echo "make build     Build the live CD ISO"
52         @echo "make boot [HDA=hda.img] [HDB=hdb.img] [ISO=livecd.iso]"
53         @echo "                 Boot built/named ISO (uses qemu)"
54         @echo "make update    Update an existing live CD ISO with new"
55         @echo "                 virt-p2v script, without doing full rebuild"
56
57 # Build live CD.
58
59 build: checkroot checkscript livecd.ks
60         rm -f $(ISO)
61         livecd-creator --config=livecd.ks --fslabel=$(LABEL)
62         ls -lhtr *.iso
63
64 livecd.ks: livecd.ks.in livecd-post.sh Makefile
65         rm -f $@
66         sed \
67           -e 's|@ARCH@|$(ARCH)|g' \
68           -e 's|@BASE@|$(BASE)|g' \
69           -e 's|@BASEURL@|$(BASEURL)|g' \
70           -e 's|@LANG@|$(LANG)|g' \
71           -e 's|@KEYBOARD@|$(KEYBOARD)|g' \
72           -e 's|@TIMEZONE@|$(TIMEZONE)|g' \
73           < $< | cat - livecd-post.sh > $@
74
75 livecd-post.sh: livecd-post.sh.in virt-p2v.ml inittab lvm.conf Makefile
76         rm -f $@
77         sed \
78           -e '/@VIRT-P2V.ML@/ r virt-p2v.ml' \
79           -e '/@VIRT-P2V.ML@/ d' \
80           -e '/@INITTAB@/ r inittab' \
81           -e '/@INITTAB@/ d' \
82           -e '/@LVM.CONF@/ r lvm.conf' \
83           -e '/@LVM.CONF@/ d' \
84           < $< > $@
85
86 # Run live CD under qemu.
87
88 QEMU    := qemu
89 HDA     :=
90 HDB     :=
91
92 QEMU_ARGS := -m 512 -cdrom $(ISO) -boot d
93 ifneq ($(HDA),)
94 QEMU_ARGS += -hda $(HDA)
95 endif
96 ifneq ($(HDB),)
97 QEMU_ARGS += -hdb $(HDB)
98 endif
99
100 boot:
101         $(QEMU) $(QEMU_ARGS)
102
103 # Update an existing ISO.
104
105 update: checkroot checkscript
106         -./iso-attach delete $(ISO)
107         ./iso-attach add $(ISO) virt-p2v.ml
108
109 # Check that we are root.
110
111 checkroot:
112         @if [ `id -u` -ne 0 ]; then \
113           echo "You must be root to perform this operation."; \
114           exit 1; \
115         fi
116
117 # Check that the script compiles.
118
119 checkscript:
120         ./virt-p2v.ml --test
121
122 # Clean.
123
124 clean:
125         rm -f *~ core livecd.ks livecd-post.sh
126
127 # Manifest.
128
129 dist:
130         $(MAKE) check-manifest
131         rm -rf $(PACKAGE)-$(VERSION)
132         mkdir $(PACKAGE)-$(VERSION)
133         tar -cf - -T MANIFEST | tar -C $(PACKAGE)-$(VERSION) -xf -
134         tar zcf $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)
135         rm -rf $(PACKAGE)-$(VERSION)
136         ls -l $(PACKAGE)-$(VERSION).tar.gz
137
138 check-manifest:
139         @hg manifest | sort > .check-manifest; \
140         sort MANIFEST > .orig-manifest; \
141         diff -u .orig-manifest .check-manifest; rv=$$?; \
142         rm -f .orig-manifest .check-manifest; \
143         exit $$rv
144
145 .PHONY: build boot checkroot