require 'package'

class Php_malware_finder < Package
  description 'Detect potentially malicious PHP files.'
  homepage 'https://github.com/nbs-system/php-malware-finder/'
  version 'b8698eb'
  license 'LGPL-3.0'
  compatibility 'all'
  source_url 'https://github.com/nbs-system/php-malware-finder.git'
  git_hashtag 'b8698eb605cc06bc0585902d7fb7f4943113cc5d'

  depends_on 'yara'

  def self.build
    system 'make || true' # || true is needed to bypass the debian release check.
    system "sed -i 's,/etc/phpmalwarefinder,#{CREW_PREFIX}/share/php-malware-finder,' php-malware-finder/phpmalwarefinder"
  end

  def self.check
    system 'make', 'tests'
  end

  def self.install
    FileUtils.mkdir_p "#{CREW_DEST_PREFIX}/bin"
    FileUtils.mkdir_p "#{CREW_DEST_PREFIX}/share"
    FileUtils.mv 'php-malware-finder', "#{CREW_DEST_PREFIX}/share"
    FileUtils.ln_s "#{CREW_PREFIX}/share/php-malware-finder/phpmalwarefinder", "#{CREW_DEST_PREFIX}/bin/pmf"
  end

  def self.postinstall
    puts "\nType 'pmf -h' to get started.\n".lightblue
  end
end
