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 b4b0384b61
commit cfbadf00dc
7 changed files with 99 additions and 31 deletions

View File

@ -15,7 +15,14 @@ Chroot ()
# Executing commands in chroot # Executing commands in chroot
Echo_debug "Executing: ${COMMANDS}" Echo_debug "Executing: ${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} ${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 "${?}" return "${?}"
} }

View File

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

View File

@ -49,13 +49,32 @@ Create_lockfile .lock
# Normally, virtual filesystems are not mounted here, but people tend to be lazy # Normally, virtual filesystems are not mounted here, but people tend to be lazy
if [ -f chroot/proc/version ] if [ -f chroot/proc/version ]
then
if [ "${LH_USE_FAKEROOT}" != "enabled" ]
then then
${LH_ROOT_COMMAND} umount chroot/proc ${LH_ROOT_COMMAND} umount chroot/proc
else
rm -rf chroot/proc
mkdir -p chroot/proc
fi
fi fi
if [ -d chroot/sys/kernel ] if [ -d chroot/sys/kernel ]
then then
if [ "${LH_USE_FAKEROOT}" != "enabled" ]
then
${LH_ROOT_COMMAND} umount chroot/sys ${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 fi
if [ "${LH_CHROOT_BUILD}" = "disabled" ] if [ "${LH_CHROOT_BUILD}" = "disabled" ]

View File

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

View File

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

View File

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

View File

@ -88,6 +88,7 @@ USAGE="${PROGRAM} [--apt apt|aptitude]\n\
\t [--packages PACKAGE|\"PACKAGES\"]\n\ \t [--packages PACKAGE|\"PACKAGES\"]\n\
\t [--quiet]\n\ \t [--quiet]\n\
\t [--root-command sudo]\n\ \t [--root-command sudo]\n\
\t [--use-fakeroot enabled|disabled]\n\
\t [--sections SECTION|\"SECTIONS\"]\n\ \t [--sections SECTION|\"SECTIONS\"]\n\
\t [--security enabled|disabled]\n\ \t [--security enabled|disabled]\n\
\t [--source enabled|disabled]\n\ \t [--source enabled|disabled]\n\
@ -107,7 +108,7 @@ USAGE="${PROGRAM} [--apt apt|aptitude]\n\
Local_arguments () 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" ] if [ "${?}" != "0" ]
then then
@ -216,6 +217,11 @@ Local_arguments ()
shift 2 shift 2
;; ;;
--use-fakeroot)
LH_USE_FAKEROOT="${2}"
shift 2
;;
--tasksel) --tasksel)
LH_TASKSEL="${2}" LH_TASKSEL="${2}"
shift 2 shift 2
@ -702,6 +708,10 @@ LH_MODE="${LH_MODE}"
# (Default: empty) # (Default: empty)
#LH_ROOT_COMMAND="sudo" #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 # \$LH_TASKSEL: set tasksel program
# (Default: ${LH_TASKSEL}) # (Default: ${LH_TASKSEL})
LH_TASKSEL="${LH_TASKSEL}" LH_TASKSEL="${LH_TASKSEL}"