Skip to content

Commit

Permalink
Split install_dependencies into two separate functions (closes #24).
Browse files Browse the repository at this point in the history
* Added `install_build_dependencies` and `install_runtime_dependencies`.
* Added `install_libraries`.
* Only install `zip` if the command is missing.
* Only install `awk` if the command is missing.
  • Loading branch information
postmodern committed Jun 25, 2024
1 parent 913fa4e commit b53628e
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 26 deletions.
69 changes: 55 additions & 14 deletions ronin-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -426,19 +426,19 @@ function termux_install_nokogiri()
}

#
# Install external dependencies for ronin.
# Install libraries and headers for other ronin's dependencies.
#
function install_dependencies()
function install_libraries()
{
case "$package_manager" in
dnf|yum)libraries=(libyaml-devel zip) ;;
zypper) libraries=(awk libyaml-devel zip) ;;
apt) libraries=(libyaml-dev zip) ;;
termux) libraries=(binutils libyaml libxml2 libxslt zip) ;;
*) libraries=(libyaml zip) ;;
dnf|yum)libraries=(libyaml-devel) ;;
zypper) libraries=(libyaml-devel) ;;
apt) libraries=(libyaml-dev) ;;
termux) libraries=(libyaml libxml2 libxslt) ;;
*) libraries=(libyaml) ;;
esac

log "Installing external dependencies ..."
log "Installing libraries ..."
install_packages "${libraries[@]}" || \
warn "Failed to install external dependencies. Proceeding anyways."

Expand All @@ -448,6 +448,51 @@ function install_dependencies()
fi
}

#
# Install awk, if it's already not installed.
#
function auto_install_awk()
{
if ! command -v awk >/dev/null; then
log "Installing awk ..."
install_packages awk || fail "Failed to install awk!"
fi
}

#
# Install external dependencies for ronin.
#
function install_build_dependencies()
{
auto_install_binutils
auto_install_cc
auto_install_cpp
auto_install_make
auto_install_pkg_config
auto_install_awk
install_libraries
}

#
# Installs zip, if it's not installed.
#
function auto_install_zip()
{
if ! command -v zip >/dev/null; then
log "Installing bundler ..."
install_packages zip || \
warn "Failed to install zip. Proceeding anyways."
fi
}

#
# Install runtime dependencies for ronin.
#
function install_runtime_dependencies()
{
auto_install_zip
}

#
# Print the --help usage.
#
Expand Down Expand Up @@ -505,14 +550,10 @@ function parse_options()
parse_options "$@" || exit $?
detect_system
auto_install_git
auto_install_binutils
auto_install_cc
auto_install_cpp
auto_install_make
auto_install_pkg_config
auto_install_ruby
auto_install_bundler
install_dependencies
install_build_dependencies
install_runtime_dependencies

mkdir -p "$ronin_src_dir"
pushd "$ronin_src_dir"/ >/dev/null
Expand Down
65 changes: 53 additions & 12 deletions ronin-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -363,17 +363,16 @@ function termux_install_nokogiri()
}

#
# Install external dependencies for ronin.
# Install libraries and headers for other ronin's dependencies.
#
function install_dependencies()
function install_libraries()
{
case "$package_manager" in
dnf|yum)libraries=(libyaml-devel git zip) ;;
termux) libraries=(libxml2 libxslt git zip) ;;
*) libraries=(git zip) ;;
dnf|yum)libraries=(libyaml-devel) ;;
termux) libraries=(libxml2 libxslt) ;;
esac

log "Installing external dependencies ..."
log "Installing libraries ..."
install_packages "${libraries[@]}" || \
warn "Failed to install external dependencies. Proceeding anyways."

Expand All @@ -383,6 +382,52 @@ function install_dependencies()
fi
}

#
# Install external dependencies for ronin.
#
function install_build_dependencies()
{
auto_install_binutils
auto_install_cc
auto_install_cpp
auto_install_make
auto_install_pkg_config
install_libraries
}

#
# Installs git, if it's not installed.
#
function auto_install_git()
{
if ! command -v git >/dev/null; then
log "Installing bundler ..."
install_packages git || \
warn "Failed to install git. Proceeding anyways."
fi
}

#
# Installs zip, if it's not installed.
#
function auto_install_zip()
{
if ! command -v zip >/dev/null; then
log "Installing bundler ..."
install_packages zip || \
warn "Failed to install zip. Proceeding anyways."
fi
}

#
# Install runtime dependencies for ronin.
#
function install_runtime_dependencies()
{
auto_install_git
auto_install_zip
}

#
# Print the --help usage.
#
Expand Down Expand Up @@ -439,13 +484,9 @@ function parse_options()

parse_options "$@" || exit $?
detect_system
auto_install_binutils
auto_install_cc
auto_install_cpp
auto_install_make
auto_install_pkg_config
auto_install_ruby
install_dependencies
install_build_dependencies
install_runtime_dependencies

if ! command -v ronin >/dev/null; then
if [[ "$prerelease" == "true" ]]; then
Expand Down
5 changes: 5 additions & 0 deletions test/ronin_dev_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ function test_make_installed()
assertCommandInstalled "did not successfully install make" 'make'
}

function test_awk_installed()
{
assertCommandInstalled "did not successfully install awk" 'awk'
}

function test_ruby_3_x_installed()
{
# check if ruby-3.x is already installed
Expand Down

0 comments on commit b53628e

Please sign in to comment.