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>
This commit is contained in:
parent
5fd96553f5
commit
2dad1c662c
2 changed files with 53 additions and 3 deletions
50
debextract
Executable file
50
debextract
Executable file
|
@ -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
|
|
@ -2502,9 +2502,9 @@ sub run_extract() {
|
||||||
close($filter_writer)
|
close($filter_writer)
|
||||||
or error "cannot 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;
|
eval { Devel::Cover::set_coverage("none") } if $is_covering;
|
||||||
exec 'dpkg-deb', '--fsys-tarfile', "$options->{root}/$deb";
|
exec 'debextract', "$options->{root}/$deb";
|
||||||
}
|
}
|
||||||
my $pid2;
|
my $pid2;
|
||||||
if (scalar @tarfilterargs > 0) {
|
if (scalar @tarfilterargs > 0) {
|
||||||
|
@ -2544,7 +2544,7 @@ sub run_extract() {
|
||||||
close($filter_writer) or error "cannot close filter_writer: $!";
|
close($filter_writer) or error "cannot close filter_writer: $!";
|
||||||
}
|
}
|
||||||
waitpid($pid1, 0);
|
waitpid($pid1, 0);
|
||||||
$? == 0 or error "dpkg-deb --fsys-tarfile failed: $?";
|
$? == 0 or error "debextract failed: $?";
|
||||||
if (scalar @tarfilterargs > 0) {
|
if (scalar @tarfilterargs > 0) {
|
||||||
waitpid($pid2, 0);
|
waitpid($pid2, 0);
|
||||||
$? == 0 or error "tarfilter failed: $?";
|
$? == 0 or error "tarfilter failed: $?";
|
||||||
|
|
Loading…
Reference in a new issue