2011-07-07 03:40:20 +02:00
|
|
|
APPLIANCE ?= base
|
2015-09-14 12:00:37 +02:00
|
|
|
VABUILDER_OUTPUT := $(CURDIR)
|
2018-12-02 05:46:12 +01:00
|
|
|
CHROOT := $(VABUILDER_OUTPUT)/build/$(APPLIANCE)
|
2018-10-27 08:26:16 +02:00
|
|
|
VA_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
|
2018-10-27 08:24:05 +02:00
|
|
|
VA_ARCH = amd64
|
|
|
|
KERNEL_CONFIG = configs/kernel.config.$(VA_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
|
2018-10-27 21:01:37 +02:00
|
|
|
EMERGE = emerge --jobs=$(shell nproc --all)
|
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
|
|
|
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
|
|
|
|
2018-12-02 05:46:12 +01:00
|
|
|
# /etc/portage targets
|
|
|
|
base_etc_portage := $(wildcard configs/portage/*)
|
|
|
|
etc_portage := $(patsubst configs/portage/%,$(CHROOT)/etc/portage/%,$(base_etc_portage))
|
|
|
|
appliance_package_files := $(wildcard appliances/$(APPLIANCE)/package.*)
|
|
|
|
portage_package_files = $(patsubst appliances/$(APPLIANCE)/package.%,$(CHROOT)/etc/portage/package.%/01$(APPLIANCE),$(appliance_package_files))
|
|
|
|
appliance_make_conf = $(wildcard appliances/$(APPLIANCE)/make.conf)
|
|
|
|
portage_make_conf_local = $(CHROOT)/etc/portage/make.conf.local
|
|
|
|
|
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
|
|
|
|
|
2018-10-27 20:04:00 +02:00
|
|
|
PATH := $(CURDIR)/scripts:$(PATH)
|
|
|
|
|
|
|
|
export PATH CHROOT container PORTAGE_DIR VA_PKGDIR DISTDIR VA_ARCH
|
2015-09-14 12:16:56 +02:00
|
|
|
|
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 \
|
2018-10-27 08:26:16 +02:00
|
|
|
--bind=$(VA_PKGDIR):/usr/portage/packages \
|
2015-02-22 16:32:16 +01:00
|
|
|
--bind=$(DISTDIR):/usr/portage/distfiles
|
|
|
|
|
2018-10-27 08:24:05 +02:00
|
|
|
ifeq ($(VA_ARCH),x86)
|
2012-12-21 20:12:25 +01:00
|
|
|
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
|
2018-10-27 20:04:00 +02:00
|
|
|
change_password = RUN usermod --password '$(ROOT_PASSWORD)' root
|
2011-01-12 04:47:14 +01:00
|
|
|
else
|
2018-10-27 20:04:00 +02:00
|
|
|
change_password = RUN passwd --delete 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
|
|
|
|
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)
|
2018-10-27 20:43:45 +02:00
|
|
|
@print Grabbing latest portage
|
2015-12-17 22:25:59 +01:00
|
|
|
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):
|
2018-10-27 20:43:45 +02:00
|
|
|
@print Grabbing the portage tree
|
2015-12-17 22:25:59 +01:00
|
|
|
git clone --depth=1 git://github.com/gentoo/gentoo.git $(PORTAGE_DIR)
|
2010-07-10 20:04:04 +02:00
|
|
|
|
2018-12-02 05:46:12 +01:00
|
|
|
$(CHROOT)/etc/portage/%: configs/portage/%
|
|
|
|
COPY --recursive $< /etc/portage/
|
|
|
|
|
|
|
|
$(PREPROOT): $(STAGE3) $(PORTAGE_DIR) configs/fstab $(etc_portage) $(portage_package_files)
|
2018-10-27 08:26:16 +02:00
|
|
|
mkdir -p $(VA_PKGDIR) $(DISTDIR)
|
2018-10-27 20:49:17 +02:00
|
|
|
COPY configs/fstab /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)
|
2018-10-27 20:49:42 +02:00
|
|
|
@print 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
|
2018-10-27 20:04:00 +02:00
|
|
|
COPY -L /etc/resolv.conf /etc/resolv.conf
|
2015-02-27 23:05:17 +01:00
|
|
|
touch $(PREPROOT)
|
2010-07-10 20:04:04 +02:00
|
|
|
|
2018-10-27 08:24:05 +02:00
|
|
|
stage3-$(VA_ARCH).tar.bz2:
|
2018-10-27 20:43:45 +02:00
|
|
|
@print You do not have a stage3 tarball. Consider \"make sync_stage3\"
|
2013-08-26 23:21:17 +02:00
|
|
|
@exit 1
|
|
|
|
|
|
|
|
sync_stage3:
|
2018-10-27 20:54:21 +02:00
|
|
|
fetch-stage3 --specialty=systemd --outfile=stage3-$(VA_ARCH).tar.bz2 $(VA_ARCH)
|
2013-08-26 23:21:17 +02:00
|
|
|
|
|
|
|
|
2018-10-27 08:24:05 +02:00
|
|
|
$(STAGE3): stage3-$(VA_ARCH).tar.bz2
|
2010-11-06 09:41:15 +01:00
|
|
|
mkdir -p $(CHROOT)
|
2011-06-29 06:43:12 +02:00
|
|
|
ifdef stage4-exists
|
2018-10-27 20:43:45 +02:00
|
|
|
@print 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
|
2018-10-27 20:43:45 +02:00
|
|
|
@print Using stage3 tarball
|
2018-10-27 08:24:05 +02:00
|
|
|
tar xpf stage3-$(VA_ARCH).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
|
|
|
|
2018-12-02 05:46:12 +01:00
|
|
|
$(CHROOT)/etc/portage/package.%/01$(APPLIANCE): appliances/$(APPLIANCE)/package.% $(STAGE3)
|
|
|
|
mkdir -p `dirname $@`
|
|
|
|
cp $< $@
|
|
|
|
|
|
|
|
$(portage_make_conf_local): $(appliance_make_conf)
|
|
|
|
COPY $< $@ || touch $@
|
|
|
|
|
|
|
|
$(COMPILE_OPTIONS): $(STAGE3) $(PORTAGE_DIR) configs/make.conf.$(VA_ARCH) configs/locale.gen $(portage_package_files) $(portage_make_conf_local)
|
2018-10-27 20:04:00 +02:00
|
|
|
COPY configs/make.conf.$(VA_ARCH) /etc/portage/make.conf
|
2012-12-10 19:13:55 +01:00
|
|
|
echo ACCEPT_KEYWORDS=$(ACCEPT_KEYWORDS) >> $(CHROOT)/etc/portage/make.conf
|
2018-10-27 20:04:00 +02:00
|
|
|
COPY configs/locale.gen /etc/locale.gen
|
|
|
|
RUN locale-gen
|
2015-02-27 21:44:52 +01:00
|
|
|
touch $(COMPILE_OPTIONS)
|
2010-07-10 20:04:04 +02:00
|
|
|
|
2016-07-24 17:08:27 +02:00
|
|
|
$(KERNEL): $(COMPILE_OPTIONS) $(KERNEL_CONFIG) scripts/build-kernel
|
2011-02-05 06:06:23 +01:00
|
|
|
ifneq ($(EXTERNAL_KERNEL),YES)
|
2018-10-27 20:43:45 +02:00
|
|
|
@print Configuring kernel
|
2018-10-27 20:04:00 +02:00
|
|
|
COPY $(KERNEL_CONFIG) /root/kernel.config
|
|
|
|
COPY scripts/build-kernel /root/build-kernel
|
|
|
|
RUN --setenv=KERNEL=$(KERNEL_PKG) \
|
|
|
|
--setenv=EMERGE="$(EMERGE)" \
|
|
|
|
--setenv=USEPKG="$(USEPKG)" \
|
|
|
|
--setenv=MAKEOPTS="$(MAKEOPTS)" \
|
|
|
|
/root/build-kernel
|
2016-07-24 17:08:27 +02:00
|
|
|
rm -f $(CHROOT)/root/build-kernel
|
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)
|
2018-10-27 20:43:45 +02:00
|
|
|
@print Installing standard system tools
|
2016-07-23 23:16:26 +02:00
|
|
|
systemd-firstboot \
|
|
|
|
--root=$(CHROOT) \
|
|
|
|
--setup-machine-id \
|
2015-02-22 16:32:16 +01:00
|
|
|
--timezone=$(TIMEZONE) \
|
|
|
|
--hostname=$(HOSTNAME) \
|
|
|
|
--root-password=
|
2018-10-27 20:04:00 +02:00
|
|
|
RUN 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)"; \
|
2018-10-27 20:04:00 +02:00
|
|
|
then RUN $(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; \
|
2018-10-27 20:04:00 +02:00
|
|
|
RUN 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
|
2018-10-27 20:04:00 +02:00
|
|
|
RUN 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
|
|
|
|
2017-05-28 00:13:01 +02:00
|
|
|
$(GRUB): $(PREPROOT) configs/grub.cfg $(KERNEL) scripts/grub-headless.sed
|
2011-02-05 06:06:23 +01:00
|
|
|
ifneq ($(EXTERNAL_KERNEL),YES)
|
2018-10-27 20:43:45 +02:00
|
|
|
@print Installing Grub
|
2018-10-27 20:25:29 +02:00
|
|
|
RUN $(EMERGE) -nN $(USEPKG) sys-boot/grub
|
2017-05-28 00:13:01 +02:00
|
|
|
mkdir -p $(CHROOT)/boot/grub
|
2018-10-27 20:25:29 +02:00
|
|
|
COPY configs/grub.cfg /boot/grub/grub.cfg
|
2011-06-29 06:43:12 +02:00
|
|
|
ifeq ($(VIRTIO),YES)
|
2017-05-28 00:13:01 +02:00
|
|
|
sed -i 's/sda/vda/' $(CHROOT)/boot/grub/grub.cfg
|
2011-06-29 06:43:12 +02:00
|
|
|
endif
|
|
|
|
ifeq ($(HEADLESS),YES)
|
2017-05-28 00:13:01 +02:00
|
|
|
sed -i -f scripts/grub-headless.sed $(CHROOT)/boot/grub/grub.cfg
|
2011-06-29 06:43:12 +02:00
|
|
|
endif
|
2011-02-05 06:06:23 +01:00
|
|
|
endif
|
2018-10-27 20:04:00 +02:00
|
|
|
ln -nsf /run/systemd/resolve/resolv.conf $(CHROOT)/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
|
|
|
|
2018-10-27 20:04:00 +02:00
|
|
|
$(SOFTWARE): $(STAGE3) $(SYSTOOLS) configs/eth.network configs/issue $(WORLD) $(PROFILE)
|
2018-10-27 20:43:45 +02:00
|
|
|
@print Building $(APPLIANCE)-specific software
|
2014-06-09 04:26:17 +02:00
|
|
|
$(MAKE) -C appliances/$(APPLIANCE) preinstall
|
2010-11-06 22:49:19 +01:00
|
|
|
|
2018-10-27 20:04:00 +02:00
|
|
|
COPY $(WORLD) /var/lib/portage/world
|
|
|
|
RUN $(EMERGE) $(USEPKG) --update --newuse --deep @system
|
2010-11-06 22:49:19 +01:00
|
|
|
|
2018-10-27 20:43:45 +02:00
|
|
|
@print Running @preserved-rebuild
|
2018-10-27 20:04:00 +02:00
|
|
|
RUN $(EMERGE) --usepkg=n @preserved-rebuild
|
2010-11-06 22:49:19 +01:00
|
|
|
|
2018-10-27 20:04:00 +02:00
|
|
|
COPY configs/issue /etc/issue
|
|
|
|
RUN $(EMERGE) $(USEPKG) --update --newuse --deep @world $(grub_package)
|
|
|
|
RUN $(EMERGE) --depclean --with-bdeps=n
|
|
|
|
RUN --setenv EDITOR=/usr/bin/nano etc-update
|
|
|
|
COPY configs/eth.network /etc/systemd/network/eth.network
|
|
|
|
RUN systemctl enable systemd-networkd.service
|
|
|
|
RUN systemctl enable systemd-resolved.service
|
2011-06-29 06:43:12 +02:00
|
|
|
ifeq ($(ENABLE_SSHD),YES)
|
2018-10-27 20:04:00 +02:00
|
|
|
RUN systemctl enable sshd.service
|
2011-06-29 06:43:12 +02:00
|
|
|
endif
|
2011-07-18 00:10:57 +02:00
|
|
|
ifeq ($(DASH),YES)
|
2018-10-27 20:04:00 +02:00
|
|
|
RUN $(EMERGE) --depclean app-shells/bash
|
2011-07-18 00:10:57 +02:00
|
|
|
endif
|
2016-12-06 03:32:58 +01:00
|
|
|
$(MAKE) -C appliances/$(APPLIANCE) postinstall
|
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
|
2018-10-27 20:43:45 +02:00
|
|
|
@print Installing files to `basename $(RAW_IMAGE)`
|
2015-02-28 23:27:39 +01:00
|
|
|
qemu-img create -f raw $(RAW_IMAGE).tmp $(DISK_SIZE)
|
2017-05-28 00:13:01 +02:00
|
|
|
parted -s $(RAW_IMAGE).tmp mklabel msdos
|
2015-02-28 23:27:39 +01:00
|
|
|
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)
|
2018-10-27 20:54:21 +02:00
|
|
|
motd.sh $(EXTERNAL_KERNEL) $(VIRTIO) $(DISK_SIZE) $(SWAP_SIZE) $(DASH) $(VA_ARCH) > $(CHROOT)/etc/motd
|
2011-02-05 06:06:23 +01:00
|
|
|
ifneq ($(EXTERNAL_KERNEL),YES)
|
2017-05-28 00:13:01 +02:00
|
|
|
echo '(hd0) ' `cat partitions` > device-map
|
|
|
|
$(CHROOT)/usr/sbin/grub-install --no-floppy --grub-mkdevicemap=device-map --directory=$(CHROOT)/usr/lib/grub/i386-pc --boot-directory=$(CHROOT)/boot `cat partitions`
|
2011-02-05 06:06:23 +01:00
|
|
|
endif
|
2018-10-27 20:04:00 +02:00
|
|
|
COPY device-map /boot/grub/device.map
|
|
|
|
RUN --bind=/dev grub-mkconfig
|
|
|
|
RUN --bind=/dev grub-mkconfig -o /boot/grub/grub.cfg
|
|
|
|
umount $(CHROOT)/boot
|
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)
|
2018-10-27 20:43:45 +02:00
|
|
|
@print 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)
|
2018-10-27 20:43:45 +02:00
|
|
|
@print 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)
|
2018-10-27 20:43:45 +02:00
|
|
|
@print 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)
|
|
|
|
|
2018-10-27 08:24:05 +02:00
|
|
|
$(STAGE4_TARBALL): $(PORTAGE_DIR) stage3-$(VA_ARCH).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)
|
2018-10-27 20:43:45 +02:00
|
|
|
@print Creating stage4 tarball: `basename $(STAGE4_TARBALL)`
|
2016-12-08 12:57:41 +01:00
|
|
|
$(change_password)
|
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)
|
2018-10-27 20:04:00 +02:00
|
|
|
RUN $(EMERGE) $(USEPKG) --oneshot --noreplace app-portage/gentoolkit
|
|
|
|
RUN eclean-pkg
|
|
|
|
RUN eclean-dist
|
|
|
|
RUN $(EMERGE) --depclean app-portage/gentoolkit
|
2015-02-22 16:32:16 +01:00
|
|
|
$(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
|
2016-08-07 12:53:09 +02:00
|
|
|
rm -f stage3-*.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:
|
2018-10-27 20:43:45 +02:00
|
|
|
@print '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:
|
2018-10-27 20:43:45 +02:00
|
|
|
@print 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)
|
2018-10-27 20:43:45 +02:00
|
|
|
@print 'Entering interactive shell for the $(APPLIANCE) build.'
|
|
|
|
@print 'Type "exit" or "^D" to leave'
|
|
|
|
@print
|
2018-10-27 20:04:00 +02:00
|
|
|
@RUN
|
2016-03-10 21:10:24 +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:
|
2018-10-27 20:43:45 +02:00
|
|
|
@print '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'
|
2018-10-27 20:43:45 +02:00
|
|
|
@print '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'
|
2018-10-27 20:43:45 +02:00
|
|
|
@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'
|
2018-10-27 08:24:05 +02:00
|
|
|
@echo 'VA_ARCH= - Architecture to build for (x86 or amd64)'
|
2013-09-17 01:26:48 +02:00
|
|
|
@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
|
2018-10-27 20:43:45 +02:00
|
|
|
@print '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
|