Package org.vafer.jdeb.debian

Examples of org.vafer.jdeb.debian.ChangesFile


                    }
                };
            }

            ChangesFileBuilder builder = new ChangesFileBuilder();
            ChangesFile changesFile = builder.createChanges(packageControlFile, deb, changesProvider);

            if (keyring != null && key != null && passphrase != null) {
                console.info("Signing the changes file with the key " + key);
                PGPSigner signer = new PGPSigner(new FileInputStream(keyring), key, passphrase);
                signer.clearSign(changesFile.toString(), out);
            } else {
                out.write(changesFile.toString().getBytes("UTF-8"));
            }
            out.flush();

        } catch (Exception e) {
            throw new PackagingException("Failed to create the Debian changes file " + changesOut, e);
View Full Code Here


*/
class ChangesFileBuilder {

    public ChangesFile createChanges(BinaryPackageControlFile packageControlFile, File binaryPackage, ChangesProvider changesProvider) throws IOException, PackagingException {

        ChangesFile changesFile = new ChangesFile();
        changesFile.setChanges(changesProvider.getChangesSets());
        changesFile.initialize(packageControlFile);

        changesFile.set("Date", ChangesFile.formatDate(new Date()));
       
        try {
            // compute the checksums of the binary package
            InformationOutputStream md5output = new InformationOutputStream(new NullOutputStream(), MessageDigest.getInstance("MD5"));
            InformationOutputStream sha1output = new InformationOutputStream(md5output, MessageDigest.getInstance("SHA1"));
            InformationOutputStream sha256output = new InformationOutputStream(sha1output, MessageDigest.getInstance("SHA-256"));
           
            FileUtils.copyFile(binaryPackage, sha256output);
           
            // Checksums-Sha1:
            //  56ef4c6249dc3567fd2967f809c42d1f9b61adf7 45964 jdeb.deb
            changesFile.set("Checksums-Sha1", sha1output.getHexDigest() + " " + binaryPackage.length() + " " + binaryPackage.getName());
           
            // Checksums-Sha256:
            //  38c6fa274eb9299a69b739bcbdbd05c7ffd1d8d6472f4245ed732a25c0e5d616 45964 jdeb.deb
            changesFile.set("Checksums-Sha256", sha256output.getHexDigest() + " " + binaryPackage.length() + " " + binaryPackage.getName());
           
            StringBuilder files = new StringBuilder(md5output.getHexDigest());
            files.append(' ').append(binaryPackage.length());
            files.append(' ').append(packageControlFile.get("Section"));
            files.append(' ').append(packageControlFile.get("Priority"));
            files.append(' ').append(binaryPackage.getName());
            changesFile.set("Files", files.toString());
           
        } catch (NoSuchAlgorithmException e) {
            throw new PackagingException("Unable to compute the checksums for " + binaryPackage, e);
        }
       
        if (!changesFile.isValid()) {
            throw new PackagingException("Changes file fields are invalid " + changesFile.invalidFields() +
                ". The following fields are mandatory: " + changesFile.getMandatoryFields() +
                ". Please check your pom.xml/build.xml and your control file.");
        }
       
        return changesFile;
    }
View Full Code Here

TOP

Related Classes of org.vafer.jdeb.debian.ChangesFile

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.