From 65d723234bf5dcd99f083ab4d5087b75ded2cfa6 Mon Sep 17 00:00:00 2001 From: Mattia Rizzolo Date: Fri, 18 Sep 2015 15:54:40 +0000 Subject: fix a whole bunch of warning from shellcheck There are still quite some, this is a first chunk based on a given patch applied where i felt confident enough. Thanks: Herbert Parentes Fortes Neto for the initial patch-set --- pbuilder-apt-config | 25 ++++++++++++------------- pbuilder-buildpackage | 12 ++++++------ pbuilder-createbuildenv | 6 +++--- pbuilder-modules | 30 +++++++++++++++--------------- pbuilder-runhooks | 2 +- pbuilder-satisfydepends-classic | 6 +++--- pbuilder-satisfydepends-funcs | 22 +++++++++++----------- pbuilder-satisfydepends-gdebi | 4 ++-- pbuilder-unshare-wrapper | 2 +- pbuilder-updatebuildenv | 4 ++-- 10 files changed, 56 insertions(+), 57 deletions(-) diff --git a/pbuilder-apt-config b/pbuilder-apt-config index 7f93088..3beb656 100755 --- a/pbuilder-apt-config +++ b/pbuilder-apt-config @@ -225,12 +225,12 @@ set_debootstrap_suite() { esac } -getopt_output="`getopt -o "" -l help,with-sources::,arch:,components:,archive:,mirror:,mirror-map:,suite:,pockets:,profile: -n "$self" -s sh -- "$@"`" +getopt_output="$(getopt -o "" -l help,with-sources::,arch:,components:,archive:,mirror:,mirror-map:,suite:,pockets:,profile: -n "$self" -s sh -- "$@")" eval set -- "$getopt_output" with_sources="disabled" -arch="`dpkg --print-architecture`" +arch="$(dpkg --print-architecture)" components="main" archive="" mirror="" @@ -324,8 +324,8 @@ pockets="$(echo "$pockets" | tr , " ")" if [ -n "$profile" ]; then base_dist="${profile%%/*}" base_dist="${base_dist%%-*}" - base_archive="`guess_dist_arch_archive "$base_dist" "$arch"`" - base_mirror="`get_archive_url "$mirror_map" "$base_archive"`" + base_archive="$(guess_dist_arch_archive "$base_dist" "$arch")" + base_mirror="$(get_archive_url "$mirror_map" "$base_archive")" case "$base_archive" in debian|debian-archive) case "$profile" in @@ -336,7 +336,7 @@ if [ -n "$profile" ]; then ;; *-proposed-updates/volatile) archive="debian-volatile" - mirror="`get_archive_url "$mirror_map" "$archive"`" + mirror="$(get_archive_url "$mirror_map" "$archive")" volatile_dist="$base_dist/volatile" add_output_sources "$with_sources" "$base_mirror" "$base_dist" "$components" add_output_sources "$with_sources" "$mirror" "$volatile_dist" "$components" @@ -347,7 +347,7 @@ if [ -n "$profile" ]; then die "Unknown Debian Volatile based profile=$profile" fi archive="debian-volatile" - mirror="`get_archive_url "$mirror_map" "$archive"`" + mirror="$(get_archive_url "$mirror_map" "$archive")" volatile_dist=${profile%-sloppy} add_output_sources "$with_sources" "$base_mirror" "$base_dist" "$components" add_output_sources "$with_sources" "$mirror" "$volatile_dist" "$components" @@ -360,7 +360,7 @@ if [ -n "$profile" ]; then die "Unknown Backports.org based profile=$profile" fi archive="backports.org" - mirror="`get_archive_url "$mirror_map" "$archive"`" + mirror="$(get_archive_url "$mirror_map" "$archive")" add_output_sources "$with_sources" "$base_mirror" "$base_dist" "$components" add_output_sources "$with_sources" "$mirror" "$profile" "$components" ;; @@ -369,7 +369,7 @@ if [ -n "$profile" ]; then die "Unknown Debian Security based profile=$profile" fi archive="debian-security" - mirror="`get_archive_url "$mirror_map" "$archive"`" + mirror="$(get_archive_url "$mirror_map" "$archive")" add_output_sources "$with_sources" "$base_mirror" "$base_dist" "$components" add_output_sources "$with_sources" "$mirror" "$profile" "$components" ;; @@ -421,7 +421,7 @@ if [ -n "$profile" ]; then done if [ "$has_security" = "yes" ]; then archive="ubuntu-security" - mirror="`get_archive_url "$mirror_map" "$archive"`" + mirror="$(get_archive_url "$mirror_map" "$archive")" if [ "$mirror" != "$base_mirror" ]; then add_output_sources "$with_sources" "$mirror" "$base_dist-security" "$components" fi @@ -438,9 +438,9 @@ fi if [ -n "$suite" ]; then if [ -z "$mirror" ]; then if [ -z "$archive" ]; then - archive="`guess_dist_arch_archive "$suite" "$arch"`" + archive="$(guess_dist_arch_archive "$suite" "$arch")" fi - mirror="`get_archive_url "$mirror_map" "$archive"`" + mirror="$(get_archive_url "$mirror_map" "$archive")" fi add_output_sources "$with_sources" "$mirror" "$suite" "$components" for pocket in $pockets; do @@ -448,13 +448,12 @@ if [ -n "$suite" ]; then done # NB: archive might be empty; best effort to try to guess it if [ -z "$archive" ]; then - archive="`guess_dist_arch_archive "$suite" "$arch"`" 2>/dev/null || true + archive="$(guess_dist_arch_archive "$suite" "$arch")" 2>/dev/null || true fi set_debootstrap_suite "$archive" "$suite" debootstrap_mirror="$mirror" fi -command="$1" case $1 in apt-sources) echo "$sources" diff --git a/pbuilder-buildpackage b/pbuilder-buildpackage index ead9dc9..d8b41af 100755 --- a/pbuilder-buildpackage +++ b/pbuilder-buildpackage @@ -97,7 +97,7 @@ fi if [ -z "${PBUILDER_BUILD_LOGFILE}" ]; then if [ "${PKGNAME_LOGFILE}" = "yes" ]; then - PBUILDER_BUILD_LOGFILE="${BUILDRESULT}/"$(basename "${PACKAGENAME}" .dsc)"${PKGNAME_LOGFILE_EXTENSION}" + PBUILDER_BUILD_LOGFILE="${BUILDRESULT}/$(basename "${PACKAGENAME}" .dsc)${PKGNAME_LOGFILE_EXTENSION}" exec > >(tee "${PBUILDER_BUILD_LOGFILE}") 2>&1 PBUILDER_BUILD_LOGFILE=$(readlink -f "${PBUILDER_BUILD_LOGFILE}") log "I: Using pkgname logfile" @@ -135,7 +135,7 @@ else log "E: pbuilder: Failed chowning to $BUILDUSERNAME:$BUILDUSERNAME" exit 1; fi -if echo "( cd $BUILDDIR; env PATH=\"$PATH\" /usr/bin/dpkg-source -x $(basename $PACKAGENAME) )" | $UNSHARE $CHROOTEXEC env $SUTOUSER ; then +if echo "( cd $BUILDDIR; env PATH=\"$PATH\" /usr/bin/dpkg-source -x $(basename "$PACKAGENAME") )" | $UNSHARE $CHROOTEXEC env $SUTOUSER ; then : # success else log "E: pbuilder: Failed extracting the source" @@ -166,14 +166,14 @@ if [ -n "${TIMEOUT_TIME}" ]; then : Timeout process sleep "${TIMEOUT_TIME}" log "I: Terminating build process due to timeout " - kill ${BUILD_PID} || true + kill "${BUILD_PID}" || true ) & # timeout process - KILL_WAIT_PID="kill "$!" || true; echo \"I: Terminate timeout process\"; " + KILL_WAIT_PID="kill $! || true; echo \"I: Terminate timeout process\"; " else KILL_WAIT_PID="" fi -if ! wait ${BUILD_PID}; then +if ! wait "${BUILD_PID}"; then trap umountproc_cleanbuildplace_trap exit sighup sigpipe eval "${KILL_WAIT_PID}" log "E: Failed autobuilding of package" @@ -195,7 +195,7 @@ if [ -d "${BUILDRESULT}" ]; then chgrp "${BUILDRESULTGID}" "${BUILDPLACE}$BUILDDIR/"* for FILE in "${BUILDPLACE}$BUILDDIR"/*; do if [ -f "${FILE}" ]; then - cp -p ${FILE} "${BUILDRESULT}" || true + cp -p "${FILE}" "${BUILDRESULT}" || true fi done for FILE in "${ADDITIONAL_BUILDRESULTS[@]}"; do diff --git a/pbuilder-createbuildenv b/pbuilder-createbuildenv index 808ef1b..17ce87d 100755 --- a/pbuilder-createbuildenv +++ b/pbuilder-createbuildenv @@ -69,13 +69,13 @@ fi # DEBOOTSTRAPOPTS, it will override the --include=apt one and apt might not be # installed if ! ( "${DEBOOTSTRAP}" \ - ${ARCHITECTURE:+--arch=$ARCHITECTURE} \ + "${ARCHITECTURE:+--arch=$ARCHITECTURE}" \ --include=apt \ "${DEBOOTSTRAPOPTS[@]}" \ "$DISTRIBUTION" \ "$BUILDPLACE" \ "$MIRRORSITE" \ - $DEBOOTSTRAPSCRIPT ) ; then + "$DEBOOTSTRAPSCRIPT" ) ; then log "E: $DEBOOTSTRAP failed" exit 1 fi @@ -97,7 +97,7 @@ mountproc $TRAP umountproc_cleanbuildplace_trap exit sighup $CHROOTEXEC /usr/bin/apt-get -q update -case "`readlink -e "$PBUILDERSATISFYDEPENDSCMD"`" in +case "$(readlink -e "$PBUILDERSATISFYDEPENDSCMD")" in *-aptitude) EXTRAPACKAGES="$EXTRAPACKAGES aptitude" ;; diff --git a/pbuilder-modules b/pbuilder-modules index 8efa273..e5ec024 100644 --- a/pbuilder-modules +++ b/pbuilder-modules @@ -226,7 +226,7 @@ function umountproc () { umount_one "run/shm" fi if [ "$USEPROC" = "yes" ]; then - if [ "$DEB_BUILD_ARCH_OS" = "linux" ] && [ -e $BUILDPLACE/proc/sys/fs/binfmt_misc/status ]; then + if [ "$DEB_BUILD_ARCH_OS" = "linux" ] && [ -e "$BUILDPLACE/proc/sys/fs/binfmt_misc/status" ]; then umount_one "proc/sys/fs/binfmt_misc" fi umount_one "proc" @@ -241,8 +241,8 @@ function umountproc () { # Workaround to remove chroot on Hurd: once /dev firmlink is # removed, chroot removal either gets stuck or fails by removing # some devices. - for dev in $BUILDPLACE/dev/{netdde,tty*,pty*,fd,vcs}; do - settrans -fg $dev + for dev in "$BUILDPLACE"/dev/{netdde,tty*,pty*,fd,vcs}; do + settrans -fg "$dev" done fi } @@ -255,7 +255,7 @@ function mountproc () { DEB_BUILD_ARCH_OS=$(dpkg-architecture -qDEB_BUILD_ARCH_OS) if [ "$USEPROC" = "yes" ]; then log "I: mounting /proc filesystem" - mkdir -p "$BUILDPLACE"/proc + mkdir -p "$BUILDPLACE/proc" case "$DEB_BUILD_ARCH_OS" in kfreebsd) PROCFS="linprocfs" @@ -269,24 +269,24 @@ function mountproc () { ;; esac mount -t "$PROCFS" /proc "$BUILDPLACE/proc" || [ "$DEB_BUILD_ARCH_OS" = hurd ] - ln -s ../proc/mounts $BUILDPLACE/etc/mtab 2> /dev/null || true + ln -s ../proc/mounts "$BUILDPLACE/etc/mtab" 2> /dev/null || true mounted[${#mounted[@]}]="$BUILDPLACE/proc" fi if [ "$USEDEVFS" = "yes" ]; then log "I: mounting /dev filesystem" - mkdir -p $BUILDPLACE/dev || true + mkdir -p "$BUILDPLACE/dev" || true mount -t devfs /dev "$BUILDPLACE/dev" mounted[${#mounted[@]}]="$BUILDPLACE/dev" fi if [ "$DEB_BUILD_ARCH_OS" = "linux" ] && [ "$USERUNSHM" = "yes" ]; then log "I: mounting /run/shm filesystem" - mkdir -p $BUILDPLACE/run/shm || true + mkdir -p "$BUILDPLACE/run/shm" || true mount -t tmpfs tmpfs "$BUILDPLACE/run/shm" mounted[${#mounted[@]}]="$BUILDPLACE/run/shm" fi if [ "$DEB_BUILD_ARCH_OS" = "linux" ] && [ "$USEDEVPTS" = "yes" ]; then log "I: mounting /dev/pts filesystem" - mkdir -p $BUILDPLACE/dev/pts || true + mkdir -p "$BUILDPLACE/dev/pts" || true TTYGRP=5 TTYMODE=620 [ -f /etc/default/devpts ] && . /etc/default/devpts @@ -295,7 +295,7 @@ function mountproc () { fi if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then log "I: mounting selinux filesystem" - mkdir -p $BUILDPLACE/selinux + mkdir -p "$BUILDPLACE/selinux" mount -t selinuxfs /selinux "$BUILDPLACE/selinux" mounted[${#mounted[@]}]="$BUILDPLACE/selinux" fi @@ -336,7 +336,7 @@ function mountproc () { #!/bin/sh while true; do -case "\$1" in +case \"\$1\" in -*) shift ;; makedev) exit 0;; x11-common) exit 0;; @@ -381,7 +381,7 @@ function cleanbuildplace () { # The readlink -f is a simple way to canonicalize the path for # $BUILDPLACE (no dirty double slashes for *us*), so it matches # what will be in the output of mount. - if mount |grep -q -F " $(readlink -f $BUILDPLACE)/"; then + if mount |grep -q -F " $(readlink -f "$BUILDPLACE")/"; then log "E: Something is still mounted under ${BUILDPLACE}; unmount and remove ${BUILDPLACE} manually" else log "I: cleaning the build env " @@ -454,7 +454,7 @@ function copy_local_configuration () { for a in hosts hostname resolv.conf mailname; do if [ -f "/etc/$a" ]; then rm -f "$BUILDPLACE/etc/$a" - cp $( readlink -f "/etc/$a" ) "$BUILDPLACE/etc/$a"; + cp "$( readlink -f "/etc/$a" )" "$BUILDPLACE/etc/$a"; else log "W: No local /etc/$a to copy, relying on $BUILDPLACE/etc/$a to be correct" fi @@ -558,8 +558,8 @@ function save_aptcache() { fi find "$BUILDPLACE/var/cache/apt/archives/" -maxdepth 1 -name \*.deb | \ while read A ;do - if [ ! -f "$APTCACHE/"$(basename "$A") -a -f "$A" ]; then - log "I: new cache content "$(basename "$A")" added" + if [ ! -f "$APTCACHE/$(basename "$A")" -a -f "$A" ]; then + log "I: new cache content '$(basename "$A")' added" $doit "$A" "$APTCACHE/" || true fi done @@ -581,7 +581,7 @@ function create_basetgz() { if [ -h "$BUILDPLACE/tmp/buildd" ] && [ "$(readlink -f "$BUILDPLACE/tmp/buildd")" = "${BUILDPLACE}$BUILDDIR" ]; then rm "$BUILDPLACE/tmp/buildd" fi - if ! tar -c --use-compress-program "$COMPRESSPROG" -f "${BASETGZ}.tmp" * ; then + if ! tar -c --use-compress-program "$COMPRESSPROG" -f "${BASETGZ}.tmp" ./* ; then log "E: failed building base tarball" rm -f "${BASETGZ}.tmp" exit 1; diff --git a/pbuilder-runhooks b/pbuilder-runhooks index 26a1158..d5c8d23 100644 --- a/pbuilder-runhooks +++ b/pbuilder-runhooks @@ -91,7 +91,7 @@ function executehooks () { if [ -x "$fn" ]; then log "I: user script $fn starting" BUILDDIR="$BUILDDIR" \ - $CHROOTEXEC "/$hooks/"$(basename "$fn") + $CHROOTEXEC "/$hooks/$(basename "$fn")" log "I: user script $fn finished" else if [ -f "$fn" ]; then diff --git a/pbuilder-satisfydepends-classic b/pbuilder-satisfydepends-classic index f149b4f..c7bab1e 100755 --- a/pbuilder-satisfydepends-classic +++ b/pbuilder-satisfydepends-classic @@ -90,7 +90,7 @@ checkbuilddep_internal() { fi if echo "$INSTALLPKG" | grep -q '('; then #echo "Debug: $INSTALLPKG" - if ! checkbuilddep_versiondeps "$CURRENTREALPKGNAME" `get_dep_op_and_ver "$INSTALLPKG"`; then + if ! checkbuilddep_versiondeps "$CURRENTREALPKGNAME" "$(get_dep_op_and_ver "$INSTALLPKG")"; then echo " -> Does not satisfy version, not trying" continue fi @@ -167,7 +167,7 @@ checkbuilddep_internal() { fi if echo "$INSTALLPKG" | grep -q '('; then # this package has version-conflicts - if ! checkbuilddep_versiondeps "$CURRENTREALPKGNAME" `get_dep_op_and_ver "$INSTALLPKG"`; then + if ! checkbuilddep_versiondeps "$CURRENTREALPKGNAME" "$(get_dep_op_and_ver "$INSTALLPKG")"; then echo "I: Satisfies version, not trying" continue fi @@ -175,7 +175,7 @@ checkbuilddep_internal() { # if package exists, remove it. if $CHROOTEXEC /usr/bin/dpkg -s "$CURRENTREALPKGNAME" 2>&1 | grep -q ^Package:; then - if ! $CHROOTEXEC /usr/bin/apt-get -y remove $CURRENTREALPKGNAME ; then + if ! $CHROOTEXEC /usr/bin/apt-get -y remove "$CURRENTREALPKGNAME" ; then echo "E: Could not satisfy build-conflicts" >&2 exit 1 fi diff --git a/pbuilder-satisfydepends-funcs b/pbuilder-satisfydepends-funcs index 12ae25a..9332168 100755 --- a/pbuilder-satisfydepends-funcs +++ b/pbuilder-satisfydepends-funcs @@ -109,10 +109,10 @@ p' \ get_build_deps() { local output - output="`get_source_control_field "Build-Depends"`" + output="$(get_source_control_field "Build-Depends")" output="${output%, }" if [ "$BINARY_ARCH" = no ]; then - output="${output:+$output, }`get_source_control_field "Build-Depends-Indep"`" + output="${output:+$output, }$(get_source_control_field "Build-Depends-Indep")" output="${output%, }" fi echo "$output" @@ -121,9 +121,9 @@ get_build_deps() { get_build_conflicts() { local output - output="`get_source_control_field "Build-Conflicts"`" + output="$(get_source_control_field "Build-Conflicts")" if [ "$BINARY_ARCH" = no ]; then - output="${output:+$output, }`get_source_control_field "Build-Conflicts-Indep"`" + output="${output:+$output, }$(get_source_control_field "Build-Conflicts-Indep")" fi echo "$output" } @@ -203,20 +203,20 @@ checkbuilddep_archdeps() { # Use 'dpkg-architecture' to support architecture wildcards. for d in $DEP_ARCHES; do if echo "$d" | grep -q '!'; then - d="$(echo $d | sed 's/!//')" - if dpkg-architecture -a$ARCH -i$d -f; then + d="$(echo "$d" | sed 's/!//')" + if dpkg-architecture -a"$ARCH" -i"$d" -f; then IGNORE_IT="yes" fi else - if dpkg-architecture -a$ARCH -i$d -f; then + if dpkg-architecture -a"$ARCH" -i"$d" -f; then USE_IT="yes" fi INCLUDE="yes" fi done if [ $IGNORE_IT ] && [ $USE_IT ]; then - printf "W: inconsistent arch restriction on $PKG: " >&2 - printf "$DEP_ARCHES depedency\n" >&2 + printf "W: inconsistent arch restriction on %s: " "$PKG" >&2 + printf "%s depedency\n" "$DEP_ARCHES" >&2 fi if [ $IGNORE_IT ] || ( [ $INCLUDE ] && [ ! $USE_IT ] ); then return 0 @@ -273,7 +273,7 @@ checkbuilddep_restrictiondeps() { checkbuilddep_provides() { local PACKAGENAME="$1" # PROVIDED needs to be used outside of this function. - PROVIDED=$($CHROOTEXEC /usr/bin/apt-cache showpkg $PACKAGENAME \ + PROVIDED=$($CHROOTEXEC /usr/bin/apt-cache showpkg "$PACKAGENAME" \ | awk '{p=0}/^Reverse Provides:/,/^$/{p=1}{if(p && ($0 !~ "Reverse Provides:")){PACKAGE=$1}} END{print PACKAGE}') } @@ -307,7 +307,7 @@ versioneddep_to_aptcmd() { # try the candidate version, then all available versions (asc) for VERSION in $CANDIDATE_VERSION $PACKAGEVERSIONS; do if dpkg --compare-versions "$VERSION" "$COMPARESTRING" "$DEPSVERSION"; then - if [ $VERSION != $CANDIDATE_VERSION ]; then + if [ "$VERSION" != "$CANDIDATE_VERSION" ]; then PACKAGE_WITHVERSION="$PACKAGE=$VERSION" fi break; diff --git a/pbuilder-satisfydepends-gdebi b/pbuilder-satisfydepends-gdebi index bdf812d..3bd3cf7 100644 --- a/pbuilder-satisfydepends-gdebi +++ b/pbuilder-satisfydepends-gdebi @@ -30,12 +30,12 @@ function checkbuilddep_internal () { NO_RECOMMENDS="" if VERSION=$(/usr/bin/gdebi --version 2>/dev/null); then - if dpkg --compare-versions $VERSION ge 0.3.9; then + if dpkg --compare-versions "$VERSION" ge 0.3.9; then NO_RECOMMENDS="-o APT::Install-Recommends=false" fi fi - INSTALL=$(/usr/bin/gdebi --quiet --root $CHROOT --apt-line $NO_RECOMMENDS $DEBIAN_CONTROL) + INSTALL=$(/usr/bin/gdebi --quiet --root "$CHROOT" --apt-line "$NO_RECOMMENDS" "$DEBIAN_CONTROL") $CHROOTEXEC /usr/bin/apt-get install -y "${APTGETOPT[@]}" $INSTALL } diff --git a/pbuilder-unshare-wrapper b/pbuilder-unshare-wrapper index 518db44..2dcf95a 100755 --- a/pbuilder-unshare-wrapper +++ b/pbuilder-unshare-wrapper @@ -1,7 +1,7 @@ #!/bin/sh die() { - echo >&2 E: $2 returned error code $1 + echo >&2 E: "$2" returned error code "$1" echo >&2 N: Could not set up the loopback interface. exit 1 } diff --git a/pbuilder-updatebuildenv b/pbuilder-updatebuildenv index e673592..13dd043 100755 --- a/pbuilder-updatebuildenv +++ b/pbuilder-updatebuildenv @@ -41,7 +41,7 @@ log "I: Refreshing the base.tgz " log "I: upgrading packages" $CHROOTEXEC /usr/bin/apt-get -q update -case "`readlink -e "$PBUILDERSATISFYDEPENDSCMD"`" in +case "$(readlink -e "$PBUILDERSATISFYDEPENDSCMD")" in *-aptitude) EXTRAPACKAGES="$EXTRAPACKAGES aptitude" ;; @@ -84,7 +84,7 @@ if [ "${AUTOCLEANAPTCACHE}" = "yes" -a -n "$APTCACHE" ]; then $CHROOTEXEC /usr/bin/apt-get autoclean || true find "$APTCACHE/" -maxdepth 1 -name \*.deb | \ while read A; do - if [ ! -f "$BUILDPLACE/var/cache/apt/archives/"$(basename "$A") -a \ + if [ ! -f "$BUILDPLACE/var/cache/apt/archives/$(basename "$A")" -a \ -f "$A" ]; then log "I: obsolete cache content "$(basename "$A")" removed" rm -f "$A" || true -- cgit v1.2.3