| 1 | #!/bin/bash |
| 2 | # de-rpm.sh: Unpack an 'rpm' archive |
| 3 | |
| 4 | : ${1?"Usage: `basename $0` target-file"} |
| 5 | # Must specify 'rpm' archive name as an argument. |
| 6 | |
| 7 | |
| 8 | TEMPFILE=$$.cpio # Tempfile with "unique" name. |
| 9 | # $$ is process ID of script. |
| 10 | |
| 11 | rpm2cpio < $1 > $TEMPFILE # Converts rpm archive into |
| 12 | #+ cpio archive. |
| 13 | cpio --make-directories -F $TEMPFILE -i # Unpacks cpio archive. |
| 14 | rm -f $TEMPFILE # Deletes cpio archive. |
| 15 | |
| 16 | exit 0 |
| 17 | |
| 18 | # Exercise: |
| 19 | # Add check for whether 1) "target-file" exists and |
| 20 | #+ 2) it is an rpm archive. |
| 21 | # Hint: Parse output of 'file' command. |