2011-07-07 03:40:20 +02:00
|
|
|
APPLIANCE ?= base
|
2015-09-14 12:00:37 +02:00
|
|
|
VABUILDER_OUTPUT := $(CURDIR)
|
2015-09-14 12:22:42 +02:00
|
|
|
CHROOT = $(VABUILDER_OUTPUT)/build/$(APPLIANCE)
|
2015-09-14 12:00:37 +02:00
|
|
|
PKGDIR = $(VABUILDER_OUTPUT)/packages
|
2015-02-22 16:32:16 +01:00
|
|
|
DISTDIR = $(CURDIR)/distfiles
|
|
|
|
PORTAGE_DIR = $(CURDIR)/portage
|
I learned a lot about Makefiles :D
So, basically I re-architeched things a bit:
The appliance/Makefile.inc fiels are now appliance/Makefile (again). The
main Makefile will call "make -C appliance preinstall" and "postinstall"
(and in future "clean"). So I got rid of the ugly make variables/include
thing. Some of the main Makefile's variables are exported to the
sub-makes. Appliances don't really need $(APPLIANCE) anymore as the
appliance directory is their CWD.
Added some new targets and smarter targets. I can do more with this, but
it's a big improvment from last time. Still learning a lot of Makefile
magic (been reading other people's Makefiles).
Verified that "make -j3" works (at least on the base appliance) but will
kill your hard drive :D
Introduced "profiles" Which are files with variables you want to override.
The file will be "include"ed by the main Makefile. For example, I have a
file, "local.cfg" that looks like this:
--- 8< -----------------------------
CHROOT = /var/scratch/marduk/vabuild
HEADLESS = YES
PRUNE_CRITICAL = NO
VIRTIO = YES
TIMEZONE = EST5EDT
DISK_SIZE = 60.0G
SWAP_SIZE = 48
PKGDIR = /var/scratch/packages
NBD_DEV = /dev/nbd8
all: qcow
--- 8< ------------------------------
Then, e.g. i can run "make PROFILE=local APPLIANCE=kde". If you don't
specify a PROFILE variable, then it will default to the empty string, which
means the main Makefile will attempt to include .cfg
So, for example i have:
$ ln -s local.cfg .cfg
$ make APPLIANCE=kde
Don't set PROFILE inside your .cfg file (why would you?). Also, if the
[pro]file does not exist, the include fails silently.
I will put this info in the wiki eventually...
2010-11-14 00:22:18 +01:00
|
|
|
HOSTNAME = $(APPLIANCE)
|
2015-09-14 12:00:37 +02:00
|
|
|
IMAGES = $(VABUILDER_OUTPUT)/images
|
2015-02-22 16:32:16 +01:00
|
|
|
RAW_IMAGE = $(IMAGES)/$(APPLIANCE).img
|
|
|
|
QCOW_IMAGE = $(IMAGES)/$(APPLIANCE).qcow
|
|
|
|
VMDK_IMAGE = $(IMAGES)/$(APPLIANCE).vmdk
|
|
|
|
XVA_IMAGE = $(IMAGES)/$(APPLIANCE).xva
|
|
|
|
LST_FILE = $(IMAGES)/$(APPLIANCE)-packages.lst
|
2015-09-14 13:09:15 +02:00
|
|
|
CHECKSUMS = $(IMAGES)/SHA256SUMS
|
2015-12-17 22:25:03 +01:00
|
|
|
STAGE3 = $(CHROOT)/var/tmp/stage3
|
|
|
|
COMPILE_OPTIONS = $(CHROOT)/var/tmp/compile_options
|
|
|
|
SOFTWARE = $(CHROOT)/var/tmp/software
|
|
|
|
KERNEL = $(CHROOT)/var/tmp/kernel
|
|
|
|
GRUB = $(CHROOT)/var/tmp/grub
|
|
|
|
PREPROOT = $(CHROOT)/var/tmp/preproot
|
|
|
|
SYSTOOLS = $(CHROOT)/var/tmp/systools
|
2015-09-14 12:00:37 +02:00
|
|
|
STAGE4_TARBALL = $(VABUILDER_OUTPUT)/images/$(APPLIANCE).tar.xz
|
I learned a lot about Makefiles :D
So, basically I re-architeched things a bit:
The appliance/Makefile.inc fiels are now appliance/Makefile (again). The
main Makefile will call "make -C appliance preinstall" and "postinstall"
(and in future "clean"). So I got rid of the ugly make variables/include
thing. Some of the main Makefile's variables are exported to the
sub-makes. Appliances don't really need $(APPLIANCE) anymore as the
appliance directory is their CWD.
Added some new targets and smarter targets. I can do more with this, but
it's a big improvment from last time. Still learning a lot of Makefile
magic (been reading other people's Makefiles).
Verified that "make -j3" works (at least on the base appliance) but will
kill your hard drive :D
Introduced "profiles" Which are files with variables you want to override.
The file will be "include"ed by the main Makefile. For example, I have a
file, "local.cfg" that looks like this:
--- 8< -----------------------------
CHROOT = /var/scratch/marduk/vabuild
HEADLESS = YES
PRUNE_CRITICAL = NO
VIRTIO = YES
TIMEZONE = EST5EDT
DISK_SIZE = 60.0G
SWAP_SIZE = 48
PKGDIR = /var/scratch/packages
NBD_DEV = /dev/nbd8
all: qcow
--- 8< ------------------------------
Then, e.g. i can run "make PROFILE=local APPLIANCE=kde". If you don't
specify a PROFILE variable, then it will default to the empty string, which
means the main Makefile will attempt to include .cfg
So, for example i have:
$ ln -s local.cfg .cfg
$ make APPLIANCE=kde
Don't set PROFILE inside your .cfg file (why would you?). Also, if the
[pro]file does not exist, the include fails silently.
I will put this info in the wiki eventually...
2010-11-14 00:22:18 +01:00
|
|
|
VIRTIO = NO
|
|
|
|
TIMEZONE = UTC
|
|
|
|
DISK_SIZE = 6.0G
|
|
|
|
SWAP_SIZE = 30
|
|
|
|
SWAP_FILE = $(CHROOT)/.swap
|
|
|
|
ARCH = amd64
|
2014-06-09 04:26:17 +02:00
|
|
|
KERNEL_CONFIG = configs/kernel.config.$(ARCH)
|
2015-02-22 16:32:16 +01:00
|
|
|
MAKEOPTS = -j5 -l5.64
|
2011-01-21 00:17:32 +01:00
|
|
|
ENABLE_SSHD = NO
|
2010-12-20 05:04:11 +01:00
|
|
|
CHANGE_PASSWORD = YES
|
I learned a lot about Makefiles :D
So, basically I re-architeched things a bit:
The appliance/Makefile.inc fiels are now appliance/Makefile (again). The
main Makefile will call "make -C appliance preinstall" and "postinstall"
(and in future "clean"). So I got rid of the ugly make variables/include
thing. Some of the main Makefile's variables are exported to the
sub-makes. Appliances don't really need $(APPLIANCE) anymore as the
appliance directory is their CWD.
Added some new targets and smarter targets. I can do more with this, but
it's a big improvment from last time. Still learning a lot of Makefile
magic (been reading other people's Makefiles).
Verified that "make -j3" works (at least on the base appliance) but will
kill your hard drive :D
Introduced "profiles" Which are files with variables you want to override.
The file will be "include"ed by the main Makefile. For example, I have a
file, "local.cfg" that looks like this:
--- 8< -----------------------------
CHROOT = /var/scratch/marduk/vabuild
HEADLESS = YES
PRUNE_CRITICAL = NO
VIRTIO = YES
TIMEZONE = EST5EDT
DISK_SIZE = 60.0G
SWAP_SIZE = 48
PKGDIR = /var/scratch/packages
NBD_DEV = /dev/nbd8
all: qcow
--- 8< ------------------------------
Then, e.g. i can run "make PROFILE=local APPLIANCE=kde". If you don't
specify a PROFILE variable, then it will default to the empty string, which
means the main Makefile will attempt to include .cfg
So, for example i have:
$ ln -s local.cfg .cfg
$ make APPLIANCE=kde
Don't set PROFILE inside your .cfg file (why would you?). Also, if the
[pro]file does not exist, the include fails silently.
I will put this info in the wiki eventually...
2010-11-14 00:22:18 +01:00
|
|
|
HEADLESS = NO
|
2011-02-05 06:06:23 +01:00
|
|
|
EXTERNAL_KERNEL = NO
|
2011-06-23 03:42:59 +02:00
|
|
|
PKGLIST = 0
|
I learned a lot about Makefiles :D
So, basically I re-architeched things a bit:
The appliance/Makefile.inc fiels are now appliance/Makefile (again). The
main Makefile will call "make -C appliance preinstall" and "postinstall"
(and in future "clean"). So I got rid of the ugly make variables/include
thing. Some of the main Makefile's variables are exported to the
sub-makes. Appliances don't really need $(APPLIANCE) anymore as the
appliance directory is their CWD.
Added some new targets and smarter targets. I can do more with this, but
it's a big improvment from last time. Still learning a lot of Makefile
magic (been reading other people's Makefiles).
Verified that "make -j3" works (at least on the base appliance) but will
kill your hard drive :D
Introduced "profiles" Which are files with variables you want to override.
The file will be "include"ed by the main Makefile. For example, I have a
file, "local.cfg" that looks like this:
--- 8< -----------------------------
CHROOT = /var/scratch/marduk/vabuild
HEADLESS = YES
PRUNE_CRITICAL = NO
VIRTIO = YES
TIMEZONE = EST5EDT
DISK_SIZE = 60.0G
SWAP_SIZE = 48
PKGDIR = /var/scratch/packages
NBD_DEV = /dev/nbd8
all: qcow
--- 8< ------------------------------
Then, e.g. i can run "make PROFILE=local APPLIANCE=kde". If you don't
specify a PROFILE variable, then it will default to the empty string, which
means the main Makefile will attempt to include .cfg
So, for example i have:
$ ln -s local.cfg .cfg
$ make APPLIANCE=kde
Don't set PROFILE inside your .cfg file (why would you?). Also, if the
[pro]file does not exist, the include fails silently.
I will put this info in the wiki eventually...
2010-11-14 00:22:18 +01:00
|
|
|
ACCEPT_KEYWORDS = amd64
|
2011-04-06 16:25:05 +02:00
|
|
|
DASH = NO
|
2015-09-26 22:57:49 +02:00
|
|
|
LOCALE ?= en_US.utf8
|
I learned a lot about Makefiles :D
So, basically I re-architeched things a bit:
The appliance/Makefile.inc fiels are now appliance/Makefile (again). The
main Makefile will call "make -C appliance preinstall" and "postinstall"
(and in future "clean"). So I got rid of the ugly make variables/include
thing. Some of the main Makefile's variables are exported to the
sub-makes. Appliances don't really need $(APPLIANCE) anymore as the
appliance directory is their CWD.
Added some new targets and smarter targets. I can do more with this, but
it's a big improvment from last time. Still learning a lot of Makefile
magic (been reading other people's Makefiles).
Verified that "make -j3" works (at least on the base appliance) but will
kill your hard drive :D
Introduced "profiles" Which are files with variables you want to override.
The file will be "include"ed by the main Makefile. For example, I have a
file, "local.cfg" that looks like this:
--- 8< -----------------------------
CHROOT = /var/scratch/marduk/vabuild
HEADLESS = YES
PRUNE_CRITICAL = NO
VIRTIO = YES
TIMEZONE = EST5EDT
DISK_SIZE = 60.0G
SWAP_SIZE = 48
PKGDIR = /var/scratch/packages
NBD_DEV = /dev/nbd8
all: qcow
--- 8< ------------------------------
Then, e.g. i can run "make PROFILE=local APPLIANCE=kde". If you don't
specify a PROFILE variable, then it will default to the empty string, which
means the main Makefile will attempt to include .cfg
So, for example i have:
$ ln -s local.cfg .cfg
$ make APPLIANCE=kde
Don't set PROFILE inside your .cfg file (why would you?). Also, if the
[pro]file does not exist, the include fails silently.
I will put this info in the wiki eventually...
2010-11-14 00:22:18 +01:00
|
|
|
|
|
|
|
M4 = m4
|
2012-05-25 18:33:40 +02:00
|
|
|
EMERGE = /usr/bin/emerge --jobs=4
|
I learned a lot about Makefiles :D
So, basically I re-architeched things a bit:
The appliance/Makefile.inc fiels are now appliance/Makefile (again). The
main Makefile will call "make -C appliance preinstall" and "postinstall"
(and in future "clean"). So I got rid of the ugly make variables/include
thing. Some of the main Makefile's variables are exported to the
sub-makes. Appliances don't really need $(APPLIANCE) anymore as the
appliance directory is their CWD.
Added some new targets and smarter targets. I can do more with this, but
it's a big improvment from last time. Still learning a lot of Makefile
magic (been reading other people's Makefiles).
Verified that "make -j3" works (at least on the base appliance) but will
kill your hard drive :D
Introduced "profiles" Which are files with variables you want to override.
The file will be "include"ed by the main Makefile. For example, I have a
file, "local.cfg" that looks like this:
--- 8< -----------------------------
CHROOT = /var/scratch/marduk/vabuild
HEADLESS = YES
PRUNE_CRITICAL = NO
VIRTIO = YES
TIMEZONE = EST5EDT
DISK_SIZE = 60.0G
SWAP_SIZE = 48
PKGDIR = /var/scratch/packages
NBD_DEV = /dev/nbd8
all: qcow
--- 8< ------------------------------
Then, e.g. i can run "make PROFILE=local APPLIANCE=kde". If you don't
specify a PROFILE variable, then it will default to the empty string, which
means the main Makefile will attempt to include .cfg
So, for example i have:
$ ln -s local.cfg .cfg
$ make APPLIANCE=kde
Don't set PROFILE inside your .cfg file (why would you?). Also, if the
[pro]file does not exist, the include fails silently.
I will put this info in the wiki eventually...
2010-11-14 00:22:18 +01:00
|
|
|
M4_DEFS = -D HOSTNAME=$(HOSTNAME)
|
|
|
|
M4C = $(M4) $(M4_DEFS)
|
|
|
|
USEPKG = --usepkg --binpkg-respect-use=y
|
2011-06-25 04:48:07 +02:00
|
|
|
RSYNC_MIRROR = rsync://rsync.gtlib.gatech.edu/gentoo/
|
2015-02-27 22:20:43 +01:00
|
|
|
KERNEL_PKG = gentoo-sources
|
2014-06-09 04:26:17 +02:00
|
|
|
PACKAGE_FILES = $(wildcard appliances/$(APPLIANCE)/package.*)
|
|
|
|
WORLD = appliances/$(APPLIANCE)/world
|
2011-11-16 12:44:32 +01:00
|
|
|
EXTRA_WORLD =
|
I learned a lot about Makefiles :D
So, basically I re-architeched things a bit:
The appliance/Makefile.inc fiels are now appliance/Makefile (again). The
main Makefile will call "make -C appliance preinstall" and "postinstall"
(and in future "clean"). So I got rid of the ugly make variables/include
thing. Some of the main Makefile's variables are exported to the
sub-makes. Appliances don't really need $(APPLIANCE) anymore as the
appliance directory is their CWD.
Added some new targets and smarter targets. I can do more with this, but
it's a big improvment from last time. Still learning a lot of Makefile
magic (been reading other people's Makefiles).
Verified that "make -j3" works (at least on the base appliance) but will
kill your hard drive :D
Introduced "profiles" Which are files with variables you want to override.
The file will be "include"ed by the main Makefile. For example, I have a
file, "local.cfg" that looks like this:
--- 8< -----------------------------
CHROOT = /var/scratch/marduk/vabuild
HEADLESS = YES
PRUNE_CRITICAL = NO
VIRTIO = YES
TIMEZONE = EST5EDT
DISK_SIZE = 60.0G
SWAP_SIZE = 48
PKGDIR = /var/scratch/packages
NBD_DEV = /dev/nbd8
all: qcow
--- 8< ------------------------------
Then, e.g. i can run "make PROFILE=local APPLIANCE=kde". If you don't
specify a PROFILE variable, then it will default to the empty string, which
means the main Makefile will attempt to include .cfg
So, for example i have:
$ ln -s local.cfg .cfg
$ make APPLIANCE=kde
Don't set PROFILE inside your .cfg file (why would you?). Also, if the
[pro]file does not exist, the include fails silently.
I will put this info in the wiki eventually...
2010-11-14 00:22:18 +01:00
|
|
|
|
2011-06-29 06:43:12 +02:00
|
|
|
# Allow appliance to override variables
|
2015-12-11 02:15:10 +01:00
|
|
|
-include appliances/$(APPLIANCE)/$(APPLIANCE).cfg
|
2011-06-29 06:43:12 +02:00
|
|
|
|
|
|
|
# Allow user to override variables
|
2010-12-07 02:19:37 +01:00
|
|
|
-include $(profile).cfg
|
I learned a lot about Makefiles :D
So, basically I re-architeched things a bit:
The appliance/Makefile.inc fiels are now appliance/Makefile (again). The
main Makefile will call "make -C appliance preinstall" and "postinstall"
(and in future "clean"). So I got rid of the ugly make variables/include
thing. Some of the main Makefile's variables are exported to the
sub-makes. Appliances don't really need $(APPLIANCE) anymore as the
appliance directory is their CWD.
Added some new targets and smarter targets. I can do more with this, but
it's a big improvment from last time. Still learning a lot of Makefile
magic (been reading other people's Makefiles).
Verified that "make -j3" works (at least on the base appliance) but will
kill your hard drive :D
Introduced "profiles" Which are files with variables you want to override.
The file will be "include"ed by the main Makefile. For example, I have a
file, "local.cfg" that looks like this:
--- 8< -----------------------------
CHROOT = /var/scratch/marduk/vabuild
HEADLESS = YES
PRUNE_CRITICAL = NO
VIRTIO = YES
TIMEZONE = EST5EDT
DISK_SIZE = 60.0G
SWAP_SIZE = 48
PKGDIR = /var/scratch/packages
NBD_DEV = /dev/nbd8
all: qcow
--- 8< ------------------------------
Then, e.g. i can run "make PROFILE=local APPLIANCE=kde". If you don't
specify a PROFILE variable, then it will default to the empty string, which
means the main Makefile will attempt to include .cfg
So, for example i have:
$ ln -s local.cfg .cfg
$ make APPLIANCE=kde
Don't set PROFILE inside your .cfg file (why would you?). Also, if the
[pro]file does not exist, the include fails silently.
I will put this info in the wiki eventually...
2010-11-14 00:22:18 +01:00
|
|
|
|
2015-09-14 12:16:56 +02:00
|
|
|
ifneq ($(profile),)
|
|
|
|
container = $(profile)-$(APPLIANCE)-build
|
|
|
|
else
|
|
|
|
container = $(APPLIANCE)-build
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2015-02-22 16:32:16 +01:00
|
|
|
inroot := systemd-nspawn --quiet \
|
|
|
|
--directory=$(CHROOT) \
|
2015-09-14 12:16:56 +02:00
|
|
|
--machine=$(container) \
|
2015-12-17 22:25:59 +01:00
|
|
|
--bind=$(PORTAGE_DIR):/usr/portage \
|
2015-02-22 16:32:16 +01:00
|
|
|
--bind=$(PKGDIR):/usr/portage/packages \
|
|
|
|
--bind=$(DISTDIR):/usr/portage/distfiles
|
|
|
|
|
2012-12-21 20:12:25 +01:00
|
|
|
ifeq ($(ARCH),x86)
|
|
|
|
inroot := linux32 $(inroot)
|
|
|
|
endif
|
|
|
|
|
2011-06-29 06:43:12 +02:00
|
|
|
stage4-exists := $(wildcard $(STAGE4_TARBALL))
|
I learned a lot about Makefiles :D
So, basically I re-architeched things a bit:
The appliance/Makefile.inc fiels are now appliance/Makefile (again). The
main Makefile will call "make -C appliance preinstall" and "postinstall"
(and in future "clean"). So I got rid of the ugly make variables/include
thing. Some of the main Makefile's variables are exported to the
sub-makes. Appliances don't really need $(APPLIANCE) anymore as the
appliance directory is their CWD.
Added some new targets and smarter targets. I can do more with this, but
it's a big improvment from last time. Still learning a lot of Makefile
magic (been reading other people's Makefiles).
Verified that "make -j3" works (at least on the base appliance) but will
kill your hard drive :D
Introduced "profiles" Which are files with variables you want to override.
The file will be "include"ed by the main Makefile. For example, I have a
file, "local.cfg" that looks like this:
--- 8< -----------------------------
CHROOT = /var/scratch/marduk/vabuild
HEADLESS = YES
PRUNE_CRITICAL = NO
VIRTIO = YES
TIMEZONE = EST5EDT
DISK_SIZE = 60.0G
SWAP_SIZE = 48
PKGDIR = /var/scratch/packages
NBD_DEV = /dev/nbd8
all: qcow
--- 8< ------------------------------
Then, e.g. i can run "make PROFILE=local APPLIANCE=kde". If you don't
specify a PROFILE variable, then it will default to the empty string, which
means the main Makefile will attempt to include .cfg
So, for example i have:
$ ln -s local.cfg .cfg
$ make APPLIANCE=kde
Don't set PROFILE inside your .cfg file (why would you?). Also, if the
[pro]file does not exist, the include fails silently.
I will put this info in the wiki eventually...
2010-11-14 00:22:18 +01:00
|
|
|
|
2015-02-22 16:32:16 +01:00
|
|
|
COPY_ARGS = --exclude-from=configs/rsync-excludes
|
2011-06-29 06:43:12 +02:00
|
|
|
|
2010-12-20 05:04:11 +01:00
|
|
|
ifeq ($(CHANGE_PASSWORD),YES)
|
2011-01-12 04:47:14 +01:00
|
|
|
ifdef ROOT_PASSWORD
|
2011-02-25 05:20:38 +01:00
|
|
|
change_password = $(inroot) usermod -p '$(ROOT_PASSWORD)' root
|
2011-01-12 04:47:14 +01:00
|
|
|
else
|
2015-08-02 19:48:27 +02:00
|
|
|
change_password = $(inroot) passwd --delete --expire root
|
2011-01-12 04:47:14 +01:00
|
|
|
endif
|
2010-12-20 05:04:11 +01:00
|
|
|
endif
|
|
|
|
|
2011-02-25 05:20:38 +01:00
|
|
|
gcc_config = $(inroot) gcc-config 1
|
2010-11-27 22:43:40 +01:00
|
|
|
|
2011-04-02 15:56:19 +02:00
|
|
|
export APPLIANCE ACCEPT_KEYWORDS CHROOT EMERGE HEADLESS M4 M4C inroot
|
2015-02-22 16:32:16 +01:00
|
|
|
export HOSTNAME MAKEOPTS TIMEZONE USEPKG WORLD
|
2015-02-21 14:17:08 +01:00
|
|
|
export USEPKG RSYNC_MIRROR
|
I learned a lot about Makefiles :D
So, basically I re-architeched things a bit:
The appliance/Makefile.inc fiels are now appliance/Makefile (again). The
main Makefile will call "make -C appliance preinstall" and "postinstall"
(and in future "clean"). So I got rid of the ugly make variables/include
thing. Some of the main Makefile's variables are exported to the
sub-makes. Appliances don't really need $(APPLIANCE) anymore as the
appliance directory is their CWD.
Added some new targets and smarter targets. I can do more with this, but
it's a big improvment from last time. Still learning a lot of Makefile
magic (been reading other people's Makefiles).
Verified that "make -j3" works (at least on the base appliance) but will
kill your hard drive :D
Introduced "profiles" Which are files with variables you want to override.
The file will be "include"ed by the main Makefile. For example, I have a
file, "local.cfg" that looks like this:
--- 8< -----------------------------
CHROOT = /var/scratch/marduk/vabuild
HEADLESS = YES
PRUNE_CRITICAL = NO
VIRTIO = YES
TIMEZONE = EST5EDT
DISK_SIZE = 60.0G
SWAP_SIZE = 48
PKGDIR = /var/scratch/packages
NBD_DEV = /dev/nbd8
all: qcow
--- 8< ------------------------------
Then, e.g. i can run "make PROFILE=local APPLIANCE=kde". If you don't
specify a PROFILE variable, then it will default to the empty string, which
means the main Makefile will attempt to include .cfg
So, for example i have:
$ ln -s local.cfg .cfg
$ make APPLIANCE=kde
Don't set PROFILE inside your .cfg file (why would you?). Also, if the
[pro]file does not exist, the include fails silently.
I will put this info in the wiki eventually...
2010-11-14 00:22:18 +01:00
|
|
|
|
2014-06-11 17:59:57 +02:00
|
|
|
unexport PKGDIR ARCH
|
2010-07-09 05:22:37 +02:00
|
|
|
|
2015-03-01 02:55:57 +01:00
|
|
|
all: stage4
|
2010-07-09 05:22:37 +02:00
|
|
|
|
2015-02-28 23:27:39 +01:00
|
|
|
image: $(RAW_IMAGE)
|
2010-07-09 05:22:37 +02:00
|
|
|
|
2015-12-17 22:25:59 +01:00
|
|
|
sync_portage: $(PORTAGE_DIR)
|
|
|
|
@scripts/echo Grabbing latest portage
|
|
|
|
git -C $(PORTAGE_DIR) pull
|
|
|
|
touch $(PORTAGE_DIR)
|
2013-08-25 11:24:46 +02:00
|
|
|
|
2015-12-17 22:25:59 +01:00
|
|
|
$(PORTAGE_DIR):
|
|
|
|
@scripts/echo Grabbing the portage tree
|
|
|
|
git clone --depth=1 git://github.com/gentoo/gentoo.git $(PORTAGE_DIR)
|
2010-07-10 20:04:04 +02:00
|
|
|
|
2015-02-27 23:05:17 +01:00
|
|
|
$(PREPROOT): $(STAGE3) $(PORTAGE_DIR) configs/fstab
|
2015-02-22 16:32:16 +01:00
|
|
|
mkdir -p $(PKGDIR) $(DISTDIR)
|
|
|
|
#$(inroot) sed -i 's/root:.*/root::9797:0:::::/' /etc/shadow
|
2014-06-09 04:26:17 +02:00
|
|
|
cp configs/fstab $(CHROOT)/etc/fstab
|
2015-03-01 02:06:24 +01:00
|
|
|
ifeq ($(VIRTIO),YES)
|
|
|
|
sed -i 's/sda/vda/' $(CHROOT)/etc/fstab
|
|
|
|
endif
|
|
|
|
ifneq ($(SWAP_SIZE),0)
|
2015-03-01 02:52:49 +01:00
|
|
|
@scripts/echo Creating swap file: `basename $(SWAP_FILE)`
|
2015-03-01 02:06:24 +01:00
|
|
|
dd if=/dev/zero of=$(SWAP_FILE) bs=1M count=$(SWAP_SIZE)
|
|
|
|
/sbin/mkswap $(SWAP_FILE)
|
|
|
|
else
|
|
|
|
sed -i '/swap/d' $(CHROOT)/etc/fstab
|
|
|
|
endif
|
2015-02-27 21:09:13 +01:00
|
|
|
rm -f $(CHROOT)/etc/resolv.conf
|
|
|
|
cp -L /etc/resolv.conf $(CHROOT)/etc/resolv.conf
|
2015-02-27 23:05:17 +01:00
|
|
|
touch $(PREPROOT)
|
2010-07-10 20:04:04 +02:00
|
|
|
|
2013-08-26 23:21:17 +02:00
|
|
|
stage3-$(ARCH)-latest.tar.bz2:
|
2015-02-22 16:32:16 +01:00
|
|
|
@scripts/echo You do not have a stage3 tarball. Consider \"make sync_stage3\"
|
2013-08-26 23:21:17 +02:00
|
|
|
@exit 1
|
|
|
|
|
|
|
|
sync_stage3:
|
2015-02-16 19:03:44 +01:00
|
|
|
./scripts/sync-stage3.sh $(ARCH)
|
2013-08-26 23:21:17 +02:00
|
|
|
|
|
|
|
|
2015-02-27 21:37:14 +01:00
|
|
|
$(STAGE3): stage3-$(ARCH)-latest.tar.bz2
|
2010-11-06 09:41:15 +01:00
|
|
|
mkdir -p $(CHROOT)
|
2011-06-29 06:43:12 +02:00
|
|
|
ifdef stage4-exists
|
2015-03-01 02:52:49 +01:00
|
|
|
@scripts/echo Using stage4 tarball: `basename $(STAGE4_TARBALL)`
|
2013-10-13 17:56:20 +02:00
|
|
|
tar xpf "$(STAGE4_TARBALL)" -C $(CHROOT)
|
2011-06-29 06:43:12 +02:00
|
|
|
else
|
2014-06-09 04:26:17 +02:00
|
|
|
@scripts/echo Using stage3 tarball
|
2013-10-13 17:56:20 +02:00
|
|
|
tar xpf stage3-$(ARCH)-latest.tar.bz2 -C $(CHROOT)
|
2011-06-29 06:43:12 +02:00
|
|
|
endif
|
2015-02-22 16:32:16 +01:00
|
|
|
rm -f $(CHROOT)/etc/localtime
|
2015-02-27 21:37:14 +01:00
|
|
|
touch $(STAGE3)
|
2010-07-10 20:04:04 +02:00
|
|
|
|
2015-02-27 21:44:52 +01:00
|
|
|
$(COMPILE_OPTIONS): $(STAGE3) $(PORTAGE_DIR) configs/make.conf.$(ARCH) configs/locale.gen $(PACKAGE_FILES)
|
2014-06-09 04:26:17 +02:00
|
|
|
cp configs/make.conf.$(ARCH) $(CHROOT)/etc/portage/make.conf
|
2012-12-10 19:13:55 +01:00
|
|
|
echo ACCEPT_KEYWORDS=$(ACCEPT_KEYWORDS) >> $(CHROOT)/etc/portage/make.conf
|
2014-06-09 04:26:17 +02:00
|
|
|
-[ -f "appliances/$(APPLIANCE)/make.conf" ] && cat "appliances/$(APPLIANCE)/make.conf" >> $(CHROOT)/etc/portage/make.conf
|
2013-07-22 15:13:55 +02:00
|
|
|
$(inroot) eselect profile set 1
|
2014-06-09 04:26:17 +02:00
|
|
|
cp configs/locale.gen $(CHROOT)/etc/locale.gen
|
2011-02-25 05:20:38 +01:00
|
|
|
$(inroot) locale-gen
|
2015-02-28 23:20:50 +01:00
|
|
|
for f in $(PACKAGE_FILES); do \
|
|
|
|
base=`basename $$f` ; \
|
|
|
|
mkdir -p $(CHROOT)/etc/portage/$$base; \
|
|
|
|
cp $$f $(CHROOT)/etc/portage/$$base/virtual-appliance-$$base; \
|
|
|
|
done
|
2015-02-27 21:44:52 +01:00
|
|
|
touch $(COMPILE_OPTIONS)
|
2010-07-10 20:04:04 +02:00
|
|
|
|
2015-02-27 22:20:43 +01:00
|
|
|
$(KERNEL): $(COMPILE_OPTIONS) $(KERNEL_CONFIG) scripts/kernel.sh
|
2011-02-05 06:06:23 +01:00
|
|
|
ifneq ($(EXTERNAL_KERNEL),YES)
|
2014-06-09 04:26:17 +02:00
|
|
|
@scripts/echo Configuring kernel
|
2011-06-29 06:43:12 +02:00
|
|
|
cp $(KERNEL_CONFIG) $(CHROOT)/root/kernel.config
|
2015-02-22 16:32:16 +01:00
|
|
|
cp scripts/kernel.sh $(CHROOT)/root/kernel.sh
|
2015-02-27 22:20:43 +01:00
|
|
|
$(inroot) --setenv=KERNEL=$(KERNEL_PKG) \
|
2015-02-22 16:32:16 +01:00
|
|
|
--setenv=EMERGE="$(EMERGE)" \
|
|
|
|
--setenv=USEPKG="$(USEPKG)" \
|
|
|
|
--setenv=MAKEOPTS="$(MAKEOPTS)" \
|
|
|
|
/bin/sh /root/kernel.sh
|
|
|
|
rm -f $(CHROOT)/root/kernel.sh
|
2011-02-05 06:06:23 +01:00
|
|
|
endif
|
2015-02-27 22:20:43 +01:00
|
|
|
touch $(KERNEL)
|
2010-07-09 05:22:37 +02:00
|
|
|
|
2015-03-01 02:06:24 +01:00
|
|
|
$(SYSTOOLS): $(PREPROOT) $(COMPILE_OPTIONS)
|
2014-06-09 04:26:17 +02:00
|
|
|
@scripts/echo Installing standard system tools
|
2015-02-22 16:32:16 +01:00
|
|
|
-$(inroot) $(EMERGE) --unmerge sys-fs/udev
|
2015-03-13 12:31:00 +01:00
|
|
|
$(inroot) $(EMERGE) $(USEPKG) --noreplace --oneshot sys-apps/systemd
|
2015-02-22 16:32:16 +01:00
|
|
|
$(inroot) systemd-firstboot \
|
|
|
|
--timezone=$(TIMEZONE) \
|
|
|
|
--hostname=$(HOSTNAME) \
|
|
|
|
--root-password=
|
2015-09-26 22:57:49 +02:00
|
|
|
$(inroot) eselect locale set $(LOCALE)
|
2011-04-06 16:25:05 +02:00
|
|
|
ifeq ($(DASH),YES)
|
2012-12-16 16:49:21 +01:00
|
|
|
if ! test -e "$(STAGE4_TARBALL)"; \
|
2015-03-13 12:31:00 +01:00
|
|
|
then $(inroot) $(EMERGE) --noreplace $(USEPKG) app-shells/dash; \
|
Baselayout-2/openrc compatibility and stage4 tarballs.
The first major change here is the support of baselayout-2/openrc. So far
Gentoo has not released a stage3 tarball with baselayout-2, but I've tested
this enough that I feel it works even when doing an upgrade. The
baselayout-1 stuff has been converted, however it is recommended to not use
this until baselayout-2 is available in Gentoo stage3s as I don't want to
support converting, or you can do this:
stage4 tarball support. I'm not sure why I didn't support this before.
Now not only can stage4 tarballs be build, instead of or in addition to
virtual appliance images, but stage4 tarballs can also be used in lieu of a
stage3. There is a new "stage4" make target, and also when building the
Makefile will first look for stage4/<appliance>-stage4.tar.bz2 and if that
exists use it instead of the Gentoo stage3. If you specify stage4 as a
target and also already have a stage4, then the Makefile will unpack the
stage4 into the chroot, perform updates, and then re-create the stage4
based on the updates (atomically). In addition there is a new Makefile
variable, SOFTWARE. The default value is "1" meaning it will call the
software target (thereby installing/updatein software), but if you set
SOFTWARE=0, then the software phase will not be run. This can allow, for
example, to build a VM image from a stage4 without performing software
updates, in effect a straight stage4 to image for quick image building.
Since most appliances are pretty much based on the "base" appliance, one
could imply copy the base stage4 to the new appliance stage4 and start from
there, instead of having to start from a vanilla stage3, for example:
# cp stage4/base-stage4.tar.bz2 stage4/kde-stage4.tar.bz2
# make APPLIANCE=kde stage4
Will take the already existing base stage4 and simply update it to kde,
which will be easier/faster than starting from a stage3.
There are still some tweaks that need to be done for the stage4 support.
Specifically Makefile targets need to be written with the assumption that
they may be called more than once (e.g. updating a stage4 or going from
stage4 to image with SOFTWARE=1). For the most part things work according
to that assumption, but there are a few things that need to be tweeked,
such as the inittab settings if one is building a "headed" image but it's
based off a headless stage4. New appliance authors should also write their
"preinstall" and "postinstall" targets with the assmption that it may be
called more than once.
2011-05-18 02:44:04 +02:00
|
|
|
echo /bin/dash >> $(CHROOT)/etc/shells; \
|
2012-12-16 16:49:21 +01:00
|
|
|
$(inroot) chsh -s /bin/sh root; \
|
Baselayout-2/openrc compatibility and stage4 tarballs.
The first major change here is the support of baselayout-2/openrc. So far
Gentoo has not released a stage3 tarball with baselayout-2, but I've tested
this enough that I feel it works even when doing an upgrade. The
baselayout-1 stuff has been converted, however it is recommended to not use
this until baselayout-2 is available in Gentoo stage3s as I don't want to
support converting, or you can do this:
stage4 tarball support. I'm not sure why I didn't support this before.
Now not only can stage4 tarballs be build, instead of or in addition to
virtual appliance images, but stage4 tarballs can also be used in lieu of a
stage3. There is a new "stage4" make target, and also when building the
Makefile will first look for stage4/<appliance>-stage4.tar.bz2 and if that
exists use it instead of the Gentoo stage3. If you specify stage4 as a
target and also already have a stage4, then the Makefile will unpack the
stage4 into the chroot, perform updates, and then re-create the stage4
based on the updates (atomically). In addition there is a new Makefile
variable, SOFTWARE. The default value is "1" meaning it will call the
software target (thereby installing/updatein software), but if you set
SOFTWARE=0, then the software phase will not be run. This can allow, for
example, to build a VM image from a stage4 without performing software
updates, in effect a straight stage4 to image for quick image building.
Since most appliances are pretty much based on the "base" appliance, one
could imply copy the base stage4 to the new appliance stage4 and start from
there, instead of having to start from a vanilla stage3, for example:
# cp stage4/base-stage4.tar.bz2 stage4/kde-stage4.tar.bz2
# make APPLIANCE=kde stage4
Will take the already existing base stage4 and simply update it to kde,
which will be easier/faster than starting from a stage3.
There are still some tweaks that need to be done for the stage4 support.
Specifically Makefile targets need to be written with the assumption that
they may be called more than once (e.g. updating a stage4 or going from
stage4 to image with SOFTWARE=1). For the most part things work according
to that assumption, but there are a few things that need to be tweeked,
such as the inittab settings if one is building a "headed" image but it's
based off a headless stage4. New appliance authors should also write their
"preinstall" and "postinstall" targets with the assmption that it may be
called more than once.
2011-05-18 02:44:04 +02:00
|
|
|
fi
|
|
|
|
$(inroot) ln -sf dash /bin/sh
|
2011-06-27 12:43:59 +02:00
|
|
|
endif
|
2015-02-27 23:25:56 +01:00
|
|
|
touch $(SYSTOOLS)
|
2010-07-10 20:04:04 +02:00
|
|
|
|
2015-02-27 23:05:17 +01:00
|
|
|
$(GRUB): $(PREPROOT) configs/grub.conf $(KERNEL) scripts/grub-headless.sed
|
2011-02-05 06:06:23 +01:00
|
|
|
ifneq ($(EXTERNAL_KERNEL),YES)
|
2014-06-09 04:26:17 +02:00
|
|
|
@scripts/echo Installing Grub
|
2012-12-10 19:13:55 +01:00
|
|
|
$(inroot) $(EMERGE) -nN $(USEPKG) sys-boot/grub-static
|
2014-06-09 04:26:17 +02:00
|
|
|
cp configs/grub.conf $(CHROOT)/boot/grub/grub.conf
|
2011-06-29 06:43:12 +02:00
|
|
|
ifeq ($(VIRTIO),YES)
|
|
|
|
sed -i 's/sda/vda/' $(CHROOT)/boot/grub/grub.conf
|
|
|
|
endif
|
|
|
|
ifeq ($(HEADLESS),YES)
|
2014-06-09 04:26:17 +02:00
|
|
|
sed -i -f scripts/grub-headless.sed $(CHROOT)/boot/grub/grub.conf
|
2011-06-29 06:43:12 +02:00
|
|
|
endif
|
2011-02-05 06:06:23 +01:00
|
|
|
endif
|
2015-02-22 16:32:16 +01:00
|
|
|
$(inroot) ln -nsf /run/systemd/resolve/resolv.conf /etc/resolv.conf
|
2015-02-27 22:35:15 +01:00
|
|
|
touch $(GRUB)
|
2010-07-09 05:22:37 +02:00
|
|
|
|
2015-03-01 02:31:55 +01:00
|
|
|
|
|
|
|
$(SOFTWARE): $(STAGE3) $(SYSTOOLS) configs/eth.network configs/issue $(WORLD)
|
2014-06-09 04:26:17 +02:00
|
|
|
@scripts/echo Building $(APPLIANCE)-specific software
|
|
|
|
$(MAKE) -C appliances/$(APPLIANCE) preinstall
|
2010-11-06 22:49:19 +01:00
|
|
|
|
2015-12-17 22:25:03 +01:00
|
|
|
cp $(WORLD) $(CHROOT)/var/tmp/world
|
|
|
|
$(inroot) xargs -a/var/tmp/world -d'\n' -r $(EMERGE) $(USEPKG) --update --newuse --deep
|
2015-02-22 16:32:16 +01:00
|
|
|
-$(gcc_config)
|
2010-11-06 22:49:19 +01:00
|
|
|
|
2015-02-22 16:32:16 +01:00
|
|
|
@scripts/echo Running @preserved-rebuild
|
|
|
|
$(inroot) $(EMERGE) --usepkg=n @preserved-rebuild
|
2010-11-06 22:49:19 +01:00
|
|
|
|
2014-06-09 04:26:17 +02:00
|
|
|
cp configs/issue $(CHROOT)/etc/issue
|
2015-02-22 16:32:16 +01:00
|
|
|
-$(gcc_config)
|
2011-02-25 05:20:38 +01:00
|
|
|
$(inroot) $(EMERGE) $(USEPKG) --update --newuse --deep world
|
|
|
|
$(inroot) $(EMERGE) --depclean --with-bdeps=n
|
2015-02-22 16:32:16 +01:00
|
|
|
-$(gcc_config)
|
2015-04-10 11:25:44 +02:00
|
|
|
$(inroot) --setenv EDITOR=/usr/bin/nano etc-update
|
2014-06-09 04:26:17 +02:00
|
|
|
$(MAKE) -C appliances/$(APPLIANCE) postinstall
|
2015-02-22 16:32:16 +01:00
|
|
|
cp configs/eth.network $(CHROOT)/etc/systemd/network/eth.network
|
|
|
|
$(inroot) systemctl enable systemd-networkd.service
|
|
|
|
$(inroot) systemctl enable systemd-resolved.service
|
2011-06-29 06:43:12 +02:00
|
|
|
ifeq ($(ENABLE_SSHD),YES)
|
2015-02-22 16:32:16 +01:00
|
|
|
$(inroot) systemctl enable sshd.service
|
2011-06-29 06:43:12 +02:00
|
|
|
endif
|
2010-12-20 05:04:11 +01:00
|
|
|
$(change_password)
|
2011-07-18 00:10:57 +02:00
|
|
|
ifeq ($(DASH),YES)
|
2015-03-13 12:31:00 +01:00
|
|
|
$(inroot) $(EMERGE) --depclean app-shells/bash
|
2011-07-18 00:10:57 +02:00
|
|
|
endif
|
2011-06-23 03:42:59 +02:00
|
|
|
ifneq ($(PKGLIST),0)
|
2011-06-27 12:43:59 +02:00
|
|
|
echo \# > $(LST_FILE)
|
|
|
|
echo \# Gentoo Virtual Appliance \"$(APPLIANCE)\" package list >> $(LST_FILE)
|
|
|
|
echo \# Generated `date -u` >> $(LST_FILE)
|
|
|
|
echo \# >> $(LST_FILE)
|
2015-09-03 16:11:01 +02:00
|
|
|
(cd "$(CHROOT)"/var/db/pkg ; /bin/ls -1d */* | grep -v '^virtual/') >> $(LST_FILE)
|
2011-06-23 03:42:59 +02:00
|
|
|
endif
|
2015-02-27 22:46:57 +01:00
|
|
|
touch $(SOFTWARE)
|
2010-07-09 05:22:37 +02:00
|
|
|
|
|
|
|
|
2015-02-28 23:27:39 +01:00
|
|
|
$(RAW_IMAGE): $(STAGE4_TARBALL) scripts/grub.shell scripts/motd.sh
|
2015-03-01 02:52:49 +01:00
|
|
|
@scripts/echo Installing files to `basename $(RAW_IMAGE)`
|
2015-02-28 23:27:39 +01:00
|
|
|
qemu-img create -f raw $(RAW_IMAGE).tmp $(DISK_SIZE)
|
|
|
|
parted -s $(RAW_IMAGE).tmp mklabel gpt
|
|
|
|
parted -s $(RAW_IMAGE).tmp mkpart primary 1 $(DISK_SIZE)
|
|
|
|
parted -s $(RAW_IMAGE).tmp set 1 boot on
|
|
|
|
sync
|
|
|
|
losetup --show --find --partscan $(RAW_IMAGE).tmp > partitions
|
|
|
|
mkfs.ext4 -O sparse_super,^has_journal -L "$(APPLIANCE)"_root -m 0 `cat partitions`p1
|
2015-02-22 16:32:16 +01:00
|
|
|
mkdir $(CHROOT)
|
|
|
|
mount -o noatime `cat partitions`p1 $(CHROOT)
|
|
|
|
tar -xf $(STAGE4_TARBALL) --numeric-owner $(COPY_ARGS) -C $(CHROOT)
|
|
|
|
scripts/motd.sh $(EXTERNAL_KERNEL) $(VIRTIO) $(DISK_SIZE) $(SWAP_SIZE) $(DASH) $(ARCH) > $(CHROOT)/etc/motd
|
2011-02-05 06:06:23 +01:00
|
|
|
ifneq ($(EXTERNAL_KERNEL),YES)
|
2015-02-28 23:27:39 +01:00
|
|
|
echo '(hd0) ' $(RAW_IMAGE).tmp > device-map
|
2015-02-22 16:32:16 +01:00
|
|
|
$(CHROOT)/sbin/grub --device-map=device-map --no-floppy --batch < scripts/grub.shell
|
2011-02-05 06:06:23 +01:00
|
|
|
endif
|
2015-02-28 23:27:39 +01:00
|
|
|
umount $(CHROOT)
|
2015-02-22 16:32:16 +01:00
|
|
|
rmdir $(CHROOT)
|
2014-06-11 17:59:57 +02:00
|
|
|
sync
|
|
|
|
losetup --detach `cat partitions`
|
2014-08-30 20:12:04 +02:00
|
|
|
rm -f partitions device-map
|
2015-02-28 23:27:39 +01:00
|
|
|
mv $(RAW_IMAGE).tmp $(RAW_IMAGE)
|
2010-07-09 05:22:37 +02:00
|
|
|
|
2015-02-28 23:30:01 +01:00
|
|
|
$(QCOW_IMAGE): $(RAW_IMAGE)
|
2015-03-01 02:52:49 +01:00
|
|
|
@scripts/echo Creating `basename $(QCOW_IMAGE)`
|
2015-02-22 16:32:16 +01:00
|
|
|
qemu-img convert -f raw -O qcow2 -c $(RAW_IMAGE) $(QCOW_IMAGE).tmp
|
|
|
|
mv $(QCOW_IMAGE).tmp $(QCOW_IMAGE)
|
2010-07-09 05:22:37 +02:00
|
|
|
|
|
|
|
qcow: $(QCOW_IMAGE)
|
|
|
|
|
2015-02-28 23:30:01 +01:00
|
|
|
$(XVA_IMAGE): $(RAW_IMAGE)
|
2015-03-01 02:52:49 +01:00
|
|
|
@scripts/echo Creating `basename $(XVA_IMAGE)`
|
2011-06-23 15:09:41 +02:00
|
|
|
xva.py --disk=$(RAW_IMAGE) --is-hvm --memory=256 --vcpus=1 --name=$(APPLIANCE) \
|
2015-02-22 16:32:16 +01:00
|
|
|
--filename=$(XVA_IMAGE).tmp
|
|
|
|
mv $(XVA_IMAGE).tmp $(XVA_IMAGE)
|
2011-06-23 15:09:41 +02:00
|
|
|
|
|
|
|
xva: $(XVA_IMAGE)
|
|
|
|
|
2010-07-09 05:22:37 +02:00
|
|
|
|
2015-02-28 23:30:01 +01:00
|
|
|
$(VMDK_IMAGE): $(RAW_IMAGE)
|
2015-03-01 02:52:49 +01:00
|
|
|
@scripts/echo Creating `basename $(VMDK_IMAGE)`
|
2015-02-22 16:32:16 +01:00
|
|
|
qemu-img convert -f raw -O vmdk $(RAW_IMAGE) $(VMDK_IMAGE).tmp
|
|
|
|
mv $(VMDK_IMAGE).tmp $(VMDK_IMAGE)
|
2010-07-09 05:22:37 +02:00
|
|
|
|
|
|
|
vmdk: $(VMDK_IMAGE)
|
|
|
|
|
2015-03-01 13:46:18 +01:00
|
|
|
$(STAGE4_TARBALL): $(PORTAGE_DIR) stage3-$(ARCH)-latest.tar.bz2 appliances/$(APPLIANCE) configs/rsync-excludes
|
2015-02-28 23:35:45 +01:00
|
|
|
$(MAKE) $(STAGE3)
|
|
|
|
$(MAKE) $(PREPROOT)
|
|
|
|
$(MAKE) $(SOFTWARE)
|
|
|
|
$(MAKE) $(KERNEL)
|
|
|
|
$(MAKE) $(GRUB)
|
2015-03-01 02:52:49 +01:00
|
|
|
@scripts/echo Creating stage4 tarball: `basename $(STAGE4_TARBALL)`
|
2015-02-22 16:32:16 +01:00
|
|
|
mkdir -p $(IMAGES)
|
|
|
|
tar -acf "$(STAGE4_TARBALL).tmp.xz" --numeric-owner $(COPY_ARGS) -C $(CHROOT) --one-file-system .
|
2012-11-15 14:30:30 +01:00
|
|
|
mv "$(STAGE4_TARBALL).tmp.xz" "$(STAGE4_TARBALL)"
|
2015-02-28 23:35:45 +01:00
|
|
|
$(MAKE) clean
|
Baselayout-2/openrc compatibility and stage4 tarballs.
The first major change here is the support of baselayout-2/openrc. So far
Gentoo has not released a stage3 tarball with baselayout-2, but I've tested
this enough that I feel it works even when doing an upgrade. The
baselayout-1 stuff has been converted, however it is recommended to not use
this until baselayout-2 is available in Gentoo stage3s as I don't want to
support converting, or you can do this:
stage4 tarball support. I'm not sure why I didn't support this before.
Now not only can stage4 tarballs be build, instead of or in addition to
virtual appliance images, but stage4 tarballs can also be used in lieu of a
stage3. There is a new "stage4" make target, and also when building the
Makefile will first look for stage4/<appliance>-stage4.tar.bz2 and if that
exists use it instead of the Gentoo stage3. If you specify stage4 as a
target and also already have a stage4, then the Makefile will unpack the
stage4 into the chroot, perform updates, and then re-create the stage4
based on the updates (atomically). In addition there is a new Makefile
variable, SOFTWARE. The default value is "1" meaning it will call the
software target (thereby installing/updatein software), but if you set
SOFTWARE=0, then the software phase will not be run. This can allow, for
example, to build a VM image from a stage4 without performing software
updates, in effect a straight stage4 to image for quick image building.
Since most appliances are pretty much based on the "base" appliance, one
could imply copy the base stage4 to the new appliance stage4 and start from
there, instead of having to start from a vanilla stage3, for example:
# cp stage4/base-stage4.tar.bz2 stage4/kde-stage4.tar.bz2
# make APPLIANCE=kde stage4
Will take the already existing base stage4 and simply update it to kde,
which will be easier/faster than starting from a stage3.
There are still some tweaks that need to be done for the stage4 support.
Specifically Makefile targets need to be written with the assumption that
they may be called more than once (e.g. updating a stage4 or going from
stage4 to image with SOFTWARE=1). For the most part things work according
to that assumption, but there are a few things that need to be tweeked,
such as the inittab settings if one is building a "headed" image but it's
based off a headless stage4. New appliance authors should also write their
"preinstall" and "postinstall" targets with the assmption that it may be
called more than once.
2011-05-18 02:44:04 +02:00
|
|
|
|
2015-02-28 23:35:45 +01:00
|
|
|
stage4: $(STAGE4_TARBALL)
|
Baselayout-2/openrc compatibility and stage4 tarballs.
The first major change here is the support of baselayout-2/openrc. So far
Gentoo has not released a stage3 tarball with baselayout-2, but I've tested
this enough that I feel it works even when doing an upgrade. The
baselayout-1 stuff has been converted, however it is recommended to not use
this until baselayout-2 is available in Gentoo stage3s as I don't want to
support converting, or you can do this:
stage4 tarball support. I'm not sure why I didn't support this before.
Now not only can stage4 tarballs be build, instead of or in addition to
virtual appliance images, but stage4 tarballs can also be used in lieu of a
stage3. There is a new "stage4" make target, and also when building the
Makefile will first look for stage4/<appliance>-stage4.tar.bz2 and if that
exists use it instead of the Gentoo stage3. If you specify stage4 as a
target and also already have a stage4, then the Makefile will unpack the
stage4 into the chroot, perform updates, and then re-create the stage4
based on the updates (atomically). In addition there is a new Makefile
variable, SOFTWARE. The default value is "1" meaning it will call the
software target (thereby installing/updatein software), but if you set
SOFTWARE=0, then the software phase will not be run. This can allow, for
example, to build a VM image from a stage4 without performing software
updates, in effect a straight stage4 to image for quick image building.
Since most appliances are pretty much based on the "base" appliance, one
could imply copy the base stage4 to the new appliance stage4 and start from
there, instead of having to start from a vanilla stage3, for example:
# cp stage4/base-stage4.tar.bz2 stage4/kde-stage4.tar.bz2
# make APPLIANCE=kde stage4
Will take the already existing base stage4 and simply update it to kde,
which will be easier/faster than starting from a stage3.
There are still some tweaks that need to be done for the stage4 support.
Specifically Makefile targets need to be written with the assumption that
they may be called more than once (e.g. updating a stage4 or going from
stage4 to image with SOFTWARE=1). For the most part things work according
to that assumption, but there are a few things that need to be tweeked,
such as the inittab settings if one is building a "headed" image but it's
based off a headless stage4. New appliance authors should also write their
"preinstall" and "postinstall" targets with the assmption that it may be
called more than once.
2011-05-18 02:44:04 +02:00
|
|
|
|
|
|
|
|
2015-02-27 21:44:52 +01:00
|
|
|
eclean: $(COMPILE_OPTIONS)
|
2015-03-13 12:31:00 +01:00
|
|
|
$(inroot) $(EMERGE) $(USEPKG) --oneshot --noreplace app-portage/gentoolkit
|
2015-02-22 16:32:16 +01:00
|
|
|
$(inroot) eclean-pkg
|
|
|
|
$(inroot) eclean-dist
|
|
|
|
$(inroot) $(EMERGE) --depclean app-portage/gentoolkit
|
|
|
|
$(MAKE) clean
|
2010-07-09 05:22:37 +02:00
|
|
|
|
2010-11-06 09:41:15 +01:00
|
|
|
|
2015-02-22 16:32:16 +01:00
|
|
|
clean:
|
2015-03-15 13:56:18 +01:00
|
|
|
rm -f partitions device-map $(IMAGES)/*.tmp
|
2015-02-22 16:32:16 +01:00
|
|
|
rm -rf --one-file-system -- $(CHROOT)
|
2010-07-09 05:22:37 +02:00
|
|
|
|
|
|
|
realclean: clean
|
I learned a lot about Makefiles :D
So, basically I re-architeched things a bit:
The appliance/Makefile.inc fiels are now appliance/Makefile (again). The
main Makefile will call "make -C appliance preinstall" and "postinstall"
(and in future "clean"). So I got rid of the ugly make variables/include
thing. Some of the main Makefile's variables are exported to the
sub-makes. Appliances don't really need $(APPLIANCE) anymore as the
appliance directory is their CWD.
Added some new targets and smarter targets. I can do more with this, but
it's a big improvment from last time. Still learning a lot of Makefile
magic (been reading other people's Makefiles).
Verified that "make -j3" works (at least on the base appliance) but will
kill your hard drive :D
Introduced "profiles" Which are files with variables you want to override.
The file will be "include"ed by the main Makefile. For example, I have a
file, "local.cfg" that looks like this:
--- 8< -----------------------------
CHROOT = /var/scratch/marduk/vabuild
HEADLESS = YES
PRUNE_CRITICAL = NO
VIRTIO = YES
TIMEZONE = EST5EDT
DISK_SIZE = 60.0G
SWAP_SIZE = 48
PKGDIR = /var/scratch/packages
NBD_DEV = /dev/nbd8
all: qcow
--- 8< ------------------------------
Then, e.g. i can run "make PROFILE=local APPLIANCE=kde". If you don't
specify a PROFILE variable, then it will default to the empty string, which
means the main Makefile will attempt to include .cfg
So, for example i have:
$ ln -s local.cfg .cfg
$ make APPLIANCE=kde
Don't set PROFILE inside your .cfg file (why would you?). Also, if the
[pro]file does not exist, the include fails silently.
I will put this info in the wiki eventually...
2010-11-14 00:22:18 +01:00
|
|
|
${RM} $(RAW_IMAGE) $(QCOW_IMAGE) $(VMDK_IMAGE)
|
2010-11-05 13:06:13 +01:00
|
|
|
|
2010-11-06 23:46:07 +01:00
|
|
|
distclean:
|
2015-02-22 16:32:16 +01:00
|
|
|
rm -f -- *.qcow *.img *.vmdk
|
2010-11-06 23:46:07 +01:00
|
|
|
rm -f latest-stage3.txt stage3-*-latest.tar.bz2
|
2013-08-25 11:24:46 +02:00
|
|
|
rm -f portage-snapshot.tar.bz2
|
2010-11-06 23:46:07 +01:00
|
|
|
|
2014-06-09 04:26:17 +02:00
|
|
|
appliance-list:
|
|
|
|
@scripts/echo 'Available appliances:'
|
2015-03-09 12:20:14 +01:00
|
|
|
@/bin/ls -1 appliances
|
2014-06-09 04:26:17 +02:00
|
|
|
|
2015-03-16 03:08:25 +01:00
|
|
|
|
|
|
|
checksums:
|
2015-12-10 18:17:21 +01:00
|
|
|
@scripts/echo 'Calculating checksums'
|
2015-09-14 13:09:15 +02:00
|
|
|
$(RM) $(CHECKSUMS)
|
|
|
|
cd $(IMAGES) && sha256sum --binary * > $(CHECKSUMS).tmp
|
2015-08-02 20:15:26 +02:00
|
|
|
mv $(CHECKSUMS).tmp $(CHECKSUMS)
|
2015-03-16 03:08:25 +01:00
|
|
|
|
2015-12-09 19:15:09 +01:00
|
|
|
shell: $(PREPROOT)
|
2015-12-10 18:17:21 +01:00
|
|
|
@scripts/echo 'Entering interactive shell for the $(APPLIANCE) build.'
|
|
|
|
@scripts/echo 'Type "exit" or "^D" to leave'
|
2015-12-09 19:15:09 +01:00
|
|
|
$(inroot)
|
2015-12-10 18:17:50 +01:00
|
|
|
rm -f $(CHROOT)/root/.bash_history
|
2015-12-09 19:15:09 +01:00
|
|
|
|
2013-09-17 01:26:48 +02:00
|
|
|
help:
|
2014-06-09 04:26:17 +02:00
|
|
|
@scripts/echo 'Help targets (this is not a comprehensive list)'
|
2013-09-17 01:26:48 +02:00
|
|
|
@echo
|
|
|
|
@echo 'sync_portage - Download the latest portage snapshot'
|
|
|
|
@echo 'sync_stage3 - Download the latest stage3 tarball'
|
|
|
|
@echo 'stage4 - Build a stage4 tarball'
|
|
|
|
@echo 'clean - Unmount chroot and clean directory'
|
2015-03-15 13:56:38 +01:00
|
|
|
@echo 'eclean - Clean outdated packages and distfiles'
|
2013-09-17 01:26:48 +02:00
|
|
|
@echo 'realclean - Clean and remove image files'
|
2015-12-09 19:15:09 +01:00
|
|
|
@echo 'shell - Enter a shell in the build environment'
|
2014-06-09 04:26:17 +02:00
|
|
|
@scripts/echo 'Images'
|
2013-09-17 01:26:48 +02:00
|
|
|
@echo 'image - Build a raw VM image from stage4'
|
|
|
|
@echo 'qcow - Build a qcow VM image from a raw image'
|
|
|
|
@echo 'vmdk - Build a vmdk image from a raw image'
|
|
|
|
@echo 'xva - Build an xva image from a raw image'
|
2014-06-09 04:26:17 +02:00
|
|
|
@echo 'appliance-list - List built-in appliances'
|
|
|
|
@echo 'help - Show this help'
|
|
|
|
@scripts/echo 'Variables'
|
2013-09-17 01:26:48 +02:00
|
|
|
@echo 'APPLIANCE= - The appliance to build'
|
|
|
|
@echo 'HOSTNAME= - Hostname to give appliance'
|
|
|
|
@echo 'TIMEZONE= - Timezone to set for the appliance'
|
|
|
|
@echo 'CHROOT= - The directory to build the chroot'
|
|
|
|
@echo 'DISK_SIZE= - Size of the disk image'
|
|
|
|
@echo 'SWAP_SIZE= - Size of the swap file'
|
|
|
|
@echo 'ARCH= - Architecture to build for (x86 or amd64)'
|
|
|
|
@echo 'VIRTIO=YES - Configure the stage2/image to use virtio'
|
|
|
|
@echo 'EXTERNAL_KERNEL=YES - Do not build a kernel in the image'
|
|
|
|
@echo 'HEADLESS=YES - Build a headless (serial console) image.'
|
|
|
|
@echo 'ENABLE_SSHD=YES - Enable sshd to start automatically in the image'
|
|
|
|
@echo
|
2014-06-09 04:26:17 +02:00
|
|
|
@scripts/echo 'Example'
|
2013-09-17 01:26:48 +02:00
|
|
|
@echo 'make APPLIANCE=mongodb HEADLESS=YES VIRTIO=YES stage4 qcow clean'
|
|
|
|
|
2015-08-08 00:34:42 +02:00
|
|
|
.PHONY: qcow vmdk clean realclean distclean stage4 image stage4 help appliance-list eclean sync_portage sync_stage3 checksums
|