Ideally, the build shouldn't care what is the pathname of the build directory. But some parts of the build process use, for historical reasons and for convenience, full pathnames, and some of that code did not correctly handle the case where the pathname might contain spaces, and the build fails.
The fix is to use relative pathnames where it's easy, but where it's not, be more careful to quote the filename or avoid using the shell's argument splitting in Python code. Fixes #1034 for basic "make" and "scripts/build image=rogue", but some modules (e.g., Java) still don't build properly in this case and should be fixed separately. Signed-off-by: Nadav Har'El <n...@scylladb.com> --- scripts/imgedit.py | 7 +++++-- scripts/upload_manifest.py | 2 +- Makefile | 10 +++++----- scripts/build | 22 +++++++++++----------- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/scripts/imgedit.py b/scripts/imgedit.py index a58e9b8c..7fa566c2 100755 --- a/scripts/imgedit.py +++ b/scripts/imgedit.py @@ -50,13 +50,16 @@ def write_cstr(file, str): class nbd_file(object): def __init__(self, filename): + fileformat = [] + if filename.startswith("-f raw "): + filename = filename[7:] + fileformat = ['-f', 'raw'] self._filename = filename self._offset = 0 self._buf = None self._closed = True nbd_port = randint(10809, 20809) - self._process = subprocess.Popen("qemu-nbd -p %d %s" % (nbd_port, filename), - shell=True, stdout=_devnull) + self._process = subprocess.Popen(["qemu-nbd", "-p", str(nbd_port)] + fileformat + [filename], shell=False, stdout=_devnull) # wait for qemu-nbd to start: this thing doesn't tell anything on stdout while True: try: diff --git a/scripts/upload_manifest.py b/scripts/upload_manifest.py index 341c4349..ae13cfbf 100755 --- a/scripts/upload_manifest.py +++ b/scripts/upload_manifest.py @@ -154,7 +154,7 @@ def main(): image_path = os.path.abspath(options.output) upload_port = find_free_port() - osv = subprocess.Popen('cd ../..; scripts/run.py --vnc none -m 512 -c1 -i %s -u -s -e "--norandom --nomount --noinit /tools/mkfs.so; /tools/cpiod.so --prefix /zfs/zfs/; /zfs.so set compression=off osv" --forward tcp:127.0.0.1:%s-:10000' % (image_path,upload_port), shell=True, stdout=subprocess.PIPE) + osv = subprocess.Popen('cd ../..; scripts/run.py --vnc none -m 512 -c1 -i "%s" -u -s -e "--norandom --nomount --noinit /tools/mkfs.so; /tools/cpiod.so --prefix /zfs/zfs/; /zfs.so set compression=off osv" --forward tcp:127.0.0.1:%s-:10000' % (image_path,upload_port), shell=True, stdout=subprocess.PIPE) upload(osv, manifest, depends, upload_port) diff --git a/Makefile b/Makefile index 3f560807..a433074d 100644 --- a/Makefile +++ b/Makefile @@ -231,10 +231,10 @@ local-includes = INCLUDES = $(local-includes) -Iarch/$(arch) -I. -Iinclude -Iarch/common INCLUDES += -isystem include/glibc-compat -glibcbase = $(CURDIR)/external/$(arch)/glibc.bin -gccbase = $(CURDIR)/external/$(arch)/gcc.bin -miscbase = $(CURDIR)/external/$(arch)/misc.bin -jdkbase := $(shell find $(CURDIR)/external/$(arch)/openjdk.bin/usr/lib/jvm \ +glibcbase = external/$(arch)/glibc.bin +gccbase = external/$(arch)/gcc.bin +miscbase = external/$(arch)/misc.bin +jdkbase := $(shell find external/$(arch)/openjdk.bin/usr/lib/jvm \ -maxdepth 1 -type d -name 'java*') @@ -1911,7 +1911,7 @@ $(bootfs_manifest_dep): phony $(out)/bootfs.bin: scripts/mkbootfs.py $(bootfs_manifest) $(bootfs_manifest_dep) $(tools:%=$(out)/%) \ $(out)/zpool.so $(out)/zfs.so $(out)/libenviron.so $(out)/libvdso.so - $(call quiet, olddir=`pwd`; cd $(out); $$olddir/scripts/mkbootfs.py -o bootfs.bin -d bootfs.bin.d -m $$olddir/$(bootfs_manifest) \ + $(call quiet, olddir=`pwd`; cd $(out); "$$olddir"/scripts/mkbootfs.py -o bootfs.bin -d bootfs.bin.d -m "$$olddir"/$(bootfs_manifest) \ -D jdkbase=$(jdkbase) -D gccbase=$(gccbase) -D \ glibcbase=$(glibcbase) -D miscbase=$(miscbase), MKBOOTFS $@) diff --git a/scripts/build b/scripts/build index 557a88a4..03366ded 100755 --- a/scripts/build +++ b/scripts/build @@ -119,10 +119,10 @@ esac modules=${vars[modules]-!$image} # TODO: some modules need these... Would be better if they wouldn't... -jdkbase=${vars[jdkbase]-`find $SRC/external/$arch/openjdk.bin/usr/lib/jvm -maxdepth 1 -type d -name 'java*'`} -gccbase=${vars[gccbase]-$SRC/external/$arch/gcc.bin} -glibcbase=${vars[glibcbase]-$SRC/external/$arch/glibc.bin} -miscbase=${vars[miscbase]-$SRC/external/$arch/misc.bin} +jdkbase=${vars[jdkbase]-`find "$SRC"/external/$arch/openjdk.bin/usr/lib/jvm -maxdepth 1 -type d -name 'java*'`} +gccbase=${vars[gccbase]-"$SRC"/external/$arch/gcc.bin} +glibcbase=${vars[glibcbase]-"$SRC"/external/$arch/glibc.bin} +miscbase=${vars[miscbase]-"$SRC"/external/$arch/misc.bin} case $OUT in /*) OSV_BUILD_PATH=$OUT;; @@ -182,26 +182,26 @@ case $fs_type in zfs) cp loader.img bare.raw zfs_size=$(($fs_size - $kernel_end)) - $SRC/scripts/imgedit.py setpartition "-f raw bare.raw" 2 $kernel_end $zfs_size + "$SRC"/scripts/imgedit.py setpartition "-f raw bare.raw" 2 $kernel_end $zfs_size qemu-img convert -f raw -O qcow2 bare.raw usr.img qemu-img resize usr.img ${fs_size}b >/dev/null 2>&1 if [ "$export" == "none" ] then - $SRC/scripts/upload_manifest.py -o usr.img -m usr.manifest -D jdkbase=$jdkbase -D gccbase=$gccbase -D glibcbase=$glibcbase -D miscbase=$miscbase + "$SRC"/scripts/upload_manifest.py -o usr.img -m usr.manifest -D jdkbase="$jdkbase" -D gccbase="$gccbase" -D glibcbase="$glibcbase" -D miscbase="$miscbase" else export_dir=${vars[export_dir]-$SRC/build/export} - $SRC/scripts/export_manifest.py -e "$export_dir" -m usr.manifest -D jdkbase=$jdkbase -D gccbase=$gccbase -D glibcbase=$glibcbase -D miscbase=$miscbase + "$SRC"/scripts/export_manifest.py -e "$export_dir" -m usr.manifest -D jdkbase="$jdkbase" -D gccbase="$gccbase" -D glibcbase="$glibcbase" -D miscbase="$miscbase" fi ;; rofs) rm -rf rofs.img - $SRC/scripts/gen-${fs_type}-img.py -o rofs.img -m usr.manifest -D jdkbase=$jdkbase -D gccbase=$gccbase -D glibcbase=$glibcbase -D miscbase=$miscbase + "$SRC"/scripts/gen-${fs_type}-img.py -o rofs.img -m usr.manifest -D jdkbase="$jdkbase" -D gccbase="$gccbase" -D glibcbase="$glibcbase" -D miscbase="$miscbase" rofs_size=`stat --printf %s rofs.img` img_size=$((kernel_end + rofs_size)) cp loader.img bare.raw - $SRC/scripts/imgedit.py setpartition "-f raw bare.raw" 2 $kernel_end $rofs_size + "$SRC"/scripts/imgedit.py setpartition "-f raw bare.raw" 2 $kernel_end $rofs_size qemu-img resize bare.raw ${img_size}b >/dev/null 2>&1 dd if=rofs.img of=bare.raw obs=${kernel_end} seek=1 >/dev/null 2>&1 qemu-img convert -f raw -O qcow2 bare.raw usr.img @@ -211,14 +211,14 @@ ramfs) ;; esac -$SRC/scripts/imgedit.py setargs usr.img `cat cmdline` +"$SRC"/scripts/imgedit.py setargs usr.img `cat cmdline` # Support "build check" for i do case $i in check) set -x - cd $SRC + cd "$SRC" exec ./scripts/test.py esac done -- 2.20.1 -- You received this message because you are subscribed to the Google Groups "OSv Development" group. To unsubscribe from this group and stop receiving emails from it, send an email to osv-dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.