User Tools

Site Tools


packages:alternatives

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
packages:alternatives [2016-02-01 06:14]
glen created
packages:alternatives [2016-02-01 06:25] (current)
glen
Line 1: Line 1:
 ====== alternatives ====== ====== alternatives ======
  
-[[http://​linux.die.net/​man/​8/​update-alternatives|update-alternatives]] - maintain symbolic links determining default commands+[[http://​linux.die.net/​man/​8/​update-alternatives|update-alternatives]] - maintain symbolic links determining default commands
 + 
 +Default implementation in PLD Linux is provided by ''​alternatives''​ package from [[package>​chkconfig]]. 
 + 
 +===== switching alternative ===== 
 + 
 +By default ''​alternatives''​ uses ''​auto''​ mode picking the "​best"​ alternative. 
 + 
 +//TODO: how to enforce sysadmin preference//​ 
 + 
 +===== integrating ===== 
 + 
 +from [[http://​git.pld-linux.org/?​p=packages/​php.git;​a=commitdiff;​h=82885e7c57e9ee9183eead2319352703c8278a35|phar-php example]]:​ 
 + 
 +<code rpmspec>​ 
 +Requires: ​     alternatives 
 +... 
 + 
 +%install 
 +... 
 +# touch for ghost 
 +%{__rm} $RPM_BUILD_ROOT%{_bindir}/​phar 
 +touch $RPM_BUILD_ROOT%{_bindir}/​phar 
 + 
 +%post phar 
 +update-alternatives \ 
 +       ​--install %{_bindir}/​phar phar %{_bindir}/​phar%{ver_suffix}.phar %{ver_suffix} \ 
 +       ​--slave %{_mandir}/​man1/​phar.1 phar.1 %{_mandir}/​man1/​phar%{ver_suffix}.1* || : 
 + 
 +%postun phar 
 +if [ $1 -eq 0 ]; then 
 +       ​update-alternatives --remove phar %{_bindir}/​phar || : 
 +fi 
 + 
 +... 
 +%files 
 +... 
 +%ghost %{_bindir}/​phar 
 +%ghost %{_mandir}/​man1/​phar.1 
 +</​code>​ 
 + 
 +  - add ''​Requires:​ alternatives''​ to runtime deps 
 +  - the path must be ghost and regular file, otherwise rpm will complin about file-conflicts 
 +  - use ''​%%--install%%''​ to setup the symlinks in package ''​%post''​ scriptlet. 
 +  - the ''​%%--slave%%''​ option is optional and may be repeated, use if you wish to "​group"​ alternatives 
 +  - use proper ''​%postun''​ to remove alternative on package uninstall 
 + 
 +<note warning>​ 
 +Currently it remains unclear how to handle optional files, as for above example: 
 +  - ''​%{_mandir}''​ path can be missing if ''​%_excludedocs''​ is set 
 +  - ''​%{_mandir}''​ path could be ''​.gz''​ compressed or not, it's currently solved with a glob: ''​%{_mandir}/​man1/​phar%{ver_suffix}.1*''​ 
 +</​note>​
packages/alternatives.1454303693.txt.gz · Last modified: 2016-02-01 06:14 by glen