Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically sideload from inserted USB drives #3699

Merged
merged 3 commits into from Jun 23, 2020

Conversation

mwleeds
Copy link
Collaborator

@mwleeds mwleeds commented Jun 19, 2020

Fixes #3490

@mwleeds mwleeds requested a review from alexlarsson June 19, 2020 22:52
@mwleeds
Copy link
Collaborator Author

mwleeds commented Jun 19, 2020

Marked this as a draft because I'm not sure I got the automake parts right, but it can still be reviewed.

@mwleeds
Copy link
Collaborator Author

mwleeds commented Jun 19, 2020

I guess we will need a configure time option to enable this, since maybe every distribution doesn't want it.

@alexlarsson
Copy link
Member

alexlarsson commented Jun 22, 2020

Shellcheck says (for flatpak-create-sideload-symlinks.sh):

Line 11:
for f in $1/*; do
         ^-- SC2231: Quote expansions in this for loop glob to prevent wordsplitting, e.g. "$dir"/*.txt .

common/flatpak-dir.c Outdated Show resolved Hide resolved
@alexlarsson
Copy link
Member

sideload-repos-systemd/Makefile.am.inc:11: error: cannot apply '+=' because 'systemdsystemunit_DATA' is not defined in
sideload-repos-systemd/Makefile.am.inc:11: the following conditions:
sideload-repos-systemd/Makefile.am.inc:11:   !BUILD_SYSTEM_HELPER
sideload-repos-systemd/Makefile.am.inc:11: either define 'systemdsystemunit_DATA' in these conditions, or use

@mwleeds
Copy link
Collaborator Author

mwleeds commented Jun 22, 2020

Shellcheck says (for flatpak-create-sideload-symlinks.sh):

Line 11:
for f in $1/*; do
         ^-- SC2231: Quote expansions in this for loop glob to prevent wordsplitting, e.g. "$dir"/*.txt .

Fixed this, and also changed it to link to all mounts found regardless of if there's a repo on them, because I think it's confusing to a user if a USB isn't being used because they have to remove and re-insert it.

Currently we only support links in /var/lib/flatpak/sideload-repos,
/run/flatpak/sideload-repos, etc. to be actual ostree repos, but this
commit makes it so you can also link to the root directory of a USB,
and Flatpak will check the subpaths "ostree/repo", ".ostree/repo", and
".ostree/repos.d" for compatibility with "flatpak create-usb". This will
allow the logic in the following commit to be much simpler, where we're
linking to hot-plugged drives in a script run by systemd.

Note that we still only allow actual repos in the other places where a
sideload path can be specified, such as the --sideload-repo CLI option.
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 flatpak#3705

Fixes flatpak#3490
We only want the run dir to be overridable in unit tests because we
depend on it being /run/flatpak in flatpak-create-sideload-symlinks.sh,
so don't mention it in the flatpak man page.
@mwleeds mwleeds changed the title WIP: Automatically sideload from inserted USB drives Automatically sideload from inserted USB drives Jun 22, 2020
@mwleeds mwleeds marked this pull request as ready for review June 22, 2020 23:03
@alexlarsson alexlarsson merged commit 5a64611 into flatpak:master Jun 23, 2020
@mwleeds mwleeds deleted the auto-add-sideloads branch June 23, 2020 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Need udev example script to replace auto-finding sideload repos
2 participants