Created
April 26, 2018 19:15
-
-
Save yaauie/3df91c0dcc78ba57693659fd27f2fe94 to your computer and use it in GitHub Desktop.
I had a need the other day to read files out of RPM and DEB packages, but wanted to avoid extracting them to my local filesystem; the following scripts cobble together the various tools I found to simply read a single file from either to stdout.
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/env bash -x | |
# prereq: tar | |
package="${1:?package}" | |
file="${2:?file}" | |
tar -xOf $package data.tar.gz | tar -zxO $file |
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/env bash -x | |
# prereq: rpm2cpio | |
# prereq: cpio (GNU-flavored); will auto-detect from `GNU_CPIO` env var, GNU-flavored `cpio` on path, or `gnu-cpio` on path | |
package="${1:?package}" | |
file="${2:?file}" | |
# detect GNU-flavored `cpio`, which supports reading to stdout: | |
# - IF `GNU_CPIO` set, trust it; | |
# - ELSE IF `cpio` on path is GNU, use it; | |
# - ELSE look for `gnu-cpio` | |
GNU_CPIO=${GNU_CPIO:-$(cpio --help | grep GNU >/dev/null && which cpio || which gnu-cpio)} | |
rpm2cpio $package | "${GNU_CPIO:?}" -iv --to-stdout $file 2>/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment