Commit 2d9a99ee authored by Gerardo Exequiel Pozzi's avatar Gerardo Exequiel Pozzi Committed by Pierre Schmitz
Browse files

Add -d param to optionally support devtmpfs



The main intention of this patch is to take advantage of
/dev/loop-control and loop devices.

Signed-off-by: default avatarGerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
Signed-off-by: default avatarPierre Schmitz <pierre@archlinux.de>
parent cecd2577
Loading
Loading
Loading
Loading
+22 −15
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@ m4_include(lib/common.sh)
FORCE='n'
RUN=''
NOCOPY='n'
USE_DEVTMPFS='n'

working_dir=''

@@ -29,11 +30,12 @@ usage() {
	echo '    -M <file>     Location of a makepkg config file'
	echo '    -n            Do not copy config files into the chroot'
	echo '    -c <dir>      Set pacman cache. Default: /var/cache/pacman/pkg'
	echo '    -d            Use devtmpfs instead of minimal /dev (tmpfs)'
	echo '    -h            This message'
	exit 1
}

while getopts 'r:ufnhC:M:c:' arg; do
while getopts 'r:ufnhC:M:c:d' arg; do
	case "${arg}" in
		r) RUN="$OPTARG" ;;
		u) RUN='/bin/sh -c "pacman -Syu --noconfirm && (pacman -Qqu >/dev/null && pacman -Su --noconfirm || exit 0)"' ;;
@@ -42,6 +44,7 @@ while getopts 'r:ufnhC:M:c:' arg; do
		M) makepkg_conf="$OPTARG" ;;
		n) NOCOPY='y' ;;
		c) cache_dir="$OPTARG" ;;
		d) USE_DEVTMPFS="y" ;;
		h|?) usage 0 ;;
		*) error "invalid argument '${arg}'"; usage ;;
	esac
@@ -90,6 +93,9 @@ chroot_mount() {
	mount -t proc proc "${working_dir}/proc"

	[[ -e "${working_dir}/dev" ]] || mkdir "${working_dir}/dev"
	if [[ ${USE_DEVTMPFS} = "y" ]]; then
		mount -t devtmpfs dev "${working_dir}/dev" -o mode=0755,nosuid
	else
		mount -t tmpfs dev "${working_dir}/dev" -o mode=0755,size=10M,nosuid
		mknod -m 666 "${working_dir}/dev/null" c 1 3
		mknod -m 666 "${working_dir}/dev/zero" c 1 5
@@ -104,6 +110,7 @@ chroot_mount() {
		ln -s /proc/self/fd/0 "${working_dir}/dev/stdin"
		ln -s /proc/self/fd/1 "${working_dir}/dev/stdout"
		ln -s /proc/self/fd/2 "${working_dir}/dev/stderr"
	fi

	[[ -e "${working_dir}/dev/shm" ]] || mkdir "${working_dir}/dev/shm"
	mount -t tmpfs shm "${working_dir}/dev/shm" -o nodev,nosuid,size=128M