[mapguide-commits] r9728 - trunk/MgDev
svn_mapguide at osgeo.org
svn_mapguide at osgeo.org
Thu Sep 10 11:32:14 PDT 2020
Author: jng
Date: 2020-09-10 11:32:13 -0700 (Thu, 10 Sep 2020)
New Revision: 9728
Added:
trunk/MgDev/cmake_package.sh
Log:
Add packaging script for CMake build. Fixes #2821
Added: trunk/MgDev/cmake_package.sh
===================================================================
--- trunk/MgDev/cmake_package.sh (rev 0)
+++ trunk/MgDev/cmake_package.sh 2020-09-10 18:32:13 UTC (rev 9728)
@@ -0,0 +1,334 @@
+#!/bin/sh
+
+PKG_FORMAT=deb
+WORKING_DIR=
+MG_TARBALL=
+FDO_VER=4.2.0
+MG_VER=4.0.0
+MG_BUILD=8000
+MG_ARCH=amd64
+LIBDIR=lib64
+PKG_OUTPUT_DIR=
+DPKG_MG_RELPATH="usr/local/mapguideopensource-${MG_VER}"
+THIS_DIR=$(realpath "$(dirname $0)")
+
+while [ $# -gt 0 ]; do # Until you run out of parameters...
+ case "$1" in
+ --format)
+ PKG_FORMAT=$2
+ shift
+ ;;
+ --working-dir)
+ WORKING_DIR=$2
+ shift
+ ;;
+ --output-dir)
+ PKG_OUTPUT_DIR=$2
+ shift
+ ;;
+ --tarball)
+ MG_TARBALL=$2
+ shift
+ ;;
+ --help)
+ echo "Usage: $0 (options)"
+ echo "Options:"
+ echo " --format [deb|rpm]"
+ echo " --tarball [Path to MapGuide tarball]"
+ echo " --working-dir [Path to working directory]"
+ echo " --output-dir [Path to output directory]"
+ echo " --help [Display usage]"
+ exit
+ ;;
+ esac
+ shift # Check next set of parameters.
+done
+
+if [ ! -f "$MG_TARBALL" ]; then
+ if [ ! -d "/$DPKG_MG_RELPATH" ]; then
+ echo "MapGuide tarball not found. Please specify with the --tarball switch"
+ exit 1
+ else
+ echo "MapGuide installation directory appears to already exist. Allowing omission of --tarball"
+ fi
+fi
+
+if [ -z "$WORKING_DIR" ]; then
+ echo "Working directory not specified. Please specify with the --working-dir switch"
+ exit 1
+fi
+
+if [ -z "$PKG_OUTPUT_DIR" ]; then
+ echo "Package output directory not specified. Please specify with the --output-dir switch"
+ exit 1
+fi
+
+echo "Source directory: $THIS_DIR"
+echo "MapGuide tarball: $MG_TARBALL"
+echo "Package working dir: $WORKING_DIR"
+echo "Package output dir: $PKG_OUTPUT_DIR"
+
+if [ ! -d "$WORKING_DIR" ]; then
+ echo "Creating working dir"
+ mkdir -p "$WORKING_DIR"
+fi
+
+mkdir -p "$PKG_OUTPUT_DIR"
+
+mkdir -p "/${DPKG_MG_RELPATH}"
+if [ -f "$MG_TARBALL" ]; then
+ echo "Extracting tarball into staging area"
+ tar -zxf "$MG_TARBALL" -C "/${DPKG_MG_RELPATH}"
+fi
+
+dpkg_create_control_files()
+{
+ mkdir -p "$WORKING_DIR/debian"
+ cat > "$WORKING_DIR/debian/control" <<END-OF-CONTROL
+Source: mapguideopensource-src
+Maintainer: MapGuide Internals Mail List <mapguide-internals at lists.osgeo.org>
+Section: misc
+Priority: optional
+Homepage: https://mapguide.osgeo.org
+
+Package: mapguideopensource-common
+Architecture: ${MG_ARCH}
+Section: misc
+Priority: optional
+Depends: \${mapguidecommon:Depends}
+Description: OSGeo MapGuide ${MG_VER} server-specific common components
+
+Package: mapguideopensource-coordsys
+Architecture: ${MG_ARCH}
+Section: msic
+Priority: optional
+Depends: \${mapguidecoordsys:Depends}
+Description: CS-Map Coordinate System Dictionary data files
+
+Package: mapguideopensource-server
+Architecture: ${MG_ARCH}
+Section: misc
+Priority: optional
+Depends: \${mapguideserver:Depends}
+Description: OSGeo MapGuide ${MG_VER} Server
+
+Package: mapguideopensource-webextensions
+Architecture: ${MG_ARCH}
+Section: misc
+Priority: optional
+Depends: \${mapguidewebextensions:Depends}
+Description: OSGeo MapGuide ${MG_VER} Web Extensions
+
+Package: mapguideopensource-httpd
+Architecture: ${MG_ARCH}
+Section: misc
+Priority: optional
+Depends: \${mapguidehttpd:Depends}
+Description: OSGeo MapGuide ${MG_VER} Apache Web Server
+END-OF-CONTROL
+
+ # Create changelog file
+ # TODO: pull revision history from Subversion
+ #
+ CURRTIME=`date -R`
+ cat > "$WORKING_DIR/debian/changelog" <<END-OF-CHANGELOG
+mapguideopensource-src (${MG_VER}-${MG_BUILD}) experimental; urgency=low
+
+ * ${MG_BUILD}
+
+ -- MapGuide Internals Mail List <mapguide-internals at lists.osgeo.org> ${CURRTIME}
+END-OF-CHANGELOG
+
+ # Add license file
+ cp -f "$THIS_DIR/License.txt" "$WORKING_DIR/tmp/copyright"
+ iconv -f ISO-8859-1 -t UTF-8 "$WORKING_DIR/tmp/copyright" > "$WORKING_DIR/debian/copyright"
+}
+
+dpkg_component()
+{
+ echo "Generating deb package for: $1"
+
+ # Build directory structure underneath directory of this script
+ # debian/ - common build directory for all packages
+ # control - generated all packages control file with subst params
+ # changelog - generated changelog file
+ # substvars - subst params created by dpkg-shlibdeps
+ # mapguidecommon/ - packaging directory for common MapGuide components
+ # usr/local/mapguideopensource-x.y.z/ - copied tree for common components
+ # DEBIAN/
+ # control - control file generated from dpkg-gencontrol
+ # symbols - symbols file generated from dpkg-gensymbols
+ #
+ # mapguidecoordsys/ - packaging directory for CS-Map coordinate system dictionaries
+ # usr/local/mapguideopensource-x.y.z/ - copied tree for common components
+ # DEBIAN/
+ # control - control file generated from dpkg-gencontrol
+ # symbols - symbols file generated from dpkg-gensymbols
+ #
+ # mapguidecoordsyslite/ - packaging directory for CS-Map coordinate system dictionaries
+ # usr/local/mapguideopensource-x.y.z/ - copied tree for common components
+ # DEBIAN/
+ # control - control file generated from dpkg-gencontrol
+ # symbols - symbols file generated from dpkg-gensymbols
+ #
+ # mapguideserver/ - packaging directory for MapGuide Server
+ # usr/local/mapguideopensource-x.y.z/ - copied tree for Server
+ # DEBIAN/
+ # control - control file generated from dpkg-gencontrol
+ # symbols - symbols file generated from dpkg-gensymbols
+ #
+ # mapguidewebextensions/ - packaging directory for Web Extensions
+ # usr/local/mapguideopensource-x.y.z/ - copied tree for Web Extensions
+ # DEBIAN/
+ # control - control file generated from dpkg-gencontrol
+ # symbols - symbols file generated from dpkg-gensymbols
+ #
+ # mapguidehttpd/ - packaging directory for Apache Bundle
+ # usr/local/mapguideopensource-x.y.z/ - copied tree for Apache bundle
+ # DEBIAN/
+ # control - control file generated from dpkg-gencontrol
+ # symbols - symbols file generated from dpkg-gensymbols
+ #
+ DPKG_NAME="mapguideopensource-$1"
+ DPKG_NAME_N="mapguide$1"
+ MGINST="${DPKG_MG_RELPATH}$2"
+ DIRLIST="$3"
+ REMOVELIST="$4"
+ STRIPLIST="$5"
+ DPKG_TREE="$WORKING_DIR/debian"
+ DPKG_ROOT="$DPKG_TREE/${DPKG_NAME_N}"
+ DPKG_CP_ROOT="$DPKG_ROOT/$MGINST"
+
+ # Create output directory structure and ignore errors
+ #
+ if [ ! -d tmp ]; then
+ mkdir -p "$WORKING_DIR/tmp"
+ mkdir -p "$WORKING_DIR/bin"
+ mkdir -p "$WORKING_DIR/debian"
+ else
+ # clean out existing build tree
+ rm -rf "$WORKING_DIR/tmp/*"
+ rm -rf "$WORKING_DIR/bin/*"
+ rm -rf "$WORKING_DIR/debian/*"
+ fi
+
+ # Blow away old build directory
+ rm -rf ${DPKG_ROOT}
+
+ # Create and populate documentation directory for package
+ mkdir -p ${DPKG_ROOT}/usr/share/doc/${DPKG_NAME}
+ cp ${WORKING_DIR}/debian/copyright ${DPKG_ROOT}/usr/share/doc/${DPKG_NAME}
+ cp ${WORKING_DIR}/debian/changelog ${DPKG_ROOT}/usr/share/doc/${DPKG_NAME}/changelog.Debian
+ gzip -9 ${DPKG_ROOT}/usr/share/doc/${DPKG_NAME}/changelog.Debian
+
+ dpkg_create_control_files
+
+ # Create directories for binary package build and copy
+ # install image into build directory
+ for dirname in ${DIRLIST}
+ do
+ mkdir -p ${DPKG_CP_ROOT}/${dirname}
+ cp -ar /${MGINST}/${dirname} ${DPKG_CP_ROOT}
+ done
+
+ # Remove all files in the REMOVELIST
+ for pat in ${REMOVELIST}
+ do
+ for file in `find ${DPKG_CP_ROOT} -type f | grep "${pat}"`
+ do
+ echo "Removing ${file}"
+ rm -f ${file}
+ done
+ done
+
+ # Symbol strip all files in the STRIPLIST
+ for pat in ${STRIPLIST}
+ do
+ for file in `find ${DPKG_CP_ROOT} -type f | grep "${pat}"`
+ do
+ echo "Stripping ${file}"
+ strip --strip-unneeded ${file}
+ chmod a-x ${file}
+ done
+ done
+
+ # Call dpkg-shlibdeps to build out library dependencies
+ # This will create the substvars file
+ # LD_LIBRARY_PATH must be set to find private libs
+ mkdir -p "${DPKG_ROOT}/DEBIAN"
+
+ cd $WORKING_DIR || exit
+ echo "PWD is: $PWD"
+
+ # Shared library symlinks point back to install directory
+ # Add install directory to path to compensate
+ # Also add FDO libs to path
+ export LD_LIBRARY_PATH=/usr/local/fdo-${FDO_VER}/${LIBDIR}:${DPKG_CP_ROOT}/${LIBDIR}:/${MGINST}/${LIBDIR}:/${MGINST}/server/${LIBDIR}:/${MGINST}/webserverextensions/${LIBDIR}
+ echo "Using LD_LIBRARY_PATH of:"
+ echo "$LD_LIBRARY_PATH"
+ dpkg-shlibdeps -p"$DPKG_NAME_N" --ignore-missing-info ${DPKG_CP_ROOT}/${LIBDIR}/*.so
+ dpkg-gensymbols -p"$DPKG_NAME" -P"debian/$DPKG_NAME_N"
+ export LD_LIBRARY_PATH=
+
+ # Now generate a filled in control file for the binary package
+ # using information from control, changelog, and substvars
+ dpkg-gencontrol -p"$DPKG_NAME" -P"debian/$DPKG_NAME_N"
+
+ # Build binary package from ROOT
+ # And move resulting debian package and lintian results to build directory
+ dpkg-deb --build ${DPKG_ROOT}
+ lintian -i "debian/${DPKG_NAME_N}.deb" > "tmp/${DPKG_NAME_N}.lintian"
+ mv "debian/${DPKG_NAME_N}.deb" "${PKG_OUTPUT_DIR}/${DPKG_NAME}_${MG_VER}-${MG_BUILD}_${MG_ARCH}.deb"
+}
+
+create_deb_package()
+{
+ arg_inst_base=""
+ arg_dir_list="${LIBDIR}"
+ arg_remove_list="\.a\$ \.la\$"
+ arg_strip_list="\.so\$ libdwf"
+ dpkg_component common "$arg_inst_base" "$arg_dir_list" "$arg_remove_list" "$arg_strip_list"
+
+ arg_inst_base="/server"
+ arg_dir_list="bin ${LIBDIR} Logs Packages Repositories RepositoryAdmin Resources Schema Temp Trash Wfs Wms"
+ arg_remove_list="\.a\$ \.la\$"
+ arg_strip_list="\.so\$"
+ dpkg_component server "$arg_inst_base" "$arg_dir_list" "$arg_remove_list" "$arg_strip_list"
+
+ arg_inst_base="/webserverextensions"
+ arg_dir_list="bin ${LIBDIR} www"
+ arg_remove_list="\.a\$ \.la\$"
+ arg_strip_list="\.so\$"
+ dpkg_component webextensions "$arg_inst_base" "$arg_dir_list" "$arg_remove_list" "$arg_strip_list"
+
+ arg_inst_base="/webserverextensions"
+ arg_dir_list="apache2 php tomcat"
+ arg_remove_list="\.a\$ \.la\$"
+ arg_strip_list="\.so\$"
+ dpkg_component httpd "$arg_inst_base" "$arg_dir_list" "$arg_remove_list" "$arg_strip_list"
+
+ arg_inst_base=""
+ arg_dir_list="share"
+ arg_remove_list="\.a\$ \.la\$ \.c\$ \.o\$ \.mak\$ \.nmk\$"
+ arg_strip_list="\.so\$"
+ dpkg_component coordsys "$arg_inst_base" "$arg_dir_list" "$arg_remove_list" "$arg_strip_list"
+}
+
+create_rpm_package()
+{
+ echo "RPM packaging support coming soon"
+ exit 1
+}
+
+case $PKG_FORMAT in
+ deb)
+ create_deb_package
+ ;;
+ rpm)
+ create_rpm_package
+ ;;
+ *)
+ echo "Unknown or unsupported package format: $PKG_FORMAT"
+ exit 1
+ ;;
+esac
\ No newline at end of file
Property changes on: trunk/MgDev/cmake_package.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
More information about the mapguide-commits
mailing list