Mail archive
alpine-devel

Re: [alpine-devel] [PATCH v2] alpine-iso: add support to create Xen Dom0 LiveCD/USB

From: Natanael Copa <ncopa_at_alpinelinux.org>
Date: Fri, 30 Dec 2011 11:10:37 +0100

On Thu, 29 Dec 2011 20:18:18 +0100
Roger Pau Monne <roger.pau_at_entel.upc.edu> wrote:

> A new profile has been added, called alpine-xen, that shoud be used
> when trying to craft a Xen Dom0 LiveCD/USB.
>
> Changes since v1:
>
> * Removed dummy net setup, since xencommons doesn't need net to
> start.
>
> Please review and comment.


Nice!

In general, the Makefile is getting bigger and messier. We need to do
something to split it up. We should try avoid having profile specifics
in main Makefile and try avoid if/else in Makefile. (that is meant for
myself as well)

> ---
> Makefile | 64
> ++++++++++++++++++++++++++++++++++++++++++++++++++-
> alpine-xen.conf.mk | 4 +++ alpine-xen.packages | 10 ++++++++
> 3 files changed, 77 insertions(+), 1 deletions(-)
> create mode 100644 alpine-xen.conf.mk
> create mode 100644 alpine-xen.packages
>
> diff --git a/Makefile b/Makefile
> index 7fa36b2..65a7dd0 100755
> --- a/Makefile
> +++ b/Makefile
> _at_@ -200,6 +200,44 @@ $(VSTEMPLATE):
> _at_cd $(VSTEMPLATE_DIR) && $(TAR) -jcf $@ *
>
> #
> +# apkovl rules
> +#
> +
> +ifdef BUILD_APKOVL
> +APKOVL_DEST := $(ISO_DIR)/$(BUILD_APKOVL).apkovl.tar.gz
> +APKOVL_DIR := $(DESTDIR)/apkovl_$(BUILD_APKOVL)
> +endif


Have been thinking of other apkovls too, for for example
alpine-desktop. I am not convinced that shipping an iso with apkovl is
the prober direction to go though. We have talked about implementing
"policy" packages in apk so you could have a "profile" package for
different setups. policy pakcages could include some configuration that
could be overridden by user.

Not sure what the status for that is currently.


> +
> +# Helper function to link a script to runlevel
> +
> +rc_add = \
> + _at_mkdir -p "$(APKOVL_DIR)"/etc/runlevels/"$(2)"; \
> + ln -sf /etc/init.d/"$(1)"

I think the helper funciton was pretty elegant :)

> "$(APKOVL_DIR)"/etc/runlevels/"$(2)"/"$(1)"; +
> +$(ISO_DIR)/xen.apkovl.tar.gz:
> + _at_rm -rf "$(APKOVL_DIR)"
> + _at_mkdir -p "$(APKOVL_DIR)"
> + _at_mkdir -p "$(APKOVL_DIR)"/etc/apk
> + _at_echo "xen udev" >> "$(APKOVL_DIR)"/etc/apk/world
> + _at_echo "xen_netback" >> "$(APKOVL_DIR)"/etc/modules
> + _at_echo "xen_blkback" >> "$(APKOVL_DIR)"/etc/modules
> + $(call rc_add,devfs,sysinit)
> + $(call rc_add,dmesg,sysinit)
> + $(call rc_add,hwclock,boot)
> + $(call rc_add,modules,boot)
> + $(call rc_add,sysctl,boot)
> + $(call rc_add,hostname,boot)
> + $(call rc_add,bootmisc,boot)
> + $(call rc_add,syslog,boot)
> + $(call rc_add,mount-ro,shutdown)
> + $(call rc_add,killprocs,shutdown)
> + $(call rc_add,savecache,shutdown)
> + $(call rc_add,udev,sysinit)
> + $(call rc_add,udev-postmount,default)
> + $(call rc_add,xencommons,default)
> + _at_cd $(APKOVL_DIR) && $(TAR) -zcf $@ *
> + _at_echo "==> apkovl: built $@"
> +#
> # ISO rules
> #

In case we go for shipping apkovls in iso's, we might want keep some
files in there too. So we should probably do that in subdirs.

hum... need to think about this.

>
> _at_@ -223,24 +261,42 @@ $(ISOLINUX_CFG):
> _at_echo "$(SYSLINUX_SERIAL)" >$@
> _at_echo "timeout 20" >>$@
> _at_echo "prompt 1" >>$@
> +ifeq ($(PROFILE), alpine-xen)
> + _at_echo "default xen-$(KERNEL_FLAVOR_DEFAULT)" >>$@
> + _at_for flavor in $(KERNEL_FLAVOR); do \
> + echo "label xen-$$flavor"; \
> + echo " kernel /boot/mboot.c32"; \
> + echo " append /boot/xen.gz --- /boot/$$flavor


I wonder if we could/should keep those in $(PROFILE).conf.mk...


> alpine_dev=cdrom:iso9660
> modules=loop,squashfs,sd-mod,usb-storage,floppy,sr-mod
> modloop=/boot/$$flavor.modloop.squashfs $(BOOT_CONSOLE)
> --- /boot/$$flavor.gz"; \
> + done >>$_at_
> +else
> _at_echo "default $(KERNEL_FLAVOR_DEFAULT)" >>$@
> _at_for flavor in $(KERNEL_FLAVOR); do \
> echo "label $$flavor"; \
> echo " kernel /boot/$$flavor"; \
> echo " append initrd=/boot/$$flavor.gz

... hmm.. maybe not. The xen structure is pretty different. Looks
difficult to put that in alpine-xen.conf.mk.

Also, we have the update-extlinux.conf tool. I think we should try fix
that tool so it could create isolinux.cfg suitable for iso image.


> alpine_dev=cdrom:iso9660
> modules=loop,squashfs,sd-mod,usb-storage,floppy,sr-mod quiet
> $(BOOT_CONSOLE)"; \ done >>$_at_ +endif
> $(SYSLINUX_CFG): $(ALL_MODLOOP_DIRSTAMP)
> _at_echo "==> iso: configure syslinux"
> _at_echo "$(SYSLINUX_SERIAL)" >$@
> _at_echo "timeout 20" >>$@
> _at_echo "prompt 1" >>$@
> +ifeq ($(PROFILE), alpine-xen)
> + _at_echo "default xen-$(KERNEL_FLAVOR_DEFAULT)" >>$@
> + _at_for flavor in $(KERNEL_FLAVOR); do \
> + echo "label xen-$$flavor"; \
> + echo " kernel /boot/mboot.c32"; \
> + echo " append /boot/xen.gz --- /boot/$$flavor
> alpine_dev=usbdisk:vfat modules=loop,squashfs,sd-mod,usb-storage
> modloop=/boot/$$flavor.modloop.squashfs $(BOOT_CONSOLE)
> --- /boot/$$flavor.gz"; \
> + done >>$_at_
> +else
> _at_echo "default $(KERNEL_FLAVOR_DEFAULT)" >>$@
> _at_for flavor in $(KERNEL_FLAVOR); do \
> echo "label $$flavor"; \
> echo " kernel /boot/$$flavor"; \
> echo " append initrd=/boot/$$flavor.gz
> alpine_dev=usbdisk:vfat modules=loop,squashfs,sd-mod,usb-storage
> quiet $(BOOT_CONSOLE)"; \ done >>$_at_ +endif
>
> clean-syslinux:
> _at_rm -f $(SYSLINUX_CFG) $(ISOLINUX_CFG) $(ISOLINUX_BIN)
> _at_@ -266,6 +322,12 @@ $(ISO_KERNEL_STAMP): $(MODLOOP_DIRSTAMP)
> _at_mkdir -p $(dir $(ISO_KERNEL))
> _at_apk fetch $(APK_OPTS) --stdout $(KERNEL_PKGNAME) \
> | $(TAR) -C $(ISO_DIR) -xz boot
> +ifeq ($(PROFILE), alpine-xen)
> + _at_apk fetch $(APK_OPTS) --stdout xen \
> + | $(TAR) -C $(ISO_DIR) -xz boot
> + _at_apk fetch $(APK_OPTS) --stdout syslinux \
> + | $(TAR) -xz usr/share/syslinux/mboot.c32 -O >
> $(ISO_DIR)/boot/mboot.c32 +endif
> _at_rm -f $(ISO_KERNEL)
> _at_ln -s vmlinuz-$(MODLOOP_KERNEL_RELEASE) $(ISO_KERNEL)
> _at_rm -rf $(ISO_DIR)/.[A-Z]* $(ISO_DIR)/.[a-z]* $(ISO_DIR)/lib

hard to do the above without special case for xen. hum...


> _at_@ -281,7 +343,7 @@ $(APKOVL_STAMP):
> fi
> _at_touch $@
>
> -$(ISOFS_DIRSTAMP): $(ALL_MODLOOP) $(ALL_INITFS) $(ISOLINUX_CFG)
> $(ISOLINUX_BIN) $(ALL_ISO_KERNEL) $(ISO_REPOS_DIRSTAMP)
> $(APKOVL_STAMP) $(SYSLINUX_CFG) +$(ISOFS_DIRSTAMP): $(ALL_MODLOOP)
> $(ALL_INITFS) $(ISOLINUX_CFG) $(ISOLINUX_BIN) $(ALL_ISO_KERNEL)
> $(ISO_REPOS_DIRSTAMP) $(APKOVL_STAMP) $(SYSLINUX_CFG) $(APKOVL_DEST)
> _at_echo "$(ALPINE_NAME)-$(ALPINE_RELEASE) $(BUILD_DATE)" \
> > $(ISO_DIR)/.alpine-release
> _at_touch $@
> diff --git a/alpine-xen.conf.mk b/alpine-xen.conf.mk
> new file mode 100644
> index 0000000..016db33
> --- /dev/null
> +++ b/alpine-xen.conf.mk
> _at_@ -0,0 +1,4 @@
> +ALPINE_NAME := alpine-xen
> +MODLOOP_EXTRA :=
> +KERNEL_FLAVOR := grsec
> +BUILD_APKOVL := xen
> diff --git a/alpine-xen.packages b/alpine-xen.packages
> new file mode 100644
> index 0000000..b1cbd42
> --- /dev/null
> +++ b/alpine-xen.packages
> _at_@ -0,0 +1,10 @@
> +bkeymaps
> +alpine-base
> +alpine-mirrors
> +wpa_supplicant
> +wireless-tools
> +openssl
> +tzdata
> +xen
> +udev
> +multipath-tools


I think I will apply this and we can think of how to clean it up later.

-nc


---
Unsubscribe:  alpine-devel+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-devel+help_at_lists.alpinelinux.org
---
Received on Fri Dec 30 2011 - 11:10:37 UTC