简体   繁体   English

与平台无关的/ var / lib和〜/ .config版本

[英]Platform-independent version of /var/lib and ~/.config

We see that programs like apt-get store information in several places: 我们看到诸如apt-get类的程序在多个地方存储信息:

/var/cache/apt      <- cache
/var/lib/apt        <- keyrings, package db, states, locks, mirrors
/etc/apt            <- configuration file
~/.aptitude/config  <- user configuration file

So we see four kinds of paths here: 因此,我们在这里看到四种路径:

  1. Cache path 快取路径
  2. Data path 数据路径
  3. System-wide configuration 系统范围的配置
  4. User configuration 用户配置

Perhaps (1) can be made part of (2) for simplicity sake. 为了简单起见,也许(1)可以成为(2)的一部分。 Can anyone think of ways to get such appropriate paths in platform-independent way? 谁能想到以独立于平台的方式获取此类适当路径的方法吗? Is there a library that does this, or does one have to invent this wheel? 是否有图书馆可以做到这一点,还是必须发明一个轮子?

For Linux, check out the Filesystem Hierarchy Standard (but be aware that these standards are for software being part of distribution, software installed locally should not interfere with distribution's package management and stay in /usr/local/ and /var/local/). 对于Linux,请查看“ 文件系统层次结构标准” (但请注意,这些标准适用于作为分发软件的一部分,本地安装的软件不应干扰分发软件的软件包管理,并且应保留在/ usr / local /和/ var / local /中)。

If you want to be truly cross-platform, IMO best way would be to leave this things configurable for packager, defaulting to run in current directory (so that users without administrative privileges can simply unpack and run program). 如果要真正实现跨平台,IMO最好的方法是让打包程序可配置这些东西,默认情况下在当前目录中运行(这样,没有管理特权的用户可以简单地解压缩并运行程序)。 This way, people packaging for particular OS/distribution will set sensible values for system-wide installation, and users will be able to use it locally without administrative rights for the machine. 这样,打包用于特定OS /发行版的人员将为系统范围的安装设置合理的值,并且用户将能够在本地使用它,而无需计算机的管理权限。

您的意思是virtualenv吗?

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

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