mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Gaetan Boismal
10.47.2015 44f945e40b2d632fe289ba3041ba09187ccaf95f
OPENDJ-1772: Add profile to build deb package
6 files modified
221 ■■■■ changed files
opendj-server-legacy/pom.xml 157 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/resource/debian/changelog 6 ●●●●● patch | view | raw | blame | history
opendj-server-legacy/resource/debian/control/control 10 ●●●● patch | view | raw | blame | history
opendj-server-legacy/resource/debian/control/postinst 30 ●●●● patch | view | raw | blame | history
opendj-server-legacy/resource/debian/control/preinst 10 ●●●● patch | view | raw | blame | history
opendj-server-legacy/resource/debian/control/prerm 8 ●●●● patch | view | raw | blame | history
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>
opendj-server-legacy/resource/debian/changelog
@@ -1,3 +1,9 @@
 opendj (3.0.0) unstable; urgency=low
  * Package is now build using maven.
 -- ForgeRock <opendj@forgerock.org>  Tue, 10 Mar 2015 14:24:00 +0100
 opendj (2.7.0) unstable; urgency=low
  * Added changelog to /usr/share/doc/opendj/
opendj-server-legacy/resource/debian/control/control
@@ -1,12 +1,12 @@
Package: [[name]]
Version: [[version]]
Package: [[lowerCaseProductName]]
Version: [[parsedVersion.majorVersion]].[[parsedVersion.minorVersion]].[[parsedVersion.incrementalVersion]]
Section: misc
Priority: low
Architecture: all
Depends: default-jre | java6-runtime | java7-runtime
Homepage: [[homepage]]
Maintainer: [[maintainer]]
Description: [[description]]
Homepage: [[docHomepageUrl]]
Maintainer: [[deb.maintainer]]
Description: [[shortProductName]]
  OpenDJ is an LDAPv3 compliant directory service, developed for the Java
  platform, providing a high performance, highly available and secure store
  for the identities managed by enterprises. Its easy installation process,
opendj-server-legacy/resource/debian/control/postinst
@@ -2,48 +2,48 @@
set -e
# Post install script
# Install is launched with an empty second arg.
# If the package is already installed,
# If the package is already installed,
#  the second arg. is not empty.
# Registers the service
update-rc.d opendj defaults
# Symlinks to process ID
test -h "/var/run/opendj.pid" || ln -s /opt/opendj/logs/server.pid /var/run/opendj.pid
test -h "/var/run/opendj.pid" || ln -s ${deb.prefix}/logs/server.pid /var/run/opendj.pid
# In this case, we are in upgrade mode.
if [ "$1" = "configure" ] && [ ! -z "$2" ]
then
# For being secure, we check the buildinfo file too.
  if [ -f @prefix@/config/buildinfo ]
  if [ -f ${deb.prefix}/config/buildinfo ]
  then
    echo *Starting upgrade...
    @prefix@/./upgrade -n --acceptLicense
    ${deb.prefix}/./upgrade -n --acceptLicense
    echo
# Upgrade fails - Requires mandatory user interaction.
# Nevertheless, exits successfully of the pkg process.
    if [ "$?" -eq 2 ]
    then
      exit 0
      exit 0
    fi
# Restarts the service if needed.
# If server is stopped by upgrade process,
# If server is stopped by upgrade process,
#  the server will restart after upgrade.
# If server is stopped before the upgrade process
# If server is stopped before the upgrade process
#  (eg. upgrade the new package), the server will not restart.
# Uses the flag for determining server status at this point.
    if [ "$?" -eq 0 ]
    then
      if [ -f @prefix@/logs/status ]
      if [ -f ${deb.prefix}/logs/status ]
      then
        echo
        echo "*Restarting server..."
        @prefix@/./bin/start-ds
        rm -f @prefix@/logs/status
      fi
        echo "*Restarting server..."
        ${deb.prefix}/./bin/start-ds
        rm -f ${deb.prefix}/logs/status
      fi
    fi
  else
  else
# Invalid installation, could not find the buildinfo file.
    echo "Invalid installation, could not find the build info file."
    exit -1
    exit -1
  fi
fi
# End post install script
echo
echo
opendj-server-legacy/resource/debian/control/preinst
@@ -4,19 +4,19 @@
if [ "$1" = "upgrade" ]
then
# Only if the instance has been configured
  if [ -f @prefix@/config/buildinfo ] && [ "$(ls -A @prefix@/config/archived-configs)" ]
  if [ -f ${deb.prefix}/config/buildinfo ] && [ "$(ls -A ${deb.prefix}/config/archived-configs)" ]
  then
# If the server is running before upgrade, creates a flag.
    if [ -f @prefix@/logs/server.pid ]
    if [ -f ${deb.prefix}/logs/server.pid ]
    then
      touch @prefix@/logs/status
      touch ${deb.prefix}/logs/status
    fi
    echo *Stopping OpenDJ server...
    @prefix@/bin/./stop-ds
    ${deb.prefix}/bin/./stop-ds
  else
    echo "Instance is not configured. Upgrade aborded."
    exit -1
  fi
fi
echo
echo
# End of the pre installation script
opendj-server-legacy/resource/debian/control/prerm
@@ -1,17 +1,17 @@
#!/bin/bash
set -e
# Pre rm script
# Stops the service.
# Stops the service.
/etc/init.d/opendj stop >/dev/null 2>&1
# Deletes the service.
# Deletes the service.
update-rc.d -f opendj remove
# Unlink the symlink to the process ID if it exists.
test -h "/var/run/opendj.pid" && unlink /var/run/opendj.pid
# Stops the server
# Only if the instance has been configured
if [ "$1" = "remove" ] && ( [ -f @prefix@/config/buildinfo ] && [ "$(ls -A @prefix@/config/archived-configs)" ] )
if [ "$1" = "remove" ] && ( [ -f ${deb.prefix}/config/buildinfo ] && [ "$(ls -A ${deb.prefix}/config/archived-configs)" ] )
then
  echo *Stopping OpenDJ server...
  @prefix@/bin/./stop-ds
  ${deb.prefix}/bin/./stop-ds
fi
# End prem script