【问题标题】:How to set default params for xz archiver?如何为 xz 归档器设置默认参数?
【发布时间】:2020-04-08 19:27:47
【问题描述】:

默认情况下xz 压缩器使用单线程(例如,从 AUR 压缩新创建的包)。有一个--threads 选项可以使用更多线程。

在哪里可以设置 xz 的全局设置,以便将线程选项设置为我的值?在 man 中找不到任何信息。

【问题讨论】:

    标签: archlinux manjaro xz


    【解决方案1】:

    手册页确实谈到了为此目的使用环境变量:

    ENVIRONMENT
       xz parses space-separated lists of options from the environment variables XZ_DEFAULTS
       and XZ_OPT, in this order, before parsing the options from the  command  line.   Note
       that  only  options  are  parsed  from the environment variables; all non-options are
       silently ignored.  Parsing is done with getopt_long(3) which is  used  also  for  the
       command line arguments.
    
       XZ_DEFAULTS
              User-specific  or  system-wide  default  options.   Typically this is set in a
              shell initialization script to enable xz's memory usage  limiter  by  default.
              Excluding shell initialization scripts and similar special cases, scripts must
              never set or unset XZ_DEFAULTS.
    
       XZ_OPT This is for passing options to xz when it is not possible to set  the  options
              directly  on  the  xz command line.  This is the case e.g. when xz is run by a
              script or tool, e.g. GNU tar(1):
    
                     XZ_OPT=-2v tar caf foo.tar.xz foo
    
              Scripts may use XZ_OPT e.g. to set  script-specific  default  compression  op‐
              tions.   It  is still recommended to allow users to override XZ_OPT if that is
              reasonable, e.g. in sh(1) scripts one may use something like this:
    
                     XZ_OPT=${XZ_OPT-"-7e"}
                     export XZ_OPT
    

    看起来XZ_DEFAULTS 会做你想做的事。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-01-16
      • 2013-10-07
      • 1970-01-01
      • 2013-01-01
      • 2019-05-23
      • 1970-01-01
      相关资源
      最近更新 更多