環境
- OS: Windows 10 Pro Version 1709 Build 16299.19
- MSYS2
- Ruby2.4(RubyInstaller2, ruby 2.4.2p198 (2017-09-14 revision 59899) [x64-mingw32])
普通にビルドする
bundler 使うので入れる
gem install bundler
README にある通りに,Inno-Setup (unicode) をインストールして,
(git config --global core.autocrlf false
しておいた方がよいかも)
set PATH=%PATH%c:\msys64\usr\bin;c:\msys64\mingw64\bin;"c:\Program Files (x86)\Inno Setup 5" git clone https://github.com/oneclick/rubyinstaller2.git cd rubyinstaller2 bundle install --path vendor/bundle bundle exec rake rubyinstaller:ruby-2.4.2-x64
packages/rubyinstaller/recipes/
以下に生成物ができる
インストールするRubyにパッチを当てる
まず,RubyInstaller2 の pacmanレポジトリを使ってパッチを当てたRuby をビルドする
レポジトリを取ってきて,
git clone https://github.com/oneclick/rubyinstaller2-packages.git
以下のパッチを
mingw-w64-ruby\0007-fix-onedrive-file-ondemand-issue.patch
に保存して,
diff --git a/win32/win32.c b/win32/win32.c index 62801dae71..7e8afb2ddc 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -4958,7 +4958,7 @@ rb_w32_read_reparse_point(const WCHAR *path, rb_w32_reparse_buffer_t *rp, ret = rp->SymbolicLinkReparseBuffer.PrintNameLength; *len = ret / sizeof(WCHAR); } - else { /* IO_REPARSE_TAG_MOUNT_POINT */ + else if (rp->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) { static const WCHAR *volume = L"Volume{"; enum {volume_prefix_len = rb_strlen_lit("\\??\\")}; name = ((char *)rp->MountPointReparseBuffer.PathBuffer + @@ -4971,6 +4971,9 @@ rb_w32_read_reparse_point(const WCHAR *path, rb_w32_reparse_buffer_t *rp, memcmp(name, volume, sizeof(volume) - 1 * sizeof(WCHAR)) == 0) return -1; } + else { + return -1; + } *result = name; if (e) { if ((char *)name + ret + sizeof(WCHAR) > (char *)rp + bufsize)
PKGBUILD
を編集する
source
に patch ファイルを追加prepare(){}
に patch を適用する処理を追加- SHA256 hash を更新:
ridk exec sh -c "updpkgsums PKGBUILD
diff --git a/mingw-w64-ruby24/PKGBUILD b/mingw-w64-ruby24/PKGBUILD index 084a994..fc3d144 100644 --- a/mingw-w64-ruby24/PKGBUILD +++ b/mingw-w64-ruby24/PKGBUILD @@ -21,6 +21,7 @@ source=("https://cache.ruby-lang.org/pub/ruby/${pkgver%.*}/${_realname}-${pkgver 0002-use-gnu-printf.patch 0004-exclude-changelog-from-rdoc.patch 0006-fix-conversion-warning-win32-powl.patch + 0007-fix-onedrive-file-ondemand-issue.patch ruby.ico rubyw.ico) @@ -31,6 +32,7 @@ sha256sums=('08e72d0cbe870ed1317493600fbbad5995ea3af2d0166585e7ecc85d04cc50dc' '578bd0830fe96efc7656c732ec46b0658fc436a7a30d8945cf3b8240797809f0' '389236bdca5f283adde9b4b56febcfc25e228716e06a0edc21ea8fd7f27b75fa' 'e7f83bc6e3b7ddadb5e3b14aa7d3a4e30eb97aea02df38796ca78714ad20e9b7' + '4d845e75ea4558bebbce51f6f2c858f9c6db96ca5fd4757dbf07b63c6b9582e9' '6c80ba2ca49840e387a08b7fedc6e7acd298ac2ec853155209efb2af20397b22' 'c30fb04ac0e88ba634daaa811a81ea5a75027646617b895acd14df9518a4a55a') @@ -40,6 +42,7 @@ prepare() { patch -p1 -i ${srcdir}/0002-use-gnu-printf.patch patch -p1 -i ${srcdir}/0004-exclude-changelog-from-rdoc.patch patch -p1 -i ${srcdir}/0006-fix-conversion-warning-win32-powl.patch + patch -p1 --ignore-whitespace -i ${srcdir}/0007-fix-onedrive-file-ondemand-issue.patch autoreconf -fi }
ビルド(コマンドプロンプトではなくMSYS2から)
cd rubyinstaller2-packages\mingw-w64-ruby24 MINGW_INSTALLS=mingw64 makepkg-mingw -sLf
mingw-w64-x86_64-ruby24-2.4.2-1-any.pkg.tar.xz
ができるので,msys64\tmp\rubyinstaller
に置く
再びインストーラ生成
ビルドしたRubyを使うようにRake ファイルを編集して再度ビルドする.
diff --git a/recipes/unpack/50-install-msys-packages.rake b/recipes/unpack/50-install-msys-packages.rake index bddfa89..5290cb4 100644 --- a/recipes/unpack/50-install-msys-packages.rake +++ b/recipes/unpack/50-install-msys-packages.rake @@ -8,11 +8,13 @@ file ruby_exe => [self.repo_added] do %w[var/cache/pacman/pkg var/lib/pacman].each do |dir| mkdir_p File.join(unpackdir, dir) end - + require "open3" + o, s = Open3.capture2("pacman -Ss #{install_packages.map(&:inspect).join(" ")}") + rb_subver = o.split("\n")[0].split(" ")[1] msys_sh <<-EOT mount #{unpackdir_abs.inspect} #{pmrootdir.inspect} && pacman --root #{pmrootdir.inspect} -Sy && - pacman --root #{pmrootdir.inspect} --noconfirm -S #{install_packages.map(&:inspect).join(" ")}; + pacman --root #{pmrootdir.inspect} --noconfirm -U /tmp/rubyinstaller/#{install_packages.map(&:inspect).join(" ")}-#{rb_subver}-any.pkg.tar.xz; umount #{pmrootdir.inspect} EOT touch ruby_exe
出来た 7zip を展開してPATHを通して終了.