void buildControl ( BinaryPackageControlFile packageControlFile , File [ ] controlFiles , List < String > conffiles , StringBuilder checksums , File output ) throws IOException , ParseException { final File dir = output . getParentFile ( ) ; if ( dir != null && ( ! dir . exists ( ) || ! dir . isDirectory ( ) ) ) { throw new IOException ( "Cannot write control file at '" + output . getAbsolutePath ( ) + "'" ) ; } final TarArchiveOutputStream outputStream = new TarArchiveOutputStream ( new GZIPOutputStream ( new FileOutputStream ( output ) ) ) ; outputStream . setLongFileMode ( TarArchiveOutputStream . LONGFILE_GNU ) ; boolean foundConffiles = false ; // create the final package control file out of the "control" file, copy all other files, ignore the directories for ( File file : controlFiles ) { if ( file . isDirectory ( ) ) { // warn about the misplaced directory, except for directories ignored by default (.svn, cvs, etc) if ( ! isDefaultExcludes ( file ) ) { console . warn ( "Found directory '" + file + "' in the control directory. Maybe you are pointing to wrong dir?" ) ; } continue ; } if ( "conffiles" . equals ( file . getName ( ) ) ) { foundConffiles = true ; } if ( CONFIGURATION_FILENAMES . contains ( file . getName ( ) ) || MAINTAINER_SCRIPTS . contains ( file . getName ( ) ) ) { FilteredFile configurationFile = new FilteredFile ( new FileInputStream ( file ) , resolver ) ; configurationFile . setOpenToken ( openReplaceToken ) ; configurationFile . setCloseToken ( closeReplaceToken ) ; addControlEntry ( file . getName ( ) , configurationFile . toString ( ) , outputStream ) ; } else if ( ! "control" . equals ( file . getName ( ) ) ) { // initialize the information stream to guess the type of the file InformationInputStream infoStream = new InformationInputStream ( new FileInputStream ( file ) ) ; Utils . copy ( infoStream , NullOutputStream . NULL_OUTPUT_STREAM ) ; infoStream . close ( ) ; // fix line endings for shell scripts InputStream in = new FileInputStream ( file ) ; if ( infoStream . isShell ( ) && ! infoStream . hasUnixLineEndings ( ) ) { byte [ ] buf = Utils . toUnixLineEndings ( in ) ; in = new ByteArrayInputStream ( buf ) ; } addControlEntry ( file . getName ( ) , IOUtils . toString ( in ) , outputStream ) ; in . close ( ) ; } } if ( foundConffiles ) { console . info ( "Found file 'conffiles' in the control directory. Skipping conffiles generation." ) ; } else if ( ( conffiles != null ) && ( conffiles . size ( ) > 0 ) ) { addControlEntry ( "conffiles" , createPackageConffilesFile ( conffiles ) , outputStream ) ; } else { console . info ( "Skipping 'conffiles' generation. No entries defined in maven/pom or ant/build.xml." ) ; } if ( packageControlFile == null ) { throw new FileNotFoundException ( "No 'control' file found in " + controlFiles . toString ( ) ) ; } addControlEntry ( "control" , packageControlFile . toString ( ) , outputStream ) ; addControlEntry ( "md5sums" , checksums . toString ( ) , outputStream ) ; outputStream . close ( ) ; }
Build control archive of the deb