Hi,
I want to tar a directory and all it's subs and files using
ant.
my directory structure looks like this:
A---
bin
etc
sconf
var
logs
lib
tmp
bin, lib and tmp are empty directories.
while taring everything I want to set directory modes and file modes too.
The problem is when I do that the empty directories are not included in the tar and the unix permission modes are not set.
This is my code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="test" basedir="." default="Main">
<description>
Build a tar file which includes all the directories and files under "test"
</description>
<property name="tar_dir_loc" location="tar"/>
<property name="tar_file_name" value="ff.tar" />
<target name="Main" depends="usage">
</target>
<target name="usage" depends="-Init">
<echo message="Usage message"/>
</target>
<target name="-Init" depends="-Prep">
<echo message="-Init target starts ..."/>
<tstamp/>
<echo message="Build time is ${TODAY} ${TSTAMP}" />
<echo message="-Init completed."/>
</target>
<target name="-Prep">
<!-- Delete output directory and all its content -->
<delete dir="${tar_dir_loc}"/>
<echo message="${tar_dir_loc} deleted."/>
<!-- Create output directory -->
<mkdir dir="${tar_dir_loc}"/>
<echo message="${tar_dir_loc} created."/>
<echo message="-Prep completed."/>
</target>
<target name="-FixLineFeed">
<!-- create unix line end version of input files -->
<echo message="-FixLineFeed begin"/>
<delete dir="${FixOutDir}"/>
<mkdir dir="${FixOutDir}"/>
<mkdir dir="../dst/tar/"/>
<copy todir="${FixOutDir}">
<fileset dir="${FixSource}"/>
</copy>
<fixcrlf srcDir="${FixOutDir}" eol="lf"/>
<echo message="-FixLineFeed complete"/>
</target>
<target name="ff" depends="-Init">
<property name="FixOutDir" value="../dst/work/ff"/>
<antcall target="-FixLineFeed">
<param name="FixSource" value="."/>
</antcall>
<property name="tarfile" value="../dst/tar/${tar_file_name}"/>
<delete file="${tarfile}"/>
<tar destfile="${tarfile}">
<tarfileset dir="${FixOutDir}/var"
prefix="var" dirmode="770" mode="770">
</tarfileset>
<tarfileset dir="${FixOutDir}/tmp"
prefix="tmp" dirmode="750" mode="750">
</tarfileset>
<tarfileset dir="${FixOutDir}/bin"
prefix="bin" dirmode="750" mode="750">
</tarfileset>
<tarfileset dir="${FixOutDir}/etc"
prefix="etc" dirmode="750" mode="750">
</tarfileset>
<tarfileset dir="${FixOutDir}/lib"
prefix="lib" dirmode="750" mode="750">
</tarfileset>
</tar>
<echo message="A new ${tarfile} has been created."/>
<echo message="Tar completed."/>
</target>
</project>
Never mind the fixlinefeed all it does is change files line feed from windows to unix like.
Thanks in advance