Create a configurable rpm from your grails artifacts.
Here's a sample rpm configuration that you can drop into BuildConfig.groovy:
rpm = [
appUser: "testApp",
appGroup: "sg_testApp",
metaData: [
vendor: "You",
group: "Applications/Internet",
description: "$appName RPM",
packager: "Rpm Script",
license: "Company. All rights reserved",
summary: "$appName",
url: "http://github.com/project?id=${argsMap.git_hash}",
distribution: "(none)",
buildHost: System.getProperty("HOSTNAME") ?: 'localhost',
type: "BINARY",
prefixes: "/apps/test"
],
preRemove: "rpm/scripts/preremove.sh",
postInstall: "rpm/scripts/postinstall.sh",
packageInfo: [name: appName, version: appVersion],
platform: [arch: "NOARCH", osName: "LINUX"],
dependencies: [
jdk: "1.7",
curl: "7.0.0"
],
structure: [
apps: [
test: [
permissions: 775,
user: rpm.appUser,
group: rpm.appGroup,
directive: "CONFIG",
bin: [
permissions: 775,
files: [
"target/$appName*.jar": [
permissions: 744,
dirPermissions: 644
links: [
"$appName.jar": [
to: "/apps/test/other.txt",
permissions: 0755
]
]
]
]
],
etc: [
permissions: 775,
user: rpm.appUser,
group: rpm.appGroup,
files: [
"rpm/apps/test/etc/.keystorepassword": [
permissions: 644,
directive: "CONFIG"
]
]
]
]
],
etc: [
logrotate: [
files: [
"rpm/etc/logrotate.d/test": [
permissions: 644,
directive: "CONFIG"
]
]
]
]
]
]
Tweak it as needed. Then run:
grails rpm
to produce your rpm.
The rpm plugin works by reading from your grails build configuration the property "rpm", which is an object defining the structure of the rpm you wish to build. The rpm property is broken into the following sections:
The metaData section is a map, allowing you to set any of the bean properties on redline's Builder class.
type is one of the enum values from redline's RpmType.
You can specify shell scripts inside your grails project to run on post-install or pre-uninstall of the rpm:
preRemove = "rpm/scripts/preremove.sh"
postInstall = "rpm/scripts/postinstall.sh"
packageInfo is a double which lets you specify the name and version of the installed package. See "Command-Line Arguments" below for how to set the release.
platform lets you specify the intended architecture and OS for your rpm. The values here should be one of enum values from redline's Architecture or Os
dependencies is map of the installed packages (and their versions) that your rpm depends on.
structure is the actual layout of the content of the rpm. It specifies the files (and associated metadata) that the rpm will install onto the box as a tree structure. At each node (i.e. directory) in the tree, you can specify the permissions, user and group and RPM directive for that node. If you don't specify values for each node then it will assume the defaults:
- permissions: 775
- user: "root"
- group: "root"
- RPM directive: none
Each node may also then specify a set of files to install at that directory, via the "files" map. Each file node can specify, as with a directory, the permissions, user, group and directive. The name of the file may also be wildcarded, according to commons-io WildcardFileFilter to match multiple files or to match a file with a variable name (e.g. jar file whose name includes a version or date). It can also specify a map of "links", which will be symlinks created to this file.
Each node may also specify a set of symlinks to install at that directory, via the "links" map. Each entry should specify the real file the link points to, as well as optionally the permissions for that symlink
By default, the rpm will be named with the following form: appName-appVersion-date.noarch.rpm. You can optionally add a release to the end of the name, which can be useful for CI servers to add their build number to:
grails rpm --release=123
would produce an rpm something like "testapp-1.0-2013.01.01_123.noarch.rpm".
Furthermore, you can completely override the name of the rpm like this:
grails rpm --name=hello
would produce the rpm: hello.noarch.rpm