From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6654500580778573824 X-Received: by 2002:a1c:658a:: with SMTP id z132mr340093wmb.25.1549371659088; Tue, 05 Feb 2019 05:00:59 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a7b:c253:: with SMTP id b19ls2359760wmj.9.canary-gmail; Tue, 05 Feb 2019 05:00:58 -0800 (PST) X-Google-Smtp-Source: AHgI3IaGqX+ZCH4fGbpIJZSJO2sEeFirgiIxj4fhIfb3hUt6KpP7e+9pEe8JGNEH7D5zj5j8jpXn X-Received: by 2002:a1c:b4c1:: with SMTP id d184mr374531wmf.9.1549371658649; Tue, 05 Feb 2019 05:00:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549371658; cv=none; d=google.com; s=arc-20160816; b=HBoTVvOjRiaTn3jQt+2t/HV3NdsJYpmFNuRWtu9j7dyZnHBwgdzJiJqdeYrQNlzm0g 8aPCAvgo+T+gQsfJqaCs7JT8turi5yMy+Y5isWFFqZaAI3zqFWRMr7+CWvDWQHRcKONg 3z28mnnRgrq75tNcIcJJ+H0WdpuqKbf7p1CGjYpsGQsPcWKIMC2QVolZn2e4LzEr6nuQ S9R9VZZs0g/E4wWd/h0RRBPhg1NRHxp5MlHopoISxoQb7Xf0SwgwNNAr/nT1c2YmXzcw UzQ7OeaRJPsRErvsEPdbjfT0l8/A/GW4Ndfzy+3U2LWnn6XjDDeAGIm+xJ07bYw34lZk piRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from; bh=9+Un8Wyj1BChTZzc9Sbtg3G4xmRRIVT7icmskXcM91Y=; b=GWlOe3T5/tK87+4nV1rtQRFV5o4jILd1zS8BtfnTIuBVt3Ptuagqvhxhqdsk3FUask 44MiDwnevHd+gZDea2S3IOpF3+3+9uAVKeWBUPo/wQDX6JlzqtGqGLtdfaC7FoHAxMMu 1lUWBafyE6JVDXqtME+Kbdc7BgPwXOx9ROvDUbIu2QHEH0jZFvXndcZZGrDkE32VMIO8 pV2C530BRzOz5UXft+jFLrj1K/H2Ga2KZtiGx4xiTR+XtO536zs5UnAgDh0Vuf6H7BOH xobenkBiYJdJgpMx9u5VRmGTCZBTkXw768bzUimM4xLyO3Jxtvl0373hyKlTYOTIQH+f lIrQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of hws@denx.de) smtp.mailfrom=hws@denx.de Return-Path: Received: from mail-out.m-online.net (mail-out.m-online.net. [212.18.0.9]) by gmr-mx.google.com with ESMTPS id 64si523373wma.1.2019.02.05.05.00.58 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 05 Feb 2019 05:00:58 -0800 (PST) Received-SPF: neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of hws@denx.de) client-ip=212.18.0.9; Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 212.18.0.9 is neither permitted nor denied by best guess record for domain of hws@denx.de) smtp.mailfrom=hws@denx.de Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 43v4Sp3Rmwz1rRDg for ; Tue, 5 Feb 2019 14:00:58 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 43v4Sp3LhWz1qvWR for ; Tue, 5 Feb 2019 14:00:58 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id ZVP2lbTVmy-y for ; Tue, 5 Feb 2019 14:00:53 +0100 (CET) X-Auth-Info: WNMKklO4Ef34MYjxZ7BFMR2mr0CBUo7Af7OpDi/COf0= Received: from sandvich.fritz.box (p578a821c.dip0.t-ipconnect.de [87.138.130.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA for ; Tue, 5 Feb 2019 14:00:53 +0100 (CET) From: Harald Seiler To: isar-users@googlegroups.com Subject: [PATCH 1/2] Fix all shell-script expansions Date: Tue, 5 Feb 2019 14:00:03 +0100 Message-Id: <20190205130004.15200-2-hws@denx.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190205130004.15200-1-hws@denx.de> References: <20190205130004.15200-1-hws@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TUID: aSLQd3rxB08z Expansions behave weirdly if paths contain special characters. This commit fixes expansions in all applicable shell-scripts. Signed-off-by: Harald Seiler --- isar-init-build-env | 6 ++-- meta-isar/conf/distro/raspbian-configscript.sh | 2 +- .../isar-bootstrap/files/chroot-setup.sh | 8 ++--- meta/recipes-devtools/buildchroot/files/common.sh | 2 +- meta/recipes-kernel/linux/files/build-kernel.sh | 36 +++++++++++----------- .../enable-fsck/files/enable-fsck.sh | 4 +-- .../files/expand-last-partition.sh | 16 +++++----- scripts/ci_build.sh | 14 ++++----- scripts/mount_chroot.sh | 12 ++++---- scripts/rpm2cpio.sh | 4 +-- 10 files changed, 52 insertions(+), 52 deletions(-) diff --git a/isar-init-build-env b/isar-init-build-env index e19d984..b08bb59 100755 --- a/isar-init-build-env +++ b/isar-init-build-env @@ -48,10 +48,10 @@ if [ -z "$ISARROOT" ]; then fi unset THIS_SCRIPT -ISARROOT=`readlink -f "$ISARROOT"` +ISARROOT=$(readlink -f "$ISARROOT") export ISARROOT -. $ISARROOT/scripts/isar-buildenv-internal $1 && \ - TEMPLATECONF="$TEMPLATECONF" $ISARROOT/scripts/isar-setup-builddir || { +. "$ISARROOT/scripts/isar-buildenv-internal" "$1" && \ + TEMPLATECONF="$TEMPLATECONF" "$ISARROOT/scripts/isar-setup-builddir" || { unset ISARROOT return 1 } diff --git a/meta-isar/conf/distro/raspbian-configscript.sh b/meta-isar/conf/distro/raspbian-configscript.sh index 3631c26..7a32c5d 100644 --- a/meta-isar/conf/distro/raspbian-configscript.sh +++ b/meta-isar/conf/distro/raspbian-configscript.sh @@ -14,7 +14,7 @@ if [ -f /etc/inittab ]; then >> /etc/inittab fi -KERNEL_IMAGE=`ls /boot | grep vmlinuz` +KERNEL_IMAGE="$(find /boot -maxdepth 1 -name "vmlinuz*" -printf "%p\n")" cat > /boot/config.txt << EOF kernel=$KERNEL_IMAGE diff --git a/meta/recipes-core/isar-bootstrap/files/chroot-setup.sh b/meta/recipes-core/isar-bootstrap/files/chroot-setup.sh index 9ad86bc..f84f63a 100644 --- a/meta/recipes-core/isar-bootstrap/files/chroot-setup.sh +++ b/meta/recipes-core/isar-bootstrap/files/chroot-setup.sh @@ -23,7 +23,7 @@ usage() { is prevented. Usage: - $(basename $0) [command] [parameters] + $(basename "$0") [command] [parameters] commands: setup [target path] Setup chroot environment cleanup [target path] Cleanup chroot environment @@ -132,9 +132,9 @@ main() { case "${CMD}" in "setup") - chroot_setup $@;; + chroot_setup "$@";; "cleanup") - chroot_cleanup $@;; + chroot_cleanup "$@";; *) echo "Unknown command '${CMD}'." 1>&2 echo 1>&2 @@ -143,4 +143,4 @@ main() { esac } -main $@ +main "$@" diff --git a/meta/recipes-devtools/buildchroot/files/common.sh b/meta/recipes-devtools/buildchroot/files/common.sh index 25b0bb6..8caa4f4 100644 --- a/meta/recipes-devtools/buildchroot/files/common.sh +++ b/meta/recipes-devtools/buildchroot/files/common.sh @@ -24,7 +24,7 @@ else fi # Go to build directory -cd $1 +cd "$1" # To avoid Perl locale warnings: export LC_ALL=C diff --git a/meta/recipes-kernel/linux/files/build-kernel.sh b/meta/recipes-kernel/linux/files/build-kernel.sh index 745c89a..6e4d347 100644 --- a/meta/recipes-kernel/linux/files/build-kernel.sh +++ b/meta/recipes-kernel/linux/files/build-kernel.sh @@ -48,27 +48,27 @@ fi rm -f .version KBUILD_DEBARCH=$target_arch make -j $(($(nproc) * 2)) deb-pkg -rm -rf ${REPACK_DIR} -mkdir -p ${REPACK_DIR} -mkdir -p ${REPACK_LINUX_IMAGE_DIR} -mkdir -p ${REPACK_LINUX_HEADERS_DIR} +rm -rf "${REPACK_DIR}" +mkdir -p "${REPACK_DIR}" +mkdir -p "${REPACK_LINUX_IMAGE_DIR}" +mkdir -p "${REPACK_LINUX_HEADERS_DIR}" -cp -a debian ${REPACK_DIR} +cp -a debian "${REPACK_DIR}" # dpkg-gencontrol performs cross-incompatible checks on the # Architecture field; trick it to accept the control file -sed -i "s/Architecture: .*/Architecture: any/" ${REPACK_DIR}/debian/control +sed -i "s/Architecture: .*/Architecture: any/" "${REPACK_DIR}/debian/control" cd .. -dpkg-deb -R linux-image-${PV}_${PV}-1_*.deb ${REPACK_LINUX_IMAGE_DIR} -dpkg-deb -R linux-headers-${PV}_${PV}-1_*.deb ${REPACK_LINUX_HEADERS_DIR} +dpkg-deb -R linux-image-${PV}_${PV}-1_*.deb "${REPACK_LINUX_IMAGE_DIR}" +dpkg-deb -R linux-headers-${PV}_${PV}-1_*.deb "${REPACK_LINUX_HEADERS_DIR}" dpkg-gencontrol -crepack/debian/control \ -lrepack/debian/changelog \ -frepack/debian/files \ -plinux-image-${PV} \ - -P${REPACK_LINUX_IMAGE_DIR} \ + -P"${REPACK_LINUX_IMAGE_DIR}" \ -DPackage="linux-image-${KERNEL_NAME}" \ -DSection=kernel \ -DPriority=required \ @@ -76,8 +76,8 @@ dpkg-gencontrol -crepack/debian/control \ -DArchitecture=$target_arch # Add Debian-like link installation to postinst -touch ${REPACK_LINUX_IMAGE_DIR}/lib/modules/${PV}/.fresh-install -sed -i ${REPACK_LINUX_IMAGE_DIR}/DEBIAN/postinst \ +touch "${REPACK_LINUX_IMAGE_DIR}/lib/modules/${PV}/.fresh-install" +sed -i "${REPACK_LINUX_IMAGE_DIR}/DEBIAN/postinst" \ -e "/^set -e$/a\\ \\ if [ -f /lib/modules/${PV}/.fresh-install ]; then\\ @@ -89,7 +89,7 @@ linux-update-symlinks \$change ${PV} /boot/vmlinuz-${PV}\\ rm -f /lib/modules/${PV}/.fresh-install" # Add Debian-like link removal to postrm -sed -i ${REPACK_LINUX_IMAGE_DIR}/DEBIAN/postrm \ +sed -i "${REPACK_LINUX_IMAGE_DIR}/DEBIAN/postrm" \ -e "/^set -e$/a\\ \\ rm -f /lib/modules/${PV}/.fresh-install\\ @@ -100,26 +100,26 @@ fi" # Make sure arm64 kernels are decompressed if [ "$target_arch" = "arm64" ]; then - vmlinuz=${REPACK_LINUX_IMAGE_DIR}/boot/vmlinuz-${PV} - mv $vmlinuz $vmlinuz.gz - gunzip $vmlinuz.gz + vmlinuz="${REPACK_LINUX_IMAGE_DIR}/boot/vmlinuz-${PV}" + mv "$vmlinuz" "$vmlinuz.gz" + gunzip "$vmlinuz.gz" fi dpkg-gencontrol -crepack/debian/control \ -lrepack/debian/changelog \ -frepack/debian/files \ -plinux-headers-${PV} \ - -P${REPACK_LINUX_HEADERS_DIR} \ + -P"${REPACK_LINUX_HEADERS_DIR}" \ -Vkernel:debarch="${KERNEL_NAME}" \ -DPackage="linux-headers-${KERNEL_NAME}" \ -DSection=kernel \ -DDepends="${KERNEL_HEADERS_DEBIAN_DEPENDS}" \ -DArchitecture=$target_arch -fakeroot dpkg-deb -b ${REPACK_LINUX_IMAGE_DIR} \ +fakeroot dpkg-deb -b "${REPACK_LINUX_IMAGE_DIR}" \ linux-image-${KERNEL_NAME}_${PV}-1_${KERNEL_NAME}.deb rm -f linux-image-${PV}_${PV}-1_*.deb -fakeroot dpkg-deb -b ${REPACK_LINUX_HEADERS_DIR} \ +fakeroot dpkg-deb -b "${REPACK_LINUX_HEADERS_DIR}" \ linux-headers-${KERNEL_NAME}_${PV}-1_${KERNEL_NAME}.deb rm -f linux-headers-${PV}_${PV}-1_*.deb diff --git a/meta/recipes-support/enable-fsck/files/enable-fsck.sh b/meta/recipes-support/enable-fsck/files/enable-fsck.sh index b3dce44..d09e35d 100644 --- a/meta/recipes-support/enable-fsck/files/enable-fsck.sh +++ b/meta/recipes-support/enable-fsck/files/enable-fsck.sh @@ -9,8 +9,8 @@ set -e -ROOT_DEV=$(/bin/findmnt -n -o SOURCE /) -sed -i -e 's|^/dev/root\([ ]\+.*[ ]\+\)0[ ]\+0|'$ROOT_DEV'\10 1|' \ +ROOT_DEV="$(/bin/findmnt -n -o SOURCE /)" +sed -i -e 's|^/dev/root\([ ]\+.*[ ]\+\)0[ ]\+0|'"$ROOT_DEV"'\10 1|' \ -e 's|^\(/dev/.*[ ]\+\)0[ ]\+0|\10 2|' /etc/fstab update-initramfs -u diff --git a/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh b/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh index 913e63b..4cf90de 100644 --- a/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh +++ b/meta/recipes-support/expand-on-first-boot/files/expand-last-partition.sh @@ -9,23 +9,23 @@ set -e -ROOT_DEV=$(findmnt / -o source -n) -BOOT_DEV=$(echo ${ROOT_DEV} | sed 's/p\?[0-9]*$//') +ROOT_DEV="$(findmnt / -o source -n)" +BOOT_DEV="$(echo "${ROOT_DEV}" | sed 's/p\?[0-9]*$//')" if [ "${ROOT_DEV}" = "${BOOT_DEV}" ]; then echo "Boot device equals root device - no partitioning found" >&2 exit 1 fi -LAST_PART=$(sfdisk -d ${BOOT_DEV} 2>/dev/null | tail -1 | cut -d ' ' -f 1) +LAST_PART="$(sfdisk -d ${BOOT_DEV} 2>/dev/null | tail -1 | cut -d ' ' -f 1)" # Remove all hints to the current medium (last-lba) and last partition size, # then ask sfdisk to recreate the partitioning -sfdisk -d ${BOOT_DEV} 2>/dev/null | grep -v last-lba | \ - sed 's|\('${LAST_PART}' .*, \)size=[^,]*, |\1|' | \ - sfdisk --force ${BOOT_DEV} +sfdisk -d "${BOOT_DEV}" 2>/dev/null | grep -v last-lba | \ + sed 's|\('"${LAST_PART}"' .*, \)size=[^,]*, |\1|' | \ + sfdisk --force "${BOOT_DEV}" # Inform the kernel about the partitioning change -partx -u ${LAST_PART} +partx -u "${LAST_PART}" -resize2fs ${LAST_PART} +resize2fs "${LAST_PART}" diff --git a/scripts/ci_build.sh b/scripts/ci_build.sh index f3523e8..1789183 100755 --- a/scripts/ci_build.sh +++ b/scripts/ci_build.sh @@ -13,7 +13,7 @@ ES_BUG=3 export PATH=$PATH:/sbin # Go to Isar root -cd $(dirname $0)/.. +cd "$(dirname "$0")/.." # Start build in Isar tree by default BUILD_DIR=./build @@ -76,10 +76,10 @@ do done # Setup build folder for the current build -if [ ! -d $BUILD_DIR ]; then - mkdir -p $BUILD_DIR +if [ ! -d "$BUILD_DIR" ]; then + mkdir -p "$BUILD_DIR" fi -source isar-init-build-env $BUILD_DIR +source isar-init-build-env "$BUILD_DIR" if [ -n "$CROSS_BUILD" ]; then sed -i -e 's/ISAR_CROSS_COMPILE ?= "0"/ISAR_CROSS_COMPILE ?= "1"/g' conf/local.conf @@ -120,9 +120,9 @@ else #multiconfig:qemuarm64-buster:isar-image-base fi -cp -a ${ISARROOT}/meta/classes/dpkg-base.bbclass ${ISARROOT}/meta/classes/dpkg-base.bbclass.ci-backup -echo -e "do_fetch_append() {\n\n}" >> ${ISARROOT}/meta/classes/dpkg-base.bbclass +cp -a "${ISARROOT}/meta/classes/dpkg-base.bbclass" "${ISARROOT}/meta/classes/dpkg-base.bbclass.ci-backup" +echo -e "do_fetch_append() {\n\n}" >> "${ISARROOT}/meta/classes/dpkg-base.bbclass" bitbake $BB_ARGS multiconfig:qemuamd64-stretch:isar-image-base -mv ${ISARROOT}/meta/classes/dpkg-base.bbclass.ci-backup ${ISARROOT}/meta/classes/dpkg-base.bbclass +mv "${ISARROOT}/meta/classes/dpkg-base.bbclass.ci-backup" "${ISARROOT}/meta/classes/dpkg-base.bbclass" diff --git a/scripts/mount_chroot.sh b/scripts/mount_chroot.sh index 74f2b22..e238f1c 100755 --- a/scripts/mount_chroot.sh +++ b/scripts/mount_chroot.sh @@ -2,9 +2,9 @@ set -e -mount /tmp $1/tmp -o bind -mount proc $1/proc -t proc -o nosuid,noexec,nodev -mount sysfs $1/sys -t sysfs -o nosuid,noexec,nodev -mount devtmpfs $1/dev -t devtmpfs -o mode=0755,nosuid -mount devpts $1/dev/pts -t devpts -o gid=5,mode=620 -mount tmpfs $1/dev/shm -t tmpfs -o rw,seclabel,nosuid,nodev +mount /tmp "$1/tmp" -o bind +mount proc "$1/proc" -t proc -o nosuid,noexec,nodev +mount sysfs "$1/sys" -t sysfs -o nosuid,noexec,nodev +mount devtmpfs "$1/dev" -t devtmpfs -o mode=0755,nosuid +mount devpts "$1/dev/pts" -t devpts -o gid=5,mode=620 +mount tmpfs "$1/dev/shm" -t tmpfs -o rw,seclabel,nosuid,nodev diff --git a/scripts/rpm2cpio.sh b/scripts/rpm2cpio.sh index db3cae6..aa7b7b9 100755 --- a/scripts/rpm2cpio.sh +++ b/scripts/rpm2cpio.sh @@ -11,12 +11,12 @@ fatal() { } pkg="$1" -[ -n "$pkg" -a -e "$pkg" ] || +[ -n "$pkg" ] && [ -e "$pkg" ] || fatal "No package supplied" _dd() { local o="$1"; shift - dd if="$pkg" skip="$o" iflag=skip_bytes status=none $* + dd if="$pkg" skip="$o" iflag=skip_bytes status=none "$@" } calcsize() { -- 2.14.1