Skip to content

Commit

Permalink
Add CPack configuration for building Debian packages, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie Snape committed Feb 26, 2018
1 parent 81643cd commit a8e3002
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 4 deletions.
66 changes: 66 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,28 @@ ExternalProject_Add(drake_cxx_python
USES_TERMINAL_INSTALL 1
)

set(GIT_REVISION HEAD)

find_package(Git)

if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
execute_process(COMMAND "${GIT_EXECUTABLE}" rev-parse HEAD
RESULT_VARIABLE GIT_REV_PARSE_RESULT_VARIABLE
OUTPUT_VARIABLE GIT_REV_PARSE_OUTPUT_VARIABLE
OUTPUT_STRIP_TRAILING_WHITESPACE
)

if(GIT_REV_PARSE_RESULT_VARIABLE EQUAL 0)
set(GIT_REVISION "${GIT_REV_PARSE_OUTPUT_VARIABLE}")
endif()
endif()

string(TIMESTAMP BUILD_TIMESTAMP "%Y%m%d%H%M%S")

configure_file(tools/install/libdrake/VERSION.TXT.in VERSION.TXT @ONLY)

install(FILES "${PROJECT_BINARY_DIR}/VERSION.TXT" DESTINATION share/doc/drake)

list(APPEND CMAKE_PREFIX_PATH "${CMAKE_INSTALL_PREFIX}")

if(WITH_MATLAB)
Expand All @@ -145,3 +167,47 @@ if(WITH_MATLAB)
BUILD_ALWAYS 1
)
endif()

set(CPACK_GENERATOR TGZ)
set(CPACK_INSTALLED_DIRECTORIES "${CMAKE_INSTALL_PREFIX}" .)
set(CPACK_PACKAGE_CONTACT RobotLocomotion)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
"Planning, control, and analysis toolbox for nonlinear dynamical systems"
)
set(CPACK_PACKAGE_VENDOR RobotLocomotion)
set(CPACK_PACKAGE_VERSION_MAJOR 0)
set(CPACK_PACKAGE_VERSION_MINOR 0)
set(CPACK_PACKAGE_VERSION_PATCH 0)
set(CPACK_PACKAGE_CHECKSUM SHA256)
set(CPACK_SET_DESTDIR ON)
set(CPACK_SOURCE_GENERATOR "")

if(APPLE)
set(CPACK_SYSTEM_NAME mac)
else()
string(TOLOWER "${CMAKE_SYSTEM_NAME}" CPACK_SYSTEM_NAME)

list(APPEND CPACK_GENERATOR DEB)

set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION ON)
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE http://drake.mit.edu/)
set(CPACK_DEBIAN_PACKAGE_RELEASE 1)
set(CPACK_DEBIAN_PACKAGE_SECTION contrib/devel)

file(STRINGS setup/ubuntu/16.04/binary_distribution/packages.txt
CPACK_DEBIAN_PACKAGE_DEPENDS
)
string(REGEX REPLACE "([a-z0-9\\-]+)=([a-z0-9\\-\\.~]+)" "\\1 (= \\2)"
CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}"
)
string(REPLACE ";" ", " CPACK_DEBIAN_PACKAGE_DEPENDS
"${CPACK_DEBIAN_PACKAGE_DEPENDS}"
)
endif()

set(CPACK_PACKAGE_FILE_NAME
"${PROJECT_NAME}-${BUILD_TIMESTAMP}-${CPACK_SYSTEM_NAME}"
)

include(CPack)
19 changes: 15 additions & 4 deletions tools/install/install.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ def install(src, dst):
dst_full = os.path.join(prefix, dst)
# Install file, if not up to date.
if needs_install(src, dst):
print("[Installing] {}".format(dst))
print("-- Installing: {}".format(dst_full))
if os.path.exists(dst_full):
os.remove(dst_full)
shutil.copy2(src, dst_full)
installed = True
else:
print("[Up to date] {}".format(dst))
print("-- Up-to-date: {}".format(dst_full))
re_result = re.match(dylib_match, dst)
if re_result is not None: # It is a library
basename = os.path.basename(re_result.group(0))
Expand Down Expand Up @@ -255,9 +255,11 @@ def create_java_launcher(filename, classpath, jvm_flags, main_class):
if list_only:
print(filename)
return
print("[Generating] {}".format(filename))
# Make sure install directory exists.

filename = os.path.join(prefix, filename)
print("-- Generating: {}".format(filename))

# Make sure install directory exists.
filepath = os.path.dirname(filename)
if not os.path.exists(filepath):
os.makedirs(filepath)
Expand Down Expand Up @@ -304,6 +306,12 @@ def main(args):
prefix = args.prefix
list_only = args.list

# Transform install prefix if DESTDIR is set.
# https://www.gnu.org/prep/standards/html_node/DESTDIR.html
destdir = os.environ.get('DESTDIR')
if destdir:
prefix = destdir + prefix

# Because Bazel executes us in a strange working directory and not the
# working directory of the user's shell, enforce that the install
# location is an absolute path so that the user is not surprised.
Expand All @@ -313,6 +321,9 @@ def main(args):
.format(prefix))
sys.exit(1)

# Match the output of the CMake install step.
print("Install the project...")

# Execute the install actions.
<<actions>>

Expand Down
1 change: 1 addition & 0 deletions tools/install/libdrake/VERSION.TXT.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@BUILD_TIMESTAMP@ @GIT_REVISION@

0 comments on commit a8e3002

Please sign in to comment.