From 44f945e40b2d632fe289ba3041ba09187ccaf95f Mon Sep 17 00:00:00 2001
From: Gaetan Boismal <gaetan.boismal@forgerock.com>
Date: Tue, 10 Mar 2015 14:47:08 +0000
Subject: [PATCH] OPENDJ-1772: Add profile to build deb package

---
 opendj-server-legacy/pom.xml |  157 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 157 insertions(+), 0 deletions(-)

diff --git a/opendj-server-legacy/pom.xml b/opendj-server-legacy/pom.xml
index 3671bd2..13ba6d9 100644
--- a/opendj-server-legacy/pom.xml
+++ b/opendj-server-legacy/pom.xml
@@ -1514,6 +1514,163 @@
       </build>
     </profile>
 
+    <!-- Build the debian package -->
+    <profile>
+      <id>package-deb</id>
+
+        <properties>
+          <deb.prefix>/opt/${lowerCaseProductName}</deb.prefix>
+          <deb.docprefix>/usr/share/doc/${lowerCaseProductName}</deb.docprefix>
+          <deb.release>1</deb.release>
+          <deb.maintainer>opendj@forgerock.org</deb.maintainer>
+        </properties>
+
+        <build>
+          <plugins>
+            <!-- Filter deb install and remove scripts -->
+            <plugin>
+              <artifactId>maven-resources-plugin</artifactId>
+              <executions>
+                <execution>
+                  <id>copy-deb-scripts</id>
+                  <phase>verify</phase>
+                  <goals>
+                    <goal>copy-resources</goal>
+                  </goals>
+                  <configuration>
+                    <outputDirectory>${project.build.directory}/deb/control</outputDirectory>
+                    <resources>
+                      <resource>
+                        <directory>${basedir}/resource/debian/control</directory>
+                        <filtering>true</filtering>
+                      </resource>
+                    </resources>
+                  </configuration>
+                </execution>
+              </executions>
+            </plugin>
+
+            <!-- Generates changelog.Debian.gz file -->
+            <plugin>
+              <groupId>org.apache.maven.plugins</groupId>
+              <artifactId>maven-antrun-plugin</artifactId>
+              <executions>
+                <execution>
+                  <id>generate-deb-gzipped-changelog</id>
+                  <phase>verify</phase>
+                  <goals>
+                    <goal>run</goal>
+                  </goals>
+                  <configuration>
+                    <target>
+                      <gzip src="resource/debian/changelog" destfile="${project.build.directory}/deb/changelog.Debian.gz" />
+                    </target>
+                  </configuration>
+                </execution>
+              </executions>
+            </plugin>
+
+            <!-- Generates the deb package -->
+            <plugin>
+              <groupId>org.vafer</groupId>
+              <artifactId>jdeb</artifactId>
+              <version>1.3</version>
+              <executions>
+                <execution>
+                  <phase>verify</phase>
+                  <goals>
+                    <goal>jdeb</goal>
+                  </goals>
+                  <configuration>
+                    <deb>${project.build.directory}/deb/${lowerCaseProductName}_${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}-${deb.release}.${maven.build.timestamp}_all.deb</deb>
+                    <controlDir>${project.build.directory}/deb/control</controlDir>
+                    <dataSet>
+                      <!-- OpenDJ service file -->
+                      <data>
+                        <src>${basedir}/resource/sysv/opendj</src>
+                        <type>file</type>
+                        <mapper>
+                          <type>perm</type>
+                          <prefix>/etc/init.d</prefix>
+                          <filemode>755</filemode>
+                        </mapper>
+                      </data>
+
+                      <!-- Debian copyright file in documentation -->
+                      <data>
+                        <src>${basedir}/resource/debian/copyright</src>
+                        <type>file</type>
+                        <mapper>
+                          <type>perm</type>
+                          <prefix>${deb.docprefix}</prefix>
+                        </mapper>
+                      </data>
+
+                      <!-- Debian changelog file in documentation -->
+                      <data>
+                        <src>${project.build.directory}/deb/changelog.Debian.gz</src>
+                        <type>file</type>
+                        <mapper>
+                          <type>perm</type>
+                          <prefix>${deb.docprefix}</prefix>
+                        </mapper>
+                      </data>
+
+                      <!-- OpenDJ archive documentation files -->
+                      <data>
+                        <src>${project.build.directory}/package/${lowerCaseProductName}</src>
+                        <type>directory</type>
+                        <includes>legal-notices/**, copyright, example-plugin.zip, changelog.Debian.gz</includes>
+                        <mapper>
+                          <type>perm</type>
+                          <prefix>${deb.docprefix}</prefix>
+                        </mapper>
+                      </data>
+
+                      <!-- OpenDJ archive files without specific permission -->
+                      <data>
+                        <src>${project.build.directory}/package/${lowerCaseProductName}</src>
+                        <type>directory</type>
+                        <excludes>**/bat/**, **/*.app/**, **/*.bat*, **/*.exe*, bin/*, template/**/*, lib/*.sh, setup, uninstall, upgrade, legal-notices/**, copyright, README, example-plugin.zip, opendj</excludes>
+                        <mapper>
+                          <type>perm</type>
+                          <prefix>${deb.prefix}</prefix>
+                        </mapper>
+                      </data>
+
+                      <!-- OpenDJ archive files with specific permission -->
+                      <data>
+                        <src>${project.build.directory}/package/${lowerCaseProductName}</src>
+                        <type>directory</type>
+                        <includes>lib/*.sh, bin/*, setup, uninstall, upgrade</includes>
+                        <excludes>bin/ControlPanel.app/**</excludes>
+                        <mapper>
+                          <type>perm</type>
+                          <prefix>${deb.prefix}</prefix>
+                          <filemode>755</filemode>
+                        </mapper>
+                      </data>
+
+                      <!-- OpenDJ archive template folder -->
+                      <data>
+                        <src>${project.build.directory}/package/${lowerCaseProductName}</src>
+                        <type>directory</type>
+                        <includes>template/**/*</includes>
+                        <mapper>
+                          <type>perm</type>
+                          <prefix>${deb.prefix}</prefix>
+                          <filemode>444</filemode>
+                        </mapper>
+                      </data>
+                    </dataSet>
+                  </configuration>
+                </execution>
+              </executions>
+            </plugin>
+          </plugins>
+        </build>
+    </profile>
+
     <!-- Build the RPM package -->
     <profile>
       <id>package-rpm</id>

--
Gitblit v1.10.0