Create a gist now

Instantly share code, notes, and snippets.

@ruario /rpm2cpio
Last active Jul 19, 2016

Minimal rpm2cpio using only bash, grep, tail and a decompressor
RPMHDRLGTH=$(LANG=X grep -abom1 '.7zXZ\|]'$'\000\000''....'$'\377\377\377\377\377\377''\|BZh9\|'$'\037\213\b' "$1")
case "$RPMHDRLGTH" in
*]*) COMPRESSOR=lzma ;;
*BZh9) COMPRESSOR=bzip2 ;;
*) COMPRESSOR=gzip ;;
tail -c+$[${RPMHDRLGTH%:*}+1] "$1" | $COMPRESSOR -d

Just some notes. This assumes GNU tools. Additionally it will not work with rpm's that use xar instead of cpio internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment