diff --git a/CI/azure/ci-ubuntu.sh b/CI/azure/ci-ubuntu.sh index 25ccea0b1..f7fce9340 100644 --- a/CI/azure/ci-ubuntu.sh +++ b/CI/azure/ci-ubuntu.sh @@ -6,3 +6,4 @@ mkdir build && cd build cmake .. -Werror=dev -DCOMPILE_WARNING_AS_ERROR=ON -DWITH_SERIAL_BACKEND=ON -DWITH_EXAMPLES=ON -DCPP_BINDINGS=ON -DPYTHON_BINDINGS=ON -DENABLE_PACKAGING=ON -DCPACK_SYSTEM_NAME="${ARTIFACTNAME}" make make package +make required2tar diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4e1bddc28..e39eeb035 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -73,6 +73,7 @@ stages: fi make make package + make required2tar displayName: 'Build' - task: CopyFiles@2 inputs: diff --git a/cmake/LinuxPackaging.cmake b/cmake/LinuxPackaging.cmake index 750e13772..396b391f9 100644 --- a/cmake/LinuxPackaging.cmake +++ b/cmake/LinuxPackaging.cmake @@ -10,6 +10,10 @@ set(CPACK_PACKAGE_VERSION_PATCH g${LIBIIO_VERSION_GIT}) set(CPACK_BUNDLE_NAME libiio) set(CPACK_PACKAGE_VERSION ${LIBIIO_VERSION}) +# Start with empty file +set(REQUIRES "${CMAKE_BINARY_DIR}/require_manifest.txt") +file(WRITE ${REQUIRES} "") + # Determine the distribution we are on file(STRINGS /etc/os-release distro REGEX "^NAME=") string(REGEX REPLACE "NAME=\"(.*)\"" "\\1" distro "${distro}") @@ -209,12 +213,47 @@ foreach(package ${PACKAGES}) set(CPACK_RPM_PACKAGE_REQUIRES "${CPACK_RPM_PACKAGE_REQUIRES}" "${match} >= ${RPM_VER}, ") endif() + # find the actual so files + STRING(REGEX MATCHALL "libc6|glibc" TEMP_TEST ${match}) + if(NOT "${TEMP_TEST}" STREQUAL "") + continue() + endif() + if (CPACK_GENERATOR MATCHES "DEB" AND DPKG_CMD) + # build up the so locations + execute_process(COMMAND "${DPKG_CMD}" + -L "${match}" + OUTPUT_VARIABLE DPK_RESULT) + elseif (CPACK_GENERATOR MATCHES "RPM" AND RPM_CMD) + execute_process(COMMAND "${RPM_CMD}" -ql ${match} + OUTPUT_VARIABLE DPK_RESULT) + else() + continue() + endif() + STRING(STRIP ${DPK_RESULT} STRIPPED) + STRING(REGEX REPLACE "[\r\n]" ";" POSSIBLE_SO "${STRIPPED}") + foreach(is_so ${POSSIBLE_SO}) + # match with ".so." or ".so" (and the end) + STRING(REGEX MATCHALL "\\.so$|\\.so\\." TEMP_TEST ${is_so}) if("${TEMP_TEST}" STREQUAL "") continue() endif() + if(IS_SYMLINK ${is_so}) + continue() + endif() + file(APPEND ${REQUIRES} "${is_so}\n") + endforeach(is_so) endforeach(match) endforeach(package) +configure_file( "${CMAKE_SOURCE_DIR}/cmake/add_requirements2tar.sh.in" + "${CMAKE_BINARY_DIR}/add_requirements2tar.sh" + IMMEDIATE @ONLY + ) +add_custom_target(required2tar + COMMAND sh ${CMAKE_BINARY_DIR}/add_requirements2tar.sh + COMMENT "Adding requirements to tarball" + ) + if (CPACK_GENERATOR MATCHES "DEB") if (NOT DPKGQ_CMD) set(CPACK_DEBIAN_PACKAGE_DEPENDS "${DEFAULT_DEB}") diff --git a/cmake/add_requirements2tar.sh.in b/cmake/add_requirements2tar.sh.in new file mode 100644 index 000000000..848a13bed --- /dev/null +++ b/cmake/add_requirements2tar.sh.in @@ -0,0 +1,69 @@ +#!/bin/sh +# should be called from "make required2tar" +set -e + +cd @CMAKE_BINARY_DIR@ + +manifest=./require_manifest.txt +if [ ! -f ${manifest} ] ; then + echo "Can not find manifest at ${manifest}" + exit 1 +fi + +gz=$(ls ./libiio*.tar.gz) +if [ -z "${gz}" ] ; then + echo "try make package first" + exit 1 +fi +if [ "$(echo -n ${gz} | tr -cd ' \t' | wc -c)" -ne "0" ] ; then + echo "too many tar, there should be only one, but found ${gz}" + exit 1 +fi +tar=$(echo ${gz} | sed 's/\.gz$//') + +#unzip the file (can not append while it is gzipped) +#gunzip ${gz} + +# We should be able to just "tar --append -f ${tar} -T manufest.txt, but the tar on +# CenrOS7 doesn't support that - so we we need to split it apart, and add +# files manually. + +if [ -d tarball_fixup ] ; then + rm -rf tarball_fixup +fi +mkdir tarball_fixup +tar -xzf ${gz} -C ./tarball_fixup + +while read -r line +do + if [ -f ${line} ] ; then + echo "adding ${line} to architve" + #make sure the directory exists as a target + mkdir -p ./tarball_fixup$(dirname ${line}) + cp ${line} ./tarball_fixup${line} + + cd ./tarball_fixup$(dirname ${line}) + line=$(basename ${line}) + + until echo ${line} | grep -q \.so.[0-9]*$ + do + tmp=$(echo ${line} | sed 's/\.[0-9]*$//') + if [ ! -f "${tmp}" ] ; then + ln -s ${line} ${tmp} + else + echo "target ${tmp} already exists" + ls -l ${tmp} + fi + line=${tmp} + done + cd @CMAKE_BINARY_DIR@ + + else + echo "could not find ${line} to copy" + exit 1 + fi +done < ${manifest} + +tar -czf ${gz} -C ./tarball_fixup/ . +rm -rf tarball_fixup +