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

时间:2021-05-22 05:34:57

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. 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?

为简单起见,也许(1)可以成为(2)的一部分。有人能想出以平台无关的方式获得这些适当路径的方法吗?有没有这样做的图书馆,还是有人必须发明这个*?

2 个解决方案

#1


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). 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.

如果你想成为真正的跨平台,IMO最好的方法是将这些东西配置为打包器,默认在当前目录中运行(这样没有管理权限的用户可以简单地解压缩并运行程序)。这样,针对特定OS /分发的人员打包将为系统范围的安装设置合理的值,并且用户将能够在本地使用它而无需机器的管理权限。

#2


Do you mean something like virtualenv?

你的意思是virtualenv吗?

#1


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). 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.

如果你想成为真正的跨平台,IMO最好的方法是将这些东西配置为打包器,默认在当前目录中运行(这样没有管理权限的用户可以简单地解压缩并运行程序)。这样,针对特定OS /分发的人员打包将为系统范围的安装设置合理的值,并且用户将能够在本地使用它而无需机器的管理权限。

#2


Do you mean something like virtualenv?

你的意思是virtualenv吗?