lib/src_postinst.cygpart: use DWARF_PARSE optionally instead of objdump -dl
[cygport/rpm-style.git] / tools / deb2targz
blobffaff430ac18e5e97191858923a77c3a55906189
1 #! /bin/bash
2 ###############################################################################
4 # deb2targz - converts Debian binary packages into tarballs
6 # Copyright (C) 2006-2020 Cygport authors
7 # Provided by the Cygwin project <https://cygwin.com/>
9 # cygport is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # cygport is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with cygport. If not, see <https://www.gnu.org/licenses/>.
22 ################################################################################
24 set -e
26 if (( $# < 1 ))
27 then
28 echo "$0: No packages specified" > /dev/stderr
29 exit 1
32 if ! hash ar &> /dev/null
33 then
34 echo "$0: ar not found, install binutils" > /dev/stderr
35 exit 2
38 for deb in $@
40 deb=$(readlink -f $deb)
42 echo -n "$deb: "
44 if [ ! -f $deb ]
45 then
46 echo "ERROR: file not found"
47 continue
50 case "$(file -b $deb)" in
51 Debian*) ;;
52 *) echo "ERROR: not a Debian package"
53 continue ;;
54 esac
56 t=$(mktemp -d)
58 # .debs are 'ar' archives containing three files: debian-binary (text
59 # file containing package format version), control.tar.gz (small amount
60 # of data, including debian/control used by package manager), and
61 # data.tar.gz, the actual file contents. We need only the latter.
63 pushd $t > /dev/null
64 ar x $deb data.tar.gz
65 mv data.tar.gz ${deb%.deb}.tar.gz
66 popd > /dev/null
68 rm -fr $t
70 echo "Success"
71 done