Merge pull request #3866 from wjt/create-sideload-symlinks-nullglob

sideload-repo-systemd: Various fixes
This commit is contained in:
Phaedrus Leeds
2020-09-22 13:21:39 -07:00
committed by GitHub
3 changed files with 13 additions and 5 deletions

View File

@@ -2,6 +2,8 @@
# This script is intended to be run by flatpak-sideload-usb-repo.service
shopt -s nullglob
if ! test $# -eq 1 || ! test -d "$1"; then
echo "Error: first argument must be a directory"
exit 1
@@ -15,7 +17,7 @@ for f in "$1"/*; do
if ! test -d "$f"; then
continue
fi
unique_name=automount-$(echo "$f" | sha256sum | cut -f 1 -d ' ')
unique_name=automount$(systemd-escape "$f")
if test -e "/run/flatpak/sideload-repos/$unique_name"; then
continue
fi
@@ -23,7 +25,11 @@ for f in "$1"/*; do
done
# Remove any broken symlinks e.g. from drives that were removed
for f in /run/flatpak/sideload-repos/automount-*; do
for f in /run/flatpak/sideload-repos/automount*; do
OWNER=$(stat -c '%u' "$f")
if [ "$UID" != "$OWNER" ]; then
continue
fi
if ! test -e "$f"; then
rm "$f"
fi

View File

@@ -1,11 +1,10 @@
# This unit is intended to be installed in the systemd user instance, and
# depends on flatpak-sideload-repos-dir.service being in the system instance
# and running first. The idea here is that we add any USB drive mounts to the
# depends on /run/flatpak/sideload-repos having been created via
# systemd-tmpfiles. The idea here is that we add any USB drive mounts to the
# appropriate directory so Flatpak can find and pull from them in case they
# have flatpaks on them, both when a new drive is inserted and at the start of
# the user session.
[Path]
PathExists=@media_dir@/%u
PathChanged=@media_dir@/%u
[Install]

View File

@@ -3,3 +3,6 @@
[Service]
Type=oneshot
ExecStart=@libexecdir@/flatpak-create-sideload-symlinks.sh @media_dir@/%u
[Install]
WantedBy=default.target