Commit f45e6190 authored by Anthony Towns's avatar Anthony Towns

initial commit of debootstrap from sid (0.3.3.3)

r47260
parents
CC=gcc
CFLAGS=-Wall -W -O2
ARCH := $(shell dpkg --print-architecture)
setarchdevs = $(if $(findstring $(ARCH),$(1)),$(2))
DEVS := generic hde hdf hdg hdh sde sdf sdg sdh scd-all initrd input usb md lp rtc video \
$(call setarchdevs,i386,isdn-io eda edb sonycd mcd mcdx cdu535 \
optcd sjcd cm206cd gscd lmscd sbpcd \
aztcd bpcd dac960 ida fd0 fd1 ataraid cciss) \
$(call setarchdevs,sparc,hdc hdd busmice) \
$(call setarchdevs,m68k,fd0 fd1 adc add ade adf hdc hdd) \
$(call setarchdevs,powerpc,hdc hdd fd0 fd1 isdn-io m68k-mice) \
$(call setarchdevs,ia64,ida fd0 fd1 ataraid cciss)
all: pkgdetails devices-std.tar.gz devices.tar.gz debootstrap-arch
clean:
rm -f pkgdetails pkgdetails.o devices-std.tar.gz devices.tar.gz
rm -f debootstrap-arch
rm -rf dev
DSDIR=$(DESTDIR)/usr/lib/debootstrap
install:
mkdir -p $(DSDIR)/scripts
mkdir -p $(DESTDIR)/usr/sbin
mkdir -p $(DESTDIR)/usr/share/man/man8
install -o root -g root -m 0644 potato $(DSDIR)/scripts/
install -o root -g root -m 0644 woody $(DSDIR)/scripts/
install -o root -g root -m 0644 woody.buildd $(DSDIR)/scripts/
install -o root -g root -m 0644 sarge $(DSDIR)/scripts/
install -o root -g root -m 0644 sarge.buildd $(DSDIR)/scripts/
install -o root -g root -m 0644 sarge.fakechroot $(DSDIR)/scripts/
install -o root -g root -m 0644 sid $(DSDIR)/scripts/
install -o root -g root -m 0644 warty $(DSDIR)/scripts/
install -o root -g root -m 0644 warty.buildd $(DSDIR)/scripts/
install -o root -g root -m 0644 hoary $(DSDIR)/scripts/
install -o root -g root -m 0644 hoary.buildd $(DSDIR)/scripts/
install -o root -g root -m 0644 breezy $(DSDIR)/scripts/
install -o root -g root -m 0644 functions $(DSDIR)/
# no special script for etch anymore
ln -s sid $(DSDIR)/scripts/etch
ln -s sid $(DSDIR)/scripts/lenny
install -o root -g root -m 0755 debootstrap.8 $(DESTDIR)/usr/share/man/man8/
install -o root -g root -m 0755 debootstrap $(DESTDIR)/usr/sbin/
install-allarch: install
install -o root -g root -m 0644 devices-std.tar.gz \
$(DSDIR)/devices.tar.gz
install-arch: install
install -o root -g root -m 0755 pkgdetails $(DSDIR)/
install -o root -g root -m 0644 devices.tar.gz $(DSDIR)/
install -o root -g root -m 0644 debootstrap-arch $(DSDIR)/arch
pkgdetails: pkgdetails.o
$(CC) -o $@ $^
debootstrap-arch:
echo $(ARCH) >debootstrap-arch
devices-std.tar.gz:
rm -rf dev
mkdir -p dev
chown 0:0 dev
chmod 755 dev
(cd dev && /dev/MAKEDEV std ptmx)
tar cf - dev | gzip -9 >devices-std.tar.gz
rm -rf dev
devices.tar.gz:
rm -rf dev
mkdir -p dev
chown 0:0 dev
chmod 755 dev
(cd dev && /dev/MAKEDEV $(DEVS))
ifeq ($(ARCH),powerpc)
# Maybe remove amiga/atari mice also? What about usbmouse?
rm -f dev/adbmouse
ln -sf input/mice dev/mouse
ln -sf input/js0 dev/js0
ln -sf input/js1 dev/js1
endif
@if ! find dev -maxdepth 0 -perm 755 -uid 0 -gid 0 | \
grep -q "^dev$$"; \
then \
echo "======================================================="; \
echo "ERROR"; echo; \
echo "./dev has bad permissions! should be 755 root.root. Was:"; \
ls -ld ./dev; \
echo "======================================================="; \
false; \
fi
tar cf - dev | gzip -9 >devices.tar.gz
rm -rf dev
Features:
++ second stage via chroot debootstrap/debootstrap
++ debootstrap/deb file to record deb destinations/information
-- configuration file
-- versus command line
-- support for sources (vs mirrors)
-- faux-pinning for packages
++ merge variants into single script (optionally anyway)
++ makedev in second stage
++ awk/perl pkgdetails
++ granular dpkg progress bar
++ determine required/base dynamically
++ store required/base in $T/debootstrap for two-stage installs
Packages format:
std: Priority: required + Priority: important
buildd: Priority: required + Build-Essential: yes
mirror_style release
download_style apt
finddebs_style from-indices
variants - buildd
work_out_debs () {
LIBC6=libc6
if [ "$ARCH" = "alpha" -o "$ARCH" = "ia64" ]; then LIBC6="libc6.1"; fi
required="$(get_debs Priority: required)"
if doing_variant -; then
#required="$required $(get_debs Priority: important)"
# ^^ should be getting debconf here somehow maybe
base="$(get_debs Priority: important)"
elif doing_variant buildd; then
# TODO: add Build-Essential: yes extraoverrides
#base="$(get_debs Build-Essential: yes)"
add () { if [ "$ARCH" = "$1" ]; then eval "$2=\"\$$2 $3\""; fi; }
base="apt binutils cpio cpp cpp-4.0 dpkg-dev g++ g++-4.0 gcc gcc-4.0 gcc-4.0-base ${LIBC6}-dev libdb4.2 libgdbm3 libstdc++6 libstdc++6-4.0-dev linux-kernel-headers make patch perl perl-modules"
add ia64 base "libunwind7-dev"
add sparc base "lib64gcc1"
add sparc base "libc6-dev-sparc64"
add sparc base "libc6-sparc64"
fi
}
first_stage_install () {
extract $required
mkdir -p "$TARGET/var/lib/dpkg"
: >"$TARGET/var/lib/dpkg/status"
echo >"$TARGET/var/lib/dpkg/available"
setup_etc
if [ ! -e "$TARGET/etc/fstab" ]; then
echo '# UNCONFIGURED FSTAB FOR BASE SYSTEM' > "$TARGET/etc/fstab"
chown 0.0 "$TARGET/etc/fstab"; chmod 644 "$TARGET/etc/fstab"
fi
setup_devices
x_feign_install () {
local pkg="$1"
local deb="$(debfor $pkg)"
local ver="$(
ar -p "$TARGET/$deb" control.tar.gz | zcat |
tar -O -xf - control ./control 2>/dev/null |
sed -ne 's/^Version: *//Ip' | head -n 1
)"
mkdir -p "$TARGET/var/lib/dpkg/info"
echo \
"Package: $pkg
Version: $ver
Status: install ok installed" >> "$TARGET/var/lib/dpkg/status"
touch "$TARGET/var/lib/dpkg/info/${pkg}.list"
}
x_feign_install dpkg
}
second_stage_install () {
x_core_install () {
smallyes '' | in_target dpkg --force-depends --install $(debfor "$@")
}
p () {
baseprog="$(($baseprog + ${1:-1}))"
}
setup_proc
in_target /sbin/ldconfig
DEBIAN_FRONTEND=noninteractive
DEBCONF_NONINTERACTIVE_SEEN=true
export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN
baseprog=0
bases=7
p; progress $baseprog $bases INSTCORE "Installing core packages" #1
info INSTCORE "Installing core packages..."
p; progress $baseprog $bases INSTCORE "Installing core packages" #2
ln -sf mawk $TARGET/usr/bin/awk
x_core_install base-files base-passwd
p; progress $baseprog $bases INSTCORE "Installing core packages" #3
x_core_install dpkg
if [ ! -e "$TARGET/etc/localtime" ]; then
ln -sf /usr/share/zoneinfo/UTC "$TARGET/etc/localtime"
fi
p; progress $baseprog $bases INSTCORE "Installing core packages" #4
x_core_install $LIBC6
p; progress $baseprog $bases INSTCORE "Installing core packages" #5
x_core_install perl-base
p; progress $baseprog $bases INSTCORE "Installing core packages" #6
rm $TARGET/usr/bin/awk
x_core_install mawk
p; progress $baseprog $bases INSTCORE "Installing core packages" #7
if doing_variant -; then
x_core_install debconf
fi
baseprog=0
bases=$(set -- $required; echo $#)
info UNPACKREQ "Unpacking required packages..."
smallyes '' |
(repeat 5 in_target_failmsg UNPACK_REQ_FAIL_FIVE "Failure while unpacking required packages. This will be attempted up to five times." "" \
dpkg --status-fd 8 --force-depends --unpack $(debfor $required) 8>&1 1>&7 |
dpkg_progress $baseprog $bases UNPACKREQ "Unpacking required packages" UNPACKING) 7>&1
info CONFREQ "Configuring required packages..."
mv "$TARGET/sbin/start-stop-daemon" "$TARGET/sbin/start-stop-daemon.REAL"
echo \
"#!/bin/sh
echo
echo \"Warning: Fake start-stop-daemon called, doing nothing\"" > "$TARGET/sbin/start-stop-daemon"
chmod 755 "$TARGET/sbin/start-stop-daemon"
setup_dselect_method apt
smallyes '' |
(in_target_failmsg CONF_REQ_FAIL "Failure while configuring required packages." "" \
dpkg --status-fd 8 --configure --pending --force-configure-any --force-depends 8>&1 1>&7 |
dpkg_progress $baseprog $bases CONFREQ "Configuring required packages" CONFIGURING) 7>&1
baseprog=0
bases="$(set -- $base; echo $#)"
info UNPACKBASE "Unpacking the base system..."
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 --status-fd 8 --force-auto-select --force-overwrite --force-confold --skip-same-version --unpack $(debfor $base) 8>&1 1>&7 |
dpkg_progress $baseprog $bases UNPACKBASE "Unpacking base system" UNPACKING) 7>&1
info CONFBASE "Configuring the base system..."
smallyes '' |
(repeat 5 in_target_failmsg CONF_BASE_FAIL_FIVE "Failure while configuring base packages. This will be attempted 5 times." "" \
dpkg --status-fd 8 --force-confold --skip-same-version --configure -a 8>&1 1>&7 |
dpkg_progress $baseprog $bases CONFBASE "Configuring base system" CONFIGURING) 7>&1
mv "$TARGET/sbin/start-stop-daemon.REAL" "$TARGET/sbin/start-stop-daemon"
progress $bases $bases CONFBASE "Configuring base system"
info BASESUCCESS "Base system installed successfully."
}
README for debootstrap
======================
See the manpage for (some) documentation.
Future
------
* Cross-strap support - so you can bootstrap a filesystem to the
point where it will successfully boot, and finish installing itself
without having to be running the target architecture or OS yourself.
This means you should be able to run
debootstrap --arch powerpc sarge ./sarge-ppc-chroot ...
on an i386 system, boot a powerpc box with sarge-ppc-chroot as its
root files system, and have it "work". The cross-hurd package does
something similar, and should be replaced by this feature.
* There should be some (better) way of telling debootstrap what "base"
packages you want to install -- this varies between making a chroot,
doing an install, and doing a buildd. Also, some installs want
different base packages (to setup networking, or kernels, eg)
* There should be some be some way of intuiting required/base from the
Packages file. Unfortunately this requires changes to apt-ftparchive
so we can have different packages be required or in base on different
architectures.
NMUing
------
If you're working on boot-floppies or debian-installer or similar, and
there's a problem with debootstrap that you need fixed, feel free to do
an NMU to fix it. Usual rules: try not to break anything, and mail the
patch to the BTS. Don't worry about asking first though.
This diff is collapsed.
Source: debootstrap
Section: admin
Maintainer: Anthony Towns <ajt@debian.org>
Uploaders: J.H.M. Dassen (Ray) <jdassen@debian.org>
Build-Depends: debhelper (>= 4.2), makedev (>= 2.3.1-69)
Standards-Version: 3.6.2
Package: debootstrap
Priority: extra
Architecture: all
Depends: wget, binutils
Description: Bootstrap a basic Debian system
debootstrap is used to create a Debian base system from scratch,
without requiring the availability of dpkg or apt. It does this by
downloading .deb files from a mirror site, and carefully unpacking them
into a directory which can eventually be chrooted into.
Package: debootstrap-udeb
Priority: required
Section: debian-installer
XC-Package-Type: udeb
Architecture: any
Depends: ${shlibs:Depends}, mounted-partitions
Description: Bootstrap the Debian system
debootstrap is used to create a Debian base system from scratch,
without requiring the availability of dpkg or apt. It does this by
downloading .deb files from a mirror site, and carefully unpacking them
into a directory which can eventually be chrooted into.
.
debootstrap-udeb is a minimal package used by debian-installer.
This package was debianized by Anthony Towns <ajt@debian.org> on
Tue, 30 Jan 2001 10:54:45 +1000.
It was written from scratch for Debian by Anthony Towns <ajt@debian.org>
based loosely on the code for constructing base tarballs as part of the
boot-floppies package.
The upstream site is http://code.erisian.com.au/Wiki/debootstrap .
Copyright:
Copyright (c) 2001-2005 Anthony Towns
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
usr/lib/debootstrap/scripts
usr/share/man/man8
usr/sbin
usr/share/man/man8
#!/usr/bin/make -f
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
configure:
dh_testdir
clean:
dh_testdir
-$(MAKE) clean
dh_clean
build: configure
# need to be root to make devices, so build is done in install target
real-build: build
dh_testdir
dh_testroot
$(MAKE) all
install: real-build
dh_testdir
dh_testroot
dh_clean -k
dh_installdirs
# install the package into debian/debootstrap
$(MAKE) install-allarch DESTDIR=$(CURDIR)/debian/debootstrap
$(MAKE) install-arch DESTDIR=$(CURDIR)/debian/debootstrap-udeb
binary-indep: install
# We have nothing to do by default.
ARCHES="i386"
SUITE="testing"
VERSION=$(SUITE)
MIRROR="http://ftp.debian.org/debian"
binary-basedebs:
dh_testdir
dh_testroot
$(MAKE) pkgdetails
ln -s . scripts
for a in $(ARCHES); do \
rm -rf chroot-dir; \
mkdir -p chroot-dir; \
DEBOOTSTRAP_DIR=. ./debootstrap --arch $$a --download-only $(SUITE) chroot-dir $(MIRROR); \
(cd chroot-dir && tar cf ../../basedebs_$(VERSION)_$$a.tar *); \
rm -rf chroot-dir; \
done
rm -f scripts
binary-indep: install
dh_testdir
dh_testroot
dh_installdocs -i
dh_installman -i debootstrap.8
dh_installchangelogs -i
dh_link -i
dh_compress -i
dh_fixperms -i
dh_installdeb -i
dh_shlibdeps -i
dh_gencontrol -i
dh_md5sums -i
dh_builddeb -i
binary-arch: install
dh_testdir
dh_testroot
-rm -rf debian/debootstrap-udeb/usr/share \
debian/debootstrap-udeb/usr/lib/debootstrap/scripts/potato \
debian/debootstrap-udeb/usr/lib/debootstrap/scripts/*.buildd \
debian/debootstrap-udeb/usr/lib/debootstrap/scripts/*.fakechroot
dh_strip -s
dh_compress -s
dh_fixperms -s
dh_installdeb -s
dh_shlibdeps -s
dh_gencontrol -s
dh_builddeb -s
binary: binary-indep binary-arch
.PHONY: build real-build clean binary-indep binary-arch binary install configure binary-basedebs
This diff is collapsed.
.TH DEBOOTSTRAP 8 2001-04-27 "Debian Project" "Debian GNU/Linux manual"
.SH NAME
debootstrap \- Bootstrap a basic Debian system
.SH SYNOPSIS
.B debootstrap
.RB [ OPTION\&.\&.\&. ]
.I SUITE TARGET
.RI [ MIRROR
.RI [ SCRIPT ]]
.B debootstrap
.RB [ OPTION\&.\&.\&. ]
.R --second-stage
.SH DESCRIPTION
.B debootstrap
bootstraps a basic Debian system of
.I SUITE
(eg, sarge, etch, lenny, sid) into
.I TARGET
from
.I MIRROR
by running
.IR SCRIPT .
.I MIRROR
can be an http:// URL or a file:/// URL. Notice that file:/ URLs are
translated to file:/// (correct scheme as described in RFC1738 for local filenames),
and file:// will \fBnot\fR work.
.PP
\fBDebootstrap\fR can be used to install Debian in a system without using an
installation disk but can also be used to run a different Debian flavor in a \fBchroot\fR
environment. This way you can create a full (minimal) Debian installation which
can be used for testing purposes (see the \fBEXAMPLES\fR section).
If you are looking for a chroot system to build packages please take a look at
\fBpbuilder\fR.
.SH "OPTIONS"
.PP
.IP "\fB\-\-arch ARCH\fP"
Set the target architecture (use if dpkg isn't installed). See also \-\-foreign.
.IP
.IP "\fB\-\-include=alpha,beta\fP"
Comma separated list of packages which will be added to download and extract
lists. Don't forget to resolve the dependencies manually, otherwise the
installation may fail.
.IP
.IP "\fB\-\-exclude=alpha,beta\fP"
Comma separated list of packages which will be removed from download and
extract lists. WARNING: you can and probably will exclude essential packages, be
careful using this option.
.IP
.IP "\fB\-\-no\-resolve\-deps\fP"
By default, debootstrap will attempt to automatically resolve any missing
dependencies, warning if any are found. Note that this is not a complete
dependency resolve in the sense of dpkg or apt, and that it is far better
to specify the entire base system than rely on this option. With this
option set, this behaviour is disabled.
.IP
.IP "\fB\-\-variant=buildd|fakechroot\fP"
Name of the bootstrap script variant to use. Currently, the variant
supported are buildd, which installs the build-essential packages into
.IR TARGET
and fakechroot, which installs the packages without root privileges.
The default, with no \fB\-\-variant=X\fP argument, is to create a base
Debian installation in
.IR TARGET .
.IP
.IP "\fB\-\-verbose\fP"
Produce more info about downloading.
.IP
.IP "\fB\-\-print\-debs\fP"
Print the packages to be installed, and exit. Note that a TARGET directory
must be specified so debootstrap can download Packages files to determine
which packages should be installed, and to resolve dependencies. The TARGET
directory will be deleted unless \-\-keep\-debootstrap\-dir is specified.
.IP
.IP "\fB\-\-download\-only\fP"
Download packages, but don't perform installation
.IP
.IP "\fB\-\-foreign\fP"
Do the initial unpack phase of bootstrapping only, for example if the
target architecture does not match the host architecture. A copy of
debootstrap sufficient for completing the bootstrap process will be
installed as /deboostrap/debootstrap in the target filesystem.
.IP
.IP "\fB\-\-second\-stage\fP"
Complete the bootstrapping process. Other arguments are generally not
needed.
.IP
.IP "\fB\-\-keep\-debootstrap\-dir\fP"
Don't delete the /debootstrap directory in the target after completing the
installation.
.IP
.IP "\fB\-\-unpack\-tarball FILE\fP"
Acquire .debs from tarball FILE instead of downloading via http
.IP
.IP "\fB\-\-boot\-floppies\fP"
Used for internal purposes by boot-floppies
.IP
.IP "\fB\-\-debian\-installer\fP"
Used for internal purposes by the debian-installer
.IP
.SH "EXAMPLE"
.
.PP
To setup a \fIsarge\fR system:
.PP
# debootstrap sarge ./sarge-chroot http://ftp.debian.org/debian
.PP
# debootstrap sarge ./sarge-chroot file:///PATH_TO_LOCAL_MIRROR/debian
.PP
Full process to create a complete Debian installation of \fIsid\fR (unstable):
.PP
main # cd / ; mkdir /sid-root
main # debootstrap sid /sid-root http://ftp.debian.org/debian/
[ ... watch it download the whole system ]
main # echo "proc /sid-root/proc proc none 0 0" >> /etc/fstab
main # mount proc /sid-root/proc -t proc
main # cp /etc/hosts /sid-root/etc/hosts
main # chroot /sid-root /bin/bash
chroot # dselect
[ you may use aptitude, install mc and vim ... ]
main # echo "8:23:respawn:/usr/sbin/chroot /sid-root " \\
"/sbin/getty 38400 tty8" >> /etc/inittab
[ define a login tty that will use this system ]
main # init q
[ reload init ]
.PP
Note that you will generally need a recent version of debootstrap to
do this; the version currently in stable will generally have stopped
working due to changes to unstable shortly after the last release.
.SH AUTHOR
.B debootstrap
was written by Anthony Towns <ajt@debian.org>.
This manpage was written by Matt Kraai <kraai@debian.org>.
This diff is collapsed.
mirror_style release
download_style apt
work_out_debs () {
required="base-files base-passwd bash bsdutils coreutils libacl1 libattr1 debconf debconf-i18n liblocale-gettext-perl libtext-iconv-perl libtext-wrapi18n-perl libtext-charwidth-perl debianutils diff dpkg dselect libblkid1 e2fsprogs e2fslibs libcomerr2 libss2 libuuid1 findutils grep gzip hostname libcap1 libdb1-compat libdb3 libncurses5 libnewt0.51 libpam-modules libpam-runtime libpam0g libpopt0 login makedev mawk mount ncurses-base ncurses-bin passwd perl-base procps python-minimal python2.4-minimal sed slang1a-utf8 lsb-base initscripts sysvinit sysv-rc tar util-linux zlib1g whiptail libgcc1 gcc-3.3-base libstdc++5"
base="adduser alsa-base alsa-utils apt apt-utils aptitude at base-config bind9-host bsdmainutils bzip2 console-common console-data console-tools cpio cramfsprogs cron dash dhcp3-client dhcp3-common discover1 discover1-data dmsetup dnsutils dosfstools ed eject ethtool evms evms-ncurses fdutils file ftp gettext-base gnupg grepmap groff-base hdparm hotplug ifrename ifupdown info initrd-tools iproute iptables iputils-arping iputils-ping iputils-tracepath jfsutils klogd less libasound2 libbz2-1.0 libconsole libdb4.2 libdevmapper1.00 libdiscover1 libdns16 libevms-2.5 libfribidi0 libgc1 libgcrypt11 libgdbm3 libgnutls11 libgpg-error0 libgpmg1 libidn11 libisc7 libiw27 libldap2 liblockfile1 liblwres1 liblzo1 libmagic1 libncursesw5 libopencdk8 libparted1.6-12 libpcap0.8 libreiserfs0.3-0 libsasl2 libsasl2-modules libsigc++-1.2-5c102 libssl0.9.7 libtasn1-2 libusb-0.1-4 libwrap0 locales logrotate lsb-release lshw lsof lvm-common lvm10 lvm2 mailx man-db manpages mdadm mii-diag mime-support module-init-tools mtr-tiny mutt nano net-tools netbase netcat netkit-inetd ntp ntpdate openssh-client parted pciutils popularity-contest postfix postfix-tls ppp pppconfig pppoeconf psmisc python python2.4 reiser4progs reiserfsprogs reportbug rsync strace sudo sysklogd tcpd tcpdump telnet time ubuntu-base ubuntu-keyring udev usbutils vim vim-common w3m wget wireless-tools xfsprogs"
without_package () {
echo "$2" | tr ' ' '\n' | grep -v "^$1$" | tr '\n' ' '
}
subst_package () {
echo "$3" | tr ' ' '\n' | sed "s/^$1$/$2/" | tr '\n' ' '
}
LIBC6=libc6
case $ARCH in
"i386")
required="$required libc6 libc6-i686"
base="$base dmidecode libelfg0 ltrace memtest86+ libreadline4"
;;
"powerpc")
required="$required libc6 libreadline4"
base="$base hfsplus hfsutils libelfg0 libhfsp0 ltrace mac-fdisk pmac-fdisk powerpc-utils"
;;
"amd64")
required="$required libc6"
base="$base dmidecode libelfg0 ltrace memtest86+ libreadline4"
;;
"ia64")
required="$required libc6.1 libunwind7"
base="$base dmidecode libreadline4"
LIBC6="libc6.1"
;;
"sparc")
required="$required libc6"
base="$base lib64gcc1 libc6-sparc64 libreadline4"
;;
*)
# who knows?
;;
esac
}
install_debs () {
first_stage_install
second_stage_install
}
first_stage_install () {
extract $required
mkdir -p "$TARGET/var/lib/dpkg"
: >"$TARGET/var/lib/dpkg/status"
echo >"$TARGET/var/lib/dpkg/available"
setup_etc
if [ ! -e "$TARGET/etc/fstab" ]; then
echo '# UNCONFIGURED FSTAB FOR BASE SYSTEM' > "$TARGET/etc/fstab"
chown 0.0 "$TARGET/etc/fstab"; chmod 644 "$TARGET/etc/fstab"
fi
setup_devices
x_feign_install () {
local pkg="$1"
local deb="$(debfor $pkg)"
local ver="$(
ar -p "$TARGET/$deb" control.tar.gz | zcat |
tar -O -xf - control ./control 2>/dev/null |
sed -ne 's/^Version: *//Ip' | head -n 1
)"
mkdir -p "$TARGET/var/lib/dpkg/info"
echo \
"Package: $pkg
Version: $ver
Status: install ok installed" >> "$TARGET/var/lib/dpkg/status"
touch "$TARGET/var/lib/dpkg/info/${pkg}.list"
}
x_feign_install dpkg
}
second_stage_install () {
x_core_install () {
smallyes '' | in_target dpkg --force-depends --install $(debfor "$@")
}
p () {
baseprog="$(($baseprog + ${1:-1}))"
}
DEBIAN_FRONTEND=noninteractive
DEBCONF_NONINTERACTIVE_SEEN=true
export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN
baseprog=0
bases=7
setup_proc
in_target /sbin/ldconfig
p; progress $baseprog $bases INSTCORE "Installing core packages" #1
info INSTCORE "Installing core packages..."
p; progress $baseprog $bases INSTCORE "Installing core packages" #2
ln -sf mawk $TARGET/usr/bin/awk
x_core_install base-files base-passwd
p; progress $baseprog $bases INSTCORE "Installing core packages" #3
x_core_install dpkg
if [ ! -e "$TARGET/etc/localtime" ]; then
ln -sf /usr/share/zoneinfo/UTC "$TARGET/etc/localtime"
fi
p; progress $baseprog $bases INSTCORE "Installing core packages" #4
x_core_install $LIBC6
p; progress $baseprog $bases INSTCORE "Installing core packages" #5
x_core_install perl-base
p; progress $baseprog $bases INSTCORE "Installing core packages" #6
rm $TARGET/usr/bin/awk
x_core_install mawk
p; progress $baseprog $bases INSTCORE "Installing core packages" #7
x_core_install debconf
baseprog=0
bases="$(set -- $required; echo $#)"
info UNPACKREQ "Unpacking required packages..."
smallyes '' | (repeat 5 in_target_failmsg UNPACK_REQ_FAIL_FIVE "Failure while unpacking required packages. This will be attempted up to five times." "" dpkg --status-fd 8 --force-depends --unpack $(debfor $required) 8>&1 1>&7 | dpkg_progress $baseprog $bases UNPACKREQ "Unpacking required packages" UNPACKING) 7>&1
baseprog=0
info CONFREQ "Configuring required packages..."
mv "$TARGET/sbin/start-stop-daemon" "$TARGET/sbin/start-stop-daemon.REAL"
echo \
"#!/bin/sh
echo
echo \"Warning: Fake start-stop-daemon called, doing nothing\"" > "$TARGET/sbin/start-stop-daemon"
chmod 755 "$TARGET/sbin/start-stop-daemon"
setup_dselect_method apt
#on_exit "(in_target_nofail umount /dev/pts) || true"
smallyes '' | (in_target_failmsg CONF_REQ_FAIL "Failure while configuring required packages." "" dpkg --status-fd 8 --configure --pending --force-configure-any --force-depends 8>&1 1>&7 | dpkg_progress $baseprog $bases CONFREQ "Configuring required packages" CONFIGURING) 7>&1
baseprog=0