~ubuntu-branches/ubuntu/wily/debootstrap/wily

« back to all changes in this revision

Viewing changes to functions

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2009-07-23 16:45:00 UTC
  • Revision ID: james.westby@ubuntu.com-20090723164500-jep034mv3cq78qwy
On Linux, clear out /etc/mtab on exit if it's not a symlink. Should fix
problems Wouter Verhelst and Martin Michlmayr are seeing with
initramfs-tools MODULES=dep, although it probably isn't a perfect
solution.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
                (echo "E: $name"
18
18
                for x in "$@"; do echo "EA: $x"; done
19
19
                echo "EF: $fmt") >&4
20
 
        elif [ "$USE_GETTEXT_INTERACTION" ]; then
21
 
                (printf "E: `LANG=$GETTEXT_LANG gettext debootstrap "$fmt"`\n" "$@") >&4
22
20
        else
23
21
                (printf "E: $fmt\n" "$@") >&4
24
22
        fi
34
32
                (echo "W: $name"
35
33
                for x in "$@"; do echo "WA: $x"; done
36
34
                echo "WF: $fmt") >&4
37
 
        elif [ "$USE_GETTEXT_INTERACTION" ]; then
38
 
                printf "W: `LANG=$GETTEXT_LANG gettext debootstrap "$fmt"`\n" "$@" >&4
39
35
        else
40
36
                printf "W: $fmt\n" "$@" >&4
41
37
        fi
50
46
                (echo "I: $name"
51
47
                for x in "$@"; do echo "IA: $x"; done
52
48
                echo "IF: $fmt") >&4
53
 
        elif [ "$USE_GETTEXT_INTERACTION" ]; then
54
 
                printf "I: `LANG=$GETTEXT_LANG gettext debootstrap "$fmt"`\n" "$@" >&4
55
49
        else
56
50
                printf "I: $fmt\n" "$@" >&4
57
51
        fi
257
251
        fi
258
252
 
259
253
        if [ -e "$2" ]; then
260
 
                if [ "$3" = "" ]; then
 
254
                if [ -z "$3" ]; then
261
255
                        return 0
262
256
                elif [ "$3" = nocache ]; then
263
257
                        rm -f "$2"
312
306
                                md5=""
313
307
                        fi
314
308
                fi
315
 
                if [ "$md5" = "" ]; then
 
309
                if [ -z "$md5" ]; then
316
310
                        [ "$dest2" = "$dest" ] || mv "$dest2" "$dest"
317
311
                        case "$typ" in
318
312
                            gz)  gunzip "$dest" ;;
399
393
        #   rel suite mirror path
400
394
        case "$1" in
401
395
            deb)
402
 
                echo "var/cache/apt/archives/${2}_${3}_${4}.deb" | sed 's/:/%3a/'
 
396
                echo "/var/cache/apt/archives/${2}_${3}_${4}.deb" | sed 's/:/%3a/'
403
397
                ;;
404
398
            pkg)
405
399
                local m="$5"
484
478
        done
485
479
        COMPONENTS="$(echo $COMPONENTS)"
486
480
 
487
 
        if [ "$COMPONENTS" = "" ]; then
 
481
        if [ -z "$COMPONENTS" ]; then
488
482
                mv "$reldest" "$reldest.malformed"
489
483
                error 1 INVALIDREL "Invalid Release file, no valid components"
490
484
        fi
643
637
                local pkgdest="$TARGET/$($DLDEST pkg "$SUITE" "$c" "$ARCH" "$m" "$path")"
644
638
                if [ ! -e "$pkgdest" ]; then continue; fi
645
639
                pkgs_to_get="$(download_debs "$m" "$pkgdest" $pkgs_to_get 5>&1 1>&6)"
646
 
                if [ "$pkgs_to_get" = "" ]; then break; fi
 
640
                if [ -z "$pkgs_to_get" ]; then break; fi
647
641
            done 6>&1
648
 
            if [ "$pkgs_to_get" = "" ]; then break; fi
 
642
            if [ -z "$pkgs_to_get" ]; then break; fi
649
643
        done
650
644
        progress $dloaddebs $totaldebs DOWNDEBS "Downloading packages"
651
645
        if [ "$pkgs_to_get" != "" ]; then
736
730
); }
737
731
 
738
732
in_target_nofail () {
739
 
        if ! chroot "$TARGET" "$@" 2>/dev/null; then
 
733
        if ! $CHROOT_CMD "$@" 2>/dev/null; then
740
734
                true
741
735
        fi
742
736
        return 0
747
741
        local msg="$2"
748
742
        local arg="$3"
749
743
        shift; shift; shift
750
 
        if ! chroot "$TARGET" "$@"; then
 
744
        if ! $CHROOT_CMD "$@"; then
751
745
                warning "$code" "$msg" "$arg"
752
746
                return 1
753
747
        fi
755
749
}
756
750
 
757
751
in_target () {
758
 
        in_target_failmsg IN_TARGET_FAIL "Failure trying to run: %s" "chroot $TARGET $*" "$@"
 
752
        in_target_failmsg IN_TARGET_FAIL "Failure trying to run: %s" "$CHROOT_CMD $*" "$@"
759
753
}
760
754
 
761
755
###################################################### standard setup stuff
821
815
        fi
822
816
}
823
817
 
 
818
clear_mtab () {
 
819
        if [ -f "$TARGET/etc/mtab" ] && [ ! -h "$TARGET/etc/mtab" ]; then
 
820
                rm -f "$TARGET/etc/mtab"
 
821
        fi
 
822
}
 
823
 
824
824
setup_proc () {
825
825
        case "$ARCH" in
826
826
            kfreebsd-*)
844
844
                        umount "$TARGET/sys" 2>/dev/null || true
845
845
                        in_target mount -t sysfs sysfs /sys
846
846
                fi
 
847
                on_exit clear_mtab
847
848
                ;;
848
849
        esac
849
850
        umount_on_exit /lib/init/rw
862
863
                setup_devices_hurd ;;
863
864
            *)
864
865
                if [ -e "$DEVICES_TARGZ" ]; then
865
 
                        (cd "$TARGET"; zcat "$DEVICES_TARGZ" | tar -xf -)
 
866
                        zcat "$DEVICES_TARGZ" | (cd "$TARGET"; tar -xf -)
866
867
                else
867
868
                        if [ -e /dev/.devfsd ] ; then
868
869
                                in_target mount -t devfs devfs /dev
1096
1097
        echo
1097
1098
}
1098
1099
 
1099
 
repeat () {
 
1100
# Formerly called 'repeat', but that's a reserved word in zsh.
 
1101
repeatn () {
1100
1102
        local n="$1"
1101
1103
        shift
1102
1104
        while [ "$n" -gt 0 ]; do