Also support uncompressed control.tar files
[tools/build.git] / unrpm
1 #!/bin/bash
2
3 ################################################################
4 #
5 # Copyright (c) 1995-2014 SUSE Linux Products GmbH
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License version 2 or 3 as
9 # published by the Free Software Foundation.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program (see the file COPYING); if not, write to the
18 # Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20 #
21 ################################################################
22
23 function Usage () {
24     echo "Usage: $(basename $0) [-vq] rpm-files...";
25     echo "Unpack rpm files in current directory.";
26     exit 1
27 }
28
29 CPIO_OPTS="--extract --unconditional --preserve-modification-time --make-directories"
30
31 FILES=""
32 VERBOSE=false
33 QUIET=false
34
35 for i in $* ; do
36     case "$i" in
37       -v)
38         VERBOSE=true
39         ;;
40       -q)
41         QUIET=true
42         ;;
43       *)
44         FILES="$FILES $i"
45         ;;
46     esac
47 done
48
49 test "$VERBOSE" = "true" && CPIO_OPTS="$CPIO_OPTS --verbose"
50 test "$QUIET" = "true" && CPIO_OPTS="$CPIO_OPTS --quiet"
51
52 test -z "$FILES" && Usage
53
54 for f in $FILES; do
55     if test "$QUIET" = "false" ; then
56         echo -ne "$f:\t"
57     fi
58     rpm2cpio $f | cpio ${CPIO_OPTS}
59 done