~udienz/+junk/debootstrap-blankon

« back to all changes in this revision

Viewing changes to scripts/debian/sarge.fakechroot

  • Committer: Andy Apdhani
  • Date: 2007-09-29 13:24:53 UTC
  • Revision ID: imtheface@ubuntu.com-20070929132453-r0ir93lt4fk29u7m
Impor awal

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
test "$FAKECHROOT" = "true" || error 1 FAKECHROOTREQ "This variant requires fakechroot environment to be started"
 
2
 
 
3
mirror_style release
 
4
download_style apt
 
5
 
 
6
work_out_debs () {
 
7
 
 
8
    required="base-files base-passwd bash bsdutils coreutils debianutils diff dpkg dselect e2fslibs e2fsprogs findutils gcc-3.3-base grep gzip hostname initscripts libacl1 libattr1 libblkid1 libc6 libcap1 libcomerr2 libdb1-compat libdb3 libgcc1 libncurses5 libpam-modules libpam-runtime libpam0g libss2 libstdc++5 libuuid1 login mawk mount ncurses-base ncurses-bin passwd perl-base sed slang1a-utf8 sysv-rc sysvinit tar util-linux zlib1g"
 
9
 
 
10
    base="apt binutils cpio cpp cpp-3.3 dpkg-dev g++ g++-3.3 gcc gcc-3.3 libc6-dev libdb4.2 libgdbm3 libstdc++5-3.3-dev linux-kernel-headers make patch perl perl-modules"
 
11
 
 
12
    without_package () {
 
13
        echo "$2" | tr ' ' '\n' | grep -v "^$1$" | tr '\n' ' '
 
14
    }
 
15
    subst_package () {
 
16
        echo "$3" | tr ' ' '\n' | sed "s/^$1$/$2/" | tr '\n' ' '
 
17
    }
 
18
 
 
19
    required="$required binutils fakechroot"
 
20
    base="$(without_package "binutils" "$base")"
 
21
 
 
22
    LIBC6=libc6
 
23
 
 
24
    case $ARCH in
 
25
        "alpha")
 
26
            required="$(subst_package "libc6" "libc6.1" "$required")"
 
27
            base="$(subst_package "libc6-dev" "libc6.1-dev" "$base")"
 
28
            LIBC6="libc6.1"
 
29
            ;;
 
30
        "arm")
 
31
            ;;
 
32
        "i386")
 
33
            ;;
 
34
        "ia64")
 
35
            required="$(subst_package "libc6" "libc6.1" "$required")"
 
36
            base="$(subst_package "libc6-dev" "libc6.1-dev" "$base")"
 
37
            LIBC6="libc6.1"
 
38
            ;;
 
39
        "m68k")
 
40
            ;;
 
41
        "powerpc")
 
42
            ;;
 
43
        "sparc")
 
44
            ;;
 
45
        "mips")
 
46
            ;;
 
47
        "mipsel")
 
48
            ;;
 
49
        "hppa")
 
50
            ;;
 
51
        s390|s390x)
 
52
            ;;
 
53
        sh*)
 
54
            ;;
 
55
        *)
 
56
            # who knows?
 
57
            ;;
 
58
    esac
 
59
}
 
60
 
 
61
first_stage_install () {
 
62
    extract $required
 
63
 
 
64
    mkdir -p "$TARGET/var/lib/dpkg"
 
65
    : >"$TARGET/var/lib/dpkg/status"
 
66
    : >"$TARGET/var/lib/dpkg/available"
 
67
 
 
68
    setup_etc
 
69
    if [ ! -e "$TARGET/etc/fstab" ]; then
 
70
        echo '# UNCONFIGURED FSTAB FOR BASE SYSTEM' > "$TARGET/etc/fstab"
 
71
        chown 0.0 "$TARGET/etc/fstab"; chmod 644 "$TARGET/etc/fstab"
 
72
    fi
 
73
 
 
74
    setup_devices_fakechroot
 
75
 
 
76
    x_feign_install () {
 
77
        local pkg="$1"
 
78
        local deb="$(debfor $pkg)"
 
79
        local ver="$(
 
80
            ar -p "$TARGET/$deb" control.tar.gz | zcat |
 
81
                tar -O -xf - control ./control 2>/dev/null |
 
82
                sed -ne 's/^Version: *//Ip' | head -n 1
 
83
        )"
 
84
 
 
85
        mkdir -p "$TARGET/var/lib/dpkg/info"
 
86
 
 
87
        echo \
 
88
"Package: $pkg
 
89
Version: $ver
 
90
Status: install ok installed" >> "$TARGET/var/lib/dpkg/status"
 
91
 
 
92
        touch "$TARGET/var/lib/dpkg/info/${pkg}.list"
 
93
    }
 
94
 
 
95
    x_feign_install dpkg
 
96
}
 
97
 
 
98
second_stage_install () {
 
99
    x_core_install () {
 
100
        smallyes '' | in_target dpkg --force-depends --install $(debfor "$@")
 
101
    }
 
102
 
 
103
    p () {
 
104
        baseprog="$(($baseprog + ${1:-1}))"
 
105
    }
 
106
 
 
107
    setup_proc_fakechroot
 
108
 
 
109
    DEBIAN_FRONTEND=noninteractive
 
110
    export DEBIAN_FRONTEND
 
111
 
 
112
    baseprog=0
 
113
    bases=40
 
114
 
 
115
    p; progress $baseprog $bases INSTBASE "Installing base system" #1
 
116
    info INSTCORE "Installing core packages..."
 
117
 
 
118
    p; progress $baseprog $bases INSTBASE "Installing base system" #2
 
119
    ln -sf mawk "$TARGET/usr/bin/awk"
 
120
    x_core_install base-files base-passwd
 
121
    p; progress $baseprog $bases INSTBASE "Installing base system" #3
 
122
    x_core_install dpkg
 
123
 
 
124
    if [ ! -e "$TARGET/etc/localtime" ]; then
 
125
        ln -sf /usr/share/zoneinfo/UTC "$TARGET/etc/localtime"
 
126
    fi
 
127
 
 
128
    install_fakechroot_tools
 
129
 
 
130
    p; progress $baseprog $bases INSTBASE "Installing base system" #4
 
131
    x_core_install $LIBC6
 
132
 
 
133
    p; progress $baseprog $bases INSTBASE "Installing base system" #5
 
134
    x_core_install perl-base
 
135
    p; progress $baseprog $bases INSTBASE "Installing base system" #6
 
136
    rm "$TARGET/usr/bin/awk"
 
137
    x_core_install mawk
 
138
    p; progress $baseprog $bases INSTBASE "Installing base system" #7
 
139
 
 
140
    info UNPACKREQ "Unpacking required packages..."
 
141
 
 
142
    p; progress $baseprog $bases INSTBASE "Installing base system" #8
 
143
    smallyes '' | repeat 5 in_target_failmsg UNPACK_REQ_FAIL_FIVE "Failure while unpacking required packages.  This will be attempted up to five times." "" dpkg --force-depends --unpack $(debfor $required)
 
144
    p 10; progress $baseprog $bases INSTBASE "Installing base system" #18
 
145
 
 
146
    info CONFREQ "Configuring required packages..."
 
147
 
 
148
    mv "$TARGET/sbin/start-stop-daemon" "$TARGET/sbin/start-stop-daemon.REAL"
 
149
    echo \
 
150
"#!/bin/sh
 
151
echo
 
152
echo \"Warning: Fake start-stop-daemon called, doing nothing\"" > "$TARGET/sbin/start-stop-daemon"
 
153
    chmod 755 "$TARGET/sbin/start-stop-daemon"
 
154
 
 
155
    setup_dselect_method apt
 
156
 
 
157
    p; progress $baseprog $bases INSTBASE "Installing base system" #19
 
158
    smallyes '' | in_target_failmsg CONF_REQ_FAIL "Failure while configuring required packages." "" dpkg --configure --pending --force-configure-any --force-depends
 
159
    p 10; progress $baseprog $bases INSTBASE "Installing base system" #29 
 
160
 
 
161
    info INSTBASE "Installing base packages..."
 
162
 
 
163
    p; progress $baseprog $bases INSTBASE "Installing base system" #30
 
164
    smallyes '' | repeat 5 in_target_failmsg INST_BASE_FAIL_FIVE "Failure while installing base packages.  This will be re-attempted up to five times." "" dpkg --force-auto-select --force-overwrite --force-confold --skip-same-version --unpack $(debfor $base)
 
165
 
 
166
    smallyes '' | repeat 5 in_target_failmsg CONF_BASE_FAIL_FIVE "Failure while configuring base packages.  This will be attempted 5 times." "" dpkg  --force-confold --skip-same-version  --configure -a
 
167
 
 
168
    p 9; progress $baseprog $bases INSTBASE "Installing base system" #39
 
169
 
 
170
    mv "$TARGET/sbin/start-stop-daemon.REAL" "$TARGET/sbin/start-stop-daemon"
 
171
 
 
172
    progress $bases $bases INSTBASE "Installing base system" #40
 
173
    info BASESUCCESS "Base system installed successfully."
 
174
}