# Tanım: ileri düzey exploit kullanarak geliştirme ve test etme çatı uygulaması
# URL: http://www.metasploit.com
# Paketçi: milisarge
# Gerekler: ruby libpcap postgresql ruby-bundler sqlite libxslt clang

isim=metasploit
surum=4.14.24
devir=1
kaynak=(https://github.com/rapid7/metasploit-framework/archive/$surum.tar.gz)

derle() {
	cd "${isim}-framework-$surum"
	bundle config build.nokogiri --use-system-libraries
	sed 's|git ls-files|find -type f|' -i metasploit-framework.gemspec
	export CC=clang
	export CXX=clang++
	bundle install -j"$(nproc)" --no-cache --deployment
	find vendor/bundle/ruby -exec chmod o+r '{}' \;

	install -d "${PKG}/opt/${isim}" "${PKG}/usr/bin"
	find . -maxdepth 1 -mindepth 1 -not -path './.git*' -exec cp -r '{}' "${PKG}/opt/${isim}" \;

	for f in "${PKG}"/opt/${isim}/msf*; do
	local _msffile="${PKG}/usr/bin/`basename "${f}"`"
	echo -e "#!/bin/sh\nBUNDLE_GEMFILE=/opt/${isim}/Gemfile bundle exec ruby /opt/${isim}/`basename "${f}"` \"\$@\"" > "${_msffile}"
	chmod 755 "${_msffile}"
	done

	(cd "${PKG}/opt/${isim}"
	for f in tools/*/*.rb; do
	  install -Dm 755 "${f}" ".${f}"
	  echo -e "#!/bin/sh\nBUNDLE_GEMFILE=/opt/${isim}/Gemfile bundle exec ruby /opt/${isim}/."${f}" \"\$@\"" > "${f}"
	  chmod 755 "${f}"
	done
	)

	install -Dm 644 external/zsh/_* -t "${PKG}/usr/share/zsh/site-functions"
	install -d "${PKG}/usr/share/doc"
	mv "${PKG}/opt/${isim}/documentation" "${PKG}/usr/share/doc/${isim}"
	rm "${PKG}/usr/bin/msfupdate"
}