forked from josch/mmdebstrap
mmdebstrap: unpack essential packages with proxy script
try unpack package with dpkg-deb and fallback to manual extraction Signed-off-by: Konstantin Demin <rockdrilla@gmail.com>
parent
5fd96553f5
commit
2dad1c662c
@ -0,0 +1,50 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -ef
|
||||||
|
|
||||||
|
# assume that both data.tar and control.tar are compressed with same compressor
|
||||||
|
# if dpkg-deb can handle control.tar.* then it will handle data.tar.* too
|
||||||
|
if dpkg-deb --ctrl-tarfile "$1" >/dev/null 2>&1 ; then
|
||||||
|
exec dpkg-deb --fsys-tarfile "$1"
|
||||||
|
fi
|
||||||
|
|
||||||
|
me=${0##*/}
|
||||||
|
log() { echo "${me}: $*" 1>&2 ; }
|
||||||
|
|
||||||
|
# here we're unpacking data.tar.* manually
|
||||||
|
|
||||||
|
# naive test for .deb file
|
||||||
|
# also check `ar' presense
|
||||||
|
ar t "$1" >/dev/null
|
||||||
|
|
||||||
|
data_tar=
|
||||||
|
while read -r pkg_member ; do
|
||||||
|
[ -n "${pkg_member}" ] || continue
|
||||||
|
|
||||||
|
if [ -n "${data_tar}" ] ; then
|
||||||
|
log "extra data tarball '${pkg_member}' in package $1 - bailing out"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
data_tar="${pkg_member}"
|
||||||
|
done <<-EOF
|
||||||
|
$(ar t "$1" | grep -E '^data\.tar')
|
||||||
|
EOF
|
||||||
|
|
||||||
|
decomp=
|
||||||
|
case "${data_tar}" in
|
||||||
|
data.tar.gz) decomp='gzip' ;;
|
||||||
|
data.tar.xz) decomp='xz' ;;
|
||||||
|
data.tar.zst) decomp='zstd' ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if [ -z "${decomp}" ] ; then
|
||||||
|
log "unable to handle '${data_tar}' from $1 - compression type isn't known to script"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v ${decomp} >/dev/null ; then
|
||||||
|
log "enable to find '${decomp}'"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
ar p "$1" "${data_tar}" | ${decomp} -d
|
Loading…
Reference in New Issue