Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
@jlsherrill

This comment has been minimized.

Owner

jlsherrill commented Jul 29, 2016

Usage:

./file_repogen.rb /path/to/file_repo/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment