Bug#586158: debootstrap fails if the directory contains a space
On 4 December 2015 at 04:13, Matthijs Kooijman <matthijs@stdin.nl> wrote:
> Apparently the path isn't escaped properly when passing it to sed. I
> haven't tried fixing it, or seeing if there are other problems, though.
I took a look, and there were actually quite a few places, but with
the attached patch, `DEBOOTSTRAP_DIR="$PWD" ./debootstrap
--variant=minbase sid ~/temp/test\ space
http://httpredir.debian.org/debian` succeeds at least. :)
Not sure if this is something the debootstrap maintainers want to
accept going forward, but most of the codebase seemed to already be
quoting properly for this sort of thing so it seemed appropriate to
continue.
As a note to the debootstrap maintainers, if you _do_ want this patch
(or something like it), I'm happy to adjust and enhance it however so
that it's acceptable (even if that's just recreating the patch file in
a format that's easier for whatever method you prefer for applying
it)!
♥,
- Tianon
4096R / B42F 6819 007F 00F8 8E36 4FD4 036A 9C25 BF35 7DD4
diff --git a/debootstrap b/debootstrap
index 2a959bb..23c0553 100755
--- a/debootstrap
+++ b/debootstrap
@@ -467,7 +467,7 @@ elif doing_variant scratchbox; then
[ "x$SB2_TARGET" != "x" ] || error 1 SBOXTARGETREQ "No scratchbox target configured for $TARGET"
CHROOT_CMD="sb2 -eR -t $SB2_TARGET"
else
- CHROOT_CMD="chroot $TARGET"
+ CHROOT_CMD="chroot \"$TARGET\""
fi
if [ -z "$SHA_SIZE" ]; then
@@ -620,7 +620,7 @@ if am_doing_phase dldebs; then
fi
if am_doing_phase maketarball; then
- (cd $TARGET;
+ (cd "$TARGET";
tar czf - var/lib/apt var/cache/apt) >$MAKE_TARBALL
fi
diff --git a/functions b/functions
index 8bef5e6..1aaec66 100644
--- a/functions
+++ b/functions
@@ -547,7 +547,7 @@ download_release_indices () {
download_release_sig "$m1" "$reldest" "$relsigdest"
- extract_release_components $reldest
+ extract_release_components "$reldest"
local totalpkgs=0
for c in $COMPONENTS; do
@@ -644,8 +644,8 @@ download_debs () {
local debdest="$($DLDEST deb "$p" "$ver" "$arc" "$m" "$fil")"
if get "$m/$fil" "$TARGET/$debdest" "$checksum" "$size"; then
dloaddebs="$(($dloaddebs + $size))"
- echo >>$TARGET/debootstrap/deburis "$p $ver $m/$fil"
- echo >>$TARGET/debootstrap/debpaths "$p $debdest"
+ echo >>"$TARGET/debootstrap/deburis" "$p $ver $m/$fil"
+ echo >>"$TARGET/debootstrap/debpaths" "$p $debdest"
else
warning COULDNTDL "Couldn't download package %s (ver %s arch %s)" "$p" "$ver" "$arc"
leftover="$leftover $p"
@@ -698,7 +698,7 @@ download_release () {
local dloaddebs=0
progress $dloaddebs $totaldebs DOWNDEBS "Downloading packages"
- :>$TARGET/debootstrap/debpaths
+ :>"$TARGET/debootstrap/debpaths"
pkgs_to_get="$*"
for c in $COMPONENTS; do
@@ -745,7 +745,7 @@ download_main_indices () {
download_main () {
local m1="${MIRRORS%% *}"
- :>$TARGET/debootstrap/debpaths
+ :>"$TARGET/debootstrap/debpaths"
for p in "$@"; do
for c in $COMPONENTS; do
local details=""
@@ -762,7 +762,7 @@ download_main () {
checksum="${details##* }"; details="${details% *}"
local debdest="$($DLDEST deb $details)"
if get "$m/${details##* }" "$TARGET/$debdest" "$checksum" "$size"; then
- echo >>$TARGET/debootstrap/debpaths "$p $debdest"
+ echo >>"$TARGET/debootstrap/debpaths" "$p $debdest"
details="done"
break
fi
@@ -900,7 +900,7 @@ extract () { (
); }
in_target_nofail () {
- if ! $CHROOT_CMD "$@" 2>/dev/null; then
+ if ! eval "$CHROOT_CMD \"\$@\"" 2>/dev/null; then
true
fi
return 0
@@ -911,7 +911,7 @@ in_target_failmsg () {
local msg="$2"
local arg="$3"
shift; shift; shift
- if ! $CHROOT_CMD "$@"; then
+ if ! eval "$CHROOT_CMD \"\$@\""; then
warning "$code" "$msg" "$arg"
# Try to point user at actual failing package.
msg="See %s for details"
@@ -1017,7 +1017,7 @@ setup_proc () {
if [ "$HOST_OS" = kfreebsd ]; then
in_target mount -t linprocfs proc /proc
else
- mount -t linprocfs proc $TARGET/proc
+ mount -t linprocfs proc "$TARGET/proc"
fi
;;
hurd*)
@@ -1056,7 +1056,7 @@ setup_devices () {
kfreebsd*)
in_target mount -t devfs devfs /dev ;;
freebsd)
- mount -t devfs devfs $TARGET/dev ;;
+ mount -t devfs devfs "$TARGET/dev" ;;
hurd*)
setup_devices_hurd ;;
*)
@@ -1077,8 +1077,8 @@ setup_devices_hurd () {
# Use the setup-translators of the hurd package, and firmlink
# $TARGET/{dev,servers} to the system ones.
in_target /usr/lib/hurd/setup-translators -k
- settrans -a $TARGET/dev /hurd/firmlink /dev
- settrans -a $TARGET/servers /hurd/firmlink /servers
+ settrans -a "$TARGET/dev" /hurd/firmlink /dev
+ settrans -a "$TARGET/servers" /hurd/firmlink /servers
}
setup_devices_fakechroot () {
Reply to: