Adding initial support for virtual-hdd binary image type.

This commit is contained in:
Daniel Baumann 2009-02-25 09:51:28 +01:00
parent ef9121fc23
commit f73041f2f0
20 changed files with 367 additions and 8 deletions

View File

@ -354,6 +354,9 @@ Set_defaults ()
# Setting chroot filesystem
LH_CHROOT_FILESYSTEM="${LH_CHROOT_FILESYSTEM:-squashfs}"
# Setting virtual root size
LH_VIRTUAL_ROOT_SIZE="${LH_VIRTUAL_ROOT_SIZE:-10000}"
# Setting whether to expose root filesystem as read only
LH_EXPOSED_ROOT="${LH_EXPOSED_ROOT:-disabled}"

View File

@ -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

View File

@ -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"

View File

@ -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)
;;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

110
helpers/lh_binary_virtual-hdd Executable file
View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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}"

View File

@ -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

114
helpers/lh_source_virtual-hdd Executable file
View File

@ -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

View File

@ -0,0 +1,29 @@
.TH LH_BINARY_VIRTUAL\-HDD 1 "2009\-01\-23" "1.0.2" "live\-helper"
.SH NAME
lh_binary_virtual\-hdd \- build binary virtual\-hdd image
.SH SYNOPSIS
\fBlh_binary_virtual\-hdd\fR [\fIlive\-helper options\fR]
.SH DESCRIPTION
lh_binary_virtual\-hdd is a low\-level command (plumbing) of live\-helper, the Debian Live tool suite. It builds binary virtual\-hdd image.
.SH OPTIONS
lh_binary_virtual\-hdd has no specific options but understands all generic live\-helper options. See \fIlive\-helper\fR(7) for a complete list of all generic live\-helper options.
.SH SEE ALSO
\fIlh_binary\fR(1)
.br
\fIlive\-helper\fR(7)
.PP
This program is a part of live\-helper.
.SH HOMEPAGE
More information about live\-helper and the Debian Live project can be found in the homepage at <\fIhttp://debian\-live.alioth.debian.org/\fR> and in the manual at <\fIhttp://live.debian.net/manual/\fR>.
.SH BUGS
Report bugs by submitting a bugreport for the live\-helper package in the Debian Bug Tracking System at <\fIhttp://bugs.debian.org/\fR> or write a mail to the mailinglist at <\fIdebian-live@lists.debian.org\fR>.
.SH AUTHOR
live\-helper was written by Daniel Baumann <\fIdaniel@debian.org\fR> for the Debian project.

View File

@ -185,6 +185,10 @@ lh_config \- create configuration for live\-helper
[\fB\-\-templates\fR \fIPATH\fR]
.br
[\fB\-\-union\-filesystem\fR aufs|unionfs]
.br
[\fB\-\-virtual\-root\-filesystem\fR ext3]
.br
[\fB\-\-virtual\-root\-size \fIMB\fR]
.br
[\fB\-\-exposed\-root\fR enabled|disabled]
.br
@ -389,6 +393,10 @@ defines one or more package tasks to be installed in the live system. This is a
sets the path to the templates that live\-helper is going to use, e.g. for bootloaders. By default, this is set to /usr/share/live-helper/templates/.
.IP "\fB\-\-union\-filesystem\fR aufs|unionfs" 4
defines whetever to use UnionFS or Aufs as stackable unification filesystem. When building etch images, this defaults to unionfs, everywhere else to aufs.
.IP "\fB\-\-virtual\-root\-filesystem\fR ext3" 4
defines what filesystem to format the root filesystem when building virtual-hdd images.
.IP "\fB\-\-virtual\-root\-size\fR MB" 4
defines what size the virtual-hdd image should be. Note that although the default is set to 10000 (= 10GB), it will not need 10GB space on your harddisk as the files are created as sparse files.
.IP "\fB\-\-exposed\-root\fR enabled|disabled" 4
FIXME
.IP "\fB\-\-username\fR \fINAME\fR" 4

View File

@ -0,0 +1,29 @@
.TH LH_SOURCE_VIRTUAL\-HDD 1 "2009\-01\-23" "1.0.2" "live\-helper"
.SH NAME
lh_source_virtual\-hdd \- build source virtual-hdd image
.SH SYNOPSIS
\fBlh_source_virtual\-hdd\fR [\fIlive\-helper options\fR]
.SH DESCRIPTION
lh_source_virtual\-hdd is a low\-level command (plumbing) of live\-helper, the Debian Live tool suite. It builds source virtual-hdd image.
.SH OPTIONS
lh_source_virtual\-hdd has no specific options but understands all generic live\-helper options. See \fIlive\-helper\fR(7) for a complete list of all generic live\-helper options.
.SH SEE ALSO
\fIlh_source\fR(1)
.br
\fIlive\-helper\fR(7)
.PP
This program is a part of live\-helper.
.SH HOMEPAGE
More information about live\-helper and the Debian Live project can be found in the homepage at <\fIhttp://debian\-live.alioth.debian.org/\fR> and in the manual at <\fIhttp://live.debian.net/manual/\fR>.
.SH BUGS
Report bugs by submitting a bugreport for the live\-helper package in the Debian Bug Tracking System at <\fIhttp://bugs.debian.org/\fR> or write a mail to the mailinglist at <\fIdebian-live@lists.debian.org\fR>.
.SH AUTHOR
live\-helper was written by Daniel Baumann <\fIdaniel@debian.org\fR> for the Debian project.

View File

@ -189,6 +189,8 @@ installs syslinux into binary
build harddisk binary image
.IP "\fBlh_binary_usb-hdd\fR(1)" 4
build binary usb-hdd image
.IP "\fBlh_binary_virtual-hdd\fR(1)" 4
build binary virtual-hdd image
.IP "\fBlh_binary_win32-loader\fR(1)" 4
installs win32-loader into binary
.IP "\fBlh_binary_yaboot\fR(1)" 4
@ -210,6 +212,8 @@ build source net image
build source tarball
.IP "\fBlh_source_usb-hdd\fR(1)" 4
build source usb-hdd image
.IP "\fBlh_source_virtual-hdd\fR(1)" 4
build source virtual-hdd image
.SH CONFIG FILES
Many live\-helper commands make use of files in the \fIconfig/\fR directory to control what they do. Besides the common \fIconfig/common\fR, which is used by all live\-helper commands, some additional files can be used to configure the behavior of specific live\-helper commands. These files are typically named config/stage or config/stage_helper (where "stage" of course, is replaced with the name of the stage that they belong to, and "helper" with the name of the helper).