WIP: unpack essential packages with proxy script #32
2 changed files with 62 additions and 3 deletions
59
debextract
Executable file
59
debextract
Executable file
|
@ -0,0 +1,59 @@
|
|||
#!/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
|
||||
|
||||
# here we're unpacking data.tar.* manually
|
||||
|
||||
me=${0##*/}
|
||||
log() { echo "${me}: $*" 1>&2 ; }
|
||||
|
||||
have_cmd() {
|
||||
if ! command -v "$1" >/dev/null ; then
|
||||
log "unable to find '$1' - install package '$2' first"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
have_cmd ar binutils
|
||||
|
||||
# naive test for .deb file
|
||||
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
|
||||
|
||||
if [ -z "${data_tar}" ] ; then
|
||||
log "unable to find data.tar.* in $1 - bailing out"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
decomp= ; decomp_pkg=
|
||||
case "${data_tar}" in
|
||||
data.tar.gz) decomp='gzip' decomp_pkg='gzip' ;;
|
||||
data.tar.xz) decomp='xz' decomp_pkg='xz-utils' ;;
|
||||
data.tar.zst) decomp='zstd' decomp_pkg='zstd' ;;
|
||||
*)
|
||||
log "unable to handle '${data_tar}' from $1 - compression type isn't known to script"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
have_cmd ${decomp} ${decomp_pkg}
|
||||
|
||||
ar p "$1" "${data_tar}" | ${decomp} -d
|
|
@ -2502,9 +2502,9 @@ sub run_extract() {
|
|||
close($filter_writer)
|
||||
or error "cannot close filter_writer: $!";
|
||||
}
|
||||
debug("running dpkg-deb --fsys-tarfile $options->{root}/$deb");
|
||||
debug("running debextract $options->{root}/$deb");
|
||||
eval { Devel::Cover::set_coverage("none") } if $is_covering;
|
||||
exec 'dpkg-deb', '--fsys-tarfile', "$options->{root}/$deb";
|
||||
exec 'debextract', "$options->{root}/$deb";
|
||||
}
|
||||
my $pid2;
|
||||
if (scalar @tarfilterargs > 0) {
|
||||
|
@ -2544,7 +2544,7 @@ sub run_extract() {
|
|||
close($filter_writer) or error "cannot close filter_writer: $!";
|
||||
}
|
||||
waitpid($pid1, 0);
|
||||
$? == 0 or error "dpkg-deb --fsys-tarfile failed: $?";
|
||||
$? == 0 or error "debextract failed: $?";
|
||||
if (scalar @tarfilterargs > 0) {
|
||||
waitpid($pid2, 0);
|
||||
$? == 0 or error "tarfilter failed: $?";
|
||||
|
|
Loading…
Reference in a new issue