@@ -84,6 +84,10 @@ task extract: [:fetch] do
84
84
File . open ( target_file , "rb" ) do |file |
85
85
Gem ::Package . new ( "" ) . extract_tar_gz ( file , target_directory )
86
86
end
87
+
88
+ # Fix file permissions after extraction
89
+ puts "Fixing file permissions in #{ target_directory } "
90
+ Helpers . fix_file_permissions ( target_directory )
87
91
end
88
92
end
89
93
@@ -140,6 +144,9 @@ task push_to_rubygems: [
140
144
end
141
145
142
146
module Helpers
147
+ # Files that should have executable permissions (755) in the gem
148
+ EXECUTABLE_FILES = [ "libdatadog-crashtracking-receiver" , "libdatadog_profiling.so" ] . freeze
149
+
143
150
def self . each_github_release_variant
144
151
LIB_GITHUB_RELEASES . each do |variant |
145
152
file = variant . fetch ( :file )
@@ -169,6 +176,29 @@ module Helpers
169
176
puts ( "-" * 80 )
170
177
end
171
178
179
+ def self . fix_file_permissions ( directory )
180
+ Dir . glob ( "#{ directory } /**/*" ) . each do |path |
181
+ next unless File . file? ( path )
182
+
183
+ filename = File . basename ( path )
184
+ current_permissions = File . stat ( path ) . mode & 0777
185
+
186
+ if EXECUTABLE_FILES . include? ( filename )
187
+ # Should be executable (755), fix if not
188
+ if current_permissions != 0755
189
+ puts "Fixing permissions for #{ filename } : #{ current_permissions . to_s ( 8 ) } -> 755"
190
+ FileUtils . chmod ( 0755 , path )
191
+ end
192
+ else
193
+ # Should be non-executable (644), fix if not
194
+ if current_permissions != 0644
195
+ puts "Fixing permissions for #{ filename } : #{ current_permissions . to_s ( 8 ) } -> 644"
196
+ FileUtils . chmod ( 0644 , path )
197
+ end
198
+ end
199
+ end
200
+ end
201
+
172
202
def self . files_for (
173
203
*included_platforms ,
174
204
excluded_files : [
0 commit comments