From 1a26964b5a4af518020682f03785abab1a8524e2 Mon Sep 17 00:00:00 2001 From: Gio Lodi Date: Thu, 1 Jun 2023 23:01:56 +1000 Subject: [PATCH] Remove an absolute path that messed up the checksum --- Gutenberg/Gutenberg.podspec | 14 +++--- Gutenberg/cocoapods_helpers.rb | 78 ---------------------------------- Podfile.lock | 2 +- 3 files changed, 9 insertions(+), 85 deletions(-) diff --git a/Gutenberg/Gutenberg.podspec b/Gutenberg/Gutenberg.podspec index 40ce565fc49b..24443940e2ae 100644 --- a/Gutenberg/Gutenberg.podspec +++ b/Gutenberg/Gutenberg.podspec @@ -42,9 +42,11 @@ Pod::Spec.new do |s| # See https://github.com/CocoaPods/CocoaPods/issues/10288#issuecomment-1517711223 # s.source = { http: xcframework_archive_url } archive_name = "Gutenberg-#{gutenberg_version}.tar.gz" - absolute_download_path = File.join(GUTENBERG_DOWNLOADS_DIRECTORY, archive_name) # Always use relative paths, otherwise the checksums in the lockfile will change from machine to machine - relative_download_path = Pathname.new(absolute_download_path).relative_path_from(__dir__).to_s + relative_extracted_archive_directory = Pathname.new("#{GUTENBERG_ARCHIVE_DIRECTORY}").relative_path_from(__dir__).to_s + relative_download_directory = Pathname.new(GUTENBERG_DOWNLOADS_DIRECTORY).relative_path_from(__dir__).to_s + relative_download_path = File.join(relative_download_directory, archive_name) + s.source = { http: "file://#{relative_download_path}" } s.vendored_frameworks = [ @@ -55,17 +57,17 @@ Pod::Spec.new do |s| 'yoga.xcframework' ].map do |f| # This needs to be a relative path to the local extraction location and account for the archive folder structure. - Pathname.new("#{GUTENBERG_ARCHIVE_DIRECTORY}/Frameworks/#{f}").relative_path_from(__dir__).to_s + File.join(relative_extracted_archive_directory, 'Frameworks', f) end # Print the message here because the prepare_command output is not forwarded by CocoaPods puts "Will skip downloading Gutenberg archive because it already exists at #{relative_download_path}" if File.exist? relative_download_path s.prepare_command = <<-CMD - mkdir -p #{GUTENBERG_DOWNLOADS_DIRECTORY} + mkdir -p #{relative_download_directory} if [[ ! -f "#{relative_download_path}" ]]; then curl --progress-bar #{xcframework_archive_url} -o #{relative_download_path} fi - mkdir -p #{GUTENBERG_ARCHIVE_DIRECTORY} - tar -xzf #{relative_download_path} --directory=#{GUTENBERG_ARCHIVE_DIRECTORY} + mkdir -p #{relative_extracted_archive_directory} + tar -xzf #{relative_download_path} --directory=#{relative_extracted_archive_directory} CMD end diff --git a/Gutenberg/cocoapods_helpers.rb b/Gutenberg/cocoapods_helpers.rb index c4d7a3a30100..ce7eaad42230 100644 --- a/Gutenberg/cocoapods_helpers.rb +++ b/Gutenberg/cocoapods_helpers.rb @@ -127,81 +127,3 @@ def archive_url(commit:) xcframework_storage_url = 'https://d2twmm2nzpx3bg.cloudfront.net' "#{xcframework_storage_url}/Gutenberg-#{commit}.tar.gz" end - -def gutenberg_pre_install_hook - # At this time, we only support XCFramework-commit builds - commit = GUTENBERG_CONFIG[:commit] - if commit.nil? - puts 'Skipping Gutenberg XCFramework download because no commit was given.' - return - end - - url = archive_url(commit: commit) - archive_download_path = File.join(GUTENBERG_DOWNLOADS_DIRECTORY, File.basename(url)) - - if File.exist?(archive_download_path) - puts "Skipping download for #{url} because archive already exists at #{archive_download_path}." - else - download(archive_url: url, destination: archive_download_path) - end - - extract( - archive: archive_download_path, - destination: GUTENBERG_ARCHIVE_DIRECTORY - ) -end - -private - -# rubocop:disable Metrics/AbcSize -def download(archive_url:, destination:) - puts "Attempting to download #{archive_url} to #{destination}..." - - FileUtils.mkdir_p(File.dirname(destination)) - - # Perform HTTP HEAD request to retrieve file size - uri = URI.parse(archive_url) - http = Net::HTTP.new(uri.host, uri.port) - http.use_ssl = true - response = http.head(uri.path) - - # Check if the response is successful and contains Content-Length header - content_length_key = 'Content-Length' - raise "Failed to retrieve file information: #{response.code} #{response.message}" unless response.is_a?(Net::HTTPSuccess) && response.key?(content_length_key) - - file_size = response[content_length_key].to_i - - # Check file size - raise 'File size is 0. Aborting download.' if file_size.zero? - - puts "File size: #{(file_size / (1024.0 * 1024.0)).round(2)} MB" - - progress_bar = ProgressBar.create(title: 'Downloading Gutenberg XCFrameworks archive', total: file_size, format: '%t |%B| %p%%') - - http.request_get(uri.path) do |archive_response| - File.open(destination, 'wb') do |file| - archive_response.read_body do |chunk| - file.write(chunk) - progress_bar.progress += chunk.length - end - end - end - - progress_bar.finish - - puts 'Finished downloading.' -end -# rubocop:enable Metrics/AbcSize - -def extract(archive:, destination:) - FileUtils.rm_rf(destination) - FileUtils.mkdir_p(destination) - - puts "Extracting #{archive} to #{destination}..." - - Zlib::GzipReader.open(archive) do |gzip_file| - Archive::Tar::Minitar.unpack(gzip_file, destination) - end - - puts 'Finished extracting.' -end diff --git a/Podfile.lock b/Podfile.lock index e7c8e93002cd..6af6c884a7d1 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -255,7 +255,7 @@ SPEC CHECKSUMS: Gridicons: 17d660b97ce4231d582101b02f8280628b141c9a GTMAppAuth: 0ff230db599948a9ad7470ca667337803b3fc4dd GTMSessionFetcher: 5595ec75acf5be50814f81e9189490412bad82ba - Gutenberg: 1f44813dc914ad38cccf0bd9eb3044c05922e3c7 + Gutenberg: f6ab396a049c97e753a6af5a61b0223e9c881d22 JTAppleCalendar: 932cadea40b1051beab10f67843451d48ba16c99 Kanvas: f932eaed3d3f47aae8aafb6c2d27c968bdd49030 MediaEditor: 20cdeb46bdecd040b8bc94467ac85a52b53b193a