-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #154 from sbt/wip/rpm-tests
Adding tests for #76
- Loading branch information
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import NativePackagerKeys._ | ||
|
||
packagerSettings | ||
|
||
mapGenericFilesToLinux | ||
|
||
name := "rpm-test" | ||
|
||
version := "0.1.0" | ||
|
||
maintainer := "Josh Suereth <[email protected]>" | ||
|
||
packageSummary := "Test rpm package" | ||
|
||
packageDescription := """A fun package description of our software, | ||
with multiple lines.""" | ||
|
||
rpmRelease := "1" | ||
|
||
rpmVendor := "typesafe" | ||
|
||
rpmUrl := Some("https://github.com/sbt/sbt-native-packager") | ||
|
||
rpmLicense := Some("BSD") | ||
|
||
rpmPre := Some("""echo "pre-install"""") | ||
|
||
rpmPost := Some("""echo "post-install"""") | ||
|
||
rpmPretrans := Some("""echo "pretrans"""") | ||
|
||
rpmPosttrans := Some("""echo "posttrans"""") | ||
|
||
rpmPreun := Some("""echo "pre-uninstall"""") | ||
|
||
rpmPostun := Some("""echo "post-uninstall"""") | ||
|
||
TaskKey[Unit]("check-spec-file") <<= (target, streams) map { (target, out) => | ||
val spec = IO.read(target / "rpm" / "SPECS" / "rpm-test.spec") | ||
assert(spec contains "%pre\necho \"pre-install\"", "Spec doesn't contain %pre scriptlet") | ||
assert(spec contains "%post\necho \"post-install\"", "Spec doesn't contain %post scriptlet") | ||
assert(spec contains "%pretrans\necho \"pretrans\"", "Spec doesn't contain %pretrans scriptlet") | ||
assert(spec contains "%posttrans\necho \"posttrans\"", "Spec doesn't contain %posttrans scriptlet") | ||
assert(spec contains "%preun\necho \"pre-uninstall\"", "Spec doesn't contain %preun scriptlet") | ||
assert(spec contains "%postun\necho \"post-uninstall\"", "Spec doesn't contain %postun scriptlet") | ||
out.log.success("Successfully tested rpm test file") | ||
() | ||
} | ||
|
||
TaskKey[Unit]("check-rpm-version") <<= (target, streams) map { (target, out) => | ||
val fullRpmVersion = Process("rpm", Seq("--version")) !! | ||
val firstDigit = fullRpmVersion indexWhere Character.isDigit | ||
val rpmVersion = fullRpmVersion substring firstDigit | ||
out.log.info("Found rpmVersion: " + rpmVersion) | ||
val (major, minor, patch) = rpmVersion.trim.split("\\.").map(_.toInt) match { | ||
case Array(major) => (major, 0, 0) | ||
case Array(major, minor) => (major, minor, 0) | ||
case Array(major, minor, patch, _*) => (major, minor, patch) | ||
} | ||
assert(major >= 4, "RPM version must be greater than than 4.x.x. Is " + fullRpmVersion) | ||
() | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Test configuration file! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Run the debian packaging. | ||
> rpm:package-bin | ||
$ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-1.noarch.rpm | ||
$ exists target/rpm/SPECS/rpm-test.spec | ||
|
||
# Check files for defaults | ||
> check-spec-file | ||
> check-rpm-version |