简体   繁体   中英

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

We see that programs like apt-get store information in several places:

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

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

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.

您的意思是virtualenv吗?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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