Skip to content

Commit

Permalink
Include additional dependencies. (#3186)
Browse files Browse the repository at this point in the history
Some dependencies have additional dependencies that are installed in the systems. This PR ensures all the required dependencies and certs are included in the package.

Bug: flutter/flutter#136377
  • Loading branch information
godofredoc authored Oct 23, 2023
1 parent 7272bdb commit 5ea10ff
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 11 deletions.
10 changes: 10 additions & 0 deletions cipd_packages/ruby/third_party/ruby_ship/ruby_ship_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ fi
make
make install

# Copy default libraries to build directory
mkdir -p "$DIR/../build/bin/darwin_ruby/dylibs/"
find $(brew --prefix curl)/lib/ -name '*.dylib' -exec cp {} -f "$DIR/../build/bin/darwin_ruby/dylibs/" \;
find $(brew --prefix gdbm)/lib/ -name '*.dylib' -exec cp {} -f "$DIR/../build/bin/darwin_ruby/dylibs/" \;
find $(brew --prefix libffi)/lib/ -name '*.dylib' -exec cp {} -f "$DIR/../build/bin/darwin_ruby/dylibs/" \;
find $(brew --prefix libyaml)/lib/ -name '*.dylib' -exec cp {} -f "$DIR/../build/bin/darwin_ruby/dylibs/" \;
find $(brew --prefix openldap)/lib/ -name '*.dylib' -exec cp {} -f "$DIR/../build/bin/darwin_ruby/dylibs/" \;
find $(brew --prefix openssl)/lib/ -name '*.dylib' -exec cp {} -f "$DIR/../build/bin/darwin_ruby/dylibs/" \;
find $(brew --prefix readline)/lib/ -name '*.dylib' -exec cp {} -f "$DIR/../build/bin/darwin_ruby/dylibs/" \;

# Setting up reference directories.
RUBY_INSTALL_DIR="$(ls $DIR/../build/bin/${OS}_ruby/include)"
RUBY_VERSION_DIR="$(echo $RUBY_INSTALL_DIR | cut -d'-' -f 2)"
Expand Down
37 changes: 26 additions & 11 deletions cipd_packages/ruby/tools/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,36 @@ mkdir -p $DIR/../cleanup
curl https://cache.ruby-lang.org/pub/ruby/$RUBY_MAJOR_VERSION/$RUBY_FILE_NAME -o $DIR/../cleanup/$RUBY_FILE_NAME

# Install brew dependencies
brew install --build-from-source gdbm
brew install --build-from-source gmp
brew install --build-from-source libffi
brew install libyaml
brew install --build-from-source readline
brew install --build-from-source openssl@3
brew install --build-from-source m4
brew install curl
brew install openldap
brew reinstall --build-from-source gdbm
brew reinstall --build-from-source gmp
brew reinstall --build-from-source libffi
brew reinstall libyaml
brew reinstall --build-from-source readline
brew reinstall --build-from-source openssl@3
brew reinstall --build-from-source m4

bash -e $DIR/ruby_build.sh $DIR/../cleanup/$RUBY_FILE_NAME

# Copy certificates bundle for mac x64.
if [ -f /usr/local/etc/ca-certificates/cert.pem ]; then
cp /usr/local/etc/ca-certificates/cert.pem $DIR/../build/bin/darwin_ruby/
fi;

# Copy certificates bundle for mac x64.
if [ -f /opt/homebrew/etc/openssl@3/cert.pem ]; then
cp /opt/homebrew/etc/openssl@3/cert.pem $DIR/../build/bin/darwin_ruby/
fi;

# Update wrapper scripts to make them use libraries from new location.
sed -i'' -e 's/bindir="\${0%\/\*}"/&\nLIBSPATH="\$( cd -- "\$(dirname "\$0")" >\/dev\/null 2>\&1 ; pwd -P )\/..\/dylibs"\nexport DYLD_FALLBACK_LIBRARY_PATH=\$LIBSPATH:\$DYLD_FALLBACK_LIBRARY_PATH/' $DIR/../build/bin/darwin_ruby/bin/gem
sed -i'' -e 's/bindir="\${0%\/\*}"/&\nLIBSPATH="\$( cd -- "\$(dirname "\$0")" >\/dev\/null 2>\&1 ; pwd -P )\/..\/dylibs"\nexport DYLD_FALLBACK_LIBRARY_PATH=\$LIBSPATH:\$DYLD_FALLBACK_LIBRARY_PATH/' $DIR/../build/bin/darwin_ruby/bin/bundler
sed -i'' -e 's/bindir="\${0%\/\*}"/&\nLIBSPATH="\$( cd -- "\$(dirname "\$0")" >\/dev\/null 2>\&1 ; pwd -P )\/..\/dylibs"\nexport DYLD_FALLBACK_LIBRARY_PATH=\$LIBSPATH:\$DYLD_FALLBACK_LIBRARY_PATH/' $DIR/../build/bin/darwin_ruby/bin/bundle
sed -i'' -e 's/bindir="\${0%\/\*}"/&\nLIBSPATH="\$( cd -- "\$(dirname "\$0")" >\/dev\/null 2>\&1 ; pwd -P )\/..\/dylibs"\nexport DYLD_FALLBACK_LIBRARY_PATH=\$LIBSPATH:\$DYLD_FALLBACK_LIBRARY_PATH/' $DIR/../build/bin/darwin_ruby/bin/pod
sed -i'' -e 's/bindir="\${0%\/\*}"/&\nSSL_CERTS="\$( cd -- "\$(dirname "\$0")" >\/dev\/null 2>\&1 ; pwd -P )\/..\/cert.pem"\nLIBSPATH="\$( cd -- "\$(dirname "\$0")" >\/dev\/null 2>\&1 ; pwd -P )\/..\/dylibs"\nexport DYLD_FALLBACK_LIBRARY_PATH=\$LIBSPATH:\$DYLD_FALLBACK_LIBRARY_PATH\nexport SSL_CERT_FILE="\${SSL_CERTS}"/' $DIR/../build/bin/darwin_ruby/bin/gem
sed -i'' -e 's/bindir="\${0%\/\*}"/&\nSSL_CERTS="\$( cd -- "\$(dirname "\$0")" >\/dev\/null 2>\&1 ; pwd -P )\/..\/cert.pem"\nLIBSPATH="\$( cd -- "\$(dirname "\$0")" >\/dev\/null 2>\&1 ; pwd -P )\/..\/dylibs"\nexport DYLD_FALLBACK_LIBRARY_PATH=\$LIBSPATH:\$DYLD_FALLBACK_LIBRARY_PATH\nexport SSL_CERT_FILE="\${SSL_CERTS}"/' $DIR/../build/bin/darwin_ruby/bin/bundler
sed -i'' -e 's/bindir="\${0%\/\*}"/&\nSSL_CERTS="\$( cd -- "\$(dirname "\$0")" >\/dev\/null 2>\&1 ; pwd -P )\/..\/cert.pem"\nLIBSPATH="\$( cd -- "\$(dirname "\$0")" >\/dev\/null 2>\&1 ; pwd -P )\/..\/dylibs"\nexport DYLD_FALLBACK_LIBRARY_PATH=\$LIBSPATH:\$DYLD_FALLBACK_LIBRARY_PATH\nexport SSL_CERT_FILE="\${SSL_CERTS}"/' $DIR/../build/bin/darwin_ruby/bin/bundle
sed -i'' -e 's/bindir="\${0%\/\*}"/&\nSSL_CERTS="\$( cd -- "\$(dirname "\$0")" >\/dev\/null 2>\&1 ; pwd -P )\/..\/cert.pem"\nLIBSPATH="\$( cd -- "\$(dirname "\$0")" >\/dev\/null 2>\&1 ; pwd -P )\/..\/dylibs"\nexport DYLD_FALLBACK_LIBRARY_PATH=\$LIBSPATH:\$DYLD_FALLBACK_LIBRARY_PATH\nexport SSL_CERT_FILE="\${SSL_CERTS}"/' $DIR/../build/bin/darwin_ruby/bin/pod

# Patch FFI to find libc.dylib in the standard location.
find $DIR/../build -name library.rb -exec sed -i'' -e 's/LIBC = FFI\:\:Platform\:\:LIBC/LIBC = \x27\/usr\/lib\/libc.dylib\x27/' {} \;

# Ensure all the command are working properly
$DIR/../build/bin/bundle --version
Expand Down

0 comments on commit 5ea10ff

Please sign in to comment.