From 9907c958b3f487c33a8b9445e71618e8a41f103e Mon Sep 17 00:00:00 2001 From: adfoster-r7 Date: Tue, 30 Apr 2024 21:36:30 +0100 Subject: [PATCH] Ensure omnibus on windows can be rebuilt multiple times --- .github/workflows/verify.yml | 10 +++++++++- config/software/metasploit-framework.rb | 19 ++++++++++++++++++- config/software/rubygems.rb | 6 ++++-- local/cache | 2 +- 4 files changed, 32 insertions(+), 5 deletions(-) diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 6149bc97..7b318446 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -19,7 +19,7 @@ permissions: on: push: branches: - - '*' + - 'master' pull_request: branches: - '*' @@ -341,3 +341,11 @@ jobs: rem Don't run the main build itslef under `make`, as the process will be spawned under msys2 rem and the ridk.cmd Ruby installer will forcibly kill the msys2 process before attempting to install ruby ruby bin/omnibus build metasploit-framework + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: metasploit-windows-installer + path: | + metasploit-omnibus/pkg/*.msi + retention-days: 1 diff --git a/config/software/metasploit-framework.rb b/config/software/metasploit-framework.rb index 438c2f55..a15c5f28 100644 --- a/config/software/metasploit-framework.rb +++ b/config/software/metasploit-framework.rb @@ -1,8 +1,17 @@ name "metasploit-framework" + +# Detect a local checkout of metasploit-framework at '../metasploit-framework' - i.e. for the scenario of: +# - c:/temp/metasploit-omnibus +# - c:/temp/metasploit-framework (A local checkout of framework to use during the build process) +# but try and use 'C:/metasploit-framework' - as that's the metasploit-omnibus artifacts output directory +def has_windows_metasploit_framework_repo? + windows? && File.exist?('../metasploit-framework') && File.expand_path(File.join(Dir.pwd, "..", "metasploit-framework")) != "c:/metasploit-framework" +end + if linux? && File.exist?("/metasploit-framework") # supply current version of metasploit-framework at root of filesystem source path: "/metasploit-framework" -elsif windows? && File.exist?('../metasploit-framework') +elsif has_windows_metasploit_framework_repo? # supply current version of metasploit-framework relative to the current directory source path: "../metasploit-framework" else @@ -154,4 +163,12 @@ end end end + + # Workaround for a Windows bug with chef r7_9.0.23_custom that allows the `.git` folders through + # into the final build result, leading to the .exe being an extra 1gb in size + block do + self.project.exclusions.each do |exclusion| + Pathname(install_dir).glob(exclusion).each(&:rmtree) + end + end end diff --git a/config/software/rubygems.rb b/config/software/rubygems.rb index 68f5acf6..dca9ae9b 100644 --- a/config/software/rubygems.rb +++ b/config/software/rubygems.rb @@ -28,7 +28,7 @@ dependency "ruby" end -default_version "3.2.22" +default_version "3.5.10" if version && !source # NOTE: 2.1.11 is the last version of rubygems before the 2.2.x change to native gem install location @@ -40,7 +40,9 @@ # we pin the previously known tarballs. known_tarballs = { "3.1.4" => "d117187a8f016cbe8f52011ae02e858b", - "3.2.22"=> "b128d5493da2ec7a1da49a7189c04b35", + "3.2.22" => "b128d5493da2ec7a1da49a7189c04b35", + "3.3.26" =>"ba171c52fd9beda6dac7194413601795", + "3.5.10" => "70f46c096b4e11c42b0190cc3e3375e2" } known_tarballs.each do |vsn, md5| version vsn do diff --git a/local/cache b/local/cache index 984fcfb6..7f9a632b 160000 --- a/local/cache +++ b/local/cache @@ -1 +1 @@ -Subproject commit 984fcfb697151a942583ba831102c584d13773ad +Subproject commit 7f9a632b87580b39183cf472d54a5d56e05b36aa