GNOME Bugzilla – Bug 767630
Media symlinks are absolute which makes installed files not relocatable
Last modified: 2018-05-22 12:51:31 UTC
If a media file (e.g. a screenshot) is not translatated it has a symlink pointing to the untranslated version. These symlinks are absolute which means the installed files are not relocatable (e.g. if using a packaging system that has each app in its own directory). Attached patch uses relative symlinks instead, e.g. $ ls install/share/help/id/ghex/figures/ -l lrwxrwxrwx 1 bob bob 74 Jun 14 15:01 ghex_window_empty.png -> /home/bob/git/ghex/install/share/help/C/ghex/figures/ghex_window_empty.png becomes: $ ls install/share/help/id/ghex/figures/ -l lrwxrwxrwx 1 bob bob 45 Jun 14 15:08 ghex_window_empty.png -> ../../../C/ghex/figures/ghex_window_empty.png
Created attachment 329750 [details] [review] Use relative symlinks for media files
The problem with this is that it assumes all media files are in a one-level-deep subdirectory, e.g. HELP_MEDIA = media/foo.png These are perfectly valid things to do though: HELP_MEDIA = media/movies/foo.mp4 HELP_MEDIA = foo.png It should be possible to calculate the number of parent dirs from the number of slashes in $f. Something like this? dname="$$f"; pars="../"; while [ "$$dname" != "." ]; do pars="../$$pars"; dname=$$(dirname "$$dname"); done; \ $(LN_S) -f $$pars"C/$(HELP_ID)/$$f" "$$helpdir$$f" || exit 1; Seems right. Needs testing. Likely fails pretty miserably if you give an absolute path in HELP_MEDIA. Note that that is *NOT* something I expect to work, but this code probably throws you into an infinite loop, which is bad. Could have an error check for absolute $f early on, or maybe add a check for "$dname" != "/" in the while condition, just to break out of the loop.
Created attachment 329881 [details] [review] Use relative symlinks for media files Thanks for the review. I merged in your changes with the break for absolute paths. The symlink that will be generated doesn't make sense; not sure if it's worth handling this case. My testing seems to indicate this change works well.
Shaun, could you review the updated patch some time? Thanks!
-- GitLab Migration Automatic Message -- This bug has been migrated to GNOME's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/yelp-tools/issues/13.