Dev:2.5/Source/Installation/Unix FHS

提供: wiki
< Dev:2.5‎ | Source‎ | Installation
2018年6月29日 (金) 03:43時点におけるYamyam (トーク | 投稿記録)による版 (1版 をインポートしました)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

Unix FHS

Blender 2.4x did not support a directory structure common on most unix installations, where application data files are stored in the user's home dir ~/.blender

This page outlines how blender can fit into this filesystem layout while maintaining compatibility with a portable layout.

  • ~/.blender stays working, existing configurations wont need to change.
  • An optional new DIR is defined for UNIX systems (not win/mac), for brevity will call it SYS-PATH
  • This dir could be named as follows $PREFIX/share/blender/$VERSION
    Eg. /usr/local/share/blender/2.5
  • When the SYS-PATH directory is found it will be used as the primary directory for scripts, language files, icons etc. (Otherwise ~/.blender will be used like it is now)
  • Scripts scan SYS-PATH first (if it exists) then ~/.blender, other data files only use one path (SYS-PATH and fall back to ~/.blender)
    . In most cases using data from both dirs at once is not needed, (you could conceivably want to access icon themes from ~/.blender & SYS-PATH, but don't think it's so important) However, scripts are an exception, On a typical linux package you'd have blender install all data files into /usr/share/blender/2.5 and then when users want to add their own scripts they can copy into /home/user/.blender/scripts.


Outcomes

  • improves out-of-box experience for users by not treating built-in files (eg, most of blender2.5s interface) as user settings/data.
  • Less trouble to package blender (no scripts copying data to ~/.blender on startup).
  • Keep support for existing "local" installs where blender can run without being installed.
  • Packages will install all blender data in /usr/share/blender/2.5.x, casual users will not create a ~/.blender, however ~/.B.blend will still be saved into their home dir.
  • Existing users who build and run blender don't need to change their configuration.
  • Package managers upgrading blender will remove system scripts and replace with new ones, ~/.blender (if exists) is untouched.

Details

  • Use a compile time option, like ./configure --prefix="/usr/local"
  • $BLENDERPATH used like $PYTHONPATH, allow for non hard-coded SYS-PATH (Better for re-distribution where users don't install into /usr/share/.... etc., and don't copy scripts into ~/.blender). Typical usage this would not need setting.
  • Can implement this as opt-in to initially, later can review making it default.
  • adds an "install" target for cmake, scons uses the installation path.

Build Systems

One problem with using the blender version number in the path is each build system needs to have the version number stored so the installation path can be made. Parsing the blender version is possible but not so nice.

CMake

CMake creates a portable bundle initially, after this running "make install" will copy these files into the FHS directory structure on your system. Running "make install" is still optional, the portable distribution will still run on its own.

  • CMAKE_INSTALL_PREFIX - the target path used for copying blender with "make install".
    eg. /usr, /usr/local, /opt/blender.
  • BLENDER_VERSION - internal variable defined in CMakeLists.txt is used for creating the version string.
  • WITH_INSTALL - must be enabled.


SCons

SCons needs to have WITH_BF_FHS enabled so running "scons" will create a unix layout in the BF_INSTALLDIR eg:

  scons WITH_BF_FHS=1 BF_INSTALLDIR="/usr/local"
  • BF_INSTALLDIR - the target path used for copying blender.
    eg. /usr, /usr/local, /opt/blender.
    Note that this path is normally set relative to blenders directory.
  • WITH_BF_FHS boolean option enabled a FHS layout,
    When enabled $BF_INSTALLDIR/bin/blender and BF_INSTALLDIR/share/2.5 will be used.
  • BF_VERSION internal variable defined in ./tools/btools.py, used to make the version string.
  • WITHOUT_BF_INSTALL must be disabled.

Make

(TODO)

Implementation

BLENDERPATH

  • creator.c has a static variable called blender_path which is defined by the build system, as... $BLENDERPATH/share/$VERSION and can replace ~/.blender

BLI_gethome_folder

  • BLI_gethome_folder(folder, flag), The flag argument can be...
    • BLI_GETHOME_LOCAL relative location for portable binaries
    • BLI_GETHOME_SYSTEM fixed system location, or set from the BLENDERPATH env variable (UNIX only)
    • BLI_GETHOME_USER home folder ~/.blender
    • BLI_GETHOME_ALL All paths, order of checking is local, system and user

Scripts

Scripts are currently searched for in 2 folders

  • First over the system data path (BLENDERPATH, using BLI_GETHOME_SYSTEM)
  • Second over LOCAL/USER script folders (whichever is found first)

This means one of 2 configurations is found...

  • local+user scripts OR...
  • system+user scripts

As mentioned before, when local scripts are found, system scripts are ignored.

TODO

  • update makefiles
  • have locale translation files use BLI_gethome_folder
  • have icon path use BLI_gethome_folder
  • create ~/.blender when not found so scripts can save their configuration.