Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-14385

CPack RPM: %pretrans scriptlets always exist [rhel-8]

    • Icon: Bug Bug
    • Resolution: Done-Errata
    • Icon: Major Major
    • rhel-8.10
    • rhel-8.8.0.z
    • cmake
    • cmake-3.26.5-1.el8
    • Yes
    • Important
    • ZStream
    • rhel-sst-pt-llvm-rust-go
    • ssg_platform_tools
    • 12
    • 14
    • 2
    • QE ack
    • False
    • Hide

      None

      Show
      None
    • No
    • Red Hat Enterprise Linux
    • None
    • Approved Blocker
    • All
    • None

      What were you trying to do that didn't work?

      !4387 (merged) introduced support for %posttrans and %pretrans scriptlets, however a consequence of these scriptlets being added is that they will be added regardless of if you make use of the scripts for pre/post transaction, meaning you cannot install a package generated via CMake 3.18.x if you are attempting to do so using RedHat's Anaconda installation process (e.g custom ISO, kickstart).

      Issue is related to:
      https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#pretrans

      Upstream Modules/Internal/CPack/CPackRPM.cmake contains the following:

       

        46   set_spec_script_if_enabled(
        47     "pretrans"
        48     "${PACKAGE_NAME}"
        49     "${CPACK_RPM_SPEC_PRETRANS}")

       

      It seems it has not been backported in the rpm we ship.

      See https://gitlab.kitware.com/cmake/cmake/-/issues/21345

      Please provide the package NVR for which bug is seen:

      cmake-3.20.2

      How reproducible:

      Always

      Steps to reproduce

       

      # cat CMakeLists.txt 
      project (test_pretrans)
      cmake_minimum_required (VERSION 3.0)
      add_executable(main ${PROJECT_SOURCE_DIR}/hello.c)
      set(VERSION "1.0.1")
      set(CPACK_PACKAGE_VERSION ${VERSION})
      set(CPACK_GENERATOR "RPM")
      set(CPACK_PACKAGE_NAME "test-pretrans")
      set(CPACK_PACKAGE_RELEASE 1)
      set(CPACK_PACKAGE_CONTACT "RH Employee")
      set(CPACK_PACKAGE_VENDOR "Red Hat Test")
      set(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
      set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_PACKAGE_RELEASE}.${CMAKE_SYSTEM_PROCESSOR}")
      include(CPack)
      
      # cd build && cmake .. ; cd -
      -- The C compiler identification is GNU 8.5.0
      -- The CXX compiler identification is GNU 8.5.0
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: /usr/bin/cc - skipped
      -- Detecting C compile features
      -- Detecting C compile features - done
      -- Detecting CXX compiler ABI info
      -- Detecting CXX compiler ABI info - done
      -- Check for working CXX compiler: /usr/bin/c++ - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      -- Configuring done
      -- Generating done
      -- Build files have been written to: /root/test/build
      
      # cd build && make package; cd -
      [ 50%] Building C object CMakeFiles/main.dir/hello.c.o
      [100%] Linking C executable main
      [100%] Built target main
      Run CPack packaging tool...
      CPack: Create package using RPM
      CPack: Install projects
      CPack: - Run preinstall target for: test_pretrans
      CPack: - Install project: test_pretrans []
      CPack: Create package
      CPackRPM: Will use GENERATED spec file: /root/test/build/_CPack_Packages/Linux/RPM/SPECS/test-pretrans.spec
      CPack: - package: /root/test/build/test-pretrans-1.0.1-1.x86_64.rpm generated.
      

       

      Expected results

      Do not add this if no scripts for pretrans.

      Actual results

      # rpm -vqp --requires /root/test/build/test-pretrans-1.0.1-1.x86_64.rpm
      interp,posttrans: /bin/sh
      interp,pretrans: /bin/sh                   <<<<<
      pre,interp: /bin/sh
      post,interp: /bin/sh
      preun,interp: /bin/sh
      postun,interp: /bin/sh
      rpmlib: rpmlib(CompressedFileNames) <= 3.0.4-1
      rpmlib: rpmlib(FileDigests) <= 4.6.0-1
      rpmlib: rpmlib(PayloadFilesHavePrefix) <= 4.0-1
      rpmlib: rpmlib(PayloadIsXz) <= 5.2-1 

              tstellar@redhat.com Thomas Stellard
              rhn-support-cbesson Christophe Besson
              Errata Tool
              Thomas Stellard Thomas Stellard
              Lenka Špačková Lenka Špačková
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: