-
-
Save RichGuk/342500 to your computer and use it in GitHub Desktop.
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/ruby | |
# cpioxz.rb | |
# Jonathan D. Stott <jonathan.stott@gmail.com> | |
if ARGV.empty? | |
warn "Usage: #{$0} directory [directories+]" | |
exit 1 | |
end | |
ARGV.each do |dir| | |
next unless File.directory?(dir) | |
directory = dir.sub(/\/$/,'') | |
xz = "#{directory}.cpio.xz" | |
system("find #{directory} -type f -print0 | xargs -0 sha1sum >#{directory}.sha1") | |
system("find #{directory} #{directory}.sha1 -type f -print0 | cpio --create --quiet --null --format=crc | xz --best -Csha256 >#{xz}") || abort("Failed to write cpio") | |
system("xzcat #{xz} | cpio --quiet --extract --only-verify-crc") || abort("failed to verify crc") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment