pkg_rpm does not seem to do anything similar, so executables end up with the same file mode as the rest of the files in the provider, which is usually a mode without the execution bit.
Workaround
A workaround is to set the execution bit for the pkg_files target, which will set it for the executable and all its runfiles, but this is not ideal. It would be better if the default was to preserve the file mode of the source file, I think that would work reasonably well.
Future work
This highlights a general issue with the include_runfiles attribute in pkg_files: because the executable and all its runfiles are grouped inside a single PackageFilesInfo provider, there is no granularity to have different attributes or prefixes for different files.
There is also the issue of executables being included twice, as the main target, and as one of the runfiles, which makes a warning show up (file mapped to two different destinations). This should probably have its own issue though.
The problem
pkg_tar
automatically detects the executable inpkg_files
: https://github.com/bazelbuild/rules_pkg/blob/c53ff51070c96b368188f057a6683d97c31b77f7/pkg/private/pkg_files.bzl#L395And sets its execution bit: https://github.com/bazelbuild/rules_pkg/blob/c53ff51070c96b368188f057a6683d97c31b77f7/pkg/private/pkg_files.bzl#L411
pkg_rpm
does not seem to do anything similar, so executables end up with the same file mode as the rest of the files in the provider, which is usually a mode without the execution bit.Workaround
A workaround is to set the execution bit for the
pkg_files
target, which will set it for the executable and all its runfiles, but this is not ideal. It would be better if the default was to preserve the file mode of the source file, I think that would work reasonably well.Future work
This highlights a general issue with the
include_runfiles
attribute inpkg_files
: because the executable and all its runfiles are grouped inside a singlePackageFilesInfo
provider, there is no granularity to have different attributes or prefixes for different files.There is also the issue of executables being included twice, as the main target, and as one of the runfiles, which makes a warning show up (file mapped to two different destinations). This should probably have its own issue though.