~ubuntu-branches/ubuntu/hardy/debootstrap/hardy-backports

« back to all changes in this revision

Viewing changes to functions

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador, Otavio Salvador, Guillem Jover, Frans Pop, Joey Hess
  • Date: 2010-02-21 23:11:06 UTC
  • mto: (0.1.7 maverick)
  • mto: This revision was merged to the branch mainline in revision 33.
  • Revision ID: james.westby@ubuntu.com-20100221231106-leq9wi54r2kbxyjk
Tags: 1.0.21
[ Otavio Salvador ]
* Apply patch from Clint Adams <schizo@debian.org> to add support for
  gz/bz2/xz data.tar (closes: #458663).

[ Guillem Jover ]
* Refactor deb extractors into two new functions.
* Use dpkg-deb if available instead of ar (closes: #557296).
* Add an --extractor option to override the automatic extractor selection.

[ Otavio Salvador ]
* Document new --extractor option in manpage.
* Apply patch from Vagrant Cascadian <vagrant+bugs@freegeek.org> not
  fail if resolv.conf is a broken symlink (closes: #390647).

[ Frans Pop ]
* Use tab indentation in scripts/debian/sid to reduce its size (relevant
  for Debian Installer).
* Add apt to base packages for the buildd variant as it is no longer marked
  Build-Essential.

[ Otavio Salvador ]
* Apply patch from Andres Salomon <dilinger@collabora.co.uk> to honor
  --components when using mirror_style 'main' (closes: #561283).
* Apply patch from Andres Salomon <dilinger@collabora.co.uk> to fix
  iteration through components in download_main (closes: #561298).

[ Joey Hess ]
* Allow the suite to be stable, testing, or unstable when debootstrapping
  Debian. Closes: #288109
* Make scripts directory in source tree look like installed directory,
  and add a section to README explaining an easy way to run
  debootstrap w/o installing it. Closes: #345762
* Convert rules file to use dh with overrides.
* Remove binary-basedebs target from debian/rules.
  This target has been broken in multiple ways since 2007. While I
  accidentially partially fixed it with the above changes, this is evidence
  it's dead code that can be safely removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
649
649
 
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
654
 
        COMPONENTS=main
 
655
 
 
656
        if [ -z "$comp" ]; then comp=main; fi
 
657
        COMPONENTS="$(echo $comp | tr '|' ' ')"
 
658
 
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
 
688
                                details=""
 
689
                                continue
 
690
                        fi
684
691
                        size="${details##* }"; details="${details% *}"
685
692
                        md5="${details##* }"; details="${details% *}"
686
693
                        local debdest="$($DLDEST deb $details)"
717
724
 
718
725
################################################################ extraction
719
726
 
 
727
EXTRACTORS_SUPPORTED="dpkg-deb ar"
 
728
 
 
729
# Native dpkg-deb based extractors
 
730
extract_dpkg_deb_field () {
 
731
        local pkg="$1"
 
732
        local field="$2"
 
733
 
 
734
        dpkg-deb -f "$pkg" "$field"
 
735
}
 
736
 
 
737
extract_dpkg_deb_data () {
 
738
        local pkg="$1"
 
739
 
 
740
        dpkg-deb --fsys-tarfile "$pkg" | tar -xf -
 
741
}
 
742
 
 
743
# Raw .deb extractors
 
744
extract_ar_deb_field () {
 
745
        local pkg="$1"
 
746
        local field="$2"
 
747
 
 
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
 
751
}
 
752
 
 
753
extract_ar_deb_data () {
 
754
        local pkg="$1"
 
755
        local tarball=$(ar -t "$pkg" | grep "^data.tar.[bgx]z")
 
756
 
 
757
        case "$tarball" in
 
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" ;;
 
762
        esac
 
763
 
 
764
        if type $cat_cmd >/dev/null 2>&1; then
 
765
                ar -p "$pkg" data.tar.gz | $cat_cmd | tar -xf -
 
766
        else
 
767
                error 1 UNPACKCMDUNVL "The $cat_cmd is not available on the system"
 
768
        fi
 
769
}
 
770
 
 
771
valid_extractor () {
 
772
        local extractor="$1"
 
773
 
 
774
        for E in $EXTRACTORS_SUPPORTED; do
 
775
                if [ "$extractor" = "$E" ]; then
 
776
                        return 0
 
777
                fi
 
778
        done
 
779
 
 
780
        return 1
 
781
}
 
782
 
 
783
choose_extractor () {
 
784
        local extractor
 
785
 
 
786
        if [ -n "$EXTRACTOR_OVERRIDE" ]; then
 
787
                extractor="$EXTRACTOR_OVERRIDE"
 
788
        elif type dpkg-deb >/dev/null 2>&1; then
 
789
                extractor="dpkg-deb"
 
790
        else
 
791
                extractor="ar"
 
792
        fi
 
793
 
 
794
        info CHOSENEXTRACTOR "Chosen extractor for .deb packages: %s" "$extractor"
 
795
        case "$extractor" in
 
796
        dpkg-deb)
 
797
                extract_deb_field () { extract_dpkg_deb_field "$@"; }
 
798
                extract_deb_data () { extract_dpkg_deb_data "$@"; }
 
799
                ;;
 
800
        ar)
 
801
                extract_deb_field () { extract_ar_deb_field "$@"; }
 
802
                extract_deb_data () { extract_ar_deb_data "$@"; }
 
803
                ;;
 
804
        esac
 
805
}
 
806
 
720
807
extract () { (
721
808
        cd "$TARGET"
722
 
        local p=0
 
809
        local p=0 cat_cmd
723
810
        for pkg in $(debfor "$@"); do
724
811
                p="$(($p + 1))"
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"
729
816
        done
730
817
); }
731
818
 
756
843
 
757
844
conditional_cp () {
758
845
        if [ ! -e "$2/$1" ]; then
759
 
                if [ -L "$1" ]; then
 
846
                if [ -L "$1" ] && [ -e "$1" ]; then
760
847
                        cat "$1" >"$2/$1"
761
848
                elif [ -e "$1" ]; then
762
849
                        cp -a "$1" "$2/$1"