Package org.redline_rpm.header

Examples of org.redline_rpm.header.Format


   */
  public static void main( String[] args) throws Exception {
      InputStream fios = new FileInputStream ( args[0] );
    ReadableChannelWrapper in = new ReadableChannelWrapper( Channels.newChannel( fios));
        Scanner scanner = new Scanner(System.out);
        Format format = scanner.run(in);
    scanner.log( format.toString());
      Header rpmHeader = format.getHeader();
      scanner.log("Payload compression: "+rpmHeader.getEntry(HeaderTag.PAYLOADCOMPRESSOR));
    InputStream uncompressed = Util.openPayloadStream(rpmHeader, fios);
    in = new ReadableChannelWrapper( Channels.newChannel( uncompressed));
    CpioHeader header;
    int total = 0;
View Full Code Here


   * @param in the channel wrapper to read input from
   * @return information describing the RPM file
   * @throws IOException if an error occurs reading the file
   */
  public Format run( ReadableChannelWrapper in) throws IOException {
    Format format = new Format();
        Key< Integer> headerStartKey = in.start();
   
    Key< Integer> lead = in.start();
    format.getLead().read( in);
    log( "Lead ended at '" + in.finish( lead) + "'.");

    Key< Integer> signature = in.start();
    int count = format.getSignature().read( in);
    int expected = ByteBuffer.wrap(( byte[]) format.getSignature().getEntry( SIGNATURES).getValues(), 8, 4).getInt() / -16;
    log( "Signature ended at '" + in.finish( signature) + "' and contained '" + count + "' headers (expected '" + expected + "').");

        Integer headerStartPos = in.finish(headerStartKey);
        format.getHeader().setStartPos(headerStartPos);
    Key< Integer> headerKey = in.start();
    count = format.getHeader().read( in);
    expected = ByteBuffer.wrap(( byte[]) format.getHeader().getEntry( HEADERIMMUTABLE).getValues(), 8, 4).getInt() / -16;
        Integer headerLength = in.finish(headerKey);
        format.getHeader().setEndPos(headerStartPos + headerLength);
        log( "Header ended at '" + headerLength + " and contained '" + count + "' headers (expected '" + expected + "').");

    return format;
  }
View Full Code Here

       Scanner.main ( new String[] { getTestResourcesDirectory ( ) + File.separator + "rpmtest-3-0.1.XZ.fc19.noarch.rpm" } );
   }

    @Test
    public void setHeaderStartAndEndPosition() throws Exception {
        Format format = new Scanner().run(channelWrapper(getTestResourcesDirectory ( ) + File.separator + "rpm-1-1.0-1.noarch.rpm"));
        assertEquals(280, format.getHeader().getStartPos());
        assertEquals(4760, format.getHeader().getEndPos());
    }
View Full Code Here

        assertEquals(4760, format.getHeader().getEndPos());
    }

    @Test
    public void fileModesHeaderIsCorrect() throws Exception {
        Format format = new Scanner().run(channelWrapper(getTestResourcesDirectory ( ) + File.separator + "rpm-1-1.0-1.noarch.rpm"));
        String rpmDescription = format.toString();
        Matcher matcher = Pattern.compile(".*filemodes\\[[^\\]]*\\]\\n[^0-9-]*([^\\n]*).*", Pattern.DOTALL).matcher(rpmDescription);
        matcher.matches();
        String [] fileModesFromString = matcher.group(1).split(", ");
        String [] expectedFileModes = {"33188", "41471", "16877", "33261", "33261", "33261", "33261", "41453", "33261", "16877", "33188", "33188", "16877", "33188", "41471"};
        assertArrayEquals(expectedFileModes, fileModesFromString);
View Full Code Here

        builder.setLicense( "GPL" );
        builder.setPlatform( NOARCH, LINUX );
        builder.setType( BINARY );
        builder.build( new File( getTargetDir()));

        Format format = new Scanner().run(channelWrapper("target" + File.separator + "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxa-1.0-1.noarch.rpm"));

    assertEquals("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", format.getLead().getName());
    }
View Full Code Here

    task.addRpmfileset(fs);

    task.execute();

    Format format = getFormat( filename );

    assertHeaderEquals("#!/bin/sh\n\necho Hello Pre Install!\n", format,
        Header.HeaderTag.PREINSCRIPT);
    assertHeaderEquals("#!/bin/sh\n\necho Hello Post Install!\n", format,
        Header.HeaderTag.POSTINSCRIPT);
View Full Code Here

    RedlineTask task = createBasicTask( dir);
    task.setPrivateKeyRingFile( new File( getFileResource( "/pgp/secring.gpg")));
    task.setPrivateKeyPassphrase( "redline");
    task.execute();

    Format format = getFormat( filename);
    assertNotNull( format.getSignature().getEntry( RSAHEADER));
    assertNotNull( format.getSignature().getEntry( LEGACY_PGP));
  }
View Full Code Here

TOP

Related Classes of org.redline_rpm.header.Format

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.