You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Kevin Jackson <fo...@gmail.com> on 2007/05/31 12:19:23 UTC
Strange property problem
Hi all,
I have a weird error caused by a property being wrong 50% of the time
and correct 50% of the time.
here's the relevant code:
build.properties
james.version=server-binary-next-major
james.home=/var/james
james.home.direct=/var/james-${james.version}
<macrodef name="ssh-cmd">
<attribute name="command"/>
<attribute name="fail" default="true"/>
<sequential>
<sshexec host="${deploy.machine.address}" port="${deploy.machine.ssh.port}"
username="root" password="${deploy.machine.root.user.password}"
command="@{command}"
failonerror="@{fail}" trust="true"/>
</sequential>
</macrodef>
<echo>james-${james.version}.tar.gz</echo>
<ssh-cmd command="cd /var;tar xzvpf
/root/james-${james.version}.tar.gz;chown -R james:james
${james.home.direct}"/>
Ok
the <echo> produces the following:
james-server-binary-next-major.tar.gz
in the ssh-cmd, the output of the tar xzvpf /root/james-${james.version}.tar.gz
tar xzvf /root/james-server-next-major.tar.gz
finally the chown -r james:james ${james.home.direct}
fails with /var/james/james-server-binary-next-major doesn't exist
so the echo thinks that ${james.version} = server-binary-next-major
the ssh-cmd macro thinks :
1 - ${james.version} = server-next-major
2 - then ${james.version} = server-binary-next-major
With ant properties are immutable, so what the hell is happening?
Kev
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Strange property problem
Posted by Kevin Jackson <fo...@gmail.com>.
Hi all,
This problem was actually to do with the names of the tar file and
what the folders were in named inside the tar file - it was not to do
with the macro property expansion (which I also thought was the
problem)
basically the tar was called james-server-binary-next-major (james
distro built from the current james trunk), but inside this the
folders were called james-server-next-major.
So when I scp'd the file to the server with james.version =
james-server-binary-next-major, the scp command worked, and the tar
command worked, but the output from the tar command produced
james-server-next-major - this looked like incorrect output, and later
on in the build there was a failure because the a symbolic link wasn't
pointing to the expanded tar it was pointing to a non-existent
location.
Simple fix was to rename the tar I was uploading to
james-server-next-major (same name as the folder inside the tar) and
change the property to james-server-next-major and everything worked
fine. Took 2 days to sort out though.
Kev
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Strange property problem
Posted by Steve Loughran <st...@apache.org>.
Peter Reilly wrote:
> On 6/4/07, Steve Loughran <st...@apache.org> wrote:
ith ant properties are immutable, so what the hell is happening?
>>
>> you are getting burned by the fact that the $ in the macro param is
>> being double expanded. Once in passing to macrodef, and then when being
>> passed to sshexec
> This is yet another wild occurance of this bug.
>
> We may need to do something about it..
>
I think
1. some special type that doesnt have properties expanded before ant
gets to it (or a specially named setter)
2. macros are switched so that by default property expansion is delayed
(unless you ask for it by setting an option)
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Strange property problem
Posted by Peter Reilly <pe...@gmail.com>.
On 6/4/07, Steve Loughran <st...@apache.org> wrote:
> Kevin Jackson wrote:
> > Hi all,
> >
> > I have a weird error caused by a property being wrong 50% of the time
> > and correct 50% of the time.
> >
> > here's the relevant code:
> >
> > build.properties
> > james.version=server-binary-next-major
> > james.home=/var/james
> > james.home.direct=/var/james-${james.version}
> >
> > <macrodef name="ssh-cmd">
> > <attribute name="command"/>
> > <attribute name="fail" default="true"/>
> > <sequential>
> > <sshexec host="${deploy.machine.address}"
> > port="${deploy.machine.ssh.port}"
> > username="root"
> > password="${deploy.machine.root.user.password}"
> > command="@{command}"
> > failonerror="@{fail}" trust="true"/>
> > </sequential>
> > </macrodef>
> >
> > <echo>james-${james.version}.tar.gz</echo>
> > <ssh-cmd command="cd /var;tar xzvpf
> > /root/james-${james.version}.tar.gz;chown -R james:james
> > ${james.home.direct}"/>
> >
> > Ok
> > the <echo> produces the following:
> >
> > james-server-binary-next-major.tar.gz
> >
> > in the ssh-cmd, the output of the tar xzvpf
> > /root/james-${james.version}.tar.gz
> >
> > tar xzvf /root/james-server-next-major.tar.gz
> >
> > finally the chown -r james:james ${james.home.direct}
> > fails with /var/james/james-server-binary-next-major doesn't exist
> >
> > so the echo thinks that ${james.version} = server-binary-next-major
> > the ssh-cmd macro thinks :
> > 1 - ${james.version} = server-next-major
> > 2 - then ${james.version} = server-binary-next-major
> >
> > With ant properties are immutable, so what the hell is happening?
>
> you are getting burned by the fact that the $ in the macro param is
> being double expanded. Once in passing to macrodef, and then when being
> passed to sshexec
This is yet another wild occurance of this bug.
We may need to do something about it..
Peter
>
> the first tune the command runs, the ${james.version} is not set, but
> the second time it is.
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org
Re: Strange property problem
Posted by Steve Loughran <st...@apache.org>.
Kevin Jackson wrote:
> Hi all,
>
> I have a weird error caused by a property being wrong 50% of the time
> and correct 50% of the time.
>
> here's the relevant code:
>
> build.properties
> james.version=server-binary-next-major
> james.home=/var/james
> james.home.direct=/var/james-${james.version}
>
> <macrodef name="ssh-cmd">
> <attribute name="command"/>
> <attribute name="fail" default="true"/>
> <sequential>
> <sshexec host="${deploy.machine.address}"
> port="${deploy.machine.ssh.port}"
> username="root"
> password="${deploy.machine.root.user.password}"
> command="@{command}"
> failonerror="@{fail}" trust="true"/>
> </sequential>
> </macrodef>
>
> <echo>james-${james.version}.tar.gz</echo>
> <ssh-cmd command="cd /var;tar xzvpf
> /root/james-${james.version}.tar.gz;chown -R james:james
> ${james.home.direct}"/>
>
> Ok
> the <echo> produces the following:
>
> james-server-binary-next-major.tar.gz
>
> in the ssh-cmd, the output of the tar xzvpf
> /root/james-${james.version}.tar.gz
>
> tar xzvf /root/james-server-next-major.tar.gz
>
> finally the chown -r james:james ${james.home.direct}
> fails with /var/james/james-server-binary-next-major doesn't exist
>
> so the echo thinks that ${james.version} = server-binary-next-major
> the ssh-cmd macro thinks :
> 1 - ${james.version} = server-next-major
> 2 - then ${james.version} = server-binary-next-major
>
> With ant properties are immutable, so what the hell is happening?
you are getting burned by the fact that the $ in the macro param is
being double expanded. Once in passing to macrodef, and then when being
passed to sshexec
the first tune the command runs, the ${james.version} is not set, but
the second time it is.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org