Package org.redline_rpm

Examples of org.redline_rpm.Builder


  public void execute() {
    if ( name == null) throw new BuildException( "Attribute 'name' is required.");
    if ( version == null) throw new BuildException( "Attribute 'version' is required.");
    if ( group == null) throw new BuildException( "Attribute 'group' is required.");

    Builder builder = new Builder();
    builder.setPackage( name, version, release);
    builder.setType( type);
    builder.setPlatform( architecture, os);
    builder.setGroup( group);
    builder.setBuildHost( host);
    builder.setSummary( summary);
    builder.setDescription( description);
    builder.setLicense( license);
    builder.setPackager( packager);
    builder.setDistribution( distribution);
    builder.setVendor( vendor);
    builder.setUrl( url);
    builder.setProvides( provides == null ? name : provides);
    builder.setPrefixes( prefixes == null ? null : prefixes.split(","));
        builder.setPrivateKeyRingFile( privateKeyRingFile);
        builder.setPrivateKeyId( privateKeyId);
        builder.setPrivateKeyPassphrase( privateKeyPassphrase);
    if (sourcePackage != null) {
      builder.addHeaderEntry(Header.HeaderTag.SOURCERPM, sourcePackage);
    }
   
    // add built-ins
    for ( BuiltIn builtIn : builtIns) {
      String text = builtIn.getText();
      if (text != null && !text.trim().equals("")) {
        builder.addBuiltinDirectory( builtIn.getText());
      }
    }

    try {
      if ( null != preTransScript) {
        builder.setPreTransScript( preTransScript);
        builder.setPreTransProgram( "");
      }
      if ( null != preInstallScript) {
        builder.setPreInstallScript( preInstallScript);
        builder.setPreInstallProgram( "");
      }
      if ( null != postInstallScript) {
        builder.setPostInstallScript( postInstallScript);
        builder.setPostInstallProgram( "");
      }
      if ( null != preUninstallScript) {
        builder.setPreUninstallScript( preUninstallScript);
        builder.setPreUninstallProgram( "");
      }
      if ( null != postUninstallScript) {
        builder.setPostUninstallScript( postUninstallScript);
        builder.setPostUninstallProgram( "");
      }
      if ( null != postTransScript) {
        builder.setPostTransScript( postTransScript);
        builder.setPostTransProgram( "");
      }

      for ( ArchiveFileSet fileset : filesets) {
        File archive = fileset.getSrc( getProject());
        String prefix = normalizePath( fileset.getPrefix( getProject()));
        if ( !prefix.endsWith( "/")) prefix += "/";
        DirectoryScanner scanner = fileset.getDirectoryScanner( getProject());

                int filemode = fileset.getFileMode( getProject()) & 07777;
        int dirmode = fileset.getDirMode( getProject()) & 07777;
        String username = null;
        String group = null;
                Directive directive = null;

        if (fileset instanceof TarFileSet) {
          TarFileSet tarFileSet = (TarFileSet)fileset;
          username = tarFileSet.getUserName();
          group = tarFileSet.getGroup();
                    if (fileset instanceof RpmFileSet) {
                        RpmFileSet rpmFileSet = (RpmFileSet)fileset;
                        directive = rpmFileSet.getDirective();
                    }
        }

        // include any directories, including empty ones, duplicates will be ignored when we scan included files
        for (String entry : scanner.getIncludedDirectories()) {
          String dir = normalizePath(prefix + entry);
          if (!"".equals(entry)) builder.addDirectory(dir, dirmode, directive, username, group, true);
        }

        for ( String entry : scanner.getIncludedFiles()) {
          if ( archive != null) {
            URL url = new URL( "jar:" + archive.toURL() + "!/" + entry);
            builder.addURL( prefix + entry, url, filemode, dirmode, directive, username, group);
          } else {
            File file = new File( scanner.getBasedir(), entry);
            builder.addFile(prefix + entry, file, filemode, dirmode, directive, username, group);
          }
        }
      }
      for ( Ghost ghost : ghosts) {
        builder.addFile( ghost.getPath(), null, ghost.getFilemode(), ghost.getDirmode(), Directive.GHOST, ghost.getUsername(), ghost.getGroup());
      }
      for ( Link link : links) builder.addLink( link.getPath(), link.getTarget(), link.getPermissions());
      for ( Depends dependency : depends) builder.addDependency( dependency.getName(), dependency.getComparison(), dependency.getVersion());

      for ( TriggerPreIn triggerPreIn : triggersPreIn) builder.addTrigger( triggerPreIn.getScript(), "", triggerPreIn.getDepends(), triggerPreIn.getFlag());
      for ( TriggerIn triggerIn : triggersIn) builder.addTrigger( triggerIn.getScript(), "", triggerIn.getDepends(), triggerIn.getFlag());
      for ( TriggerUn triggerUn : triggersUn) builder.addTrigger( triggerUn.getScript(), "", triggerUn.getDepends(), triggerUn.getFlag());
      for ( TriggerPostUn triggerPostUn : triggersPostUn) builder.addTrigger( triggerPostUn.getScript(), "", triggerPostUn.getDepends(), triggerPostUn.getFlag());

      log( "Created rpm: " + builder.build( destination));
    } catch ( IOException e) {
      throw new BuildException( "Error packaging distribution files.", e);
    } catch ( NoSuchAlgorithmException e) {
      throw new BuildException( "This system does not support MD5 digests.", e);
    }
View Full Code Here

TOP

Related Classes of org.redline_rpm.Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.