<commit_before>require 'fileutils'
require 'zlib'

module Debian
    def build_apt_repo(path, component, arch, release)
        release.each { |r|
            component.each { |c|
                arch.each { |a|
                    fpath = path + "/dists/" + r + "/" + c + "/" + "binary-" + a + "/"
                    pfpath = fpath + "Packages"
                    rfpath = fpath + "Release"

                    puts "Building Path: #{fpath}"

                    FileUtils.mkpath(fpath)
                    FileUtils.touch(pfpath)
                    FileUtils.touch(rfpath)
                    generate_packages_gz(pfpath,path,rfpath,r,c,a)
                }
            }
        }
    end

    def generate_packages_gz(pfpath,path,rfpath,r,c,a)
        puts "Generating Packages: #{r} : #{c} : binary-#{a}"
        `apt-ftparchive packages #{path} > #{pfpath}`
        puts "Generating Release: #{r}"
        `apt-ftparchive release #{path}/dists/#{r}/ > #{path}/dists/#{r}/Release`
        #data = ''
        #f = File.open(pfpath, "r").each { |line|
        #    data << line
        #}
        #f.close
        #
        #Zlib::GzipWriter.open(pfpath + ".gz") do |gz|
        #    gz.write data
        #end
    end
end

class FRM
    class FRM::Repo
        include Debian

        attr_accessor :path
        attr_accessor :type
        attr_accessor :component
        attr_accessor :arch<commit_msg>Increasing Speed of Package Generation<commit_after>require 'fileutils'
require 'zlib'

module Debian
    def build_apt_repo(path, component, arch, release)
        release.each { |r|
            component.each { |c|
                arch.each { |a|
                    fpath = path + "/dists/" + r + "/" + c + "/" + "binary-" + a + "/"
                    pfpath = fpath + "Packages"
                    rfpath = fpath + "Release"

                    puts "Building Path: #{fpath}"

                    FileUtils.mkpath(fpath)
                    FileUtils.touch(pfpath)
                    FileUtils.touch(rfpath)
                    generate_packages_gz(fpath,pfpath,path,rfpath,r,c,a)
                }
            }
        }
    end

    def generate_packages_gz(fpath,pfpath,path,rfpath,r,c,a)
        puts "Generating Packages: #{r} : #{c} : binary-#{a}"

        control_data = ''
        Dir.glob("#{fpath}*.deb") do |deb|
            `ar x #{deb} control.tar.gz` 
            `cat control.tar.gz | tar zxf - ./control`
            control_data << `cat control`
            `rm control.tar.gz`
            `rm control`
        end
       
        d = File.open(pfpath, "w+")
        d.write control_data
        d.write "\n"
        d.close

        data = ''
        f = File.open(pfpath, "r").each { |line|
            data << line
        }
        f.close
        
        Zlib::GzipWriter.open(pfpath + ".gz") do |gz|
            gz.write data
        end
        `apt-ftparchive release #{path}/dists/#{r}/ > #{path}/dists/#{r}/Release`
    end
end

class FRM
    class FRM::Repo
        include Debian

        attr_accessor :path
        attr_accessor :type
        attr_accessor :component
        attr_accessor :arch
{'fraction_non_alphanumeric': 0.12861225785963798, 'fraction_numerical': 0.0, 'mean_word_length': 1.466718872357087, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5949706', 'n_tokens_mistral': 1008, 'n_tokens_neox': 965, 'n_words': 204}