Skip to content

CPack/RPM: postinstall scriptlet contains extraneous extra newline

Note this issue I would deem very minor, I don't think it affects an RPM's run-time result; it's a cosmetic thing.

I have the following files:

CMakeLists.txt:

cmake_minimum_required(VERSION 3.17.3)

project(CMakeCPackBug VERSION 1.0.0)

set(CMAKE_CXX_STANDARD 11)

add_executable(main main.cpp)

# Provide locations of root directories of source files from which binaries were built
set(CPACK_BUILD_SOURCE_DIRS ${PROJECT_SOURCE_DIR})

set(CPACK_GENERATOR RPM)

set(CPACK_RPM_FILE_NAME RPM-DEFAULT)

set(CPACK_RPM_PACKAGE_RELEASE 1)

set(CPACK_RPM_PACKAGE_RELEASE_DIST ON)

set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE ${PROJECT_SOURCE_DIR}/rpmScriptlet.bash)
set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE ${PROJECT_SOURCE_DIR}/rpmScriptlet.bash)

set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE ${PROJECT_SOURCE_DIR}/rpmScriptlet.bash)
set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE ${PROJECT_SOURCE_DIR}/rpmScriptlet.bash)

include(CPack)

main.cpp:

#include <cstdlib>

int main()
{
  system("cmake3 --version");
}

rpmScriptlet.bash

/sbin/ldconfig

Run make package and dump resulting RPM scripts:

rm -rf ./* && cmake3 .. && make package && rpm -pq --scripts cmakecpackbug-1.0.0-1.el7.x86_64.rpm
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/gmajszak/GeneralTest/cmake-build-debug
Scanning dependencies of target main
[ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o
[100%] Linking CXX executable main
[100%] Built target main
Run CPack packaging tool...
CPack3: Create package using RPM
CPack3: Install projects
CPack3: - Run preinstall target for: CMakeCPackBug
CPack3: - Install project: CMakeCPackBug []
CPack3: Create package
CPackRPM: Will use GENERATED spec file: /home/gmajszak/GeneralTest/cmake-build-debug/_CPack_Packages/Linux/RPM/SPECS/cmakecpackbug.spec
CPack3: - package: /home/gmajszak/GeneralTest/cmake-build-debug/cmakecpackbug-1.0.0-1.el7.x86_64.rpm generated.
preinstall scriptlet (using /bin/sh):
/sbin/ldconfig
postinstall scriptlet (using /bin/sh):

/sbin/ldconfig
preuninstall scriptlet (using /bin/sh):
/sbin/ldconfig
postuninstall scriptlet (using /bin/sh):
/sbin/ldconfig

Note erroneous extra newline on dump of postinstall scriptlet. It should be the same as preinstall, preuninstall and postuninstall.

Tested with cmake3 version 3.17.3. I observed same issue in 2021-04-12 nightly build too.

Edited by Brad King
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information