650
650
download_main_indices () {
651
651
local m1="${MIRRORS%% *}"
652
local comp="${USE_COMPONENTS}"
652
653
progress 0 100 DOWNMAINPKGS "Downloading Packages file"
653
654
progress_next 100
656
if [ -z "$comp" ]; then comp=main; fi
657
COMPONENTS="$(echo $comp | tr '|' ' ')"
655
659
export COMPONENTS
656
660
for m in $MIRRORS; do
657
661
for c in $COMPONENTS; do
680
684
local pkgdest="$TARGET/$($DLDEST pkg "$SUITE" "$c" "$ARCH" "$m" "$path")"
681
685
if [ ! -e "$pkgdest" ]; then continue; fi
682
686
details="$($PKGDETAILS PKGS "$m" "$pkgdest" "$p")"
683
if [ "$details" = "$p -" ]; then continue; fi
687
if [ "$details" = "$p -" ]; then
684
691
size="${details##* }"; details="${details% *}"
685
692
md5="${details##* }"; details="${details% *}"
686
693
local debdest="$($DLDEST deb $details)"
718
725
################################################################ extraction
727
EXTRACTORS_SUPPORTED="dpkg-deb ar"
729
# Native dpkg-deb based extractors
730
extract_dpkg_deb_field () {
734
dpkg-deb -f "$pkg" "$field"
737
extract_dpkg_deb_data () {
740
dpkg-deb --fsys-tarfile "$pkg" | tar -xf -
743
# Raw .deb extractors
744
extract_ar_deb_field () {
748
ar -p "$pkg" control.tar.gz | zcat |
749
tar -O -xf - control ./control 2>/dev/null |
750
grep -i "^$field:" | sed -e 's/[^:]*: *//' | head -n 1
753
extract_ar_deb_data () {
755
local tarball=$(ar -t "$pkg" | grep "^data.tar.[bgx]z")
758
data.tar.gz) cat_cmd=zcat ;;
759
data.tar.bz2) cat_cmd=bzcat ;;
760
data.tar.xz) cat_cmd=xzcat ;;
761
*) error 1 UNKNOWNDATACOMP "Unknown compression type for %s in %s" "$tarball" "$pkg" ;;
764
if type $cat_cmd >/dev/null 2>&1; then
765
ar -p "$pkg" data.tar.gz | $cat_cmd | tar -xf -
767
error 1 UNPACKCMDUNVL "The $cat_cmd is not available on the system"
774
for E in $EXTRACTORS_SUPPORTED; do
775
if [ "$extractor" = "$E" ]; then
783
choose_extractor () {
786
if [ -n "$EXTRACTOR_OVERRIDE" ]; then
787
extractor="$EXTRACTOR_OVERRIDE"
788
elif type dpkg-deb >/dev/null 2>&1; then
794
info CHOSENEXTRACTOR "Chosen extractor for .deb packages: %s" "$extractor"
797
extract_deb_field () { extract_dpkg_deb_field "$@"; }
798
extract_deb_data () { extract_dpkg_deb_data "$@"; }
801
extract_deb_field () { extract_ar_deb_field "$@"; }
802
extract_deb_data () { extract_ar_deb_data "$@"; }
723
810
for pkg in $(debfor "$@"); do
725
812
progress "$p" "$#" EXTRACTPKGS "Extracting packages"
726
813
packagename="$(echo "$pkg" | sed 's,^.*/,,;s,_.*$,,')"
727
814
info EXTRACTING "Extracting %s..." "$packagename"
728
ar -p "./$pkg" data.tar.gz | zcat | tar -xf -
815
extract_deb_data "./$pkg"