After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 767630 - Media symlinks are absolute which makes installed files not relocatable
Media symlinks are absolute which makes installed files not relocatable
Status: RESOLVED OBSOLETE
Product: yelp-tools
Classification: Core
Component: yelp.m4
git master
Other Linux
: Normal normal
: ---
Assigned To: Yelp maintainers
Yelp maintainers
Depends on:
Blocks:
 
 
Reported: 2016-06-14 03:14 UTC by Robert Ancell
Modified: 2018-05-22 12:51 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Use relative symlinks for media files (981 bytes, patch)
2016-06-14 03:14 UTC, Robert Ancell
none Details | Review
Use relative symlinks for media files (1.16 KB, patch)
2016-06-16 00:25 UTC, Robert Ancell
none Details | Review

Description Robert Ancell 2016-06-14 03:14:12 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
Comment 1 Robert Ancell 2016-06-14 03:14:51 UTC
Created attachment 329750 [details] [review]
Use relative symlinks for media files
Comment 2 Shaun McCance 2016-06-15 16:07:45 UTC
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.
Comment 3 Robert Ancell 2016-06-16 00:25:11 UTC
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.
Comment 4 Jeremy Bicha 2018-03-24 01:30:42 UTC
Shaun, could you review the updated patch some time? Thanks!
Comment 5 GNOME Infrastructure Team 2018-05-22 12:51:31 UTC
-- 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.