-
-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add systemd units to sideload from hotplugged USBs
Currently with the sideload implementation of offline updates you have to manually create a symlink to your USB drive to sideload from it, which is a regression compared to the previous implementation which scanned all mounted filesystems in OstreeRepoFinderMount in libostree. So this commit adds a few systemd units and a bash script so that any time a USB drive is plugged in and automatically mounted by udisks, a symlink to it is created in /run/flatpak/sideload-repos. When the drive is unplugged the symlink is removed. However this solution still has a lot of moving parts, so we may want to instead have libflatpak use GVolumeMonitor and find the mounted filesystems itself; see #3705 Fixes #3490
- Loading branch information
1 parent
e84b756
commit 9caf664
Showing
9 changed files
with
105 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
if BUILD_AUTO_SIDELOADING | ||
|
||
dist_libexec_SCRIPTS = sideload-repos-systemd/flatpak-create-sideload-symlinks.sh | ||
|
||
service_in_files += sideload-repos-systemd/flatpak-sideload-usb-repo.service.in | ||
systemduserunit_DATA += sideload-repos-systemd/flatpak-sideload-usb-repo.service | ||
|
||
path_in_files = sideload-repos-systemd/flatpak-sideload-usb-repo.path.in | ||
systemduserunit_DATA += sideload-repos-systemd/flatpak-sideload-usb-repo.path | ||
|
||
systemdsystemunit_DATA += sideload-repos-systemd/flatpak-sideload-repos-dir.service | ||
|
||
%.path: %.path.in config.log | ||
$(AM_V_GEN) $(SED) -e "s|\@media_dir\@|$(RUN_MEDIA_DIR)|" $< > $@ | ||
|
||
endif | ||
|
||
EXTRA_DIST += sideload-repos-systemd/flatpak-sideload-usb-repo.path.in sideload-repos-systemd/flatpak-sideload-repos-dir.service |
30 changes: 30 additions & 0 deletions
30
sideload-repos-systemd/flatpak-create-sideload-symlinks.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash | ||
|
||
# This script is intended to be run by flatpak-sideload-usb-repo.service | ||
|
||
if ! test $# -eq 1 || ! test -d "$1"; then | ||
echo "Error: first argument must be a directory" | ||
exit 1 | ||
fi | ||
|
||
# Add a link to any newly inserted drives which might have been copied to with | ||
# "flatpak create-usb". If we were to check for a repo on the drive that would | ||
# break the case of using it for sideloading directly after copying to it (e.g. | ||
# for testing). | ||
for f in "$1"/*; do | ||
if ! test -d "$f"; then | ||
continue | ||
fi | ||
unique_name=automount-$(echo "$f" | sha256sum | cut -f 1 -d ' ') | ||
if test -e "/run/flatpak/sideload-repos/$unique_name"; then | ||
continue | ||
fi | ||
ln -s "$f" "/run/flatpak/sideload-repos/$unique_name" | ||
done | ||
|
||
# Remove any broken symlinks e.g. from drives that were removed | ||
for f in /run/flatpak/sideload-repos/automount-*; do | ||
if ! test -e "$f"; then | ||
rm "$f" | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# This unit is intended to be installed in the systemd system instance, so that | ||
# flatpak-sideload-usb-repo.{path,service} can work in the user instance | ||
[Service] | ||
Type=oneshot | ||
ExecStart=/bin/mkdir -p /run/flatpak; /bin/mkdir -p -m 777 /run/flatpak/sideload-repos | ||
|
||
[Unit] | ||
# Use basic.target to guarantee we run before flatpak-sideload-usb-repos.path | ||
# in the user systemd instance | ||
Before=basic.target | ||
After=sysinit.target | ||
DefaultDependencies=no | ||
|
||
[Install] | ||
WantedBy=basic.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# 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 | ||
# 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] | ||
WantedBy=default.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# This unit is intended to be installed in the systemd user instance; see the | ||
# docs in flatpak-sideload-usb-repo.path | ||
[Service] | ||
Type=oneshot | ||
ExecStart=@libexecdir@/flatpak-create-sideload-symlinks.sh @media_dir@/%u |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters