Java Code Examples for org.apache.tools.ant.taskdefs.Tar#setDestFile()

The following examples show how to use org.apache.tools.ant.taskdefs.Tar#setDestFile() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestFile.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestFile tgzTo(TestFile tarFile) {
    Tar tar = new Tar();
    tar.setBasedir(this);
    tar.setDestFile(tarFile);
    tar.setCompression((Tar.TarCompressionMethod) EnumeratedAttribute.getInstance(Tar.TarCompressionMethod.class, "gzip"));
    execute(tar);
    return this;
}
 
Example 2
Source File: TestFile.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestFile tbzTo(TestFile tarFile) {
    Tar tar = new Tar();
    tar.setBasedir(this);
    tar.setDestFile(tarFile);
    tar.setCompression((Tar.TarCompressionMethod) EnumeratedAttribute.getInstance(Tar.TarCompressionMethod.class, "bzip2"));
    execute(tar);
    return this;
}
 
Example 3
Source File: TestFile.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestFile tgzTo(TestFile tarFile) {
    Tar tar = new Tar();
    tar.setBasedir(this);
    tar.setDestFile(tarFile);
    tar.setCompression((Tar.TarCompressionMethod) EnumeratedAttribute.getInstance(Tar.TarCompressionMethod.class, "gzip"));
    execute(tar);
    return this;
}
 
Example 4
Source File: TestFile.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestFile tbzTo(TestFile tarFile) {
    Tar tar = new Tar();
    tar.setBasedir(this);
    tar.setDestFile(tarFile);
    tar.setCompression((Tar.TarCompressionMethod) EnumeratedAttribute.getInstance(Tar.TarCompressionMethod.class, "bzip2"));
    execute(tar);
    return this;
}
 
Example 5
Source File: TestFile.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestFile tgzTo(TestFile tarFile) {
    Tar tar = new Tar();
    tar.setBasedir(this);
    tar.setDestFile(tarFile);
    tar.setCompression((Tar.TarCompressionMethod) EnumeratedAttribute.getInstance(Tar.TarCompressionMethod.class, "gzip"));
    execute(tar);
    return this;
}
 
Example 6
Source File: TestFile.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestFile tbzTo(TestFile tarFile) {
    Tar tar = new Tar();
    tar.setBasedir(this);
    tar.setDestFile(tarFile);
    tar.setCompression((Tar.TarCompressionMethod) EnumeratedAttribute.getInstance(Tar.TarCompressionMethod.class, "bzip2"));
    execute(tar);
    return this;
}
 
Example 7
Source File: TestFile.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestFile tgzTo(TestFile tarFile) {
    Tar tar = new Tar();
    tar.setBasedir(this);
    tar.setDestFile(tarFile);
    tar.setCompression((Tar.TarCompressionMethod) EnumeratedAttribute.getInstance(Tar.TarCompressionMethod.class, "gzip"));
    execute(tar);
    return this;
}
 
Example 8
Source File: TestFile.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public TestFile tbzTo(TestFile tarFile) {
    Tar tar = new Tar();
    tar.setBasedir(this);
    tar.setDestFile(tarFile);
    tar.setCompression((Tar.TarCompressionMethod) EnumeratedAttribute.getInstance(Tar.TarCompressionMethod.class, "bzip2"));
    execute(tar);
    return this;
}
 
Example 9
Source File: Deb.java    From ganttproject with GNU General Public License v3.0 4 votes vote down vote up
private File createMasterControlFile () throws IOException
{
    File controlFile = new File (_tempFolder, "control");

    writeControlFile (controlFile, _installedSize);

    File md5sumsFile = new File (_tempFolder, "md5sums");
    File conffilesFile = new File (_tempFolder, "conffiles");

    File masterControlFile = new File (_tempFolder, "control.tar.gz");

    Tar controlTar = new Tar ();
    controlTar.setProject (getProject ());
    controlTar.setTaskName (getTaskName ());
    controlTar.setDestFile (masterControlFile);
    controlTar.setCompression (GZIP_COMPRESSION_METHOD);

    addFileToTar (controlTar, controlFile, "control", "644");
    addFileToTar (controlTar, md5sumsFile, "md5sums", "644");

    if (conffilesFile.length () > 0)
        addFileToTar (controlTar, conffilesFile, "conffiles", "644");

    if (_preinst != null)
        addFileToTar (controlTar, _preinst, "preinst", "755");

    if (_postinst != null)
        addFileToTar (controlTar, _postinst, "postinst", "755");

    if (_prerm != null)
        addFileToTar (controlTar, _prerm, "prerm", "755");

    if (_postrm != null)
        addFileToTar (controlTar, _postrm, "postrm", "755");

    if (_config != null)
        addFileToTar (controlTar, _config, "config", "755");

    if (_templates != null)
        addFileToTar (controlTar, _templates, "templates", "644");

    if (_triggers != null)
        addFileToTar (controlTar, _triggers, "triggers", "644");

    controlTar.perform ();

    deleteFileCheck(controlFile);

    return masterControlFile;
}
 
Example 10
Source File: Deb.java    From ganttproject with GNU General Public License v3.0 4 votes vote down vote up
private File createDataFile () throws IOException
{
    File dataFile = new File (_tempFolder, "data.tar.gz");

    Tar dataTar = new Tar ();
    dataTar.setProject (getProject ());
    dataTar.setTaskName (getTaskName ());
    dataTar.setDestFile (dataFile);
    dataTar.setCompression (GZIP_COMPRESSION_METHOD);
    dataTar.setLongfile(GNU_LONGFILE_MODE);

    if ( _data.size () > 0 )
    {
        // add folders
        for (Iterator dataFoldersIter = _dataFolders.iterator (); dataFoldersIter.hasNext ();)
        {
            String targetFolder = (String) dataFoldersIter.next ();

            TarFileSet targetFolderSet = dataTar.createTarFileSet ();

            targetFolderSet.setFile (_tempFolder);
            targetFolderSet.setFullpath (targetFolder);
            targetFolderSet.setUserName ("root");
            targetFolderSet.setGroup ("root");
        }

        // add actual data
     for (int i = 0; i < _data.size (); i++)
     {
         TarFileSet data = (TarFileSet) _data.get (i);
	
         if (data.getUserName() == null || data.getUserName().trim().length() == 0)
             data.setUserName ("root");
	
         if (data.getGroup() == null || data.getGroup().trim().length() == 0)
             data.setGroup ("root");
	
         dataTar.add (data);
     }
	
     dataTar.execute ();
    }
    else
    {
    	// create an empty data.tar.gz file which is still a valid tar
    	TarOutputStream tarStream = new TarOutputStream(
    		new GZipOutputStream(
    			new BufferedOutputStream(new FileOutputStream(dataFile)),
    			Deflater.BEST_COMPRESSION
     	)
    	);
    	tarStream.close();
    }

    return dataFile;
}