Skip to content

Commit

Permalink
Linux packaging enhancements (#8)
Browse files Browse the repository at this point in the history
* Add pre/post bash packaging scripts

Change package install location to /opt/rocm/hipblas
Test hipblas install in dockerfile

* Update jenkinsfile to apply versioning to packages
  • Loading branch information
Kent Knox authored May 3, 2017
1 parent 37ab62b commit 9cc1618
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 30 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ if( BUILD_LIBRARY )
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
)

if( DEFINED CPACK_PACKAGING_INSTALL_PREFIX )
list( APPEND LIBRARY_CMAKE_ARGS -DCPACK_PACKAGING_INSTALL_PREFIX=${CPACK_PACKAGING_INSTALL_PREFIX} )
endif()

# Build the library as an external project
ExternalProject_Add( hipblas
DEPENDS ${hipblas_dependencies}
Expand Down
35 changes: 27 additions & 8 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def docker_build_inside_image( def build_image, String build_config, String work
{
stage("build ${build_config}")
{
String install_prefix = "/opt/rocm"
String install_prefix = "/opt/rocm/hipblas"

// Copy our rocBLAS dependency
// Commented out because we need to compile static rocblas with fpic enabled
Expand All @@ -96,6 +96,7 @@ def docker_build_inside_image( def build_image, String build_config, String work
cd ${build_dir_rel}
cmake -B${build_dir_abs} \
-DCMAKE_INSTALL_PREFIX=${install_prefix} \
-DCPACK_PACKAGING_INSTALL_PREFIX=${install_prefix} \
-DCMAKE_BUILD_TYPE=${build_config} \
-DCMAKE_PREFIX_PATH='/opt/rocm;/usr/local/src/rocBLAS/build/library-package' \
-DBUILD_LIBRARY=ON \
Expand Down Expand Up @@ -152,22 +153,41 @@ def docker_upload_artifactory( String build_config, String workspace_dir_abs )
}

////////////////////////////////////////////////////////////////////////
// This routines defines the build flow of the project
// Calls helper routines to do the work and stitches them together
def hipblas_build_pipeline( String build_type )
// Checkout the desired source code and update the version number
def checkout_and_version( String workspace_dir_abs )
{
// Convenience variables for common paths used in building
String workspace_dir_abs = pwd()

dir("${workspace_dir_abs}")
{
stage("github clone")
{
deleteDir( )
checkout scm

if( fileExists( 'cmake/build-version.cmake' ) )
{
def cmake_version_file = readFile( 'cmake/build-version.cmake' ).trim()
//echo "cmake_version_file:\n${cmake_version_file}"

cmake_version_file = cmake_version_file.replaceAll(/(\d+\.)(\d+\.)(\d+\.)\d+/, "\$1\$2\$3${env.BUILD_ID}")
cmake_version_file = cmake_version_file.replaceAll(/VERSION_TWEAK\s+\d+/, "VERSION_TWEAK ${env.BUILD_ID}")
//echo "cmake_version_file:\n${cmake_version_file}"
writeFile( file: 'cmake/build-version.cmake', text: cmake_version_file )
}
}
}

}

////////////////////////////////////////////////////////////////////////
// This routines defines the build flow of the project
// Calls helper routines to do the work and stitches them together
def hipblas_build_pipeline( String build_type )
{
// Convenience variables for common paths used in building
String workspace_dir_abs = pwd()

checkout_and_version( "${workspace_dir_abs}" )

// Create/reuse a docker image that represents the hipblas build environment
def hipblas_build_image = docker_build_image( )

Expand All @@ -182,7 +202,6 @@ def hipblas_build_pipeline( String build_type )
////////////////////////////////////////////////////////////////////////
// -- MAIN
// This following are build nodes; start of build pipeline
//node('rocmtest')
node('docker && rocm')
{
hipblas_build_pipeline( 'Release' )
Expand Down
63 changes: 63 additions & 0 deletions cmake/package-functions.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# ########################################################################
# A helper function to generate packaging scripts to register libraries with system
# ########################################################################
function( write_rocm_package_script_files scripts_write_dir library_name library_link_name )

set( ld_conf_file "/etc/ld.so.conf.d/${library_name}-dev.conf" )

file( WRITE ${scripts_write_dir}/postinst
"#!/bin/bash
set -e
do_ldconfig() {
echo ${CPACK_PACKAGING_INSTALL_PREFIX}/${LIB_INSTALL_DIR} > ${ld_conf_file} && ldconfig
}
do_softlinks() {
ln -sr ${CPACK_PACKAGING_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR} ${CPACK_PACKAGING_INSTALL_PREFIX}/../include/${library_name}
ln -sr ${CPACK_PACKAGING_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/${library_link_name}.1 ${CPACK_PACKAGING_INSTALL_PREFIX}/../lib/${library_link_name}
ln -sr ${CPACK_PACKAGING_INSTALL_PREFIX}/${LIB_INSTALL_DIR}/cmake/${library_name} ${CPACK_PACKAGING_INSTALL_PREFIX}/../lib/cmake/${library_name}
}
case \"\$1\" in
configure)
do_ldconfig
do_softlinks
;;
abort-upgrade|abort-remove|abort-deconfigure)
echo \"\$1\"
;;
*)
exit 0
;;
esac
" )

file( WRITE ${scripts_write_dir}/prerm
"#!/bin/bash
set -e
rm_ldconfig() {
rm -f ${ld_conf_file} && ldconfig
}
rm_softlinks() {
rm -f ${CPACK_PACKAGING_INSTALL_PREFIX}/../include/${library_name}
rm -f ${CPACK_PACKAGING_INSTALL_PREFIX}/../lib/${library_link_name}
rm -f ${CPACK_PACKAGING_INSTALL_PREFIX}/../lib/cmake/${library_name}
}
case \"\$1\" in
remove|purge)
rm_ldconfig
rm_softlinks
;;
*)
exit 0
;;
esac
" )

endfunction( )
9 changes: 4 additions & 5 deletions docker/dockerfile-build-ubuntu-16.04
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@ ARG build_type=Release
# echo 'deb [arch=amd64] http://packages.amd.com/rocm/apt/debian/ xenial main' | tee /etc/apt/sources.list.d/rocm.list && \
# apt update && DEBIAN_FRONTEND=noninteractive apt install -y --no-install-recommends \
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y curl && \
echo 'deb [arch=amd64] http://compute-artifactory.amd.com/artifactory/rocm-release-1.5-deb xenial main' | tee /etc/apt/sources.list.d/rocm.list && \
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y --allow-unauthenticated \
curl -sL http://packages.amd.com/rocm/apt/debian/rocm.gpg.key | apt-key add - && \
echo 'deb [arch=amd64] http://packages.amd.com/rocm/apt/debian/ xenial main' | tee /etc/apt/sources.list.d/rocm.list && \
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
sudo \
file \
software-properties-common \
build-essential \
git \
rpm \
git \
cmake \
clang \
hsakmt-roct-dev \
Expand All @@ -26,8 +27,6 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-instal
hcc \
hip_base \
hip_hcc \
hip_doc \
hip_samples \
python-yaml \
&& \
apt-get clean && \
Expand Down
25 changes: 21 additions & 4 deletions docker/dockerfile-hipblas-ubuntu-16.04
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,24 @@ FROM ubuntu:16.04
MAINTAINER Kent Knox <kent.knox@amd>

# Initialize the image we are working with
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y curl && \
curl -sL http://packages.amd.com/rocm/apt/debian/rocm.gpg.key | apt-key add - && \
echo 'deb [arch=amd64] http://packages.amd.com/rocm/apt/debian/ xenial main' | tee /etc/apt/sources.list.d/rocm.list && \
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
rocm-dev \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*

# Copy the debian package of hcc-lc into the container from host
COPY *.deb /tmp/

# Install the debian package, and print out contents of expected changed locations
RUN dpkg -i /tmp/*.deb && \
rm -f /tmp/*.deb && \
printf "cat /etc/ld.so.conf.d/hipblas-dev.conf\n" && cat /etc/ld.so.conf.d/hipblas-dev.conf && \
printf "ls -la /opt/rocm/include\n" && ls -la /opt/rocm/include && \
printf "ls -la /opt/rocm/lib \n" && ls -la /opt/rocm/lib && \
printf "ls -la /opt/rocm/lib/cmake\n" && ls -la /opt/rocm/lib/cmake && \
printf "ls -la /opt/rocm/hipblas/include\n" && ls -la /opt/rocm/hipblas/include && \
printf "ls -la /opt/rocm/hipblas/lib\n" && ls -la /opt/rocm/hipblas/lib
32 changes: 19 additions & 13 deletions library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ message( STATUS "CMAKE_CXX_COMPILER debug flags : ${CMAKE_CXX_FLAGS_DEBU
message( STATUS "CMAKE_CXX_COMPILER release flags : ${CMAKE_CXX_FLAGS_RELEASE} " )
message( STATUS "CMAKE_CXX_COMPILER relwithdebinfo flags: ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} " )

include( GNUInstallDirs )

# configure a header file to pass the CMake version settings to the source, and package the header files in the output archive
configure_file( "${PROJECT_SOURCE_DIR}/include/hipblas-version.h.in" "${PROJECT_BINARY_DIR}/include/hipblas-version.h" )

Expand All @@ -84,16 +82,15 @@ set( hipblas_headers_public

source_group( "Header Files\\Public" FILES ${hipblas_headers_public} )

include( GNUInstallDirs )

set( BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR} )
set( LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR} )
set( INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR} )

# Build into subdirectories
add_subdirectory( src )

# # Depending on whether we are building for 64 or 32 bit, construct common paths and names that subdirectories can reference for their use
# if( BUILD_64 )
# set( CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}-amd64" )
# else( )
# set( CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}-i686" )
# endif( )

# The following code is setting variables to control the behavior of CPack to generate our
if( WIN32 )
set( CPACK_SOURCE_GENERATOR "ZIP" )
Expand All @@ -102,10 +99,6 @@ else( )
set( CPACK_SOURCE_GENERATOR "TGZ" )

set( CPACK_GENERATOR "DEB;RPM" CACHE STRING "cpack list: 7Z, DEB, IFW, NSIS, NSIS64, RPM, STGZ, TBZ2, TGZ, TXZ, TZ, ZIP" )
# set( CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64" )
# set( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/postinst;${CMAKE_CURRENT_SOURCE_DIR}/DEBIAN/prerm" )
# set( CPACK_DEBIAN_PACKAGE_DEPENDS "" )
# set( CPACK_DEBIAN_COMPRESSION_TYPE "xz" )
# set( CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON )
endif( )

Expand All @@ -120,5 +113,18 @@ set( CPACK_PACKAGE_VENDOR "AMD")
set( CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/../LICENSE" )
set( CPACK_SOURCE_IGNORE_FILES "/\\\\.git/" )

# Package specific CPACK vars
set( CPACK_DEBIAN_PACKAGE_DEPENDS "hip_hcc (>= 1.0.17174)" )
set( CPACK_RPM_PACKAGE_REQUIRES "hip_hcc >= 1.0.17174" )

if( "${CPACK_PACKAGING_INSTALL_PREFIX}" MATCHES "^/opt/rocm.*$")
include( package-functions )
write_rocm_package_script_files( ${PROJECT_BINARY_DIR} "hipblas" "libhipblas-hcc.so" )

set( CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${PROJECT_BINARY_DIR}/postinst;${PROJECT_BINARY_DIR}/prerm")
set( CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/postinst" )
set( CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${PROJECT_BINARY_DIR}/prerm" )
endif( )

# Define all variables that influence CPack before including CPack, such as install targets
include( CPack )

0 comments on commit 9cc1618

Please sign in to comment.