Skip to content

Instantly share code, notes, and snippets.

@jlsherrill
Last active August 31, 2022 18:13
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jlsherrill/e7c72e1ed82379955c2208ac472b0be7 to your computer and use it in GitHub Desktop.
Save jlsherrill/e7c72e1ed82379955c2208ac472b0be7 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
@jlsherrill
Copy link
Author

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