简体   繁体   English

哪里存储linux软件生成的数据文件?

[英]Where to store data files generated by linux software?

I have a Python script with a make install (by default to /usr/local/lib/python2.7/dist-packages/) option available. 我有一个Python脚本,带有make install (默认为/usr/local/lib/python2.7/dist-packages/)选项。 But the script also generates files with user-specific mutable data during script's normal usage. 但是在脚本正常使用期间,该脚本还会生成具有用户特定可变数据的文件。 It seems to me that I should not keep compiled script files in couple with data. 在我看来,我不应该将编译后的脚本文件与数据结合起来。 What is conventional default place to store software data in such cases? 在这种情况下,存储软件数据的传统默认位置是什么?

Summarizing from the Filesystem Hierarchy Standard : 文件系统层次标准总结:

Immutable architecture-independent data should go in /usr/share or /usr/local/share . 不可变的与体系结构无关的数据应该放在/usr/share/usr/local/share Mutable data should go in the user's home directory if it's user-specific ( XDG provides more guidance here), or in /var if it's system-wide (this usually requires a group-owned directory and files, and a setgid application, to allow writing to a shared file). 可变数据应该在用户的主目录中,如果它是特定于用户的( XDG在这里提供更多指导),或者在/var如果它是系统范围的(这通常需要一个组拥有的目录和文件,以及一个setgid应用程序,允许写入共享文件)。

/usr/share and /usr/local/share usually have a structure that somewhat mirrors /usr/lib and /usr/local/lib ; /usr/share/usr/local/share通常有一个有点镜像/usr/lib/usr/local/lib ; I don't know about Python, but Perl has a module File::ShareDir that helps a module with installing and accessing data in a share directory corresponding to the directory where the module is installed. 我不了解Python,但是Perl有一个模块File :: ShareDir ,可以帮助模块在与安装模块的目录对应的共享目录中安装和访问数据。

And don't forget the other option: just ask the user where the data should go. 并且不要忘记另一个选择:只询问用户数据应该去哪里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM