ganga don't packing all files that davinci need.

A minimum project to reproduce this issue: https://gitlab.cern.ch/xuzh/mini_test .

I am using DaVinci/v46r11 which should be the lastest version for run2 samples for now. I set it up with lb-dev and git lb-checkout because I need to make some changes. Everything is fine either I test it locally or run make test. But when I submit it to grid using Ganga, I got this error message:

Traceback (most recent call last):
  File "/cvmfs/lhcb.cern.ch/lib/lhcb/GAUDI/GAUDI_v38r3/InstallArea/x86_64_v2-el9-clang16-opt/bin/gaudirun.py", line 585, in <module>
    exec(o, g, l)
  File "<string>", line 1, in <module>
  File "/cvmfs/lhcb.cern.ch/lib/lhcb/GAUDI/GAUDI_v38r3/InstallArea/x86_64_v2-el9-clang16-opt/bin/gaudirun.py", line 544, in __call__
    importOptions(arg)
  File "/cvmfs/lhcb.cern.ch/lib/lhcb/GAUDI/GAUDI_v38r3/InstallArea/x86_64_v2-el9-clang16-opt/python/GaudiKernel/ProcessJobOptions.py", line 552, in importOptions
    _import_function_mapping[ext](optsfile)
  File "/cvmfs/lhcb.cern.ch/lib/lhcb/GAUDI/GAUDI_v38r3/InstallArea/x86_64_v2-el9-clang16-opt/python/GaudiKernel/ProcessJobOptions.py", line 486, in _import_python
    exec(code, {"__file__": file})
  File "/tmp/921901747/DaVinci_option.py", line 21, in <module>
    import StrippingSelections
  File "/tmp/921901747/DaVinciDev_46.11/InstallArea/x86_64_v2-el9-clang16-opt/python/StrippingSelections/__init__.py", line 23, in <module>
    wgDirs = os.listdir(os.environ['STRIPPINGSELECTIONSROOT'] +
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/921901747/DaVinciDev_46.11/Phys/StrippingSelections/python/StrippingSelections'

I also tested it with different Davinci version, then I found it only happens on v46rx. So I checked Makefiles and printed the current directory when ganga job is running. Then in the DaVinci/v45r7 test, I see:

# --> Including file '/tmp/921896730/DaVinci_option.py'
/tmp/921896730/cmake-input-sandbox.tgz
/tmp/921896730/std.out
/tmp/921896730/__timestamp__
/tmp/921896730/job.info
/tmp/921896730/pilot.cfg
/tmp/921896730/DaVinci_option.py
/tmp/921896730/run
/tmp/921896730/jobScripts-494_d6cc5219-3d54-4145-880c-12d95ad7d062.tar.gz
/tmp/921896730/jobDescription.xml
/tmp/921896730/diracInputFiles_494_5aafaa97-3296-41bf-8dbf-3e76761eb3e6.tgz
/tmp/921896730/DaVinciDev_v45r7
/tmp/921896730/opts
/tmp/921896730/jobScript
/tmp/921896730/DaVinciDev_v45r7/CMakeLists.txt
/tmp/921896730/DaVinciDev_v45r7/Phys
/tmp/921896730/DaVinciDev_v45r7/InstallArea
/tmp/921896730/DaVinciDev_v45r7/Phys/StrippingSelections
/tmp/921896730/DaVinciDev_v45r7/Phys/StrippingSelections/.project
/tmp/921896730/DaVinciDev_v45r7/Phys/StrippingSelections/CMakeLists.txt
/tmp/921896730/DaVinciDev_v45r7/Phys/StrippingSelections/.pydevproject
/tmp/921896730/DaVinciDev_v45r7/Phys/StrippingSelections/doc
/tmp/921896730/DaVinciDev_v45r7/Phys/StrippingSelections/python
/tmp/921896730/DaVinciDev_v45r7/Phys/StrippingSelections/options
/tmp/921896730/DaVinciDev_v45r7/Phys/StrippingSelections/tests
/tmp/921896730/DaVinciDev_v45r7/InstallArea/x86_64-centos7-gcc9-opt
/tmp/921896730/DaVinciDev_v45r7/InstallArea/x86_64-centos7-gcc9-opt/DaVinciDev.xenv
/tmp/921896730/DaVinciDev_v45r7/InstallArea/x86_64-centos7-gcc9-opt/DaVinciDevConfig.cmake
/tmp/921896730/DaVinciDev_v45r7/InstallArea/x86_64-centos7-gcc9-opt/python.zip
/tmp/921896730/DaVinciDev_v45r7/InstallArea/x86_64-centos7-gcc9-opt/manifest.xml
/tmp/921896730/DaVinciDev_v45r7/InstallArea/x86_64-centos7-gcc9-opt/DaVinciDevConfigVersion.cmake
/tmp/921896730/DaVinciDev_v45r7/InstallArea/x86_64-centos7-gcc9-opt/DaVinciDev.xenvc
/tmp/921896730/DaVinciDev_v45r7/InstallArea/x86_64-centos7-gcc9-opt/lib
/tmp/921896730/DaVinciDev_v45r7/InstallArea/x86_64-centos7-gcc9-opt/python
/tmp/921896730/DaVinciDev_v45r7/InstallArea/x86_64-centos7-gcc9-opt/include
/tmp/921896730/DaVinciDev_v45r7/InstallArea/x86_64-centos7-gcc9-opt/cmake
/tmp/921896730/opts/extra_opts_494_.py
/tmp/921896730/jobScript/GaudiExec_xzh6313_Job_494_5aafaa97-3296-41bf-8dbf-3e76761eb3e6_script.py
Trying yo import some StrippingSelections
Done
# <-- End of file '/tmp/921896730/DaVinci_option.py'

But for DaVinci/46r11 test, I see

# --> Including file '/tmp/921901747/DaVinci_option.py'
/tmp/921901747/pilot.cfg
/tmp/921901747/job.info
/tmp/921901747/jobDescription.xml
/tmp/921901747/diracInputFiles_495_353fb8f9-3f90-4192-abc1-4ca6631f0860.tgz
/tmp/921901747/jobScripts-495_00149ee2-0ba8-4bec-9b98-4b3cc677533f.tar.gz
/tmp/921901747/std.out
/tmp/921901747/cmake-input-sandbox.tgz
/tmp/921901747/DaVinci_option.py
/tmp/921901747/__timestamp__
/tmp/921901747/run
/tmp/921901747/opts
/tmp/921901747/jobScript
/tmp/921901747/DaVinciDev_46.11
/tmp/921901747/opts/extra_opts_495_.py
/tmp/921901747/jobScript/GaudiExec_xzh6313_Job_495_353fb8f9-3f90-4192-abc1-4ca6631f0860_script.py
/tmp/921901747/DaVinciDev_46.11/CMakeLists.txt
/tmp/921901747/DaVinciDev_46.11/InstallArea
/tmp/921901747/DaVinciDev_46.11/InstallArea/x86_64_v2-el9-clang16-opt
/tmp/921901747/DaVinciDev_46.11/InstallArea/x86_64_v2-el9-clang16-opt/manifest.xml
/tmp/921901747/DaVinciDev_46.11/InstallArea/x86_64_v2-el9-clang16-opt/DaVinciDev.xenv
/tmp/921901747/DaVinciDev_46.11/InstallArea/x86_64_v2-el9-clang16-opt/.data_packages_found.txt
/tmp/921901747/DaVinciDev_46.11/InstallArea/x86_64_v2-el9-clang16-opt/DaVinciDev.xenvc
/tmp/921901747/DaVinciDev_46.11/InstallArea/x86_64_v2-el9-clang16-opt/python
/tmp/921901747/DaVinciDev_46.11/InstallArea/x86_64_v2-el9-clang16-opt/include
/tmp/921901747/DaVinciDev_46.11/InstallArea/x86_64_v2-el9-clang16-opt/lib
Trying yo import some StrippingSelections

It seems that ganga didn't pack (or copy) the Phys/ directory of DaVinci/46r11 in right way. I also noticed this is controlled by GangaTools.cmake file:

  foreach(src CMakeLists.txt cmt ${packages})
    if(EXISTS ${CMAKE_SOURCE_DIR}/${src})
      if(IS_DIRECTORY ${CMAKE_SOURCE_DIR}/${src})
        set(copy_sources ${copy_sources}
            COMMAND mkdir -p ${dist_base_dir}/${src}
            COMMAND cp -a ${src}/. ${dist_base_dir}/${src}/.)
      else()
        set(copy_sources ${copy_sources}
            COMMAND cp -a ${src} ${dist_base_dir}/${src})
      endif()
    endif()
  endforeach()

But I am not familar with these building chain, so I cannot find how the ${packages} is defined or passed. I end up here, I hope you can have a check.