Last active
March 19, 2016 20:10
-
-
Save jhrcz/17fc2a001900882ddc59 to your computer and use it in GitHub Desktop.
diff existing file with its original content from rpm
This file contains hidden or 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
diff_file_with_rpm_content() | |
{ | |
# | |
# EXAMPLES: | |
# | |
# diff_file_with_rpm_content /etc/sysconfig/somefile | |
# diff_file_with_rpm_content /etc/sysconfig/somefile.rpmsave /etc/sysconfig/somefile | |
# | |
local srcfile="$1" | |
[ -f "$srcfile" ] || exit 1 | |
local TMPFILE=$(mktemp /tmp/diff_file_with_rpm_content.XXXX) | |
local PACKAGE | |
local PACKAGE_FILE | |
local file | |
if [ -n "$2" ] | |
then | |
file="$2" | |
else | |
file="$srcfile" | |
fi | |
### | |
echo "Getting package..." | |
PACKAGE=$(rpm -q -f "$file") | |
echo "$PACKAGE" | |
yumdownloader --destdir=/tmp "$PACKAGE" | |
### | |
echo "Unpacking rpm content and preparing for diff..." | |
PACKAGE_FILE=/tmp/${PACKAGE}.rpm | |
rpm2cpio "$PACKAGE_FILE" | cpio -i --to-stdout ".$file" > $TMPFILE | |
### | |
DIFF_TOOL=$"vimdiff --cmd \":colorscheme evening\"" | |
eval "$DIFF_TOOL" "\$srcfile" "\$TMPFILE" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment