From 6c27a98c6a5207a29bffaeeb486479a2c24cd26c Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Fri, 10 Nov 2017 11:25:31 +0000 Subject: Add minimal-system-image-x86_64 This element produces a disk image that boots in QEMU. It has a kernel, BusyBox, and little else; but should be suitable as a basis for more grand endeavours. This disk image we produce is 53MB. I spent a while trying to get this as small as possible and this is as far as I got: * The boot partition seems to have a minimum size just over 32MB; lower than that and SYSLINUX fails to write the boot sector. The combined size of the initramfs and kernel is about 32MB, so I imagine that's what limits us. * The main partition is limited in size only by the amount of binaries that we put there. * We have a useless 40KB swap partition, which the x86image plugin insists on creating for us. Again 40KB is the minimum size that `mkswap` will allow. It's possible to override or modify the x86image plugin to avoid swap altogether but I'm not sure of the best way to proceed. There are a few dependency cleanups in the bsp-generic stack; previously we'd build the whole 'foundation' stack which took ages and wasn't needed at all. --- elements/bsp-generic.bst | 4 +-- elements/bsp-generic/linux.bst | 5 ++- elements/bsp-generic/nasm.bst | 20 +++++++++++ elements/bsp-generic/syslinux.bst | 43 ++++++++++++++++++++++++ elements/deploy-tools.bst | 10 ++++++ elements/deploy-tools/mtools.bst | 11 ++++++ elements/deploy-tools/parted.bst | 19 +++++++++++ elements/systems/minimal-system-image-x86_64.bst | 37 ++++++++++++++++++++ elements/systems/minimal-system.bst | 12 +++++++ 9 files changed, 158 insertions(+), 3 deletions(-) create mode 100644 elements/bsp-generic/nasm.bst create mode 100644 elements/bsp-generic/syslinux.bst create mode 100644 elements/deploy-tools.bst create mode 100644 elements/deploy-tools/mtools.bst create mode 100644 elements/deploy-tools/parted.bst create mode 100644 elements/systems/minimal-system-image-x86_64.bst create mode 100644 elements/systems/minimal-system.bst diff --git a/elements/bsp-generic.bst b/elements/bsp-generic.bst index 47eb1871..b85bf117 100644 --- a/elements/bsp-generic.bst +++ b/elements/bsp-generic.bst @@ -8,5 +8,5 @@ depends: (?): - arch in ["x86_32", "x86_64"]: depends: - - bsp-x86_64-generic/nasm.bst - - bsp-x86_64-generic/syslinux.bst + (>): + - bsp-generic/syslinux.bst diff --git a/elements/bsp-generic/linux.bst b/elements/bsp-generic/linux.bst index 536d6c1d..bac015a3 100644 --- a/elements/bsp-generic/linux.bst +++ b/elements/bsp-generic/linux.bst @@ -1,6 +1,9 @@ kind: manual + depends: -- docutils.bst +- filename: core.bst + type: build + sources: - kind: git url: upstream:linux diff --git a/elements/bsp-generic/nasm.bst b/elements/bsp-generic/nasm.bst new file mode 100644 index 00000000..e78d422d --- /dev/null +++ b/elements/bsp-generic/nasm.bst @@ -0,0 +1,20 @@ +kind: autotools + +depends: +- gnu-toolchain.bst +- filename: core/autoconf.bst + type: build +- filename: docutils/asciidoc.bst + type: build +- filename: docutils/xmlto.bst + type: build + +sources: +- kind: git + url: upstream:nasm + track: nasm-2.11.08 + ref: 8fa0fe16408afc76ce1ae4387e1a9d46893cfda6 + +config: + install-commands: + - make INSTALLROOT="%{install-root}" install diff --git a/elements/bsp-generic/syslinux.bst b/elements/bsp-generic/syslinux.bst new file mode 100644 index 00000000..4ac1f98a --- /dev/null +++ b/elements/bsp-generic/syslinux.bst @@ -0,0 +1,43 @@ +kind: manual + +depends: +- gnu-toolchain.bst +- filename: core/perl.bst + type: build +- filename: python2-core.bst + type: build +- filename: bsp-generic/nasm.bst + type: build + +sources: +- kind: git + url: upstream:syslinux + track: baserock/syslinux-4.06-gcc7 + ref: 02ab5d34ba0a90e3b6dd78034d7c470c77500119 + +config: + build-commands: + - make clean + - make NO_WERROR=1 + - make NO_WERROR=1 installer + install-commands: + - make INSTALLROOT="%{install-root}" MANDIR="%{mandir}" install + +public: + bst: + split-rules: + runtime: + (>): + - | + %{datadir}/syslinux + - | + %{datadir}/syslinux/* + - | + %{datadir}/syslinux/diag/* + - | + %{datadir}/syslinux/dosutil/* + + devel: + (>): + - | + %{datadir}/syslinux/com32/** diff --git a/elements/deploy-tools.bst b/elements/deploy-tools.bst new file mode 100644 index 00000000..84de2e7f --- /dev/null +++ b/elements/deploy-tools.bst @@ -0,0 +1,10 @@ +kind: stack +description: Deployment tooling + +depends: +- core/e2fsprogs.bst +- coreutils-common/coreutils.bst +- deploy-tools/mtools.bst +- deploy-tools/parted.bst +- bsp-generic/nasm.bst +- bsp-generic/syslinux.bst diff --git a/elements/deploy-tools/mtools.bst b/elements/deploy-tools/mtools.bst new file mode 100644 index 00000000..354a1cfa --- /dev/null +++ b/elements/deploy-tools/mtools.bst @@ -0,0 +1,11 @@ +kind: autotools +depends: +- gnu-toolchain.bst +sources: +- kind: git + url: upstream:mtools + track: mtools-4.0.18 + ref: af0c3edb9706e470b45a9c8dd6debcc9e2d543c2 +config: + configure-commands: + - ./configure --prefix="%{prefix}" diff --git a/elements/deploy-tools/parted.bst b/elements/deploy-tools/parted.bst new file mode 100644 index 00000000..e1024f90 --- /dev/null +++ b/elements/deploy-tools/parted.bst @@ -0,0 +1,19 @@ +kind: autotools +depends: +- core.bst +sources: +- kind: git + url: upstream:parted + track: baserock/v3.2 + ref: 387e96e6eac59d84e9a688422b4b321ae9beaa20 + submodules: + gnulib: + url: upstream:gnulib +config: + configure-commands: + - sed -i -e '/^buildreq="/,/^"/{/rsync/d}' bootstrap.conf + - sed -i -e '/^buildreq="/,/^"/{/perl/d}' bootstrap.conf + - ./bootstrap --skip-po --no-git --gnulib-srcdir=gnulib + - ./configure --prefix="%{prefix}" --disable-device-mapper + build-commands: + - make WERROR_CFLAGS="" diff --git a/elements/systems/minimal-system-image-x86_64.bst b/elements/systems/minimal-system-image-x86_64.bst new file mode 100644 index 00000000..d92d5fd5 --- /dev/null +++ b/elements/systems/minimal-system-image-x86_64.bst @@ -0,0 +1,37 @@ +kind: buildstream-external:x86image +description: Create a deployment of the minimal system +depends: +- filename: systems/minimal-system.bst + type: build +- filename: deploy-tools.bst + type: build + +variables: + # Size of the disk to create + # + # Should be able to calculate this based on the space + # used, however it must be a multiple of (63 * 512) bytes + # as mtools wants a size that is devisable by sectors (512 bytes) + # per track (63). + # + # This is the smallest boot partition I managed to make. + boot-size: 33516K + + rootfs-size: 20M + sector-size: 512 + swap-size: 40K + + kernel-args: root=/dev/sda2 rootfstype=ext4 init=/sbin/init console=ttyS0 + +config: + base: deploy-tools.bst + input: systems/minimal-system.bst + + final-commands: + (>): + - | + cat > %{install-root}/run-in-qemu.sh << EOF + #!/bin/sh + qemu-system-x86_64 -drive file=sda.img,format=raw -nographic + EOF + chmod +x %{install-root}/run-in-qemu.sh diff --git a/elements/systems/minimal-system.bst b/elements/systems/minimal-system.bst new file mode 100644 index 00000000..57a5698a --- /dev/null +++ b/elements/systems/minimal-system.bst @@ -0,0 +1,12 @@ +kind: compose +description: Minimal system + +depends: +- filename: systems/minimal-system-content.bst + type: build +- filename: initramfs/initramfs-gz.bst + type: build + +config: + include: + - runtime -- cgit v1.2.1