diff options
author | Phaedrus Leeds <mwleeds@endlessos.org> | 2020-09-22 13:21:39 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-22 13:21:39 -0700 |
commit | eea84212e9d4f5d1600aa36e07d635f720573e64 (patch) | |
tree | 00d28722d13a8a2dd1e0d2cceafd29aee14ecc99 | |
parent | 6b46d9a0ede99dca99737fa3d4e55200cb9336e3 (diff) | |
parent | 192da15f6017c2bb6640437f49f62530614451a5 (diff) | |
download | flatpak-eea84212e9d4f5d1600aa36e07d635f720573e64.tar.gz |
Merge pull request #3866 from wjt/create-sideload-symlinks-nullglob
sideload-repo-systemd: Various fixes
3 files changed, 13 insertions, 5 deletions
diff --git a/sideload-repos-systemd/flatpak-create-sideload-symlinks.sh b/sideload-repos-systemd/flatpak-create-sideload-symlinks.sh index 0e4c57f0..4b3aabd6 100755 --- a/sideload-repos-systemd/flatpak-create-sideload-symlinks.sh +++ b/sideload-repos-systemd/flatpak-create-sideload-symlinks.sh @@ -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 diff --git a/sideload-repos-systemd/flatpak-sideload-usb-repo.path.in b/sideload-repos-systemd/flatpak-sideload-usb-repo.path.in index 095b7102..3e7d26ad 100644 --- a/sideload-repos-systemd/flatpak-sideload-usb-repo.path.in +++ b/sideload-repos-systemd/flatpak-sideload-usb-repo.path.in @@ -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] diff --git a/sideload-repos-systemd/flatpak-sideload-usb-repo.service.in b/sideload-repos-systemd/flatpak-sideload-usb-repo.service.in index 8f8895da..a3f4c93a 100644 --- a/sideload-repos-systemd/flatpak-sideload-usb-repo.service.in +++ b/sideload-repos-systemd/flatpak-sideload-usb-repo.service.in @@ -3,3 +3,6 @@ [Service] Type=oneshot ExecStart=@libexecdir@/flatpak-create-sideload-symlinks.sh @media_dir@/%u + +[Install] +WantedBy=default.target |