-
-
Save mccun934/cf4c2a8a7a1995557c7acbdcd01a83c0 to your computer and use it in GitHub Desktop.
Generate pulp file repos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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