Skip to content
Snippets Groups Projects
Commit c2684ccc authored by Frédéric Dalleau's avatar Frédéric Dalleau :sun_with_face:
Browse files

Merge branch 'wip/andrunko/T5563' into 'master'

Fix script to remove some bashisms

See merge request !1
parents 70cc8140 338fe0bc
Branches 19.03
No related tags found
1 merge request!1Fix script to remove some bashisms
#!/bin/bash
#!/bin/sh
# vim: set sts=4 sw=4 et tw=0 :
set -e
......@@ -43,23 +43,23 @@ _kill_monitor_return() {
return $1
}
bash_arrays_to_gvariant_as() {
stringlist_to_gvariant_as() {
local i converted="['$1'"
shift
for i in "$@"; do
converted+=", '$i'"
for i in $@; do
converted="$converted, '$i'"
done
converted+="]"
converted="$converted]"
echo "${converted}"
}
_check_uris_have_thumbnail() {
local size=$1
local uris=$2
for i in "${uris[@]}"; do
shift
for i in $@; do
local thumb="${HOME}/.cache/thumbnails/${size}/$(echo -n "${i}" | md5sum | cut -f1 -d\ ).png"
say $thumb
if [[ ! -f "${thumb}" ]]; then
if [ ! -f "${thumb}" ]; then
whine "Couldn't find thumbnail $thumb, file $i didn't get thumbnailed!?"
ret=1
fi
......@@ -74,20 +74,22 @@ _generate_thumbnails() {
local size="$1"
local special_dir="$2"
shift 2
files=("$@")
files=$@
logfile="${WORKDIR}/monitor-tumblerd.log"
addr="org.freedesktop.thumbnails.Thumbnailer1"
obj_path="/org/freedesktop/thumbnails/Thumbnailer1"
method="org.freedesktop.thumbnails.Thumbnailer1.Queue"
uris=()
filetypes=()
uris=""
filetypes=""
for i in "${files[@]}"; do
# FIXME: This doesn't do whitespace/special character escaping, etc
for i in ${files}; do
# Tumbler's AppArmor profile doesn't necessarily let it read the
# apertis-tests directory if we're running uninstalled. Copy the
# file to a more realistic location, which exercises the AppArmor
# profile better anyway.
if [ $(( $RANDOM % 2 )) = 0 ] && [ -e "/home/shared/$special_dir" ]; then
_rand=$(od -A n -N 2 -t u2 /dev/urandom)
if [ $(( $_rand % 2 )) = 0 ] && [ -e "/home/shared/$special_dir" ]; then
copy="/home/shared/$special_dir/apertis-tests__$(basename "$i")"
else
copy="$HOME/$special_dir/apertis-tests__$(basename "$i")"
......@@ -96,9 +98,8 @@ _generate_thumbnails() {
cp -v "$i" "$copy"
# Need path relative to /
# FIXME: This doesn't do whitespace/special character escaping, etc
uris+=("file://$copy")
filetypes+=($(file --mime-type "$copy" | cut -d ":" -f 2 | tr -d ' '))
uris="${uris} file://$copy"
filetypes="${filetypes} $(file --mime-type "$copy" | cut -d ":" -f 2 | tr -d ' ')"
done
# Clear out old thumbnails.
......@@ -109,8 +110,8 @@ _generate_thumbnails() {
# Files to thumbnail
${GDBUS} call --session --dest "${addr}" --object-path "${obj_path}" \
--method "${method}" \
"$(bash_arrays_to_gvariant_as "${uris[@]}")" \
"$(bash_arrays_to_gvariant_as "${filetypes[@]}")" \
"$(stringlist_to_gvariant_as ${uris})" \
"$(stringlist_to_gvariant_as ${filetypes})" \
"${size}" foreground 0
# Wait for thumbnailing to finish
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment