OSX installer change install directory
I got a pkg file in which I can change the installation directory when launched using the UI, but the manpage of installer only mention the target drive to install to.
Is there an environement variable to set when calling the installer ?
About the target options, from installer help :
The -target <device> parameter 开发者_如何学编程is any one of the following:
(1) One of the domains returned by -dominfo.
(2) Device node entry. Any entry of the form of /dev/disk*.
ex: /dev/disk2
(3) The disk identifier. Any entry of the form of disk*. ex: disk1s9
(4) Volume mount point. Any entry of the form of /Volumes/Mountpoint.
ex: /Volumes/Untitled
(5) Volume UUID. ex: 376C4046-083E-334F-AF08-62FAFBC4E352
So target is a "hard drive", not the "root path" where the pkg should be installed.
Most package managers include options to relocate (that is, change the installation path of) a package, on RPM-based Linux systems rpm
has the option -relocate
, on OS X, command line tool installer
has the option -target
.
However, as you have noticed, you can't specify an arbitrary path as argument to -target
, as you would do with rpm
's -relocate
The arguments to -target
are limited to (see man installer
):
A volume mount point (
/Volumes/HDD
), device node (/dev/disk0s5
) or volume UUID (376C4046-083E-334F-AF08-62FAFBC4E352
).Any of the values returned by
-dominfo
(likeLocalSystem
orCurrentUserHomeDirectory
), for example.
You write:
I got a pkg file in which I can change the installation directory when launched using the UI
If that's the case, that information can probably be queried with -dominfo
like this:
installer -verbose -dominfo -pkg <path to your package>
and can be used when installing from the command line:
installer -pkg <path to your package> -target <dominfo as listed above>
(I have queried several pkg
files and all return NoDomainsAvailable
, so can't share any experience.)
Keep in mind that, though, you can't arbitrarily relocate a pkg
file. The reason is that configuration files, binaries and libraries included in the package usually specify or depend on absolute paths.
The package builder must actively convert those into relative paths (using postinstallation scripts and techniques like @rpath
). So, generally speaking, you can only relocate a package that has been built with relocation in mind.
Your question is quite unclear: If you run the installer from the GUI and there is only one drive offered to install to, you can not change it in an easy way (means: you have to make changes to the installer package to install in a different location than offered by default).
Since you are using the "cli"-Tag (command line interface), I think you are trying to run the installer not on the GUI, instead you are running it from the terminal. There you have more options: With the -target option, you can set the installpath for your installer.
Information from the man-pages on the -target-Option:
The target volume is specified with the -target parameter ( -tgt is accepted as a synonym). It must already be mounted when the installer command is invoked.
Additional informations on how to run an installer from the Terminal (cli), you will find on my blog.
精彩评论