LDP/LDP/guide/docbook/abs-guide/de-rpm.sh

22 lines
738 B
Bash
Raw Permalink Normal View History

2001-09-04 13:36:09 +00:00
#!/bin/bash
# de-rpm.sh: Unpack an 'rpm' archive
2002-07-22 15:11:51 +00:00
: ${1?"Usage: `basename $0` target-file"}
# Must specify 'rpm' archive name as an argument.
2001-09-04 13:36:09 +00:00
2006-12-20 21:11:55 +00:00
TEMPFILE=$$.cpio # Tempfile with "unique" name.
# $$ is process ID of script.
2001-09-04 13:36:09 +00:00
rpm2cpio < $1 > $TEMPFILE # Converts rpm archive into
2006-12-20 21:11:55 +00:00
#+ cpio archive.
cpio --make-directories -F $TEMPFILE -i # Unpacks cpio archive.
rm -f $TEMPFILE # Deletes cpio archive.
2001-09-04 13:36:09 +00:00
exit 0
2002-07-22 15:11:51 +00:00
# Exercise:
# Add check for whether 1) "target-file" exists and
2006-12-20 21:11:55 +00:00
#+ 2) it is an rpm archive.
# Hint: Parse output of 'file' command.