virtual-appliance/Makefile

397 lines
13 KiB
Makefile
Raw Normal View History

APPLIANCE ?= base
VABUILDER_OUTPUT := $(CURDIR)
CHROOT := $(VABUILDER_OUTPUT)/build/$(APPLIANCE)
2018-10-27 08:26:16 +02:00
VA_PKGDIR = $(VABUILDER_OUTPUT)/packages
The great systemd commit. This change converts the appliances from openrc to systemd. In addition, systemd needs to at least be be installed on the build machine as we now use systemd-nspawn instead of chroot/bind mounts do to the fact that systemd-nspawn is much more robust and lese prone to errors. In addition: * All stage4 tarballs and images are now stored in the images/ directory by default. * A package dir is now required and is set up in the packages/ directory by default. * The portage directory is not unpacked in the chroot every time anymore and is instead bind-mounted from a directory by systemd-nspawn. This is the portage/ directory by default. * In addition there is a distfiles/ directory (by default) which is bind-mounted in the chroot. It does what you'd probably expect. * The Makefile learned new target, eclean, which will run eclean-dist and eclean-pkg to clean out obsolete distfiles and binary packages. * The REMOVE_PORTAGE_TREE option is removed as portage is no longer installed. * The unused/untested PRUNE_CRITICAL functionality has been removed. I have no idea if it worked and if it didn't I didn't want to fix it. * As appliances are always using systemd, UDEV is no longer optional. * Timezones and hostnames are now handled by systemd (systemd-firstboot). * Stage4 tarballs are now directly importable as systemd containers (and probably docker too though I haven't tested that yet). * A number of packages (for example dhcpd, acpid) have been removed from the appliances when systemd provides equivalent functionality. * We no longer override etc-update.conf. There's no reason. * A number of Makefile targets, checkpoints, temp files, etc have been removed as they are no longer needed.
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)
IMAGES = $(VABUILDER_OUTPUT)/images
The great systemd commit. This change converts the appliances from openrc to systemd. In addition, systemd needs to at least be be installed on the build machine as we now use systemd-nspawn instead of chroot/bind mounts do to the fact that systemd-nspawn is much more robust and lese prone to errors. In addition: * All stage4 tarballs and images are now stored in the images/ directory by default. * A package dir is now required and is set up in the packages/ directory by default. * The portage directory is not unpacked in the chroot every time anymore and is instead bind-mounted from a directory by systemd-nspawn. This is the portage/ directory by default. * In addition there is a distfiles/ directory (by default) which is bind-mounted in the chroot. It does what you'd probably expect. * The Makefile learned new target, eclean, which will run eclean-dist and eclean-pkg to clean out obsolete distfiles and binary packages. * The REMOVE_PORTAGE_TREE option is removed as portage is no longer installed. * The unused/untested PRUNE_CRITICAL functionality has been removed. I have no idea if it worked and if it didn't I didn't want to fix it. * As appliances are always using systemd, UDEV is no longer optional. * Timezones and hostnames are now handled by systemd (systemd-firstboot). * Stage4 tarballs are now directly importable as systemd containers (and probably docker too though I haven't tested that yet). * A number of packages (for example dhcpd, acpid) have been removed from the appliances when systemd provides equivalent functionality. * We no longer override etc-update.conf. There's no reason. * A number of Makefile targets, checkpoints, temp files, etc have been removed as they are no longer needed.
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
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
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)
The great systemd commit. This change converts the appliances from openrc to systemd. In addition, systemd needs to at least be be installed on the build machine as we now use systemd-nspawn instead of chroot/bind mounts do to the fact that systemd-nspawn is much more robust and lese prone to errors. In addition: * All stage4 tarballs and images are now stored in the images/ directory by default. * A package dir is now required and is set up in the packages/ directory by default. * The portage directory is not unpacked in the chroot every time anymore and is instead bind-mounted from a directory by systemd-nspawn. This is the portage/ directory by default. * In addition there is a distfiles/ directory (by default) which is bind-mounted in the chroot. It does what you'd probably expect. * The Makefile learned new target, eclean, which will run eclean-dist and eclean-pkg to clean out obsolete distfiles and binary packages. * The REMOVE_PORTAGE_TREE option is removed as portage is no longer installed. * The unused/untested PRUNE_CRITICAL functionality has been removed. I have no idea if it worked and if it didn't I didn't want to fix it. * As appliances are always using systemd, UDEV is no longer optional. * Timezones and hostnames are now handled by systemd (systemd-firstboot). * Stage4 tarballs are now directly importable as systemd containers (and probably docker too though I haven't tested that yet). * A number of packages (for example dhcpd, acpid) have been removed from the appliances when systemd provides equivalent functionality. * We no longer override etc-update.conf. There's no reason. * A number of Makefile targets, checkpoints, temp files, etc have been removed as they are no longer needed.
2015-02-22 16:32:16 +01:00
MAKEOPTS = -j5 -l5.64
ENABLE_SSHD = NO
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
EXTERNAL_KERNEL = NO
PKGLIST = 0
DASH = NO
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
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
RSYNC_MIRROR = rsync://rsync.gtlib.gatech.edu/gentoo/
KERNEL_PKG = gentoo-sources
WORLD = appliances/$(APPLIANCE)/world
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
# /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
appliance_profile := default/linux/amd64/17.0/systemd
# Allow appliance to override variables
-include appliances/$(APPLIANCE)/$(APPLIANCE).cfg
# Allow user to override variables
-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
ifneq ($(profile),)
container = $(profile)-$(APPLIANCE)-build
else
container = $(APPLIANCE)-build
endif
PATH := $(CURDIR)/scripts:$(PATH)
export PATH CHROOT container PORTAGE_DIR VA_PKGDIR DISTDIR VA_ARCH
The great systemd commit. This change converts the appliances from openrc to systemd. In addition, systemd needs to at least be be installed on the build machine as we now use systemd-nspawn instead of chroot/bind mounts do to the fact that systemd-nspawn is much more robust and lese prone to errors. In addition: * All stage4 tarballs and images are now stored in the images/ directory by default. * A package dir is now required and is set up in the packages/ directory by default. * The portage directory is not unpacked in the chroot every time anymore and is instead bind-mounted from a directory by systemd-nspawn. This is the portage/ directory by default. * In addition there is a distfiles/ directory (by default) which is bind-mounted in the chroot. It does what you'd probably expect. * The Makefile learned new target, eclean, which will run eclean-dist and eclean-pkg to clean out obsolete distfiles and binary packages. * The REMOVE_PORTAGE_TREE option is removed as portage is no longer installed. * The unused/untested PRUNE_CRITICAL functionality has been removed. I have no idea if it worked and if it didn't I didn't want to fix it. * As appliances are always using systemd, UDEV is no longer optional. * Timezones and hostnames are now handled by systemd (systemd-firstboot). * Stage4 tarballs are now directly importable as systemd containers (and probably docker too though I haven't tested that yet). * A number of packages (for example dhcpd, acpid) have been removed from the appliances when systemd provides equivalent functionality. * We no longer override etc-update.conf. There's no reason. * A number of Makefile targets, checkpoints, temp files, etc have been removed as they are no longer needed.
2015-02-22 16:32:16 +01:00
inroot := systemd-nspawn --quiet \
--directory=$(CHROOT) \
--machine=$(container) \
--bind=$(PORTAGE_DIR):/usr/portage \
2018-10-27 08:26:16 +02:00
--bind=$(VA_PKGDIR):/usr/portage/packages \
The great systemd commit. This change converts the appliances from openrc to systemd. In addition, systemd needs to at least be be installed on the build machine as we now use systemd-nspawn instead of chroot/bind mounts do to the fact that systemd-nspawn is much more robust and lese prone to errors. In addition: * All stage4 tarballs and images are now stored in the images/ directory by default. * A package dir is now required and is set up in the packages/ directory by default. * The portage directory is not unpacked in the chroot every time anymore and is instead bind-mounted from a directory by systemd-nspawn. This is the portage/ directory by default. * In addition there is a distfiles/ directory (by default) which is bind-mounted in the chroot. It does what you'd probably expect. * The Makefile learned new target, eclean, which will run eclean-dist and eclean-pkg to clean out obsolete distfiles and binary packages. * The REMOVE_PORTAGE_TREE option is removed as portage is no longer installed. * The unused/untested PRUNE_CRITICAL functionality has been removed. I have no idea if it worked and if it didn't I didn't want to fix it. * As appliances are always using systemd, UDEV is no longer optional. * Timezones and hostnames are now handled by systemd (systemd-firstboot). * Stage4 tarballs are now directly importable as systemd containers (and probably docker too though I haven't tested that yet). * A number of packages (for example dhcpd, acpid) have been removed from the appliances when systemd provides equivalent functionality. * We no longer override etc-update.conf. There's no reason. * A number of Makefile targets, checkpoints, temp files, etc have been removed as they are no longer needed.
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)
inroot := linux32 $(inroot)
endif
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
The great systemd commit. This change converts the appliances from openrc to systemd. In addition, systemd needs to at least be be installed on the build machine as we now use systemd-nspawn instead of chroot/bind mounts do to the fact that systemd-nspawn is much more robust and lese prone to errors. In addition: * All stage4 tarballs and images are now stored in the images/ directory by default. * A package dir is now required and is set up in the packages/ directory by default. * The portage directory is not unpacked in the chroot every time anymore and is instead bind-mounted from a directory by systemd-nspawn. This is the portage/ directory by default. * In addition there is a distfiles/ directory (by default) which is bind-mounted in the chroot. It does what you'd probably expect. * The Makefile learned new target, eclean, which will run eclean-dist and eclean-pkg to clean out obsolete distfiles and binary packages. * The REMOVE_PORTAGE_TREE option is removed as portage is no longer installed. * The unused/untested PRUNE_CRITICAL functionality has been removed. I have no idea if it worked and if it didn't I didn't want to fix it. * As appliances are always using systemd, UDEV is no longer optional. * Timezones and hostnames are now handled by systemd (systemd-firstboot). * Stage4 tarballs are now directly importable as systemd containers (and probably docker too though I haven't tested that yet). * A number of packages (for example dhcpd, acpid) have been removed from the appliances when systemd provides equivalent functionality. * We no longer override etc-update.conf. There's no reason. * A number of Makefile targets, checkpoints, temp files, etc have been removed as they are no longer needed.
2015-02-22 16:32:16 +01:00
COPY_ARGS = --exclude-from=configs/rsync-excludes
ifeq ($(CHANGE_PASSWORD),YES)
ifdef ROOT_PASSWORD
change_password = RUN usermod --password '$(ROOT_PASSWORD)' root
else
change_password = RUN passwd --delete root
endif
endif
gcc_config = $(inroot) gcc-config 1
export APPLIANCE ACCEPT_KEYWORDS CHROOT EMERGE HEADLESS M4 M4C inroot
The great systemd commit. This change converts the appliances from openrc to systemd. In addition, systemd needs to at least be be installed on the build machine as we now use systemd-nspawn instead of chroot/bind mounts do to the fact that systemd-nspawn is much more robust and lese prone to errors. In addition: * All stage4 tarballs and images are now stored in the images/ directory by default. * A package dir is now required and is set up in the packages/ directory by default. * The portage directory is not unpacked in the chroot every time anymore and is instead bind-mounted from a directory by systemd-nspawn. This is the portage/ directory by default. * In addition there is a distfiles/ directory (by default) which is bind-mounted in the chroot. It does what you'd probably expect. * The Makefile learned new target, eclean, which will run eclean-dist and eclean-pkg to clean out obsolete distfiles and binary packages. * The REMOVE_PORTAGE_TREE option is removed as portage is no longer installed. * The unused/untested PRUNE_CRITICAL functionality has been removed. I have no idea if it worked and if it didn't I didn't want to fix it. * As appliances are always using systemd, UDEV is no longer optional. * Timezones and hostnames are now handled by systemd (systemd-firstboot). * Stage4 tarballs are now directly importable as systemd containers (and probably docker too though I haven't tested that yet). * A number of packages (for example dhcpd, acpid) have been removed from the appliances when systemd provides equivalent functionality. * We no longer override etc-update.conf. There's no reason. * A number of Makefile targets, checkpoints, temp files, etc have been removed as they are no longer needed.
2015-02-22 16:32:16 +01:00
export HOSTNAME MAKEOPTS TIMEZONE USEPKG WORLD
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
all: stage4
2010-07-09 05:22:37 +02:00
image: $(RAW_IMAGE)
2010-07-09 05:22:37 +02:00
sync_portage: $(PORTAGE_DIR)
@print Grabbing latest portage
git -C $(PORTAGE_DIR) pull
touch $(PORTAGE_DIR)
2013-08-25 11:24:46 +02:00
$(PORTAGE_DIR):
@print Grabbing the portage tree
git clone --depth=1 git://github.com/gentoo/gentoo.git $(PORTAGE_DIR)
$(CHROOT)/etc/portage/%: configs/portage/%
COPY --recursive $< /etc/portage/
$(CHROOT)/etc/fstab: configs/fstab.in
ifeq ($(VIRTIO),YES)
$(M4) -DDRIVE=sda $< > $@
else
$(M4) -DDRIVE=vda $< > $@
endif
$(PREPROOT): $(STAGE3) $(PORTAGE_DIR) $(CHROOT)/etc/fstab $(etc_portage) $(portage_package_files)
mkdir -p $(VA_PKGDIR) $(DISTDIR)
2018-10-27 20:49:42 +02:00
@print Creating swap file: `basename $(SWAP_FILE)`
dd if=/dev/zero of=$(SWAP_FILE) bs=1M count=$(SWAP_SIZE)
/sbin/mkswap $(SWAP_FILE)
rm -f $(CHROOT)/etc/resolv.conf
COPY -L /etc/resolv.conf /etc/resolv.conf
touch $(PREPROOT)
2018-10-27 08:24:05 +02:00
stage3-$(VA_ARCH).tar.bz2:
@print You do not have a stage3 tarball. Consider \"make sync_stage3\"
2013-08-26 23:21:17 +02:00
@exit 1
sync_stage3:
fetch-stage3 --specialty=systemd --outfile=stage3-$(VA_ARCH).tar.bz2 $(VA_ARCH)
2013-08-26 23:21:17 +02:00
$(STAGE3): stage3-$(VA_ARCH).tar.bz2 configs/stage3-tarball-excludes
2010-11-06 09:41:15 +01:00
mkdir -p $(CHROOT)
ifdef stage4-exists
@print Using stage4 tarball: `basename $(STAGE4_TARBALL)`
tar xpf "$(STAGE4_TARBALL)" -C $(CHROOT)
else
@print Using stage3 tarball
tar xpf stage3-$(VA_ARCH).tar.bz2 -C $(CHROOT) --exclude-from=configs/stage3-tarball-excludes
endif
The great systemd commit. This change converts the appliances from openrc to systemd. In addition, systemd needs to at least be be installed on the build machine as we now use systemd-nspawn instead of chroot/bind mounts do to the fact that systemd-nspawn is much more robust and lese prone to errors. In addition: * All stage4 tarballs and images are now stored in the images/ directory by default. * A package dir is now required and is set up in the packages/ directory by default. * The portage directory is not unpacked in the chroot every time anymore and is instead bind-mounted from a directory by systemd-nspawn. This is the portage/ directory by default. * In addition there is a distfiles/ directory (by default) which is bind-mounted in the chroot. It does what you'd probably expect. * The Makefile learned new target, eclean, which will run eclean-dist and eclean-pkg to clean out obsolete distfiles and binary packages. * The REMOVE_PORTAGE_TREE option is removed as portage is no longer installed. * The unused/untested PRUNE_CRITICAL functionality has been removed. I have no idea if it worked and if it didn't I didn't want to fix it. * As appliances are always using systemd, UDEV is no longer optional. * Timezones and hostnames are now handled by systemd (systemd-firstboot). * Stage4 tarballs are now directly importable as systemd containers (and probably docker too though I haven't tested that yet). * A number of packages (for example dhcpd, acpid) have been removed from the appliances when systemd provides equivalent functionality. * We no longer override etc-update.conf. There's no reason. * A number of Makefile targets, checkpoints, temp files, etc have been removed as they are no longer needed.
2015-02-22 16:32:16 +01:00
rm -f $(CHROOT)/etc/localtime
touch $(STAGE3)
$(CHROOT)/etc/portage/package.%/01$(APPLIANCE): appliances/$(APPLIANCE)/package.% $(STAGE3)
mkdir -p `dirname $@`
cp $< $@
$(CHROOT)/etc/portage/make.conf: configs/make.conf.$(VA_ARCH)
COPY configs/make.conf.$(VA_ARCH) /etc/portage/make.conf
$(portage_make_conf_local): $(appliance_make_conf)
COPY $< /etc/portage/make.conf.local || touch $@
$(CHROOT)/var/tmp/profile: $(STAGE3)
RUN eselect profile set $(appliance_profile)
touch $@
$(CHROOT)/etc/locale.gen: configs/locale.gen
COPY configs/locale.gen $@
$(COMPILE_OPTIONS): $(STAGE3) $(PORTAGE_DIR) $(CHROOT)/etc/portage/make.conf configs/locale.gen $(portage_package_files) $(portage_make_conf_local) $(CHROOT)/var/tmp/profile $(CHROOT)/etc/locale.gen
RUN locale-gen
touch $(COMPILE_OPTIONS)
$(KERNEL): $(COMPILE_OPTIONS) $(KERNEL_CONFIG) scripts/build-kernel
ifneq ($(EXTERNAL_KERNEL),YES)
@print Configuring kernel
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
rm -f $(CHROOT)/root/build-kernel
endif
touch $(KERNEL)
2010-07-09 05:22:37 +02:00
$(SYSTOOLS): $(PREPROOT) $(COMPILE_OPTIONS)
@print Installing standard system tools
systemd-firstboot \
--root=$(CHROOT) \
--setup-machine-id \
The great systemd commit. This change converts the appliances from openrc to systemd. In addition, systemd needs to at least be be installed on the build machine as we now use systemd-nspawn instead of chroot/bind mounts do to the fact that systemd-nspawn is much more robust and lese prone to errors. In addition: * All stage4 tarballs and images are now stored in the images/ directory by default. * A package dir is now required and is set up in the packages/ directory by default. * The portage directory is not unpacked in the chroot every time anymore and is instead bind-mounted from a directory by systemd-nspawn. This is the portage/ directory by default. * In addition there is a distfiles/ directory (by default) which is bind-mounted in the chroot. It does what you'd probably expect. * The Makefile learned new target, eclean, which will run eclean-dist and eclean-pkg to clean out obsolete distfiles and binary packages. * The REMOVE_PORTAGE_TREE option is removed as portage is no longer installed. * The unused/untested PRUNE_CRITICAL functionality has been removed. I have no idea if it worked and if it didn't I didn't want to fix it. * As appliances are always using systemd, UDEV is no longer optional. * Timezones and hostnames are now handled by systemd (systemd-firstboot). * Stage4 tarballs are now directly importable as systemd containers (and probably docker too though I haven't tested that yet). * A number of packages (for example dhcpd, acpid) have been removed from the appliances when systemd provides equivalent functionality. * We no longer override etc-update.conf. There's no reason. * A number of Makefile targets, checkpoints, temp files, etc have been removed as they are no longer needed.
2015-02-22 16:32:16 +01:00
--timezone=$(TIMEZONE) \
--hostname=$(HOSTNAME) \
--root-password=
RUN eselect locale set $(LOCALE)
ifeq ($(DASH),YES)
2012-12-16 16:49:21 +01:00
if ! test -e "$(STAGE4_TARBALL)"; \
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; \
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
RUN ln -sf dash /bin/sh
endif
touch $(SYSTOOLS)
$(GRUB): $(PREPROOT) configs/grub.cfg $(KERNEL) scripts/grub-headless.sed
ifneq ($(EXTERNAL_KERNEL),YES)
@print Installing Grub
RUN $(EMERGE) -nN $(USEPKG) sys-boot/grub
mkdir -p $(CHROOT)/boot/grub
COPY configs/grub.cfg /boot/grub/grub.cfg
ifeq ($(VIRTIO),YES)
sed -i 's/sda/vda/' $(CHROOT)/boot/grub/grub.cfg
endif
ifeq ($(HEADLESS),YES)
sed -i -f scripts/grub-headless.sed $(CHROOT)/boot/grub/grub.cfg
endif
endif
ln -nsf /run/systemd/resolve/resolv.conf $(CHROOT)/etc/resolv.conf
touch $(GRUB)
2010-07-09 05:22:37 +02:00
software: $(SOFTWARE)
$(SOFTWARE): $(SYSTOOLS) configs/eth.network configs/issue $(COMPILE_OPTIONS) $(WORLD)
@print Building $(APPLIANCE)-specific software
$(MAKE) -C appliances/$(APPLIANCE) preinstall
COPY $(WORLD) /var/lib/portage/world
RUN $(EMERGE) $(USEPKG) --update --newuse --deep @system
@print Running @preserved-rebuild
RUN $(EMERGE) --usepkg=n @preserved-rebuild
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
ifeq ($(ENABLE_SSHD),YES)
RUN systemctl enable sshd.service
endif
ifeq ($(DASH),YES)
RUN $(EMERGE) --depclean app-shells/bash
endif
$(MAKE) -C appliances/$(APPLIANCE) postinstall
ifneq ($(PKGLIST),0)
echo \# > $(LST_FILE)
echo \# Gentoo Virtual Appliance \"$(APPLIANCE)\" package list >> $(LST_FILE)
echo \# Generated `date -u` >> $(LST_FILE)
echo \# >> $(LST_FILE)
(cd "$(CHROOT)"/var/db/pkg ; /bin/ls -1d */* | grep -v '^virtual/') >> $(LST_FILE)
endif
touch $(SOFTWARE)
2010-07-09 05:22:37 +02:00
$(RAW_IMAGE): $(STAGE4_TARBALL) scripts/grub.shell scripts/motd.sh
@print Installing files to `basename $(RAW_IMAGE)`
qemu-img create -f raw $(RAW_IMAGE).tmp $(DISK_SIZE)
parted -s $(RAW_IMAGE).tmp mklabel msdos
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
The great systemd commit. This change converts the appliances from openrc to systemd. In addition, systemd needs to at least be be installed on the build machine as we now use systemd-nspawn instead of chroot/bind mounts do to the fact that systemd-nspawn is much more robust and lese prone to errors. In addition: * All stage4 tarballs and images are now stored in the images/ directory by default. * A package dir is now required and is set up in the packages/ directory by default. * The portage directory is not unpacked in the chroot every time anymore and is instead bind-mounted from a directory by systemd-nspawn. This is the portage/ directory by default. * In addition there is a distfiles/ directory (by default) which is bind-mounted in the chroot. It does what you'd probably expect. * The Makefile learned new target, eclean, which will run eclean-dist and eclean-pkg to clean out obsolete distfiles and binary packages. * The REMOVE_PORTAGE_TREE option is removed as portage is no longer installed. * The unused/untested PRUNE_CRITICAL functionality has been removed. I have no idea if it worked and if it didn't I didn't want to fix it. * As appliances are always using systemd, UDEV is no longer optional. * Timezones and hostnames are now handled by systemd (systemd-firstboot). * Stage4 tarballs are now directly importable as systemd containers (and probably docker too though I haven't tested that yet). * A number of packages (for example dhcpd, acpid) have been removed from the appliances when systemd provides equivalent functionality. * We no longer override etc-update.conf. There's no reason. * A number of Makefile targets, checkpoints, temp files, etc have been removed as they are no longer needed.
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)
motd.sh $(EXTERNAL_KERNEL) $(VIRTIO) $(DISK_SIZE) $(SWAP_SIZE) $(DASH) $(VA_ARCH) > $(CHROOT)/etc/motd
ifneq ($(EXTERNAL_KERNEL),YES)
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`
endif
umount $(CHROOT)
The great systemd commit. This change converts the appliances from openrc to systemd. In addition, systemd needs to at least be be installed on the build machine as we now use systemd-nspawn instead of chroot/bind mounts do to the fact that systemd-nspawn is much more robust and lese prone to errors. In addition: * All stage4 tarballs and images are now stored in the images/ directory by default. * A package dir is now required and is set up in the packages/ directory by default. * The portage directory is not unpacked in the chroot every time anymore and is instead bind-mounted from a directory by systemd-nspawn. This is the portage/ directory by default. * In addition there is a distfiles/ directory (by default) which is bind-mounted in the chroot. It does what you'd probably expect. * The Makefile learned new target, eclean, which will run eclean-dist and eclean-pkg to clean out obsolete distfiles and binary packages. * The REMOVE_PORTAGE_TREE option is removed as portage is no longer installed. * The unused/untested PRUNE_CRITICAL functionality has been removed. I have no idea if it worked and if it didn't I didn't want to fix it. * As appliances are always using systemd, UDEV is no longer optional. * Timezones and hostnames are now handled by systemd (systemd-firstboot). * Stage4 tarballs are now directly importable as systemd containers (and probably docker too though I haven't tested that yet). * A number of packages (for example dhcpd, acpid) have been removed from the appliances when systemd provides equivalent functionality. * We no longer override etc-update.conf. There's no reason. * A number of Makefile targets, checkpoints, temp files, etc have been removed as they are no longer needed.
2015-02-22 16:32:16 +01:00
rmdir $(CHROOT)
sync
losetup --detach `cat partitions`
rm -f partitions device-map
mv $(RAW_IMAGE).tmp $(RAW_IMAGE)
2010-07-09 05:22:37 +02:00
$(QCOW_IMAGE): $(RAW_IMAGE)
@print Creating `basename $(QCOW_IMAGE)`
The great systemd commit. This change converts the appliances from openrc to systemd. In addition, systemd needs to at least be be installed on the build machine as we now use systemd-nspawn instead of chroot/bind mounts do to the fact that systemd-nspawn is much more robust and lese prone to errors. In addition: * All stage4 tarballs and images are now stored in the images/ directory by default. * A package dir is now required and is set up in the packages/ directory by default. * The portage directory is not unpacked in the chroot every time anymore and is instead bind-mounted from a directory by systemd-nspawn. This is the portage/ directory by default. * In addition there is a distfiles/ directory (by default) which is bind-mounted in the chroot. It does what you'd probably expect. * The Makefile learned new target, eclean, which will run eclean-dist and eclean-pkg to clean out obsolete distfiles and binary packages. * The REMOVE_PORTAGE_TREE option is removed as portage is no longer installed. * The unused/untested PRUNE_CRITICAL functionality has been removed. I have no idea if it worked and if it didn't I didn't want to fix it. * As appliances are always using systemd, UDEV is no longer optional. * Timezones and hostnames are now handled by systemd (systemd-firstboot). * Stage4 tarballs are now directly importable as systemd containers (and probably docker too though I haven't tested that yet). * A number of packages (for example dhcpd, acpid) have been removed from the appliances when systemd provides equivalent functionality. * We no longer override etc-update.conf. There's no reason. * A number of Makefile targets, checkpoints, temp files, etc have been removed as they are no longer needed.
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)
$(XVA_IMAGE): $(RAW_IMAGE)
@print Creating `basename $(XVA_IMAGE)`
xva.py --disk=$(RAW_IMAGE) --is-hvm --memory=256 --vcpus=1 --name=$(APPLIANCE) \
The great systemd commit. This change converts the appliances from openrc to systemd. In addition, systemd needs to at least be be installed on the build machine as we now use systemd-nspawn instead of chroot/bind mounts do to the fact that systemd-nspawn is much more robust and lese prone to errors. In addition: * All stage4 tarballs and images are now stored in the images/ directory by default. * A package dir is now required and is set up in the packages/ directory by default. * The portage directory is not unpacked in the chroot every time anymore and is instead bind-mounted from a directory by systemd-nspawn. This is the portage/ directory by default. * In addition there is a distfiles/ directory (by default) which is bind-mounted in the chroot. It does what you'd probably expect. * The Makefile learned new target, eclean, which will run eclean-dist and eclean-pkg to clean out obsolete distfiles and binary packages. * The REMOVE_PORTAGE_TREE option is removed as portage is no longer installed. * The unused/untested PRUNE_CRITICAL functionality has been removed. I have no idea if it worked and if it didn't I didn't want to fix it. * As appliances are always using systemd, UDEV is no longer optional. * Timezones and hostnames are now handled by systemd (systemd-firstboot). * Stage4 tarballs are now directly importable as systemd containers (and probably docker too though I haven't tested that yet). * A number of packages (for example dhcpd, acpid) have been removed from the appliances when systemd provides equivalent functionality. * We no longer override etc-update.conf. There's no reason. * A number of Makefile targets, checkpoints, temp files, etc have been removed as they are no longer needed.
2015-02-22 16:32:16 +01:00
--filename=$(XVA_IMAGE).tmp
mv $(XVA_IMAGE).tmp $(XVA_IMAGE)
xva: $(XVA_IMAGE)
2010-07-09 05:22:37 +02:00
$(VMDK_IMAGE): $(RAW_IMAGE)
@print Creating `basename $(VMDK_IMAGE)`
The great systemd commit. This change converts the appliances from openrc to systemd. In addition, systemd needs to at least be be installed on the build machine as we now use systemd-nspawn instead of chroot/bind mounts do to the fact that systemd-nspawn is much more robust and lese prone to errors. In addition: * All stage4 tarballs and images are now stored in the images/ directory by default. * A package dir is now required and is set up in the packages/ directory by default. * The portage directory is not unpacked in the chroot every time anymore and is instead bind-mounted from a directory by systemd-nspawn. This is the portage/ directory by default. * In addition there is a distfiles/ directory (by default) which is bind-mounted in the chroot. It does what you'd probably expect. * The Makefile learned new target, eclean, which will run eclean-dist and eclean-pkg to clean out obsolete distfiles and binary packages. * The REMOVE_PORTAGE_TREE option is removed as portage is no longer installed. * The unused/untested PRUNE_CRITICAL functionality has been removed. I have no idea if it worked and if it didn't I didn't want to fix it. * As appliances are always using systemd, UDEV is no longer optional. * Timezones and hostnames are now handled by systemd (systemd-firstboot). * Stage4 tarballs are now directly importable as systemd containers (and probably docker too though I haven't tested that yet). * A number of packages (for example dhcpd, acpid) have been removed from the appliances when systemd provides equivalent functionality. * We no longer override etc-update.conf. There's no reason. * A number of Makefile targets, checkpoints, temp files, etc have been removed as they are no longer needed.
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
$(MAKE) $(STAGE3)
$(MAKE) $(PREPROOT)
$(MAKE) $(SOFTWARE)
$(MAKE) $(KERNEL)
$(MAKE) $(GRUB)
@print Creating stage4 tarball: `basename $(STAGE4_TARBALL)`
$(change_password)
The great systemd commit. This change converts the appliances from openrc to systemd. In addition, systemd needs to at least be be installed on the build machine as we now use systemd-nspawn instead of chroot/bind mounts do to the fact that systemd-nspawn is much more robust and lese prone to errors. In addition: * All stage4 tarballs and images are now stored in the images/ directory by default. * A package dir is now required and is set up in the packages/ directory by default. * The portage directory is not unpacked in the chroot every time anymore and is instead bind-mounted from a directory by systemd-nspawn. This is the portage/ directory by default. * In addition there is a distfiles/ directory (by default) which is bind-mounted in the chroot. It does what you'd probably expect. * The Makefile learned new target, eclean, which will run eclean-dist and eclean-pkg to clean out obsolete distfiles and binary packages. * The REMOVE_PORTAGE_TREE option is removed as portage is no longer installed. * The unused/untested PRUNE_CRITICAL functionality has been removed. I have no idea if it worked and if it didn't I didn't want to fix it. * As appliances are always using systemd, UDEV is no longer optional. * Timezones and hostnames are now handled by systemd (systemd-firstboot). * Stage4 tarballs are now directly importable as systemd containers (and probably docker too though I haven't tested that yet). * A number of packages (for example dhcpd, acpid) have been removed from the appliances when systemd provides equivalent functionality. * We no longer override etc-update.conf. There's no reason. * A number of Makefile targets, checkpoints, temp files, etc have been removed as they are no longer needed.
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 .
mv "$(STAGE4_TARBALL).tmp.xz" "$(STAGE4_TARBALL)"
$(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
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
eclean: $(COMPILE_OPTIONS)
RUN $(EMERGE) $(USEPKG) --oneshot --noreplace app-portage/gentoolkit
RUN eclean-pkg
RUN eclean-dist
RUN $(EMERGE) --depclean app-portage/gentoolkit
The great systemd commit. This change converts the appliances from openrc to systemd. In addition, systemd needs to at least be be installed on the build machine as we now use systemd-nspawn instead of chroot/bind mounts do to the fact that systemd-nspawn is much more robust and lese prone to errors. In addition: * All stage4 tarballs and images are now stored in the images/ directory by default. * A package dir is now required and is set up in the packages/ directory by default. * The portage directory is not unpacked in the chroot every time anymore and is instead bind-mounted from a directory by systemd-nspawn. This is the portage/ directory by default. * In addition there is a distfiles/ directory (by default) which is bind-mounted in the chroot. It does what you'd probably expect. * The Makefile learned new target, eclean, which will run eclean-dist and eclean-pkg to clean out obsolete distfiles and binary packages. * The REMOVE_PORTAGE_TREE option is removed as portage is no longer installed. * The unused/untested PRUNE_CRITICAL functionality has been removed. I have no idea if it worked and if it didn't I didn't want to fix it. * As appliances are always using systemd, UDEV is no longer optional. * Timezones and hostnames are now handled by systemd (systemd-firstboot). * Stage4 tarballs are now directly importable as systemd containers (and probably docker too though I haven't tested that yet). * A number of packages (for example dhcpd, acpid) have been removed from the appliances when systemd provides equivalent functionality. * We no longer override etc-update.conf. There's no reason. * A number of Makefile targets, checkpoints, temp files, etc have been removed as they are no longer needed.
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
The great systemd commit. This change converts the appliances from openrc to systemd. In addition, systemd needs to at least be be installed on the build machine as we now use systemd-nspawn instead of chroot/bind mounts do to the fact that systemd-nspawn is much more robust and lese prone to errors. In addition: * All stage4 tarballs and images are now stored in the images/ directory by default. * A package dir is now required and is set up in the packages/ directory by default. * The portage directory is not unpacked in the chroot every time anymore and is instead bind-mounted from a directory by systemd-nspawn. This is the portage/ directory by default. * In addition there is a distfiles/ directory (by default) which is bind-mounted in the chroot. It does what you'd probably expect. * The Makefile learned new target, eclean, which will run eclean-dist and eclean-pkg to clean out obsolete distfiles and binary packages. * The REMOVE_PORTAGE_TREE option is removed as portage is no longer installed. * The unused/untested PRUNE_CRITICAL functionality has been removed. I have no idea if it worked and if it didn't I didn't want to fix it. * As appliances are always using systemd, UDEV is no longer optional. * Timezones and hostnames are now handled by systemd (systemd-firstboot). * Stage4 tarballs are now directly importable as systemd containers (and probably docker too though I haven't tested that yet). * A number of packages (for example dhcpd, acpid) have been removed from the appliances when systemd provides equivalent functionality. * We no longer override etc-update.conf. There's no reason. * A number of Makefile targets, checkpoints, temp files, etc have been removed as they are no longer needed.
2015-02-22 16:32:16 +01:00
clean:
rm -f partitions device-map $(IMAGES)/*.tmp
The great systemd commit. This change converts the appliances from openrc to systemd. In addition, systemd needs to at least be be installed on the build machine as we now use systemd-nspawn instead of chroot/bind mounts do to the fact that systemd-nspawn is much more robust and lese prone to errors. In addition: * All stage4 tarballs and images are now stored in the images/ directory by default. * A package dir is now required and is set up in the packages/ directory by default. * The portage directory is not unpacked in the chroot every time anymore and is instead bind-mounted from a directory by systemd-nspawn. This is the portage/ directory by default. * In addition there is a distfiles/ directory (by default) which is bind-mounted in the chroot. It does what you'd probably expect. * The Makefile learned new target, eclean, which will run eclean-dist and eclean-pkg to clean out obsolete distfiles and binary packages. * The REMOVE_PORTAGE_TREE option is removed as portage is no longer installed. * The unused/untested PRUNE_CRITICAL functionality has been removed. I have no idea if it worked and if it didn't I didn't want to fix it. * As appliances are always using systemd, UDEV is no longer optional. * Timezones and hostnames are now handled by systemd (systemd-firstboot). * Stage4 tarballs are now directly importable as systemd containers (and probably docker too though I haven't tested that yet). * A number of packages (for example dhcpd, acpid) have been removed from the appliances when systemd provides equivalent functionality. * We no longer override etc-update.conf. There's no reason. * A number of Makefile targets, checkpoints, temp files, etc have been removed as they are no longer needed.
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-06 23:46:07 +01:00
distclean:
The great systemd commit. This change converts the appliances from openrc to systemd. In addition, systemd needs to at least be be installed on the build machine as we now use systemd-nspawn instead of chroot/bind mounts do to the fact that systemd-nspawn is much more robust and lese prone to errors. In addition: * All stage4 tarballs and images are now stored in the images/ directory by default. * A package dir is now required and is set up in the packages/ directory by default. * The portage directory is not unpacked in the chroot every time anymore and is instead bind-mounted from a directory by systemd-nspawn. This is the portage/ directory by default. * In addition there is a distfiles/ directory (by default) which is bind-mounted in the chroot. It does what you'd probably expect. * The Makefile learned new target, eclean, which will run eclean-dist and eclean-pkg to clean out obsolete distfiles and binary packages. * The REMOVE_PORTAGE_TREE option is removed as portage is no longer installed. * The unused/untested PRUNE_CRITICAL functionality has been removed. I have no idea if it worked and if it didn't I didn't want to fix it. * As appliances are always using systemd, UDEV is no longer optional. * Timezones and hostnames are now handled by systemd (systemd-firstboot). * Stage4 tarballs are now directly importable as systemd containers (and probably docker too though I haven't tested that yet). * A number of packages (for example dhcpd, acpid) have been removed from the appliances when systemd provides equivalent functionality. * We no longer override etc-update.conf. There's no reason. * A number of Makefile targets, checkpoints, temp files, etc have been removed as they are no longer needed.
2015-02-22 16:32:16 +01:00
rm -f -- *.qcow *.img *.vmdk
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
appliance-list:
@print 'Available appliances:'
@/bin/ls -1 appliances
checksums:
@print Calculating checksums
2015-09-14 13:09:15 +02:00
$(RM) $(CHECKSUMS)
cd $(IMAGES) && sha256sum --binary * > $(CHECKSUMS).tmp
mv $(CHECKSUMS).tmp $(CHECKSUMS)
shell: $(PREPROOT)
@print 'Entering interactive shell for the $(APPLIANCE) build.'
@print 'Type "exit" or "^D" to leave'
@print
@RUN
@rm -f $(CHROOT)/root/.bash_history
2013-09-17 01:26:48 +02:00
help:
@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'
@echo 'shell - Enter a shell in the build environment'
@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'
@echo 'appliance-list - List built-in appliances'
@echo 'help - Show this help'
@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
@print 'Example'
2013-09-17 01:26:48 +02:00
@echo 'make APPLIANCE=mongodb HEADLESS=YES VIRTIO=YES stage4 qcow clean'
.PHONY: qcow vmdk clean realclean distclean stage4 image stage4 help appliance-list eclean sync_portage sync_stage3 checksums