Skip to content

Instantly share code, notes, and snippets.

@mccun934
Forked from jlsherrill/file_repogen.rb
Created May 17, 2017 15:33
Show Gist options
  • Save mccun934/cf4c2a8a7a1995557c7acbdcd01a83c0 to your computer and use it in GitHub Desktop.
Save mccun934/cf4c2a8a7a1995557c7acbdcd01a83c0 to your computer and use it in GitHub Desktop.
Generate pulp file repos
#!/usr/bin/env ruby
def collect_files(files)
lines = []
files.collect do |file|
if File.lstat(file).symlink? && File.directory?(file)
sub_files = collect_files(Dir.glob("#{file}/**/*"))
lines.concat(sub_files)
next
elsif File.directory?(file)
next
end
line = []
line << file
line << `sha256sum #{file}`.split(' ')[0]
line << File.stat(file).size
lines << line.join(',')
end
lines
end
Dir.chdir("#{ARGV[0]}") do
if File.exist?("PULP_MANIFEST")
`rm -rf PULP_MANIFEST`
end
files = Dir.glob("**/*")
lines = collect_files(files)
File.open("PULP_MANIFEST", 'w') do |file|
file.write(lines.compact.join("\n"))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment