4
queue=/var/lib/apt-install/queue
7
cut -d" " -f2 /proc/mounts | sort | uniq
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.
14
cat > /target/usr/sbin/policy-rc.d <<EOF
18
chmod a+rx /target/usr/sbin/policy-rc.d
20
if [ -e /target/sbin/start-stop-daemon ]; then
21
mv /target/sbin/start-stop-daemon /target/sbin/start-stop-daemon.REAL
23
cat > /target/sbin/start-stop-daemon <<EOF
26
echo 'Warning: Fake start-stop-daemon called, doing nothing.' 1>&2
29
chmod a+rx /target/sbin/start-stop-daemon
33
rm -f /target/usr/sbin/policy-rc.d
35
rm /target/sbin/start-stop-daemon
36
mv /target/sbin/start-stop-daemon.REAL /target/sbin/start-stop-daemon
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
46
if ! grep -q "^$pkg$" $queue; then
51
exit 1 # Return error as the package is not ready to be used yet.
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
60
# Try to enable proxy when using HTTP. What about using ftp_proxy for
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`
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
77
unset DEBIAN_HAS_FRONTEND
79
unset DEBCONF_FRONTEND
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
87
# Record the current mounts
88
mountpoints > /tmp/mount.pre
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
98
chroot /target apt-get -y install $@ < /dev/null >> $log 2>&1 || ERRCODE=$?
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'"
113
if [ "$ERRCODE" != 0 ]; then