Created
September 14, 2020 13:23
-
-
Save highercomve/f167b61199d120a0434900d153c0de2c 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
#!/bin/bash | |
set -x | |
cpio_file=$(mktemp /tmp/magiccpio.XXXXXXX) | |
cd $1 | |
find . | cpio -o -H newc > $cpio_file | |
xz --keep --check=crc32 --lzma2=dict=512KiB $cpio_file | |
fl=$(stat -c %s $cpio_file.xz) | |
rem=$(($fl % 4)) | |
fb= ; | |
if [ $rem = 0 ]; then | |
fb=$fl | |
else | |
fb=$(($fl + 4 - $rem)) | |
fi; | |
dd if=/dev/zero of=$cpio_file.xz4 bs=1 count=$fb | |
dd if=$cpio_file.xz of=$cpio_file.xz4 conv=notrunc | |
cd ~ | |
mv $cpio_file.xz4 $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment