do_clean

in ext/magic/extconf.rb [171:203]


def do_clean
  root = Pathname(PACKAGE_ROOT_DIR)
  pwd  = Pathname(Dir.pwd)

  
  unless (root + '.git').exist?
    message("Cleaning files only used during build.\n")

    
    

    
    Pathname.glob(pwd.join('tmp', '*', 'ports')) do |dir|
      FileUtils.rm_rf(dir, verbose: true)
    end

    FileUtils.rm_rf(root + 'ports' + 'archives', verbose: true)

    
    remove_paths = %w[bin include]
    remove_paths << 'lib' if config_static?

    Pathname.glob(File.join(root, 'ports', '*', 'libmagic', '*')) do |dir|
      remove_paths.each do |path|
        remove_dir = File.join(dir, path)
        FileUtils.rm_rf(remove_dir, verbose: true)
      end
    end
  end

  exit!(0)
end