@@ -2,10 +2,13 @@ package com.typesafe.sbt
2
2
package packager
3
3
package debian
4
4
5
+
6
+ import com .typesafe .sbt .packager .archetypes .TemplateWriter
7
+ import com .typesafe .sbt .packager .universal .Archives
5
8
import sbt ._
6
9
import sbt .Keys .{ target , normalizedName , version , streams , mappings , packageBin }
7
10
import linux .{ LinuxSymlink , LinuxPackageMapping , LinuxFileMetaData }
8
- import linux .LinuxPlugin .autoImport .{ linuxPackageMappings , linuxPackageSymlinks , packageArchitecture }
11
+ import linux .LinuxPlugin .autoImport .{ linuxPackageMappings , linuxPackageSymlinks , packageArchitecture , linuxScriptReplacements }
9
12
import scala .collection .JavaConversions ._
10
13
import org .vafer .jdeb .{ DebMaker , DataProducer }
11
14
import org .vafer .jdeb .mapping ._
@@ -67,9 +70,14 @@ object JDebPackaging extends AutoPlugin with DebianPluginLike {
67
70
val controlDir = targetDir / Names .Debian
68
71
val control = debianControlFile.value
69
72
val conffile = debianConffilesFile.value
73
+ val replacements = debianMakeChownReplacements.value +: linuxScriptReplacements.value
70
74
71
75
val controlScripts = debianMaintainerScripts.value
72
- controlScripts foreach { case (file, script) => IO .copyFile(file, controlDir / script) }
76
+ for ((file, name) <- controlScripts) {
77
+ val targetFile = controlDir / name
78
+ copyFiles(file, targetFile, LinuxFileMetaData ())
79
+ filterFiles(targetFile, replacements, LinuxFileMetaData ())
80
+ }
73
81
74
82
log.info(" Building debian package with java based implementation 'jdeb'" )
75
83
val console = new JDebConsole (log)
@@ -89,6 +97,35 @@ object JDebPackaging extends AutoPlugin with DebianPluginLike {
89
97
debianFile
90
98
})
91
99
100
+
101
+ /**
102
+ * The same as [[DebianPluginLike.copyAndFixPerms ]] except chmod invocation (for windows compatibility).
103
+ * Permissions will be handled by jDeb packager itself.
104
+ */
105
+ private [this ] def copyFiles (from : File , to : File , perms : LinuxFileMetaData , zipped : Boolean = false ): Unit = {
106
+ if (zipped) {
107
+ IO .withTemporaryDirectory { dir =>
108
+ val tmp = dir / from.getName
109
+ IO .copyFile(from, tmp)
110
+ val zipped = Archives .gzip(tmp)
111
+ IO .copyFile(zipped, to, true )
112
+ }
113
+ } else IO .copyFile(from, to, true )
114
+ }
115
+
116
+
117
+ /**
118
+ * The same as [[DebianPluginLike.filterAndFixPerms ]] except chmod invocation (for windows compatibility).
119
+ * Permissions will be handled by jDeb packager itself.
120
+ */
121
+ private [this ] final def filterFiles (script : File , replacements : Seq [(String , String )], perms : LinuxFileMetaData ): File = {
122
+ val filtered = TemplateWriter .generateScript(script.toURI.toURL, replacements)
123
+ IO .delete(script)
124
+ IO .write(script, filtered)
125
+ script
126
+ }
127
+
128
+
92
129
/**
93
130
* Creating file and directory producers. These "produce" the
94
131
* files for the debian packaging.
0 commit comments