Create a gist now

Instantly share code, notes, and snippets.

@ruario /rpm2cpio
Last active Nov 4, 2017

What would you like to do?
Minimal rpm2cpio using only bash, grep, tail and a decompressor
#!/bin/bash
RPMHDRLGTH=$(LANG=X grep -abom1 '.7zXZ\|]'$'\000\000''....'$'\377\377\377\377\377\377''\|BZh9\|'$'\037\213\b' "$1")
case "$RPMHDRLGTH" in
*7zXZ) COMPRESSOR=xz ;;
*]*) COMPRESSOR=lzma ;;
*BZh9) COMPRESSOR=bzip2 ;;
*) COMPRESSOR=gzip ;;
esac
tail -c+$[${RPMHDRLGTH%:*}+1] "$1" | $COMPRESSOR -d
Owner

ruario commented Jun 1, 2014

Just some notes. This assumes GNU tools. Additionally it will not work with rpm5.org rpms that use xar instead of cpio internally.

Owner

ruario commented Nov 4, 2017

For history buffs, I first wrote this back in 2012

https://web.archive.org/web/20140303100327/http://my.opera.com/ruario/blog/2012/01/15/rpm2cpio

The one in this gist is only slightly changed

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