Created
March 24, 2010 17:01
-
-
Save namelessjon/342496 to your computer and use it in GitHub Desktop.
cpio and xz archiving script
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 <[email protected]> | |
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