Bug 196432

Summary: Allow @sample keyword reference a symlink
Product: Ports & Packages Reporter: Jan Beich <jbeich>
Component: Ports FrameworkAssignee: freebsd-ports-bugs (Nobody) <ports-bugs>
Status: Closed Works As Intended    
Severity: Affects Only Me CC: koobs, portmgr
Priority: --- Keywords: feature, needs-qa, patch
Version: Latest   
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=196431
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=196435
Attachments:
Description Flags
copy symlink itself instead of destination
none
copy symlink itself instead of destination, v2 none

Description Jan Beich freebsd_committer freebsd_triage 2015-01-02 09:56:03 UTC
Created attachment 151203 [details]
copy symlink itself instead of destination

A port may install one or more symlinks to default content. Sometimes a user already created a file instead of symlink with alternate contents. Otherwise, @sample would copy symlink into a regular file which is unintuitive.
Comment 1 Mathieu Arnold freebsd_committer freebsd_triage 2015-01-02 10:11:11 UTC
I think @sample works as intented, if there is a symlink, the content should be copied so that it can be modified and the sample stay pristine.

Also, I think the ports using @sample with symlinks should be fixed.  What port does that ?
Comment 2 Jan Beich freebsd_committer freebsd_triage 2015-01-02 10:35:52 UTC
My intention was to allow security/ca_root_nss ignore cert.pem if already exists. The port currently installs the following symlinks and would benefit from @sample or another way to not overwrite user certificates.

  /etc/ssl/cert.pem (not default, may change per bug 189811)
  /usr/local/etc/ssl/cert.pem (since ports r372629)
  /usr/local/openssl/cert.pem (soon, bug 196431)

And some linux-* ports like linux-f10-fontconfig can allow users to override config files with a version taking into account differences between linux and native version, e.g. depending on bug 179400.
Comment 3 Jan Beich freebsd_committer freebsd_triage 2015-01-02 10:41:35 UTC
Created attachment 151204 [details]
copy symlink itself instead of destination, v2

Added -h to chmod/cmp as only rm(1) in sample.ucl is an exception according to symlink(7).
Comment 4 Kubilay Kocak freebsd_committer freebsd_triage 2015-01-02 10:45:28 UTC
+1 I like :)
Comment 5 Antoine Brodin freebsd_committer freebsd_triage 2015-01-02 10:47:45 UTC
I understand replacing -f with -e,  and replacing cmp -s with cmp -h -s,  but I don't understand the rest of the patch
Comment 6 Kubilay Kocak freebsd_committer freebsd_triage 2015-01-02 10:58:44 UTC
Re-add meta after mid-air collision with antoine@.
Comment 7 Mathieu Arnold freebsd_committer freebsd_triage 2015-01-02 11:18:34 UTC
(In reply to Antoine Brodin from comment #5)
> I understand replacing -f with -e,  and replacing cmp -s with cmp -h -s, 
> but I don't understand the rest of the patch

cp -R is a hack it uses the fact that when doing a cp -R, symlinks are copied instead of dereferenced.
chmod -h is so that the chmod is applied to the the link and not the target.

I still don't like it, I find it way better to install the target of the symlink so that it can be modified than copying the symlink which, if modified, will be overwritten on next upgrade.
Comment 8 Jan Beich freebsd_committer freebsd_triage 2015-01-02 12:13:53 UTC
(In reply to Mathieu Arnold from comment #7)
> I still don't like it, I find it way better to install the target of the
> symlink so that it can be modified than copying the symlink which, if
> modified, will be overwritten on next upgrade.

Indeed, firing up a text editor on /etc/ssl/cert.pem would try to alter contents of symlink destination. It wasn't very clear in comment 1 what sample symlink content mean, the link with .sample suffix stripped or its destination.

@sample in bug 196431 should work fine without the patch here. It'd install 3 copies of the same sample file but user can make one main and the rest point to it (e.g. bug 196435).