mirror of
https://github.com/abraunegg/onedrive
synced 2024-05-04 06:53:23 +02:00
Fix Codacy issues (#881)
* Fix double quote to prevent globbing and word splitting
This commit is contained in:
parent
1b28dc6040
commit
7f267a5a74
|
@ -13,10 +13,10 @@ CHROOT_DIR=/tmp/chroot
|
||||||
|
|
||||||
# Debian package dependencies for the host to run ARM under QEMU
|
# Debian package dependencies for the host to run ARM under QEMU
|
||||||
DEBIAN_MIRROR="http://httpredir.debian.org/debian"
|
DEBIAN_MIRROR="http://httpredir.debian.org/debian"
|
||||||
HOST_DEPENDENCIES="qemu-user-static binfmt-support debootstrap sbuild wget"
|
HOST_DEPENDENCIES=(qemu-user-static binfmt-support debootstrap sbuild wget)
|
||||||
|
|
||||||
# Debian package dependencies for the chrooted environment
|
# Debian package dependencies for the chrooted environment
|
||||||
GUEST_DEPENDENCIES="build-essential libcurl4-openssl-dev libsqlite3-dev libgnutls-openssl27 git pkg-config libxml2"
|
GUEST_DEPENDENCIES=(build-essential libcurl4-openssl-dev libsqlite3-dev libgnutls-openssl27 git pkg-config libxml2)
|
||||||
|
|
||||||
# LDC Version
|
# LDC Version
|
||||||
# Different versions due to https://github.com/ldc-developers/ldc/issues/3027
|
# Different versions due to https://github.com/ldc-developers/ldc/issues/3027
|
||||||
|
@ -31,17 +31,17 @@ function setup_arm32_chroot {
|
||||||
VERSION=jessie
|
VERSION=jessie
|
||||||
CHROOT_ARCH=armhf
|
CHROOT_ARCH=armhf
|
||||||
# Host dependencies
|
# Host dependencies
|
||||||
sudo apt-get install -qq -y ${HOST_DEPENDENCIES}
|
sudo apt-get install -qq -y "${HOST_DEPENDENCIES[@]}"
|
||||||
# Download LDC compiler
|
# Download LDC compiler
|
||||||
wget https://github.com/ldc-developers/ldc/releases/download/v${LDC_VERSION_ARMHF}/ldc2-${LDC_VERSION_ARMHF}-linux-armhf.tar.xz
|
wget "https://github.com/ldc-developers/ldc/releases/download/v${LDC_VERSION_ARMHF}/ldc2-${LDC_VERSION_ARMHF}-linux-armhf.tar.xz"
|
||||||
tar -xf ldc2-${LDC_VERSION_ARMHF}-linux-armhf.tar.xz
|
tar -xf "ldc2-${LDC_VERSION_ARMHF}-linux-armhf.tar.xz"
|
||||||
mv ldc2-${LDC_VERSION_ARMHF}-linux-armhf dlang-${ARCH}
|
mv "ldc2-${LDC_VERSION_ARMHF}-linux-armhf" "dlang-${ARCH}"
|
||||||
rm -rf ldc2-${LDC_VERSION_ARMHF}-linux-armhf.tar.xz
|
rm -rf "ldc2-${LDC_VERSION_ARMHF}-linux-armhf.tar.xz"
|
||||||
# Create chrooted environment
|
# Create chrooted environment
|
||||||
sudo mkdir ${CHROOT_DIR}
|
sudo mkdir "${CHROOT_DIR}"
|
||||||
sudo debootstrap --foreign --no-check-gpg --variant=buildd --arch=${CHROOT_ARCH} ${VERSION} ${CHROOT_DIR} ${DEBIAN_MIRROR}
|
sudo debootstrap --foreign --no-check-gpg --variant=buildd --arch="${CHROOT_ARCH}" "${VERSION}" "${CHROOT_DIR}" "${DEBIAN_MIRROR}"
|
||||||
sudo cp /usr/bin/qemu-arm-static ${CHROOT_DIR}/usr/bin/
|
sudo cp /usr/bin/qemu-arm-static "${CHROOT_DIR}"/usr/bin/
|
||||||
sudo chroot ${CHROOT_DIR} /debootstrap/debootstrap --second-stage
|
sudo chroot "${CHROOT_DIR}" /debootstrap/debootstrap --second-stage
|
||||||
sudo sbuild-createchroot --arch=${CHROOT_ARCH} --foreign --setup-only ${VERSION} ${CHROOT_DIR} ${DEBIAN_MIRROR}
|
sudo sbuild-createchroot --arch=${CHROOT_ARCH} --foreign --setup-only ${VERSION} ${CHROOT_DIR} ${DEBIAN_MIRROR}
|
||||||
configure_chroot
|
configure_chroot
|
||||||
}
|
}
|
||||||
|
@ -53,12 +53,12 @@ function setup_arm64_chroot {
|
||||||
VERSION64=stretch
|
VERSION64=stretch
|
||||||
CHROOT_ARCH64=arm64
|
CHROOT_ARCH64=arm64
|
||||||
# Host dependencies
|
# Host dependencies
|
||||||
sudo apt-get install -qq -y ${HOST_DEPENDENCIES}
|
sudo apt-get install -qq -y "${HOST_DEPENDENCIES[@]}"
|
||||||
# Download LDC compiler
|
# Download LDC compiler
|
||||||
wget https://github.com/ldc-developers/ldc/releases/download/v${LDC_VERSION_ARM64}/ldc2-${LDC_VERSION_ARM64}-linux-aarch64.tar.xz
|
wget "https://github.com/ldc-developers/ldc/releases/download/v${LDC_VERSION_ARM64}/ldc2-${LDC_VERSION_ARM64}-linux-aarch64.tar.xz"
|
||||||
tar -xf ldc2-${LDC_VERSION_ARM64}-linux-aarch64.tar.xz
|
tar -xf "ldc2-${LDC_VERSION_ARM64}-linux-aarch64.tar.xz"
|
||||||
mv ldc2-${LDC_VERSION_ARM64}-linux-aarch64 dlang-${ARCH}
|
mv "ldc2-${LDC_VERSION_ARM64}-linux-aarch64" "dlang-${ARCH}"
|
||||||
rm -rf ldc2-${LDC_VERSION_ARM64}-linux-aarch64.tar.xz
|
rm -rf "ldc2-${LDC_VERSION_ARM64}-linux-aarch64.tar.xz"
|
||||||
|
|
||||||
# ARM64 qemu-debootstrap needs to be 1.0.78, Trusty is 1.0.59
|
# ARM64 qemu-debootstrap needs to be 1.0.78, Trusty is 1.0.59
|
||||||
#sudo echo "deb http://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse" >> /etc/apt/sources.list
|
#sudo echo "deb http://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse" >> /etc/apt/sources.list
|
||||||
|
@ -67,7 +67,7 @@ function setup_arm64_chroot {
|
||||||
sudo apt-get install -t xenial debootstrap
|
sudo apt-get install -t xenial debootstrap
|
||||||
|
|
||||||
# Create chrooted environment
|
# Create chrooted environment
|
||||||
sudo mkdir ${CHROOT_DIR}
|
sudo mkdir "${CHROOT_DIR}"
|
||||||
sudo qemu-debootstrap --arch=${CHROOT_ARCH64} ${VERSION64} ${CHROOT_DIR} ${DEBIAN_MIRROR}
|
sudo qemu-debootstrap --arch=${CHROOT_ARCH64} ${VERSION64} ${CHROOT_DIR} ${DEBIAN_MIRROR}
|
||||||
configure_chroot
|
configure_chroot
|
||||||
}
|
}
|
||||||
|
@ -79,19 +79,19 @@ function setup_x32_chroot {
|
||||||
VERSION=jessie
|
VERSION=jessie
|
||||||
CHROOT_ARCH32=i386
|
CHROOT_ARCH32=i386
|
||||||
# Host dependencies
|
# Host dependencies
|
||||||
sudo apt-get install -qq -y ${HOST_DEPENDENCIES}
|
sudo apt-get install -qq -y "${HOST_DEPENDENCIES[@]}"
|
||||||
# Download DMD compiler
|
# Download DMD compiler
|
||||||
DMDVER=2.083.1
|
DMDVER=2.083.1
|
||||||
wget http://downloads.dlang.org/releases/2.x/${DMDVER}/dmd.${DMDVER}.linux.tar.xz
|
wget "http://downloads.dlang.org/releases/2.x/${DMDVER}/dmd.${DMDVER}.linux.tar.xz"
|
||||||
tar -xf dmd.${DMDVER}.linux.tar.xz
|
tar -xf "dmd.${DMDVER}.linux.tar.xz"
|
||||||
mv dmd2 dlang-${ARCH}
|
mv dmd2 "dlang-${ARCH}"
|
||||||
rm -rf dmd.${DMDVER}.linux.tar.xz
|
rm -rf "dmd.${DMDVER}.linux.tar.xz"
|
||||||
# Create chrooted environment
|
# Create chrooted environment
|
||||||
sudo mkdir ${CHROOT_DIR}
|
sudo mkdir "${CHROOT_DIR}"
|
||||||
sudo debootstrap --foreign --no-check-gpg --variant=buildd --arch=${CHROOT_ARCH32} ${VERSION} ${CHROOT_DIR} ${DEBIAN_MIRROR}
|
sudo debootstrap --foreign --no-check-gpg --variant=buildd --arch=${CHROOT_ARCH32} ${VERSION} ${CHROOT_DIR} ${DEBIAN_MIRROR}
|
||||||
sudo cp /usr/bin/qemu-i386-static ${CHROOT_DIR}/usr/bin/
|
sudo cp /usr/bin/qemu-i386-static "${CHROOT_DIR}/usr/bin/"
|
||||||
sudo cp /usr/bin/qemu-x86_64-static ${CHROOT_DIR}/usr/bin/
|
sudo cp /usr/bin/qemu-x86_64-static "${CHROOT_DIR}/usr/bin/"
|
||||||
sudo chroot ${CHROOT_DIR} /debootstrap/debootstrap --second-stage
|
sudo chroot "${CHROOT_DIR}" /debootstrap/debootstrap --second-stage
|
||||||
sudo sbuild-createchroot --arch=${CHROOT_ARCH32} --foreign --setup-only ${VERSION} ${CHROOT_DIR} ${DEBIAN_MIRROR}
|
sudo sbuild-createchroot --arch=${CHROOT_ARCH32} --foreign --setup-only ${VERSION} ${CHROOT_DIR} ${DEBIAN_MIRROR}
|
||||||
configure_chroot
|
configure_chroot
|
||||||
}
|
}
|
||||||
|
@ -103,19 +103,19 @@ function configure_chroot {
|
||||||
chmod a+x envvars.sh
|
chmod a+x envvars.sh
|
||||||
|
|
||||||
# Install dependencies inside chroot
|
# Install dependencies inside chroot
|
||||||
sudo chroot ${CHROOT_DIR} apt-get update
|
sudo chroot "${CHROOT_DIR}" apt-get update
|
||||||
sudo chroot ${CHROOT_DIR} apt-get --allow-unauthenticated install -qq -y ${GUEST_DEPENDENCIES}
|
sudo chroot "${CHROOT_DIR}" apt-get --allow-unauthenticated install -qq -y "${GUEST_DEPENDENCIES[@]}"
|
||||||
|
|
||||||
# Create build dir and copy travis build files to our chroot environment
|
# Create build dir and copy travis build files to our chroot environment
|
||||||
sudo mkdir -p ${CHROOT_DIR}/${TRAVIS_BUILD_DIR}
|
sudo mkdir -p "${CHROOT_DIR}"/"${TRAVIS_BUILD_DIR}"
|
||||||
sudo rsync -a ${TRAVIS_BUILD_DIR}/ ${CHROOT_DIR}/${TRAVIS_BUILD_DIR}/
|
sudo rsync -a "${TRAVIS_BUILD_DIR}"/ "${CHROOT_DIR}"/"${TRAVIS_BUILD_DIR}"/
|
||||||
|
|
||||||
# Indicate chroot environment has been set up
|
# Indicate chroot environment has been set up
|
||||||
sudo touch ${CHROOT_DIR}/.chroot_is_done
|
sudo touch "${CHROOT_DIR}"/.chroot_is_done
|
||||||
|
|
||||||
# Call ourselves again which will cause tests to run
|
# Call ourselves again which will cause tests to run
|
||||||
sudo chroot ${CHROOT_DIR} bash -c "cd ${TRAVIS_BUILD_DIR} && chmod a+x ./.travis-ci.sh"
|
sudo chroot "${CHROOT_DIR}" bash -c "cd ${TRAVIS_BUILD_DIR} && chmod a+x ./.travis-ci.sh"
|
||||||
sudo chroot ${CHROOT_DIR} bash -c "cd ${TRAVIS_BUILD_DIR} && ./.travis-ci.sh"
|
sudo chroot "${CHROOT_DIR}" bash -c "cd ${TRAVIS_BUILD_DIR} && ./.travis-ci.sh"
|
||||||
}
|
}
|
||||||
|
|
||||||
function build_onedrive {
|
function build_onedrive {
|
||||||
|
@ -129,12 +129,12 @@ function build_onedrive {
|
||||||
else
|
else
|
||||||
if [ "${ARCH}" = "x32" ]; then
|
if [ "${ARCH}" = "x32" ]; then
|
||||||
# 32Bit DMD Build
|
# 32Bit DMD Build
|
||||||
./configure DC=${HOMEDIR}/dlang-${ARCH}/linux/bin32/dmd
|
./configure DC="${HOMEDIR}"/dlang-"${ARCH}"/linux/bin32/dmd
|
||||||
make clean;
|
make clean;
|
||||||
make
|
make
|
||||||
else
|
else
|
||||||
# LDC Build - ARM32, ARM64
|
# LDC Build - ARM32, ARM64
|
||||||
./configure DC=${HOMEDIR}/dlang-${ARCH}/bin/ldmd2
|
./configure DC="${HOMEDIR}"/dlang-"${ARCH}"/bin/ldmd2
|
||||||
make clean;
|
make clean;
|
||||||
make
|
make
|
||||||
fi
|
fi
|
||||||
|
@ -154,7 +154,7 @@ function test_onedrive {
|
||||||
./makefiles.sh
|
./makefiles.sh
|
||||||
cd ..
|
cd ..
|
||||||
mkdir -p ~/.config/onedrive/
|
mkdir -p ~/.config/onedrive/
|
||||||
echo $ODP > ~/.config/onedrive/refresh_token
|
echo "$ODP" > ~/.config/onedrive/refresh_token
|
||||||
./onedrive --synchronize --verbose --syncdir '~/OneDriveALT'
|
./onedrive --synchronize --verbose --syncdir '~/OneDriveALT'
|
||||||
# OneDrive Cleanup
|
# OneDrive Cleanup
|
||||||
rm -rf ~/OneDriveALT/*
|
rm -rf ~/OneDriveALT/*
|
||||||
|
|
|
@ -12,7 +12,7 @@ _onedrive()
|
||||||
cur=${COMP_WORDS[COMP_CWORD]}
|
cur=${COMP_WORDS[COMP_CWORD]}
|
||||||
prev=${COMP_WORDS[COMP_CWORD-1]}
|
prev=${COMP_WORDS[COMP_CWORD-1]}
|
||||||
|
|
||||||
options='--check-for-nomount --check-for-nosync --debug-https --disable-notifications --display-config --display-sync-status --download-only --disable-upload-validation --dry-run --enable-logging --force-http-1.1 --force-http-2 --local-first --logout -m --monitor --no-remote-delete --print-token --resync --skip-dot-files --skip-symlinks --synchronize --upload-only -v --verbose --version -h --help'
|
options='--check-for-nomount --check-for-nosync --debug-https --disable-notifications --display-config --display-sync-status --download-only --disable-upload-validation --dry-run --enable-logging --force-http-1.1 --force-http-2 --local-first --logout -m --monitor --no-remote-delete --print-token --resync --skip-dot-files --skip-symlinks --synchronize --upload-only -v --verbose --version -h --help'
|
||||||
argopts='--create-directory --get-O365-drive-id --remove-directory --single-directory --source-directory'
|
argopts='--create-directory --get-O365-drive-id --remove-directory --single-directory --source-directory'
|
||||||
|
|
||||||
# Loop on the arguments to manage conflicting options
|
# Loop on the arguments to manage conflicting options
|
||||||
|
@ -31,7 +31,7 @@ _onedrive()
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
COMPREPLY=( $( compgen -W "$options $argopts" -- $cur))
|
COMPREPLY=( $( compgen -W "$options $argopts" -- "$cur"))
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -6,17 +6,17 @@ set +H -xeuo pipefail
|
||||||
: ${ONEDRIVE_GID:=$(stat /onedrive/data -c '%g')}
|
: ${ONEDRIVE_GID:=$(stat /onedrive/data -c '%g')}
|
||||||
|
|
||||||
# Create new group using target GID
|
# Create new group using target GID
|
||||||
if ! odgroup="$(getent group $ONEDRIVE_GID)"; then
|
if ! odgroup="$(getent group "$ONEDRIVE_GID")"; then
|
||||||
odgroup='onedrive'
|
odgroup='onedrive'
|
||||||
groupadd "${odgroup}" -g $ONEDRIVE_GID
|
groupadd "${odgroup}" -g "$ONEDRIVE_GID"
|
||||||
else
|
else
|
||||||
odgroup=${odgroup%%:*}
|
odgroup=${odgroup%%:*}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create new user using target UID
|
# Create new user using target UID
|
||||||
if ! oduser="$(getent passwd $ONEDRIVE_UID)"; then
|
if ! oduser="$(getent passwd "$ONEDRIVE_UID")"; then
|
||||||
oduser='onedrive'
|
oduser='onedrive'
|
||||||
useradd -m "${oduser}" -u $ONEDRIVE_UID -g $ONEDRIVE_GID
|
useradd -m "${oduser}" -u "$ONEDRIVE_UID" -g "$ONEDRIVE_GID"
|
||||||
else
|
else
|
||||||
oduser="${oduser%%:*}"
|
oduser="${oduser%%:*}"
|
||||||
usermod -g "${odgroup}" "${oduser}"
|
usermod -g "${odgroup}" "${oduser}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# This script is to assist in starting the onedrive client when using init.d
|
# This script is to assist in starting the onedrive client when using init.d
|
||||||
APP_OPTIONS="--monitor --verbose --enable-logging"
|
APP_OPTIONS="--monitor --verbose --enable-logging"
|
||||||
onedrive $APP_OPTIONS > /dev/null 2>&1 &
|
onedrive "$APP_OPTIONS" > /dev/null 2>&1 &
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in a new issue