I just found the <defaultUnixGroup> and <defaultUnixOwner> tags.

<defaultUnixGroup>${env(SUDO_USER)}</defaultUnixGroup>
<defaultUnixOwner>${env(SUDO_USER)}</defaultUnixOwner>

Is it possible to set these two project-level values only if ${installer_is_root_install} is true, maybe like this?

<setInstallerVariable>
    <name>project.defaultUnixGroup</name>
    <value>${env(SUDO_USER)}</value>
    <ruleList>
        <isTrue>
            <value>${installer_is_root_install}</value>
        </isTrue>
    </ruleList>
</setInstallerVariable>

asked 13 Jun '12, 12:50

tahoar's gravatar image

tahoar
201313236
accept rate: 42%


It is possible to set defaultUnixGroup and defaultUnixOwner this way.

However, please note that those values are used for unpacking files only when the installer was built on Windows. If the installer is built on Unix machine, the installer gets file owner/group from the filesystem.

It is a good idea to also check if the environment variable is present - for example the installer may be run by root and actually be run without sudo (such as ssh as root). Also, it can use SUDO_GID environment variable if it is present, as in some cases the group name may not be the user name:

<actionGroup>
  <ruleList>
    <isTrue>
      <value>${installer_is_root_install}</value>
    </isTrue>
    <compareTextLength>
      <length>0</length>
      <logic>does_not_equal</logic>
      <text>${env(SUDO_USER)}</text>
    </compareTextLength>
  </ruleList>
  <actionList>
    <setInstallerVariable>
      <name>project.defaultUnixGroup</name>
      <value>${env(SUDO_USER)}</value>
    </setInstallerVariable>
    <setInstallerVariable>
      <name>project.defaultUnixGroup</name>
      <value>${env(SUDO_GID)}</value>
      <ruleList>
        <compareTextLength>
          <length>0</length>
          <logic>does_not_equal</logic>
          <text>${env(SUDO_GID)}</text>
        </compareTextLength>
      </ruleList>
    </setInstallerVariable>
    <setInstallerVariable>
      <name>project.defaultUnixOwner</name>
      <value>${env(SUDO_USER)}</value>
    </setInstallerVariable>
  </actionList>
</actionGroup>
link

answered 14 Jun '12, 03:40

wojciechka's gravatar image

wojciechka ♦♦
7.8k61122
accept rate: 26%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×7

Asked: 13 Jun '12, 12:50

Seen: 1,188 times

Last updated: 14 Jun '12, 03:40