Adding option to allow building in fakeroot/fakechroot environment, thanks to An-Cheng Huang <ancheng@vyatta.com>.

This commit is contained in:
Daniel Baumann 2007-11-10 18:39:49 +01:00
parent ee91e98161
commit ba83790488
7 changed files with 99 additions and 31 deletions

View File

@ -15,7 +15,14 @@ Chroot ()
# Executing commands in chroot
Echo_debug "Executing: ${COMMANDS}"
${LH_ROOT_COMMAND} chroot chroot /usr/bin/env -i HOME="/root" PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" TERM="${TERM}" ftp_proxy="${LH_APT_FTP_PROXY}" http_proxy="${LH_APT_HTTP_PROXY}" DEBIAN_FRONTEND="${LH_DEBCONF_FRONTEND}" DEBIAN_PRIORITY="${LH_DEBCONF_PRIORITY}" DEBCONF_NOWARNINGS="${LH_DEBCONF_NOWARNINGS}" XORG_CONFIG="custom" ${COMMANDS}
if [ "${LH_USE_FAKEROOT}" != "enabled" ]
then
${LH_ROOT_COMMAND} chroot chroot /usr/bin/env -i HOME="/root" PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" TERM="${TERM}" ftp_proxy="${LH_APT_FTP_PROXY}" http_proxy="${LH_APT_HTTP_PROXY}" DEBIAN_FRONTEND="${LH_DEBCONF_FRONTEND}" DEBIAN_PRIORITY="${LH_DEBCONF_PRIORITY}" DEBCONF_NOWARNINGS="${LH_DEBCONF_NOWARNINGS}" XORG_CONFIG="custom" ${COMMANDS}
else
# Building with fakeroot/fakechroot
${LH_ROOT_COMMAND} chroot chroot ${COMMANDS}
fi
return "${?}"
}

View File

@ -590,4 +590,7 @@ Set_defaults ()
# Setting image type
LH_SOURCE_IMAGES="${LH_SOURCE_IMAGES:-tar}"
# Setting fakeroot/fakechroot
LH_USE_FAKEROOT="${LH_USE_FAKEROOT:-disabled}"
}

View File

@ -50,12 +50,31 @@ Create_lockfile .lock
# Normally, virtual filesystems are not mounted here, but people tend to be lazy
if [ -f chroot/proc/version ]
then
${LH_ROOT_COMMAND} umount chroot/proc
if [ "${LH_USE_FAKEROOT}" != "enabled" ]
then
${LH_ROOT_COMMAND} umount chroot/proc
else
rm -rf chroot/proc
mkdir -p chroot/proc
fi
fi
if [ -d chroot/sys/kernel ]
then
${LH_ROOT_COMMAND} umount chroot/sys
if [ "${LH_USE_FAKEROOT}" != "enabled" ]
then
${LH_ROOT_COMMAND} umount chroot/sys
else
rm -rf chroot/sys
mkdir -p chroot/sys
fi
fi
# Copying /dev if using fakeroot
if [ "${LH_USE_FAKEROOT}" = "enabled" ]
then
rm -rf chroot/dev
find /dev | cpio -dmpu chroot
fi
if [ "${LH_CHROOT_BUILD}" = "disabled" ]

View File

@ -82,15 +82,20 @@ then
DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --exclude=${LH_BOOTSTRAP_EXCLUDE}"
fi
if [ -z "${LH_BOOTSTRAP_FLAVOUR}" ]
if [ "${LH_USE_FAKEROOT}" != "enabled" ]
then
case "${LH_PACKAGES_LISTS}" in
minimal|mini)
DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --variant=buildd"
;;
esac
if [ -z "${LH_BOOTSTRAP_FLAVOUR}" ]
then
case "${LH_PACKAGES_LISTS}" in
minimal|mini)
DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --variant=buildd"
;;
esac
else
DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --variant=${LH_BOOTSTRAP_FLAVOUR}"
fi
else
DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --variant=${LH_BOOTSTRAP_FLAVOUR}"
DEBOOTSTRAP_OPTIONS="${DEBOOTSTRAP_OPTIONS} --variant=fakechroot"
fi
if [ "${LH_VERBOSE}" = "true" ]

View File

@ -52,14 +52,20 @@ case "${1}" in
# Creating lock file
Create_lockfile .lock
# Creating mountpoint
mkdir -p chroot/proc
if [ "${LH_USE_FAKEROOT}" != "enabled" ]
then
# Creating mountpoint
mkdir -p chroot/proc
# Mounting /proc
${LH_ROOT_COMMAND} mount proc-live -t proc chroot/proc
# Mounting /proc
${LH_ROOT_COMMAND} mount proc-live -t proc chroot/proc
# Creating stage file
Create_stagefile .stage/chroot_proc
# Creating stage file
Create_stagefile .stage/chroot_proc
else
rm -rf chroot/proc
ln -s /proc chroot/
fi
;;
remove)
@ -69,15 +75,21 @@ case "${1}" in
# Creating lock file
Create_lockfile .lock
# Workaround binfmt-support /proc locking
if [ -e chroot/proc/sys/fs/binfmt_misc/status ]
if [ "${LH_USE_FAKEROOT}" != "enabled" ]
then
${LH_ROOT_COMMAND} umount chroot/proc/sys/fs/binfmt_misc
fi
# Workaround binfmt-support /proc locking
if [ -e chroot/proc/sys/fs/binfmt_misc/status ]
then
${LH_ROOT_COMMAND} umount chroot/proc/sys/fs/binfmt_misc
fi
# Unmounting /proc
#fuser -km chroot/proc
${LH_ROOT_COMMAND} umount chroot/proc > /dev/null 2>&1
# Unmounting /proc
#fuser -km chroot/proc
${LH_ROOT_COMMAND} umount chroot/proc > /dev/null 2>&1
else
rm -rf chroot/proc
mkdir -p chroot/proc
fi
# Removing stage file
rm -f .stage/chroot_proc

View File

@ -52,11 +52,17 @@ case "${1}" in
# Creating lock file
Create_lockfile .lock
# Create mountpoint
mkdir -p chroot/sys
if [ "${LH_USE_FAKEROOT}" != "enabled" ]
then
# Create mountpoint
mkdir -p chroot/sys
# Mounting /sys
${LH_ROOT_COMMAND} mount sysfs-live -t sysfs chroot/sys
# Mounting /sys
${LH_ROOT_COMMAND} mount sysfs-live -t sysfs chroot/sys
else
rm -rf chroot/sys
ln -s /sys chroot/
fi
# Creating stage file
Create_stagefile .stage/chroot_sysfs
@ -69,9 +75,15 @@ case "${1}" in
# Creating lock file
Create_lockfile .lock
# Unmounting /sys
#fuser -km chroot/sys
${LH_ROOT_COMMAND} umount chroot/sys > /dev/null 2>&1
if [ "${LH_USE_FAKEROOT}" != "enabled" ]
then
# Unmounting /sys
#fuser -km chroot/sys
${LH_ROOT_COMMAND} umount chroot/sys > /dev/null 2>&1
else
rm -rf chroot/sys
mkdir -p chroot/sys
fi
# Removing stage file
rm -f .stage/chroot_sysfs

View File

@ -88,6 +88,7 @@ USAGE="${PROGRAM} [--apt apt|aptitude]\n\
\t [--packages PACKAGE|\"PACKAGES\"]\n\
\t [--quiet]\n\
\t [--root-command sudo]\n\
\t [--use-fakeroot enabled|disabled]\n\
\t [--sections SECTION|\"SECTIONS\"]\n\
\t [--security enabled|disabled]\n\
\t [--source enabled|disabled]\n\
@ -107,7 +108,7 @@ USAGE="${PROGRAM} [--apt apt|aptitude]\n\
Local_arguments ()
{
ARGUMENTS="$(getopt --longoptions apt:,apt-ftp-proxy:,apt-http-proxy:,apt-pdiffs:,apt-pipeline:,apt-recommends:,apt-secure:,bootstrap:,cache:,cache-indices:,cache-packages:,cache-stages:,debconf-frontend:,debconf-nowarnings:,debconf-priority:,genisoimage:,initramfs:,losetup:,mode:,root-command:,tasksel:,includes:,templates:,architecture:,bootstrap-config:,bootstrap-flavour:,bootstrap-keyring:,distribution:,mirror-bootstrap:,mirror-bootstrap-security:,mirror-binary:,mirror-binary-security:,sections:,chroot-filesystem:,union-filesystem:,exposed-root:,hooks:,interactive:,keyring-packages:,language:,linux-flavours:,linux-packages:,packages:,packages-lists:,tasks:,security:,symlinks:,sysvinit:,binary-images:,binary-indices:,bootappend-install:,bootappend-live:,bootloader:,chroot-build:,debian-installer:,debian-installer-daily:,encryption:,grub-splash:,hostname:,iso-application:,iso-preparer:,iso-publisher:,iso-volume:,memtest:,net-root-filesystem:,net-root-mountoptions:,net-root-path:,net-root-server:,net-cow-filesystem:,net-cow-mountoptions:,net-cow-path:,net-cow-server:,syslinux-splash:,syslinux-timeout:,syslinux-menu:,username:,source:,source-images:,breakpoints,conffile:,debug,force,help,quiet,usage,verbose,version --name=${PROGRAM} --options a:f:d:m:l:k:p:b:e:s:c:huv --shell sh -- "${@}")"
ARGUMENTS="$(getopt --longoptions apt:,apt-ftp-proxy:,apt-http-proxy:,apt-pdiffs:,apt-pipeline:,apt-recommends:,apt-secure:,bootstrap:,cache:,cache-indices:,cache-packages:,cache-stages:,debconf-frontend:,debconf-nowarnings:,debconf-priority:,genisoimage:,initramfs:,losetup:,mode:,root-command:,use-fakeroot:,tasksel:,includes:,templates:,architecture:,bootstrap-config:,bootstrap-flavour:,bootstrap-keyring:,distribution:,mirror-bootstrap:,mirror-bootstrap-security:,mirror-binary:,mirror-binary-security:,sections:,chroot-filesystem:,union-filesystem:,exposed-root:,hooks:,interactive:,keyring-packages:,language:,linux-flavours:,linux-packages:,packages:,packages-lists:,tasks:,security:,symlinks:,sysvinit:,binary-images:,binary-indices:,bootappend-install:,bootappend-live:,bootloader:,chroot-build:,debian-installer:,debian-installer-daily:,encryption:,grub-splash:,hostname:,iso-application:,iso-preparer:,iso-publisher:,iso-volume:,memtest:,net-root-filesystem:,net-root-mountoptions:,net-root-path:,net-root-server:,net-cow-filesystem:,net-cow-mountoptions:,net-cow-path:,net-cow-server:,syslinux-splash:,syslinux-timeout:,syslinux-menu:,username:,source:,source-images:,breakpoints,conffile:,debug,force,help,quiet,usage,verbose,version --name=${PROGRAM} --options a:f:d:m:l:k:p:b:e:s:c:huv --shell sh -- "${@}")"
if [ "${?}" != "0" ]
then
@ -216,6 +217,11 @@ Local_arguments ()
shift 2
;;
--use-fakeroot)
LH_USE_FAKEROOT="${2}"
shift 2
;;
--tasksel)
LH_TASKSEL="${2}"
shift 2
@ -702,6 +708,10 @@ LH_MODE="${LH_MODE}"
# (Default: empty)
#LH_ROOT_COMMAND="sudo"
# \$LH_USE_FAKEROOT: use fakeroot/fakechroot
# (Default: ${LH_USE_FAKEROOT})
LH_USE_FAKEROOT="${LH_USE_FAKEROOT}"
# \$LH_TASKSEL: set tasksel program
# (Default: ${LH_TASKSEL})
LH_TASKSEL="${LH_TASKSEL}"