~ubuntu-branches/ubuntu/intrepid/debian-installer-utils/intrepid

« back to all changes in this revision

Viewing changes to apt-install

  • Committer: Bazaar Package Importer
  • Author(s): Joey Hess
  • Date: 2004-10-06 14:35:42 UTC
  • Revision ID: james.westby@ubuntu.com-20041006143542-uvoedmvwb1zn0jv9
Tags: 1.08
* Updated translations: 
  - Welsh (cy.po) by Dafydd Harries
  - Hebrew (he.po) by Lior Kaplan
  - Hungarian (hu.po) by VEROK Istvan
  - Romanian (ro.po) by Eddy Petrisor
  - Traditional Chinese (zh_TW.po) by Tetralet

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh -e
 
2
 
 
3
log=/var/log/messages
 
4
queue=/var/lib/apt-install/queue
 
5
 
 
6
mountpoints () {
 
7
        cut -d" " -f2 /proc/mounts | sort | uniq
 
8
}
 
9
 
 
10
# Create a policy-rc.d to stop maintainer scripts using invoke-rc.d from
 
11
# running init scripts. In case of maintainer scripts that don't use
 
12
# invoke-rc.d, add a dummy start-stop-daemon.
 
13
disable_daemons () {
 
14
        cat > /target/usr/sbin/policy-rc.d <<EOF
 
15
#!/bin/sh
 
16
exit 101
 
17
EOF
 
18
        chmod a+rx /target/usr/sbin/policy-rc.d
 
19
        
 
20
        if [ -e /target/sbin/start-stop-daemon ]; then
 
21
                mv /target/sbin/start-stop-daemon /target/sbin/start-stop-daemon.REAL
 
22
        fi
 
23
        cat > /target/sbin/start-stop-daemon <<EOF
 
24
#!/bin/sh
 
25
echo 1>&2
 
26
echo 'Warning: Fake start-stop-daemon called, doing nothing.' 1>&2
 
27
exit 0
 
28
EOF
 
29
        chmod a+rx /target/sbin/start-stop-daemon
 
30
}
 
31
 
 
32
enable_daemons () {
 
33
        rm -f /target/usr/sbin/policy-rc.d
 
34
        
 
35
        rm /target/sbin/start-stop-daemon
 
36
        mv /target/sbin/start-stop-daemon.REAL /target/sbin/start-stop-daemon
 
37
}
 
38
 
 
39
# If we don't have a working mirror yet, only queue the package;
 
40
# it will be installed later by the postinst in base-installer.
 
41
if [ ! -f /target/etc/apt/sources.list ] ; then
 
42
        # Add to list of extra packages to be installed into /target/.
 
43
        mkdir -p /var/lib/apt-install
 
44
        touch $queue
 
45
        for pkg in $@ ; do
 
46
                if ! grep -q "^$pkg$" $queue; then
 
47
                        echo "$pkg" >> $queue
 
48
                fi
 
49
        done
 
50
 
 
51
        exit 1 # Return error as the package is not ready to be used yet.
 
52
fi
 
53
 
 
54
# The C.UTF-8 locale is not usable inside /target/.  Unset it here to avoid
 
55
# warnings like 'perl: warning: Setting locale failed.'.
 
56
if [ "$LANG" = "C.UTF-8" ] ; then
 
57
        unset LANG
 
58
fi
 
59
 
 
60
# Try to enable proxy when using HTTP.  What about using ftp_proxy for
 
61
# FTP sources?
 
62
RET=`debconf-get mirror/protocol || true`
 
63
if [ "http" = "$RET" ]; then
 
64
        # try to find http proxy
 
65
        RET=`debconf-get mirror/http/proxy || true`
 
66
        if [ "$RET" ] ; then
 
67
                http_proxy="$RET"
 
68
                export http_proxy
 
69
        fi
 
70
fi
 
71
 
 
72
# Unset to avoid problems with packages using debconf.  This should
 
73
# avoid the following error when installing dash:
 
74
# "/var/lib/dpkg/info/ash/config: 1: Bad file descriptor"
 
75
# The problem only appear if /usr/share/debconf/confmodule is sourced
 
76
# into this script.
 
77
unset DEBIAN_HAS_FRONTEND
 
78
unset DEBIAN_FRONTEND
 
79
unset DEBCONF_FRONTEND
 
80
unset DEBCONF_REDIR
 
81
# Avoid debconf mailing notes at this point, or asking questions.
 
82
DEBCONF_ADMIN_EMAIL=""
 
83
export DEBCONF_ADMIN_EMAIL
 
84
DEBIAN_FRONTEND=noninteractive
 
85
export DEBIAN_FRONTEND
 
86
 
 
87
# Record the current mounts
 
88
mountpoints > /tmp/mount.pre
 
89
 
 
90
# Some packages (eg. the kernel-image package) require a mounted /proc/
 
91
# Only mount it if it isn't mounted already
 
92
if [ ! -f /target/proc/cmdline ] ; then
 
93
        mount -t proc proc /target/proc
 
94
fi
 
95
 
 
96
disable_daemons
 
97
ERRCODE=0
 
98
chroot /target apt-get -y install $@ < /dev/null >> $log 2>&1 || ERRCODE=$?
 
99
enable_daemons
 
100
 
 
101
# Undo the mounts done by the packages during installation.
 
102
# Reverse sorting to umount the deepest mount points first.
 
103
# Items with count of 1 are new.
 
104
for dir in $( (cat /tmp/mount.pre /tmp/mount.pre; mountpoints ) | \
 
105
             sort -r | uniq -c | grep "[[:space:]]1[[:space:]]" | \
 
106
             sed "s/[[:space:]]*[0-9][[:space:]]//"); do
 
107
        if ! umount $dir ; then
 
108
                logger -t apt-install "warning: Unable to umount '$dir'"
 
109
        fi
 
110
done
 
111
rm -f /tmp/mount.pre
 
112
 
 
113
if [ "$ERRCODE" != 0 ]; then
 
114
        exit 1
 
115
else
 
116
        exit 0
 
117
fi