Skip to content

Commit

Permalink
Merge pull request #1 from ydbondt/conffiles
Browse files Browse the repository at this point in the history
Added feature to add conffiles
  • Loading branch information
ydbondt authored Oct 12, 2017
2 parents a0c7d57 + 479abbe commit f76b16c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function createDeb (data, options, cb) {
var deb = new ar.Archive();
streamToBuffer(data, compress(function (err, dataBuffer) {

generateControl(options, compress(function (err, controlBuffer) {
generateDebianFiles(options, compress(function (err, controlBuffer) {

cb(deb
.append(generateDebianBinary(), {
Expand All @@ -141,10 +141,14 @@ function createDeb (data, options, cb) {
}));
}

function generateControl(options, cb) {
function generateDebianFiles(options, cb) {

var archive = tar.pack();

if (options.conffiles) {
archive.entry({name: 'conffiles'}, new Buffer(createConffilesFile(options)));
}

archive.entry({name: 'control'}, new Buffer(createControlFile(options)));

if (options.scripts) {
Expand Down Expand Up @@ -180,6 +184,11 @@ function compress (cb) {
}
}

function createConffilesFile(options) {
var controlFileTemplate = ['<% _.each(conffiles, function(file) {%><%=file%>\n<%})%>'];
return lodash.template(controlFileTemplate.join('\n') + '\n')(options);
}

function createControlFile (options) {

var controlFileTemplate = [
Expand Down

0 comments on commit f76b16c

Please sign in to comment.