diff options
author | Daniel Baumann <daniel@debian.org> | 2009-02-25 09:51:28 +0100 |
---|---|---|
committer | Daniel Baumann <daniel@debian.org> | 2011-03-09 19:09:42 +0100 |
commit | f73041f2f0905a2bb6ee3b938a9e1fa0fc53a3e6 (patch) | |
tree | 517c37c1229fa05947a3515117c1bbdfd566f3a0 /helpers | |
parent | ef9121fc23c6eae86ff359cf429af3b096360075 (diff) | |
download | vyos-live-build-f73041f2f0905a2bb6ee3b938a9e1fa0fc53a3e6.tar.gz vyos-live-build-f73041f2f0905a2bb6ee3b938a9e1fa0fc53a3e6.zip |
Adding initial support for virtual-hdd binary image type.
Diffstat (limited to 'helpers')
-rwxr-xr-x | helpers/lh_binary | 1 | ||||
-rwxr-xr-x | helpers/lh_binary_debian-installer | 5 | ||||
-rwxr-xr-x | helpers/lh_binary_encryption | 5 | ||||
-rwxr-xr-x | helpers/lh_binary_linux-image | 5 | ||||
-rwxr-xr-x | helpers/lh_binary_manifest | 5 | ||||
-rwxr-xr-x | helpers/lh_binary_md5sum | 2 | ||||
-rwxr-xr-x | helpers/lh_binary_memtest | 2 | ||||
-rwxr-xr-x | helpers/lh_binary_rootfs | 24 | ||||
-rwxr-xr-x | helpers/lh_binary_virtual-hdd | 110 | ||||
-rwxr-xr-x | helpers/lh_binary_win32-loader | 7 | ||||
-rwxr-xr-x | helpers/lh_chroot_linux-image | 5 | ||||
-rwxr-xr-x | helpers/lh_clean | 4 | ||||
-rwxr-xr-x | helpers/lh_config | 12 | ||||
-rwxr-xr-x | helpers/lh_source | 1 | ||||
-rwxr-xr-x | helpers/lh_source_virtual-hdd | 114 |
15 files changed, 294 insertions, 8 deletions
diff --git a/helpers/lh_binary b/helpers/lh_binary index 470cae0f8..7dcb28126 100755 --- a/helpers/lh_binary +++ b/helpers/lh_binary @@ -77,6 +77,7 @@ lh_binary_iso ${*} lh_binary_net ${*} lh_binary_tar ${*} lh_binary_usb-hdd ${*} +lh_binary_virtual-hdd ${*} if [ "${LH_CHROOT_BUILD}" = "enabled" ] then diff --git a/helpers/lh_binary_debian-installer b/helpers/lh_binary_debian-installer index 563dae642..56f0b73b3 100755 --- a/helpers/lh_binary_debian-installer +++ b/helpers/lh_binary_debian-installer @@ -23,6 +23,11 @@ Arguments "${@}" Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source Set_defaults +if [ "${LH_BINARY_IMAGES}" = "virtual-hdd" ] +then + exit 0 +fi + if [ "${_DEBUG}" = "enabled" ] then WGET_OPTIONS="${WGET_OPTIONS} --verbose" diff --git a/helpers/lh_binary_encryption b/helpers/lh_binary_encryption index b21e82654..d64af3743 100755 --- a/helpers/lh_binary_encryption +++ b/helpers/lh_binary_encryption @@ -23,6 +23,11 @@ Arguments "${@}" Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source Set_defaults +if [ "${LH_BINARY_IMAGES}" = "virtual-hdd" ] +then + exit 0 +fi + case "${LH_ENCRYPTION}" in aes128|aes192|aes256) ;; diff --git a/helpers/lh_binary_linux-image b/helpers/lh_binary_linux-image index 529e57efe..f5abaab6e 100755 --- a/helpers/lh_binary_linux-image +++ b/helpers/lh_binary_linux-image @@ -23,6 +23,11 @@ Arguments "${@}" Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source Set_defaults +if [ "${LH_BINARY_IMAGES}" = "virtual-hdd" ] +then + exit 0 +fi + Echo_message "Begin install linux-image..." # Requiring stage file diff --git a/helpers/lh_binary_manifest b/helpers/lh_binary_manifest index b7d5b91af..981699af8 100755 --- a/helpers/lh_binary_manifest +++ b/helpers/lh_binary_manifest @@ -23,6 +23,11 @@ Arguments "${@}" Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source Set_defaults +if [ "${LH_BINARY_IMAGES}" = "virtual-hdd" ] +then + exit 0 +fi + Echo_message "Begin creating manifest..." # Requiring stage file diff --git a/helpers/lh_binary_md5sum b/helpers/lh_binary_md5sum index 9e4e5a31d..1ca7a1e4f 100755 --- a/helpers/lh_binary_md5sum +++ b/helpers/lh_binary_md5sum @@ -23,7 +23,7 @@ Arguments "${@}" Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source Set_defaults -if [ "${LH_CHECKSUMS}" != "enabled" ] +if [ "${LH_CHECKSUMS}" != "enabled" ] || [ "${LH_BINARY_IMAGES}" = "virtual-hdd" ] then exit 0 fi diff --git a/helpers/lh_binary_memtest b/helpers/lh_binary_memtest index c872bf633..88bacbcca 100755 --- a/helpers/lh_binary_memtest +++ b/helpers/lh_binary_memtest @@ -23,7 +23,7 @@ Arguments "${@}" Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source Set_defaults -if [ "${LH_MEMTEST}" = "disabled" ] || [ "${LH_MEMTEST}" = "none" ] +if [ "${LH_BINARY_IMAGES}" = "virtual-hdd" ] || [ "${LH_MEMTEST}" = "disabled" ] || [ "${LH_MEMTEST}" = "none" ] then exit 0 fi diff --git a/helpers/lh_binary_rootfs b/helpers/lh_binary_rootfs index 2099d3d31..9040f8710 100755 --- a/helpers/lh_binary_rootfs +++ b/helpers/lh_binary_rootfs @@ -299,6 +299,25 @@ case "${LH_CHROOT_FILESYSTEM}" in # Removing depends Remove_package ;; + + none) + if [ -d binary ] + then + rm -rf binary + fi + + case "${LH_CHROOT_BUILD}" in + enabled) + mv chroot/chroot binary + ;; + + disabled) + Echo_message "This may take a while." + cp -a chroot binary + ;; + esac + ;; + esac for STAGE in ${LH_CACHE_STAGES} @@ -309,7 +328,10 @@ do mkdir -p cache/stages_rootfs - ${LH_ROOT_COMMAND} cp -a binary/"${INITFS}"/filesystem.* cache/stages_rootfs + if [ "${LH_CHROOT_FILESYSTEM}" != "none" ] + then + ${LH_ROOT_COMMAND} cp -a binary/"${INITFS}"/filesystem.* cache/stages_rootfs + fi if [ -n "${LH_ROOT_COMMAND}" ] then diff --git a/helpers/lh_binary_virtual-hdd b/helpers/lh_binary_virtual-hdd new file mode 100755 index 000000000..b5d78761f --- /dev/null +++ b/helpers/lh_binary_virtual-hdd @@ -0,0 +1,110 @@ +#!/bin/sh + +# lh_binary_virtual-hdd(1) - build binary virtual-hdd image +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper comes with ABSOLUTELY NO WARRANTY; for details see COPYING. +# This is free software, and you are welcome to redistribute it +# under certain conditions; see COPYING for details. + +set -e + +# Including common functions +. "${LH_BASE:-/usr/share/live-helper}"/functions.sh + +# Setting static variables +DESCRIPTION="$(Echo 'build binary image')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source +Set_defaults + +if ! In_list virtual-hdd "${LH_BINARY_IMAGES}" +then + exit 0 +fi + +Echo_message "Begin building binary virtual-hdd image..." + +# Requiring stage file +Require_stagefile .stage/config .stage/bootstrap .stage/chroot_proc + +# Checking stage file +Check_stagefile .stage/binary_virtual-hdd + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +if [ "${LH_CHROOT_BUILD}" = "enabled" ] +then + case "${LH_BINARY_FILESYSTEM}" in + ext2|ext3) + Check_package chroot/sbin/mkfs.ext2 e2fsprogs + ;; + esac +fi + +# Restoring cache +Restore_cache cache/packages_binary + +# Installing depends +Install_package + +# Remove old binary +if [ -f binary-virtual.img ] +then + rm -f binary-virtual.img +fi + +Echo_message "Creating virtual disk image..." +dd if=/dev/zero of=binary-virtual.img bs=1024k count=0 seek=${LH_VIRTUAL_ROOT_SIZE} + +if [ "${LH_CHROOT_BUILD}" = "enabled" ] +then + mv binary-virtual.img chroot + + case "${LH_BINARY_FILESYSTEM}" in + ext2) + Chroot chroot "mkfs.ext2 -F binary-virtual.img" + ;; + + ext3) + Chroot chroot "mkfs.ext3 -F binary-virtual.img" + ;; + esac + + mv chroot/binary-virtual.img ./ +else + case "${LH_BINARY_FILESYSTEM}" in + ext2) + mkfs.ext2 -F binary-virtual.img + ;; + + ext3) + mkfs.ext3 -F binary-virtual.img + ;; + esac +fi + +mkdir -p binary.tmp +${LH_ROOT_COMMAND} mount -o loop binary-virtual.img binary.tmp +cp -a binary/ binary.tmp + +${LH_ROOT_COMMAND} umount binary.tmp +rmdir binary.tmp + +# Saving cache +Save_cache cache/packages_binary + +# Removing depends +Remove_package + +# Creating stage file +Create_stagefile .stage/binary_virtual-hdd diff --git a/helpers/lh_binary_win32-loader b/helpers/lh_binary_win32-loader index 1126f0149..9bf437040 100755 --- a/helpers/lh_binary_win32-loader +++ b/helpers/lh_binary_win32-loader @@ -23,6 +23,11 @@ Arguments "${@}" Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source Set_defaults +if [ "${LH_WIN32_LOADER}" != "enabled" ] || [ "${LH_BINARY_IMAGES}" = "virtual-hdd" ] +then + exit 0 +fi + Echo_message "Begin copying win32-loader..." # Requiring stage file @@ -37,7 +42,7 @@ Check_lockfile .lock # Creating lock file Create_lockfile .lock -if [ "${LH_WIN32_LOADER}" = "enabled" ] && [ "${LH_DISTRIBUTION}" != "etch" ] +if [ "${LH_DISTRIBUTION}" != "etch" ] then case "${LH_ARCHITECTURE}" in amd64|i386) diff --git a/helpers/lh_chroot_linux-image b/helpers/lh_chroot_linux-image index 1ee14bcbe..cc2c8e8a0 100755 --- a/helpers/lh_chroot_linux-image +++ b/helpers/lh_chroot_linux-image @@ -70,7 +70,10 @@ EOF fi # Queue installation of linux-image and ${LH_INITRAMFS} - echo ${LH_INITRAMFS} >> chroot/root/chroot_packages + if [ "${LH_INITRAMFS}" != "none" ] + then + echo ${LH_INITRAMFS} >> chroot/root/chroot_packages + fi # Creating stage file Create_stagefile .stage/chroot_linux-image diff --git a/helpers/lh_clean b/helpers/lh_clean index bb3d28f93..95cf60b64 100755 --- a/helpers/lh_clean +++ b/helpers/lh_clean @@ -91,7 +91,7 @@ do ${LH_ROOT_COMMAND} umount -f binary.tmp > /dev/null 2>&1 || true rm -rf binary.tmp binary.deb binary.udeb rm -f binary.iso - rm -f binary.img + rm -f binary*.img rm -f binary*.tar.gz rm -f binary.sh rm -f binary.list binary.packages md5sum.txt @@ -118,7 +118,7 @@ do --source) rm -f source.iso - rm -f source.img + rm -f source*.img rm -f source*.tar rm -f source*.tar.gz rm -f source.list diff --git a/helpers/lh_config b/helpers/lh_config index 6e6a330a6..f91f02636 100755 --- a/helpers/lh_config +++ b/helpers/lh_config @@ -120,6 +120,7 @@ USAGE="${PROGRAM} [--apt apt|aptitude]\n\ \t [--tasks TASK]\n\ \t [--templates PATH]\n\ \t [--union-filesystem aufs|unionfs]\n\ +\t [--virtual-root-size MB]\n\ \t [--exposed-root enabled|disabled]\n\ \t [--username NAME]\n\ \t [--verbose]\n\ @@ -133,7 +134,7 @@ Local_arguments () initramfs:,fdisk:,losetup:,mode:,root-command:,use-fakeroot:,tasksel:,includes:, templates:,architecture:,bootstrap-config:,bootstrap-flavour:,bootstrap-keyring:,clean, distribution:,mirror-bootstrap:,mirror-chroot:,mirror-chroot-security:,mirror-binary:, - mirror-binary-security:,categories:,chroot-filesystem:,union-filesystem:,exposed-root:, + mirror-binary-security:,categories:,chroot-filesystem:,union-filesystem:,exposed-root:,virtual-root-size:, hooks:,interactive:,keyring-packages:,language:,linux-flavours:,linux-packages:, packages:,packages-lists:,tasks:,security:,symlinks:,sysvinit:,binary-filesystem:,binary-images:, binary-indices:,bootappend-install:,bootappend-live:,bootloader:,checksums:,chroot-build:, @@ -410,6 +411,11 @@ Local_arguments () shift 2 ;; + --virtual-root-size) + LH_VIRTUAL_ROOT_SIZE="${2}" + shift 2 + ;; + --exposed-root) LH_EXPOSED_ROOT="${2}" shift 2 @@ -962,6 +968,10 @@ LH_CHROOT_FILESYSTEM="${LH_CHROOT_FILESYSTEM}" # (Default: ${LH_UNION_FILESYSTEM}) LH_UNION_FILESYSTEM="${LH_UNION_FILESYSTEM}" +# \$LH_VIRTUAL_ROOT_SIZE: set virtual-hdd filesystem size +# (Default: ${LH_VIRTUAL_ROOT_SIZE}) +LH_VIRTUAL_ROOT_SIZE="${LH_VIRTUAL_ROOT_SIZE}" + # \$LH_EXPOSED_ROOT: expose root as read only # (Default: ${LH_EXPOSED_ROOT}) LH_EXPOSED_ROOT="${LH_EXPOSED_ROOT}" diff --git a/helpers/lh_source b/helpers/lh_source index 35c1831fd..2f4707b82 100755 --- a/helpers/lh_source +++ b/helpers/lh_source @@ -45,6 +45,7 @@ lh_source_iso ${*} lh_source_net ${*} lh_source_tar ${*} lh_source_usb-hdd ${*} +lh_source_virtual-hdd ${*} # Deconfiguring chroot rm -f .stage/chroot_sources diff --git a/helpers/lh_source_virtual-hdd b/helpers/lh_source_virtual-hdd new file mode 100755 index 000000000..e02f0a0b5 --- /dev/null +++ b/helpers/lh_source_virtual-hdd @@ -0,0 +1,114 @@ +#!/bin/sh + +# lh_source_virtual-hdd(1) - build source virtual-hdd image +# Copyright (C) 2006-2009 Daniel Baumann <daniel@debian.org> +# +# live-helper comes with ABSOLUTELY NO WARRANTY; for details see COPYING. +# This is free software, and you are welcome to redistribute it +# under certain conditions; see COPYING for details. + +set -e + +# Including common functions +. "${LH_BASE:-/usr/share/live-helper}"/functions.sh + +# Setting static variables +DESCRIPTION="$(Echo 'build source image')" +HELP="" +USAGE="${PROGRAM} [--force]" + +Arguments "${@}" + +# Reading configuration files +Read_conffiles config/all config/common config/bootstrap config/chroot config/binary config/source +Set_defaults + +if [ "${LH_SOURCE}" != "enabled" ] +then + exit 0 +fi + +if ! In_list virtual-hdd "${LH_SOURCE_IMAGES}" +then + exit 0 +fi + +Echo_message "Begin building source virtual-hdd image..." + +# Requiring stage file +Require_stagefile .stage/config .stage/source_debian + +# Checking stage file +Check_stagefile .stage/source_virtual-hdd + +# Checking lock file +Check_lockfile .lock + +# Creating lock file +Create_lockfile .lock + +if [ "${LH_CHROOT_BUILD}" = "enabled" ] +then + case "${LH_BINARY_FILESYSTEM}" in + ext2|ext3) + Check_package chroot/sbin/mkfs.ext2 e2fsprogs + ;; + esac +fi + +# Installing depends +Install_package + +# Remove old source +if [ -f source-virtual.img ] +then + rm -f source-virtual.img +fi + +# Everything which comes here needs to be cleaned up, +DU_DIM="$(du -ms source | cut -f1)" +REAL_DIM="$(Calculate_partition_size ${DU_DIM} ${LH_BINARY_FILESYSTEM})" +dd if=/dev/zero of=source-virtual.img bs=1024k count=0 seek=${REAL_DIM} + +if [ "${LH_CHROOT_BUILD}" = "enabled" ] +then + mv source-virtual.img chroot + + case "${LH_BINARY_FILESYSTEM}" in + ext2) + Chroot chroot "mkfs.ext2 -F -m 0 source-virtual.img" + ;; + + ext3) + Chroot chroot "mkfs.ext3 -F source-virtual.img" + ;; + esac + + mv chroot/source-virtual.img ./ +else + case "${LH_BINARY_FILESYSTEM}" in + ext2) + mkfs.ext2 -F -m 0 source-virtual.img + ;; + + ext3) + mkfs.ext3 -F -m 0 source-virtual.img + ;; + esac +fi + +mkdir -p source.tmp +${LH_ROOT_COMMAND} mount -o loop source-virtual.img source.tmp +cp -r source/* source.tmp + +${LH_ROOT_COMMAND} umount source.tmp +rmdir source.tmp + +# Saving cache +Save_cache cache/packages_binary + +# Removing depends +Remove_package + +# Creating stage file +Create_stagefile .stage/source_virtual-hdd |