diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..e459e71 --- /dev/null +++ b/Makefile @@ -0,0 +1,14 @@ + +all: + +install: + +clean: + $(RM) *tar.gz.cdbs-config_list + $(RM) *.1 *.3 + $(RM) doc/po4a.config + +check: + +test: + diff --git a/README b/README new file mode 100644 index 0000000..db1d2b5 --- /dev/null +++ b/README @@ -0,0 +1,115 @@ + Emdebian Bootstrapping + ====================== + +Cross-building can get very confusing at times. The confusion only increases +when dealing with a chroot. This document tries to cover some of the reasons, +some of the problems and tries to provide some clarity, at least as far as how +chroots can be used in Emdebian. + +There are multiple ways that Emdebian can relate to bootstrapping and chroots. +The most common method of using a chroot within Debian is pbuilder and the +pdebuild wrapper and this is the primary inspiration for using chroots in +Emdebian. Other methods revolve around QEMU or scratchbox and whilst this code +may be able to support such uses later, there are key differences in how and +why this method is separate. + +EMDEBIAN PBUILDER CHROOT MODEL +============================== + +The Debian pbuilder package exists to ensure package dependencies are complete +and to provide an environment to automate package building on all supported +Debian architectures without cluttering the build machine with every library +and dev package in the entire archive. This is particularly useful when +building GUI packages that can have two dozen dependencies or more. In +Emdebian, this separation between the build system packages and the chroot +packages becomes even more useful because cross-building often involves not +only installing the library and -dev package for the build architecture (e.g. +i386/amd64) but also building and installing the same library and -dev package +(with dependencies) in the TARGET architecture, e.g. arm, with apt-cross and +dpkg-cross. The chaos that could result from trying to upgrade the packages on +an Emdebian buildd system with a duplicate set of cross dependencies is truly +scary. + +In the pbuilder model, an Emdebian chroot is the SAME architecture as the +buildd - i386 on i386 etc. This mimics how emdebian-tools normally work. +Packages are then downloaded, patched and cross-built for the target +architecture, just as outside the chroot. This model, the pbuilder model of an +emdebian chroot, concentrates on dependencies rather than the actual +cross-building process. Inside such a chroot, cache files are used as normal to +avoid having to run the cross-compiled code during the build. + +The Emdebian chroot is similar in size to a normal Debian pbuilder chroot, +mainly because it is a full build environment, not an installation environment. + +This directory contains my experiments with debootstrap, using this pbuilder +model, trying to make a complete Emdebian cross-building environment that can +be compressed to a base.tgz. Changes to the chroot can be discarded, just as +with pbuilder, allowing dependencies to be tested. The main benefit is that +packages can be built without having to install long chains of cross +dependencies via apt-cross or dpkg-cross on the main system. To me, it's the +only way to cross-build GUI suites like GPE against a background of changing +dependencies. + +In the pbuilder model, Emdebian builds a chroot for the build architecture +(amd64/i386 etc.) - except that it will run emdebian-tools instead of pbuilder +to create the arm binaries (or whichever architecture is the dpkg-cross +default). I expect the same code to work for arm chroots on amd64 etc, but +mechanisms already exist for those so it's not the priority. + +In order to make best use of the existing pbuilder code, these are shell scripts +whereas the rest of emdebian-tools uses perl. + +DEPENDENCIES +------------ + +To emdebianise and cross-build packages, the chroot needs to install +emdebian-tools. This brings in the majority of dependencies to support building +Debian and Emdebian packages. This (current sample) code uses part of the +pbuilder source so that the eventual chroots behave as similarly as possible to +pbuilder and pdebuild in Debian. Therefore, the emdebian pbuilder chroot is NOT +designed or intended to be installed on any embedded device - it is intended for +cross-building packages for Emdebian only. See the SLIND installer for more +information or the emsandbox script in emdebian-tools. + +empdebuild depends on pbuilder and installing emdebian-tools within a chroot +causes pbuilder to be installed inside the chroot. Whilst empdebuild and emsandbox +could be split out into a separate package to prevent pbuilder being needed inside +the chroot, there are corner cases where this can be useful providing sufficient +care is taken. + +DIFFERENCES TO PBUILDER +----------------------- + +1. emdebian-tools handles the 'installaptlines' subroutine. +2. emdebian-tools dependencies handle the installation of build-essential dpkg-dev + and apt that pbuilder normally does separately. +3. emdebian-tools handles the BUILDPLACE via debconf. +4. Other embootstrap options are hardcoded - BUILDRESULT is placed in BUILDPLACE, + APTCACHE also and APTCACHEHARDLINK is set to yes. +5. emdebian-tools provides the emdebianised source package and patches. + +EMDEBIAN NATIVE CHROOT MODEL +============================ + +The same code should also be able to create a native chroot so that the +cross-built packages can be installed alongside each other for more testing. +These chroots have already been tested and instructions exist in the Wiki: +http://wiki.debian.org/EmDebian/CrossDebootstrap + +Trying to cross-build inside scratchbox limits you to where scratchbox will +install which is only certain architectures. emdebian-tools is about +cross-building Debian packages using normal Debian tools on a normal Debian +system. Emdebian and emdebian-tools are designed to make building inside +scratchbox redundant because it simply isn't sufficiently flexible. A +scratchbox2 has been mooted but nothing has happened yet. + +Cross-build using normal tools (maybe using the chroot as above) and then test +either on a native device or via scratchbox if you really have to. + +An Emdebian native chroot would be an arm chroot running on an amd64 system - +indeed it would need to support creation of a chroot *for* any supported Debian +architecture and be able to create and run that chroot *on* any supported +Debian architecture. + +This is only the first draft - if there are areas that need further clarification +or updating, please email the debian-embedded mailing list. diff --git a/TODO b/TODO new file mode 100644 index 0000000..aedfd69 --- /dev/null +++ b/TODO @@ -0,0 +1,146 @@ +TODO for bootstrap / pbuilder config. + +(no particular order) + +note: pbuilder bug - default mirror does not include deb-src version. + also: gnupg needs the user directory and to be run once for + dpkg-source! :-( + also need apt-get build-dep if using emchain + +copy build log and built files out of jail/ before compressing +define parameters - inherit from pbuilderrc + +These chroots have already been tested and instructions +exist in the Wiki. http://wiki.debian.org/EmDebian/CrossDebootstrap + +dpkg filter to remove unneeded files: + 1. /var/lib/dpkg/info/*.symbols + 2. /var/lib/dpkg/available-old + 3. /var/lib/dpkg/status-old +modify dpkg to drop /var/log/dpkg.log + or simply mount /var/log, /var/cache in RAM. + +modify apt to remove unwanted files: + /var/cache/apt/(src)?pkgcache.bin + always run apt-get clean + always drop files in /var/lib/apt/lists/ + +Split out /usr/share/X11/locale/ (1.3Mb) + +Drop /usr/lib/xorg/modules/libscanpci.so (2Mb) + +X fails to start without: +/usr/lib/xorg/modules/libpcidata.so +(can the file size be reduced?) + +Other candidates may be amongst: +100527 +47296 /usr +30674 /usr/lib +29150 /var +25092 /var/cache +25049 /var/cache/apt +24576 /var/cache/apt/pkgcache.bin +18138 /lib +12007 /lib/modules +12005 /lib/modules/2.6.25.2-pxa270 +11345 /lib/modules/2.6.25.2-pxa270/kernel +8224 /usr/share +7378 /usr/bin +6897 /lib/modules/2.6.25.2-pxa270/kernel/drivers +5822 /usr/lib/gconv +3747 /usr/lib/xorg +3745 /usr/lib/xorg/modules +3572 /var/lib +3358 /usr/lib/libgtk-x11-2.0.so.0.1200.3 +2780 /var/lib/dpkg +2744 /sbin +2709 /lib/modules/2.6.25.2-pxa270/kernel/fs +2414 /usr/share/zoneinfo +2153 /var/lib/dpkg/info +2046 /lib/modules/2.6.25.2-pxa270/kernel/drivers/usb +1799 /lib/modules/2.6.25.2-pxa270/kernel/drivers/media +1733 /usr/share/fonts +1656 /usr/bin/Xorg +1490 /tmp +1430 /usr/share/X11 +1381 /usr/share/X11/locale +1288 /lib/modules/2.6.25.2-pxa270/kernel/drivers/net +1179 /usr/lib/libcrypto.so.0.9.8 +1160 /usr/share/fonts/X11 +1150 /lib/libc-2.7.so +1122 /usr/lib/libxml2.so.2.6.32 +1080 /bin +955 /lib/modules/2.6.25.2-pxa270/kernel/drivers/usb/serial +940 /lib/modules/2.6.25.2-pxa270/kernel/drivers/media/dvb +932 /usr/lib/xorg/modules/libpcidata.so +926 /usr/lib/libstdc++.so.6.0.10 +913 /lib/modules/2.6.25.2-pxa270/kernel/net +904 /usr/lib/libX11.so.6.2.0 +869 /usr/share/zoneinfo/right +846 /lib/modules/2.6.25.2-pxa270/kernel/drivers/media/video +842 /usr/bin/gpg +833 /usr/sbin +821 /usr/lib/libapt-pkg-libc6.6-6.so.4.6.0 +755 /var/lib/apt +751 /var/lib/apt/lists +744 /bin/busybox +742 /tmp/bb-1.11 +740 /tmp/busybox +740 /tmp/bb-1.11/busybox +731 /var/lib/apt/lists/buildd.emdebian.org_emdebian_dists_unstable_main_binary-arm_Packages +711 /usr/lib/libglib-2.0.so.0.1600.5 +685 /lib/modules/2.6.25.2-pxa270/kernel/fs/nls +666 /lib/modules/2.6.25.2-pxa270/kernel/sound +662 /usr/share/zoneinfo/posix +662 /lib/libslang.so.2.1.3 + + + +============================== + +Balloon todo list +------------------- + +Add CONFIG_DISPLAY_TOPPOLY in kernel build. + +$ grep perl usr/sbin/* +Binary file usr/sbin/chroot matches +usr/sbin/cleanup-info:#!/usr/bin/perl -- +usr/sbin/dpkg-divert:#!/usr/bin/perl -- +usr/sbin/dpkg-statoverride:#! /usr/bin/perl +Binary file usr/sbin/fbset matches +usr/sbin/install-info:#!/usr/bin/perl -- +usr/sbin/mkboot: bootpart=$(perl -ne 'print $1 if /^\s*boot\s*=\s*(\S*)/' /etc/lilo.conf) +usr/sbin/pam_getenv:#!/usr/bin/perl -w +Binary file usr/sbin/rdate matches +Binary file usr/sbin/udhcpd matches +usr/sbin/update-alternatives:#!/usr/bin/perl -- +(debianutils: /usr/sbin/mkboot) + +$ grep perl usr/bin/* | grep -v Binary +usr/bin/chkdupexe:#!/usr/bin/perl -w +usr/bin/chkdupexe:# Distribute under gnu copyleft (included in perl package) +usr/bin/chkdupexe:# - Made it possible to run with perl -w +usr/bin/chkdupexe: die "NUTS! Personaly I think your perl or filesystem is broken.\n". +(util-linux) + +Kernel command line: noinitrd root=/dev/mtdblock1 init=/linuxrc console=ttyS2,115200 rootfstype=yaffs2 cpufreq=59000-206400 machine_id=00000 + +balloon3_init_irq: chained handler installed - irq 126 automatically enabled + + +# grep oknodo /etc/init.d/S* +/etc/init.d/S10udev: if start-stop-daemon --stop --name udevd --quiet --oknodo --retry 5; then +/etc/init.d/S10udev: if start-stop-daemon --stop --name udevd --quiet --oknodo --retry 5; then +/etc/init.d/S10udev: if start-stop-daemon --stop --name udevd --quiet --oknodo --retry 5; then + +--retry is also not supported. + +mkdir /mnt/sda1 +mkdir /mnt/sda2 + +Add initscripts to get mountpoint for udev. + +drop install-info from dpkg + diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..89141d1 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +emdebian-rootfs (1.8.0) unstable; urgency=low + + * Initial split from emdebian-tools source package. + + -- Neil Williams Thu, 26 Mar 2009 21:59:13 +0000 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..6c3cd54 --- /dev/null +++ b/debian/control @@ -0,0 +1,49 @@ +Source: emdebian-rootfs +Section: utils +Priority: extra +Maintainer: Neil Williams +Uploaders: Wookey +Build-Depends: cdbs, debhelper (>= 5), po-debconf +Build-Depends-Indep: devscripts, docbook-xsl, + gnupg, libxml2-utils, po4a, xml-core, xsltproc +Standards-Version: 3.8.1 +Homepage: http://www.emdebian.org/ +Vcs-Browser: http://buildd.emdebian.org/svn/browser/current/ +Vcs-Svn: http://buildd.emdebian.org/repos/current/ + +Package: emdebian-rootfs +Architecture: all +Depends: ${perl:Depends}, ${misc:Depends}, apt, apt-cross (>= 0.5.0), + binutils-multiarch, debootstrap (>= 1.0.4), dpkg-cross (>= 2.1.0), + devscripts, emdebian-archive-keyring, multistrap, pbuilder, sudo, ucf + libparse-debian-packages-perl, libemdebian-tools-perl +Replaces: emdebian-tools (<= 1.4.3) +Suggests: deb-gview, debian-xcontrol, screen | minicom +Description: emdebian root filesystem support + Scripts for preparing root filesystems of Emdebian for specific + machines and variants. + . + Root filesystem tarballs created with emsandbox need minimal + configuration on the embedded device before the first boot. + . + Supports customisation of package selection and of files created + within the root filesystem. + +Package: multistrap +Section: admin +Architecture: all +Depends: ${perl:Depends}, ${misc:Depends}, apt, + libconfig-auto-perl, libparse-debian-packages-perl +Replaces: emdebian-rootfs (<= 1.6.0) +Description: multiple repository bootstrap based on apt + debootstrap replacement with multiple repository support + using apt to handle all dependency issues and conflicts. + . + Includes support for foreign architecture multistraps that need + only minimal configuration on the final device. Supports cleaning + up the generated bootstrap filesystem to remove downloaded packages + and hooks to modify the files in the bootstrap filesystem after + the packages have been unpacked but before being configured. + . + Unlike debootstrap, multistrap relies on working versions of + dpkg and apt outside the final filesystem. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..1c470f4 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,35 @@ +This package was downloaded from +http://buildd.emdebian.org/svn/browser/current/host/trunk/emdebian-tools/trunk/ + +Files: debian/* +Licence: GPL-3+ +Copyright: 2006-2007 Neil Williams + +Files: * +Licence: GPL-3+ +Copyright: Copyright 2006-2008 Neil Williams + Copyright 2008 Hands.com Ltd + Copyright 2006-2007 Wookey + Copyright 1998-2006 Craig Small + Copyright 1999-2003 Julian Gilbey + Copyright 2002,2003 Colin Walters + Copyright 2001-2006 Junichi Uekawa + Copyright 2001-2005 Anthony Towns + +License: + + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +On Debian systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL-3'. diff --git a/debian/emdebian-rootfs.install b/debian/emdebian-rootfs.install new file mode 100644 index 0000000..870dd66 --- /dev/null +++ b/debian/emdebian-rootfs.install @@ -0,0 +1,18 @@ +emsandbox ./usr/sbin +embootstrap ./usr/share/emdebian-tools/ +empbuilderlib ./usr/share/emdebian-tools/ +emsecondstage ./usr/share/emdebian-tools/ +update-rc.d ./usr/share/emdebian-tools/ +emrootfslib ./usr/share/emdebian-tools/ +emdebian.crossd ./usr/share/emdebian-tools/ +emdebian.gtk ./usr/share/emdebian-tools/ +emdebian.grip ./usr/share/emdebian-tools/ +emdebian.gpe ./usr/share/emdebian-tools/ +emdebian.coreutils ./usr/share/emdebian-tools/ +doc/man/man1/emsandbox.1 ./usr/share/man/man1/ +doc/man/man3/* ./usr/share/man/man3/ +examples/packages.conf ./usr/share/emdebian-tools/examples/machine/default/ +examples/setup.sh ./usr/share/emdebian-tools/examples/machine/default/ +examples/config.sh ./usr/share/emdebian-tools/examples/machine/default/ +examples/README ./usr/share/emdebian-tools/examples/ +emdebian-rootfs ./etc/bash_completion.d/ diff --git a/debian/emdebian-rootfs.postinst b/debian/emdebian-rootfs.postinst new file mode 100755 index 0000000..1326adf --- /dev/null +++ b/debian/emdebian-rootfs.postinst @@ -0,0 +1,35 @@ +#! /bin/sh +# clear out the now unsupported emsandbox conf file. + +set -e + +case "$1" in + configure) + if [ -f '/etc/emsandbox.conf' ]; then + # Remove the configuration files + if [ -e /usr/bin/ucf ]; then + ucfr --purge emdebian-rootfs /etc/emsandbox.conf + ucf --purge /etc/emsandbox.conf + fi + rm /etc/emsandbox.conf + rm -f /etc/emsandbox.conf.ucf-old + rm -f /etc/emsandbox.conf.ucf-new + rm -f /etc/emsandbox.conf.ucf-dist + fi + ;; + + remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/multistrap.install b/debian/multistrap.install new file mode 100644 index 0000000..791098e --- /dev/null +++ b/debian/multistrap.install @@ -0,0 +1,4 @@ +em_multistrap ./usr/sbin/ +multistrap ./usr/sbin/ +doc/man/man1/em_multistrap.1 ./usr/share/man/man1/ +bash/multistrap ./etc/bash_completion.d/ diff --git a/debian/multistrap.links b/debian/multistrap.links new file mode 100644 index 0000000..4decef0 --- /dev/null +++ b/debian/multistrap.links @@ -0,0 +1 @@ +/usr/share/man/man1/em_multistrap.1 /usr/share/man/man1/multistrap.1 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..dcf8533 --- /dev/null +++ b/debian/rules @@ -0,0 +1,16 @@ +#!/usr/bin/make -f +# Sample debian/rules that uses cdbs. Originally written by Robert Millan. +# This file is public domain. + +include /usr/share/cdbs/1/class/makefile.mk +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/rules/simple-patchsys.mk + +install/emdebian-rootfs:: + ./doc/genmanpages + po4a --rm-backups doc/po4a.config + +clean:: +# debconf-updatepo + rm -rf doc/man/man1 doc/man/man3 + rm -rf pod2htmd.tmp pod2htmi.tmp diff --git a/doc/genmanpages b/doc/genmanpages new file mode 100755 index 0000000..ca73d62 --- /dev/null +++ b/doc/genmanpages @@ -0,0 +1,112 @@ +#!/bin/sh +set -e + +# Copyright (C) 2006-2009 Neil Williams +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +wrap_langs () { + if [ -z "$LANGS" ]; then + echo "$1 $2" >> $CONFIG + else + echo "$1 $2 $3" >> $CONFIG + fi +} + +if [ -f po4a.config ]; then + cd ../ +fi +if [ -f ../po4a.config ]; then + cd ../../ +fi +CONFIG="doc/po4a.config" +# calculate the langs, automatically. +LANGS=`ls po/*.po 2>/dev/null || true` +if [ ! -z "$LANGS" ]; then + LANGS=`ls po/*.po | sed -e 's/.*\/\(.*\)\.po/\1 /' || true` +fi +if [ ! -z "$LANGS" ]; then + # LANGS should not include the specification, just the root. + LANGS=`echo $LANGS | sed -e 's/_.*//'` + LANGS=`echo $LANGS | sed -e 's/@.*//'` + LANGS=`echo $LANGS | sed -e 's/\+.*//'` + echo "[po4a_langs] $LANGS" > $CONFIG + else + echo > $CONFIG +fi +wrap_langs "[po4a_paths]" "po/emdebian-rootfs.pot" "\$lang:po/\$lang.po" +# need to determine directory for the target package. +# rootfs only has empbuilderlib.3, emrootfslib.3 and emsandbox.1 + +for l in $LANGS; do + mkdir -p doc/html/$l/ + mkdir -p doc/man/$l/man1/ + mkdir -p doc/man/$l/man3/ +done + +mkdir -p doc/html/ +mkdir -p doc/man/man3/ +mkdir -p doc/man/man1/ + +echo "Checking emrootfslib for POSIX compatibility" +# doesn't expect a shell library, hence nuisance message +# about interpreter that just needs to be ignored. +checkbashisms emrootfslib +echo "Processing Docbook XML . . . " +for file in `ls doc/xml/*.xml`; do + xmllint --format "$file" --output "$file" + LOCAL=`basename $file` + wrap_langs "[type:xml]" "$file" "\$lang:doc/xml/\$lang/$LOCAL" +done +echo "Processing POD . . ." + +# rootfs +for file in em_multistrap; do + pod2html -outfile doc/html/$file.html -title $file < $file + pod2man $file > doc/man/man1/$file.1 + wrap_langs "[type: pod]" "$file" "\$lang:doc/pod/\$lang/$file" +done + +echo "Refreshing POT file for translators" +# use -k to create all XML even if untranslated or the XSL breaks the build. +po4a -k 0 $CONFIG + +# just make sure the XML catalog is available for XSL. +# never go to the internet for build config, use -nonet. +XML_CATALOG_FILES="/etc/xml/catalog" \ +xsltproc -o doc/man/ -''-nonet http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl doc/xml/emdebian-rootfs.1.xml +mv doc/man/empbuilderlib.3 doc/man/man3/empbuilderlib.3 +mv doc/man/emrootfslib.3 doc/man/man3/emrootfslib.3 +mv doc/man/emsandbox.1 doc/man/man1/emsandbox.1 +mv doc/man/*.1 doc/man/man1/ +#mv doc/man/*.3 doc/man/man3/ + +for l in $LANGS; do + mkdir -p doc/man/$l/man3/ + mkdir -p doc/man/$l/man1/ + mv doc/man/$l/empbuilderlib.3 doc/man/$l/man3/empbuilderlib.3 + mv doc/man/$l/emsandbox.1 doc/man/$l/man1/emsandbox.1 + mv doc/man/$l/*.1 doc/man/$l/man1/ +done + +# never go to the internet for build config, use -nonet. +xsltproc -o doc/html/ -nonet http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl doc/xml/emdebian-rootfs.1.xml +for i in `ls doc/html/*.html`; do + iconv -t utf-8 -f iso8859-1 $i > doc/html/tmp + sed < doc/html/tmp > $i -e 's:charset=ISO-8859-1:charset=UTF-8:' +done +rm -f doc/html/tmp +rm -f pod2htmd.tmp +rm -f pod2htmi.tmp +rm -rf doc/pod/ diff --git a/doc/xml/emdebian-rootfs.1.xml b/doc/xml/emdebian-rootfs.1.xml new file mode 100644 index 0000000..8568749 --- /dev/null +++ b/doc/xml/emdebian-rootfs.1.xml @@ -0,0 +1,145 @@ + + + + + +]> + + + emdebian-rootfs + Sun 11 Jan 2009 19:55:45 GMT + Release: 1.8.0 + Emdebian + + Neil + Williams + + + The GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 + This documentation is part of emdebian-tools. + emdebian-tools is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + You should have received a copy of the GNU General Public License + along with this program. If not, see + http://www.gnu.org/licenses/. + + + In Debian you can find a copy of the GNU General + Public Licence in /usr/share/common-licenses/GPL-3 + + + + + Emdebian Tools Reference + + Purpose + This documentation consists primarily of the manpages for emdebian-tools + but also contains useful references and links to further reading on a variety of topics related + to Emdebian and cross building. It is intended to be read alongside the + Emdebian website and + Emdebian Wiki. + + + Some scripts embed the manpage content in the perl script as pod content. These manpages + are listed separately in the HTML versions. + + + Emdebian Tools manpages + &empdebuild; + &emsandbox; + &empbuilderlib; + &emrootfslib; + + + Other manpages and external links + These manpages are generated from perl instead of XML and are not currently listed + in the main table of contents. The HTML version is hosted separately: + + + Debian::Packages::Compare + Debian::Packages::Compare + manpage. + + + dh_gentdeb + dh_gentdeb manpage. + + + dpkg-gentdeb + dpkg-gentdeb manpage. + + + emtargetcmp + emtargetcmp manpage + + + emprunecross + emprunecross manpage + + + Emdebian::Tools + Emdebian::Tools function + reference. + + + + em_installtdeb + em_installtdeb manpage + + + emrecent + emrecent manpage + + + emgrip + emgrip manpage + + + em_autogrip + em_autogrip manpage + + + emdebcheck + emdebcheck manpage + + + emcache + emcache manpage + + + emdepends + emdepends manpage + + + splitout_tdeb + dplitout_tdeb manpage. + + + WWW references + + + + Emdebian.org website + + + + + Emdebian dependency maps + + + + + Emdebian presentation + + + + + + diff --git a/doc/xml/empbuilderlib.3.xml b/doc/xml/empbuilderlib.3.xml new file mode 100644 index 0000000..69c5745 --- /dev/null +++ b/doc/xml/empbuilderlib.3.xml @@ -0,0 +1,77 @@ + + + + empbuilderlib + + + + empbuilderlib + 3 + EMDEBIAN-ROOTFS + EMDEBIAN-ROOTFS + + + empbuilderlib + Common functions for Emdebian chroots + + + DESCRIPTION + empbuilderlib is intended solely for use on + the build machine. Do not use these functions in second_stage_install ! + empbuilderlib requires perl! + + empbuilderlib is a shell library which + requires perl and pbuilder (which means bash!). + empbuilderlib draws in POSIX shell functions + from emrootfslib to be able to call in functions from + first_stage_install within debootstrap. The only reasons to continue + putting new functions in here are if: + + + The functions are only useful to create cross-building chroots OR + + + the functions need to call pbuilder code directly and are not + necessary within first_stage_install. + + + + There should be no need to call pbuilder code within scripts that + generate a root filesystem. + + + autoclean_aptcache + Same as the pbuilder option but run by default in empdebuild + to remove obsolete .deb archives from the apt cache directories used by + empdebuild. + + + + copy_host_configuration + Copy hosts, hostname and resolv.conf from the system /etc/ + directory and adapts /etc/hostname to use a different + name (emdebian-$ARCH). + + + + extractembuildplace + Modified version of the equivalent function in pbuilder-modules + to extract the compressed chroot (used by empdebuild). + + + Author + empbuilderlib was written + by Neil Williams codehelp@debian.org. + + This manual page was written by Neil Williams + codehelp@debian.org + + + + SEE ALSO + See also apt-cross (1), + dpkg-cross (1), emdebian-tools (1), + emrootfslib (3). + + + diff --git a/doc/xml/empdebuild.1.xml b/doc/xml/empdebuild.1.xml new file mode 100644 index 0000000..45e4c15 --- /dev/null +++ b/doc/xml/empdebuild.1.xml @@ -0,0 +1,347 @@ + + + + empdebuild + + + + empdebuild + 1 + EMDEBIAN-TOOLS + EMDEBIAN-TOOLS + + + empdebuild + chroot tool for Emdebian cross compiling + + + + empdebuild + + -a + --arch + ARCHITECTURE + + + --testing + + + --login-after-fail + + + --build + build + + + + empdebuild + + -a + --arch + ARCHITECTURE + + + --testing + + + --create + create + + + + empdebuild + + -a + --arch + ARCHITECTURE + + + --testing + + + --save-after-login + + + --login + login + + + + empdebuild + + -a + --arch + ARCHITECTURE + + + --testing + + + --update + update + + + + empdebuild + + -a + --arch + ARCHITECTURE + + + --login-after-fail + + + --autobuild + autobuild + + + + empdebuild + + -a + --arch + ARCHITECTURE + + + --clean + clean + + + + + DESCRIPTION + Note that empdebuild does not support all the + options available to pbuilder. + + empdebuild is an Emdebian version of pdebuild, building + Emdebian packages in a chroot using code from pbuilder. The Emdebian chroot includes the + cross-building toolchain from Emdebian for the requested architecture and includes + support for installing cross versions of package dependencies via + apt-cross with all the advantages of a chroot - identification of + missing dependencies and the ability to build packages without installing the dependencies + on the main system, e.g. to support a buildd. + + + empdebuild is a build chroot + empdebuild creates a chroot for the same architecture as + the system running empdebuild and then installs a cross-building + toolchain from Emdebian using the dpkg-cross default + architecture or the specified architecture. This has some important results: + + + + The chroot is a Debian system running emdebian-tools + and is equivalent to a typical installation of emdebian-tools + after emsetup has been completed + successfully. This includes installing perl and debconf inside the chroot. + + + + A suitable Emdebian toolchain will be installed in the chroot. + + + + The same cache files are needed inside the chroot as would be needed on the + main system - cross-built binaries cannot be run + within the the chroot. All the normal emdebian patch files will be needed. + + + + This is a full build system with native and cross compilers, development + packages, autotools and subversion. It is NOT + suitable for installation on any device. Use emsandbox + instead. + + + + The chroot disables the installation of recommended packages by + apt using the Install-Recommends "false" option. + + + + + Use emsandbox to create cross chroots (where the + chroot is built for a different architecture to the system running the chroot), + e.g. to prepare a rootfs for installation on an arm device using emdebian-tools + installed on i386, amd64 etc. See emsandbox (1). + + + + COMMANDS + Options for dpkg-buildpackage can be given + after the option. The default options are + which cannot be overridden. Also certain + commands do not make sense in this context, + e.g. for architecture will be silently dropped. + + + + | + + (to provide) similar functionality to pdebuild for Emdebian - + copies the source into the chroot and runs a build using + emdebuild. + + Use to debug a failed build. + If emdebuild fails inside the chroot, + empdebuild will then open a shell at the point + of failure, allowing you to debug the build session with the active data. + + + + + | + + Runs debootstrap with a modified suite rule + set to create a basic Emdebian environment, including emdebian-tools and + an Emdebian toolchain for the default or specified architecture. + + Checks for an existing chroot and exits if one is found - either use + or move the old chroot out of the way. + + If fails after debootstrap has + completed, should be able to recover + and create the necessary tarball. + + + + + | + + Login to the chroot. Unless is used, + changes made within the chroot will be lost. + + When setting up any chroot, debconf is set to use the default values + and this leads to dpkg-cross being set to + None as the default cross building architecture. + When logged into the chroot, always specify the + option to apt-cross and all + emdebian-tools scripts. + + + + + | + + Updates the Emdebian environment, including emdebian-tools and + an Emdebian toolchain for the default or specified architecture. Depending on + the status of gcc-?.? in Debian, there can be problems updating the cross + building toolchain at this stage. If you get reports of broken packages + or toolchain packages that fail to install, allow the update to continue as + normal, then login to the chroot with the + option. If the problem relates to a package named $PACKAGE-$ARCH-cross + not $PACKAGE-$ARCHTYPE ($ARCHTYPE for arm = arm-linux-gnu), this + package is handled by dpkg-cross and apt-cross. + Use apt-cross -a $ARCH -v -i $PACKAGE (omit the -$ARCH-cross suffix) + to update such packages ahead of the Emdebian repository. Use + apt-get dist-upgrade and emsetup -a $ARCH --yes + to complete the upgrade. Type 'exit' or use 'Ctrl-D' to exit from the chroot and + the updated packages will be saved alongside the updated chroot. + + + + + | + + Uses pbuilder functions to clean the chroot build place, + removing any previous build environments. In some situations, a stale + build environment may still contain active mounts for + proc or dev/pts + and these will result in Device or resource busy errors. + To umount the relevant points, look for your Emdebian working directory being + listed in the output of mount and pass that + directory name to: + +$ sudo umount PATH + + Once umounted, either remove the files manually or run sudo empdebuild + again. + + + + + + + OPTIONS + + + | ARCHITECTURE + + Override the dpkg-cross default architecture + for this operation on the chroot. The Emdebian toolchain in the chroot + will be upgraded (or installed if the chroot contains a toolchain for a + different architecture). + + + + + + + + + Create, update, login or build a package within a chroot based on + Debian testing, not Debian unstable. This is a fallback option for the times + when Debian unstable transitions make it impossible to install a cross-building + toolchain or update the existing toolchain. + + + + + + + + + Login to the chroot and allow changes made within the chroot to persist + into subsequent sessions. Only supported in conjunction with + |. + + + + + + + + + Login to the chroot if emdebuild fails + within the chroot, at the point where the build failed. Chroot cross builds + can involve a protracted setup phase which can be hard to replicate + outside the chroot. Use this option to find out why a chroot build failed + when a normal build succeeded. Only supported in conjunction with + |. + + + + + | + + print the usage message and exit. + + + + + + + + print the usage message and exit. + + + + + + Author + empdebuild was written + by Neil Williams codehelp@debian.org. + + This manual page was written by Neil Williams + codehelp@debian.org + + + + SEE ALSO + See also apt-cross (1), em_make (1), + dpkg-cross (1), emdebian-tools (1), + emsandbox (1). + + + diff --git a/doc/xml/emrootfslib.3.xml b/doc/xml/emrootfslib.3.xml new file mode 100644 index 0000000..8816718 --- /dev/null +++ b/doc/xml/emrootfslib.3.xml @@ -0,0 +1,214 @@ + + + + emrootfslib + + + + emrootfslib + 3 + EMDEBIAN-ROOTFS + EMDEBIAN-ROOTFS + + + emrootfslib + Common functions for Emdebian root filesystems + + + DESCRIPTION + emrootfslib is intended solely for use on + the build machine. Do not use these functions in second_stage_install ! + emrootfslib requires perl! + + There should be no need to call pbuilder code within scripts that + generate a root filesystem and bash code must not be used in + emrootfslib. + + + basic_etc_fstab + Removing packages from the normal Debian debootstrap set can + mean that certain critical files can be omitted. basic_etc_fstab + creates a basic version of $TARGET/etc/fstab where it does not + already exist. + + + + basic_group_setup + Removing packages from the normal Debian debootstrap set can + mean that certain critical files can be omitted. basic_group_setup + creates a basic version of $TARGET/etc/group where it does not + already exist. + + + + basic_passwd_setup + Removing packages from the normal Debian debootstrap set can + mean that certain critical files can be omitted. basic_passwd_setup + creates a basic version of $TARGET/etc/passwd where it does not + already exist. + + + + busybox_inittab + Note: this function overwrites an existing $TARGET/etc/inittab + + busybox does not support runlevels and so the /etc/inittab + file needs to be modified to support busybox. Currently, this function + overwrites an existing $TARGET/etc/inittab - this is likely to change + in future versions. + + + + busybox_rcS + Note: this function overwrites an existing $TARGET/etc/init.d/rcS + + busybox does not support runlevels and so the /etc/init.d/rcS + script needs to be modified to support busybox. Currently, this function + overwrites an existing $TARGET/etc/init.d/rcS - this is likely to change + in future versions. + + + + check_dirs + Check that the $BUILDPLACE, $BUILDRESULT and $APTCACHE directories + exist (used by empdebuild). + + + checkarch + Calls check_arch from Debian::DpkgCross using perl. + The perl call dies if the specified string does not match a + supported architecture. + + + create_emdebiantgz + Modified version of the equivalent function in pbuilder-modules + to extract the compressed chroot (used by empdebuild). + + + disable_apt_recommends + Enforces a default of not installing recommended packages inside the + chroot. + + + + extra_etc_rcd + Removing packages from the normal Debian debootstrap set can + mean that certain critical files can be omitted. extra_etc_rcd + creates a basic version of $TARGET/etc/rcS.d where it does not + already exist. + + + + make_dpkg_dirs + Prepare for unpacking and general dpkg work by setting up + $TARGET/var/lib/dpkg/status and $TARGET/var/lib/dpkg/available. + + + + prepare_proc + Ensure that $TARGET/proc and $TARGET/sys exist so that + proc and sys can be mounted automatically. + + + + prepare_var + Ensure that $TARGET/var/log/ and $TARGET/var/spool exist so + that various installation routines can proceed. + + + + set_approx_time + Normal Debian installations have a network connection and + typical Debian desktop boxes also have a backup battery. Some + embedded machines do not have either of these systems, making + it impossible to store or retrieve even a vaguely close indication + of the current time. + + set_approx_time uses the systems available on the build + machine to store an approximate indication of the time that the + root filesystem was created and write that time to a file in the + root filesystem itself. For most purposes, this is sufficient for + the purposes of setting up the root filesystem to the point where + a network connection can be created and a call can be made to an + internet clock using ntpdate-debian. + + + + set_cdebconf_default + Adds "export DEBCONF_USE_CDEBCONF=true" to + $TARGET/etc/profile for cdebconf support. + + + + symlink_rcS + Call repeatedly to create init symlinks, using the template + $TARGET/etc/rcS.d/S$number$file + + + + + + + + file is the filename in $TARGET/etc/init.d/ + + + + + + + + + number is the number for the link in the init sequence. + + + + + + + unpack_debootstrap + Specialized routine that replaces the normal second stage of + debootstrap (you may consider it a series of hacks if you prefer). + unpack uses dpkg to extract the files from the .deb package and + process the control information. Unlike dpkg + , the unpack routine does + NOT run any maintainer scripts which + would inevitably fail in a cross built environment. + Instead, it updates the relevant dpkg status and database files + in the root filesystem and leaves the package in the unpacked state. + + unpack_debootstrap also sets up the busybox applets - future + versions may split this functionality into a separate function. + + unpack_debootstrap also performs checks on /usr/sbin/invoke-rc.d + and /usr/sbin/update-rc.d - future versions may split this functionality + into a separate function. + + Finally, unpack_debootstrap removes all .deb package files + from /var/cache/apt/archives. The remaining task (dpkg --configure -a) + is performed via emsecondstage. + + + x_feign_install + Copied from debootstrap suite scripts to make a basic + installation of a .deb package - although this is the basis of + unpack_debootstrap, it is only really used for dpkg itself. + + + + Author + empbuilderlib was written + by Neil Williams codehelp@debian.org. + + This manual page was written by Neil Williams + codehelp@debian.org + + + + SEE ALSO + See also apt-cross (1), + dpkg-cross (1), emdebian-tools (1), + empdebuilderlib (3). + + + diff --git a/doc/xml/emsandbox.1.xml b/doc/xml/emsandbox.1.xml new file mode 100644 index 0000000..63774af --- /dev/null +++ b/doc/xml/emsandbox.1.xml @@ -0,0 +1,448 @@ + + + + emsandbox + + + + emsandbox + 1 + EMDEBIAN-TOOLS + EMDEBIAN-TOOLS + + + emsandbox + create Emdebian root filesystems + + + + emsandbox + + -a + --arch + ARCHITECTURE + + + --create + create + + + + -s + --script + + FILENAME + + + -S + --suite + NAME + + + --machine-path + PATH + + + -m + --machine + NAME + + -v + --variant + NAME + + + + + + SHELL INTERPRETERS + emsandbox is bash code and uses + embootstrap which is bash code and also sources + pbuilder code which is also bash code. debootstrap + re-executes itself with the default shell and then tries to source the + suite script which fails because the re-executed copy of debootstrap is + now running under the default shell, not bash. + + This problem can show up as a failure within debootstrap + + +I: Retrieving zlib1g +I: Validating zlib1g + + The next line should be: + +I: Extracting base-passwd... + + Unfortunately, this is a result of the default shell + interpreter in Debian being changed after the scripts were written + and it is a non-trivial problem. It is not possible for + embootstrap could migrate to cdebootstrap currently. + + The only current solution is to change your default shell to + /bin/bash inside the environment running emsandbox. + + + + DESCRIPTION + emsandbox supports customised generation of + basic root filesystems from cross-built Emdebian packages, ready for + unpacking and configuring on an embedded device. + + Note that emsandbox does not support all the + options available to debootstrap. Some of the + debootstrap options that are supported are implemented as machine + specific configuration files in your Emdebian work directory. + (See and .) + + emsandbox is a wrapper for debootstrap to prepare + an Emdebian root filesystem, using Emdebian packages and a native chroot + via 'debootstrap --foreign' and code from pbuilder. + + The Emdebian rootfs, as generated by emsandbox + is not fully configured - packages are unpacked and certain support + files are created but none of the packages are configured (not even + the pre-install scripts). This last stage is the only process that + must be run on the actual device + before the first boot, using the emsecondstage + script which requires a working chroot environment. + Typically, emsecondstage is run from some kind of + minimal bootloader environment that has sufficient support for mounting + subsystems like proc and filesystems like the root filesystem partition + and can chroot into the root filesystem. This method means that the + majority of the work of creating the root filesystem can be done on + the build machine. + + The tarball created by emsandbox should be + copied onto the target device and unpacked using: + + +# cd /mnt/target/dir +# tar -xzpf emdebian-arm.tgz + + Immediately after unpacking, start the package configuration + by running ./emsecondstage on the target device. + (Configuration involves running the cross-built binaries and is the + only part of the process that must be run on the target device.) + + emsecondstage should always + be run from the directory into which it was installed. + + +# ./emsecondstage + + + + COMMANDS + + + | + + Runs debootstrap + with a modified suite rule set to create a basic Emdebian rootfs. + + Checks for an existing chroot and exits if one is found. + + + + + | + + print the usage message and exit. + + + + + + + + print the usage message and exit. + + + + + + OPTIONS + + + | ARCHITECTURE + + Override the dpkg-cross default architecture + for this operation on the chroot. + + + + + | FILENAME + + Override the default package selection and installation + script with a customised debootstrap suite script (written in shell + and compatible with whichever shell interpreter is to be installed + on the target). + + Some customised scripts are provided with emdebian-tools. The + default uses the standard Emdebian 'busybox' package with 'dpkg' and + 'apt'. Replacement scripts need to be full debootstrap suite shell + scripts that specify how to complete the first and second stage + installations. + + Customised scripts packages with emdebian-tools + include scripts for a root filesystem including libgtk2.0-0 and a complete + GPE root filesystem. + + + + + + PATH + + + Override the default path to machine and variant configuration. By + default, emsandbox uses ${WORK}/machine where + $WORK is the working directory specified + to emdebian-tools in the debconf configuration. + The specified path must already exist and contain the relevant + packages.conf configuration as well as the + setup.sh and config.sh shell + scripts (which may be empty). + + + + + | MACHINE + + Load machine specific configuration data from your Emdebian + working directory. If no variant is specified, config is read from + $WORK/machine/$MACHINE/default/ where $WORK + is the work directory specified in debconf for emdebian-tools. + + + + + | VARIANT + + Load variant specific configuration data from your Emdebian + working directory. Requires . Configuration + data is read from $WORK/machine/$MACHINE/$VARIANT/ where $WORK + is the work directory specified in debconf for emdebian-tools. + + + + + | NAME + + Override the default suite [unstable] and specify another + supported suite. Note that if the Emdebian repository is used, + the suite chosen must be a normal + Emdebian/Debian suite name from 'unstable, testing or sid', or + a Debian release codename for a release including or later + than lenny. No other suite name is supported in Emdebian. + + The selected suite is set in the root filesystem as the + default suite for apt to use when looking for updates. + + + + + + + Machine variants + emsandbox supports a set of customisation routines + for each combination of machine and variant, allowing the rootfs to be customised + to specific variants of a specific machine. Configuration data is stored in the + machine subdirectory of your Emdebian work directory. + Using the option to emsandbox loads + packages.conf from the $WORK/machine/$MACHINE/default + subdirectory prior to starting debootstrap. Once the first stage install is complete, + emsandbox calls setup.sh from the same + directory, passing the location and architecture of the tarball, so that other + fine tuning can take place prior to creating the tarball. At this stage, any + operations inside the rootfs must not try to execute any binaries within the + rootfs. Immediately before creating the tarball, config.sh + is copied into the /machine/$MACHINE/default/ directory + of the rootfs, ready to be called when emsecondstage has + completed the second stage of the debootstrap process. + + Skeleton versions of packages.conf, + setup.sh and config.sh are available + in /usr/share/emdebian-tools/machine/. + + packages.conf is intended to be the principal place + for adjusting the emsandbox tarball to suit the needs of specific machine variants. + setup.sh and config.sh can fine tune + the results but in order to avoid reinventing the wheel, if more than a few + machines need similar adjustments to the same files, future versions of + packages.conf will collate those into a single + configuration parameter available to all. + + packages.conf supports: + + + + + + + Add a comma separated list of package names to the list of packages + added to the tarball and installed in the second stage. Currently, debootstrap + has problems with multiple repositories so either upload this package to the + same repository as your other packages or create an apt-proxy that can serve + as a local repository, set it in and specify a usable + mirror for the device in . + DEFAULT: empty + + + + + + + + Overrides the default emsandbox suite-script that debootstrap uses to + determine the base and required packages and the all important sequence in which + the packages can be installed. SCRIPT can be overridden on the emsandbox command line. + + DEFAULT: /usr/share/emdebian-tools/emdebian.crossd + + + + + + + + Overrides the default emsandbox mirror. This repository will be set in + /etc/apt/sources.list and will also be used by debootstrap to obtain + all packages for the tarball unless is also set. + + DEFAULT: http://buildd.emdebian.org/emdebian/ + + + + + + + + Specifies a separate repository to pass to debootstrap that may be local or + otherwise not intended for use once the tarball is installed. Use + to set the same value in debootstrap and /etc/apt/sources.list. + If is specified without , the default + emsandbox MIRROR (http://buildd.emdebian.org/emdebian/) will be written into + /etc/apt/sources.list. + DEFAULT: empty + + + + + + + + Overrides the default name (emdebian-$ARCH) of the tarball. Do not specify a path here, + just a filename with the .tgz suffix. + DEFAULT: emdebian-$ARCH.tgz where $ARCH is specified to emsandbox or as the dpkg-cross + default architecture. + + + + + + + + + Override the default suite [unstable] and specify another + supported suite. Note that if the Emdebian repository is used, + the suite chosen must be a normal + Emdebian/Debian suite name from 'unstable, testing or sid', or + a Debian release codename for a release including or later + than lenny. No other suite name is supported in Emdebian. + + The selected suite is set in the root filesystem as the + default suite for apt to use when looking for updates. + + Not recommended to be changed. + + DEFAULT: unstable + + + + + Due to limitations in the current debootstrap support, the only way + of adding packages to the first stage is by providing a customised suite + script. Even if emsandbox migrates to using a tool from Stag to overcome + shortcomings in debootstrap, support for packages.conf, setup.sh and config.sh + will remain. + + + Automating rootfs builds + Providing you are trying to build a root filesystem for an + architecture supported within Debian, emdebian-tools + can help you automate the package builds. + See em_autobuild (1) + + + SHELL variables + Note that the Debian chroot program from coreutils expects you + to want the same shell outside the chroot as you want to use inside + the chroot. The typical Debian default shell in /etc/passwd + is bash which is not present in the Emdebian rootfs so chroot + needs the option. + + + FILES + Most emdebian-tools use configuration data from + apt-cross and dpkg-cross. + emsource and emsandbox also support + configuration using debconf to set a subversion username + and default working directory (which must be writable) for unpacking source + downloads. Default debconf values can be overridden with user-specific + values using ~/.apt-cross/emsource or + ~/.apt-cross/emsandbox respectively. + + + /etc/emsandbox.conf + System-wide configuration file handled by debconf + controlling unpacking source archives to a default working + directory. Can also include a subversion username setting, intended for + single-user installations. /etc/emsandbox.conf + settings can be overridden on a per-user basis by copying the current + file to ~/.apt-cross/emsandbox and editing the + values. + Two variables can be set (see also /etc/emsandbox.conf): + + + + workingdir: A simple default + location for emsandbox to create a source tree to + download and unpack prebuilt binary packages. If left blank, a + new top level directory tree is used but this is intended for chroot + support only. + + + + targetsuite: Emdebian follows Debian by + defaulting to building against unstable. This setting determines the + versions of libraries and packages linked against the cross-built emdebian + packages. + + + + + + ~/.apt-cross/emsandbox + User-specific version of /etc/emsandbox.conf, + supporting the same variables to provide user-specific overrides. + + + + + Author + emsandbox was written + by Neil Williams codehelp@debian.org. + + This manual page was written by Neil Williams + codehelp@debian.org + + + + SEE ALSO + See also apt-cross (1), em_make (1), + dpkg-cross (1), emdebian-tools (1). + + + diff --git a/embootstrap b/embootstrap new file mode 100755 index 0000000..03d7605 --- /dev/null +++ b/embootstrap @@ -0,0 +1,382 @@ +#!/bin/bash +set -e + +# embootstrap -- create a bootstrap for emdebian builds +# +# Note that this script controls tarballs for empdebuild and emsandbox +# pass --cross to set an emsandbox tarball. +# +# Copyright (C) 2007-2008 Neil Williams +# +# This package is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +CWD=`pwd` + +# test for sudo +# make sure sudo is in use. +# bash cannot seem to do this when set -e is enabled +# because grep returns non-zero on a non-match +# so I use perl. :-) +ISROOT=`perl -e '$e=\`printenv\`; ($e =~ /\nUSER=root\n/) ? print "yes" : print "no";'` +if [ $ISROOT == "no" ] ; then + echo "embootstrap needs to be run under sudo or as root." + exit 2 +fi + +. /usr/lib/pbuilder/pbuilder-modules +. /usr/lib/pbuilder/pbuilder-buildpackage-funcs +. /usr/share/emdebian-tools/empbuilderlib + +# move to our own function file later. + +# Need support for create (this script), update (unpack base.tgz) and login +# (sudo chroot /bin/sh) as well as the final empdebuild (emsource,emdebuild) +# in a separate script. + +# Currently, this script needs user intervention to build the chroot: +# emsetup asks for confirmation and apt-get install wants GnuPG verification. + +# This script will concentrate only on creating and updating the chroot. +# Parameters. +# WORK=location of this script. +# MIRROR=the Debian primary mirror that will replace the default debootstrap mirror +# (ftp.debian.org is not a primary and only supports 2 architectures). +# TODO: needs command line options to set the rest of these parameters. + +# Note --oknodo will cause failures, see #426877 + +WORK=$CWD + +get_work_dir +BUILDPLACE=$WORKDIR +BASETGZ="$BUILDPLACE/emdebian.tgz" +BASETGZ=`echo $BASETGZ | tr -s \/` +BUILDPLACE="$BUILDPLACE/pbuilder" +# tidy up // to / +BUILDPLACE=`echo $BUILDPLACE | tr -s \/` +MIRROR= +# don't die if the user has set 'None' for the dpkg-cross default. +get_default_arch + +BUILDPLACE="${WORKDIR}/pbuilder/build" +if [ -d $BUILDPLACE ]; then + rm -rf $BUILDPLACE/* +fi +if [ ! -d $BUILDPLACE ]; then + mkdir -p $BUILDPLACE +fi +BASETGZ="${WORKDIR}/emdebian.tgz" +SUITE=unstable +CROSS=x +MACHINE=x +VARIANT=x +MACHINEPATH="${WORKDIR}/machine/" +USEDEVPTS="yes" +USEPROC="yes" + +while [ -n "$1" ]; do +case "$1" in + -a|--arch) + shift + ARCH=$1 + # chomp the argument to --arch + shift + ;; + --testing|testing) + shift; + BASETGZ="${WORKDIR}/emdebian-testing.tgz" + SUITE=testing + echo "Creating an embootstrap testing chroot" + ;; + # only for emsandbox support, empdebuild does not pass -S + -S|--suite) + shift + SUITE=$1 + shift + ;; + --cross|cross) + shift; + BASETGZ="${WORKDIR}/emdebian-$ARCH.tgz" + CROSS=$ARCH + echo "Creating an embootstrap $ARCH chroot" + ;; + --script) + shift + CMD_SCRIPT=$1 + if [ ! -f $CMD_SCRIPT ]; then + echo "Cannot find suite script '$CMD_SCRIPT'." + exit; + fi + echo "Using $CMD_SCRIPT" + shift + ;; + --machine-path) + shift + MACHINEPATH=$1 + shift + ;; + --machine) + shift + MACHINE=$1 + VARIANT=default + if [ ! -d "${MACHINEPATH}/$MACHINE" ]; then + echo "Cannot find '${MACHINEPATH}/$MACHINE'." + exit + fi + shift + ;; + --variant) + shift + VARIANT=$1 + if [ ! $MACHINE ]; then + echo "Variant specified without a machine." + exit + fi + if [ ! -d "${MACHINEPATH}/$MACHINE/$VARIANT" ]; then + echo "Cannot find '${MACHINEPATH}/$MACHINE/$VARIANT'." + exit + fi + shift + ;; + *) + echo "Unrecognised option: $1" + exit; + ;; +esac +done + +if [ "$ARCH" = "None.\n" ]; then + echo $ARCH + echo Use the --arch option or dpkg-reconfigure dpkg-cross + exit +fi + +# include packages.conf if --machine used. +if [ "$MACHINE" != "x" -a "$VARIANT" != "x" -a $CROSS -a $CROSS = $ARCH ]; then + # sets INCLUDE, SCRIPT, MIRROR etc. + if [ -f ${MACHINEPATH}/$MACHINE/$VARIANT/packages.conf ]; then + . ${MACHINEPATH}/$MACHINE/$VARIANT/packages.conf + fi + echo "Using $MACHINE:$VARIANT" + if [ $TARBALL_NAME ]; then + echo " -> creating ${WORKDIR}/${TARBALL_NAME}" + BASETGZ="${WORKDIR}/${TARBALL_NAME}" + fi +fi + +checkarch +HOST_ARCH=`dpkg-architecture -qDEB_HOST_ARCH` + +# let the command line override the packages.conf +if [ ! $SCRIPT ]; then + SCRIPT=$CMD_SCRIPT +fi + +# if neither command line nor packages.conf have a script set, use default. +if [ ! $SCRIPT ]; then + SCRIPT="/usr/share/emdebian-tools/emdebian.crossd" +fi + +if [ $CROSS -a $CROSS = $ARCH ]; then + echo "Building $ARCH chroot on $HOST_ARCH to install $ARCH packages." +else + echo "Building $HOST_ARCH chroot on $HOST_ARCH to cross-build $ARCH packages." +fi +if [ -f ${BASETGZ} ]; then + echo "${BASETGZ} already exists! Aborting . . ." + exit 1; +fi +echo "Checking for a user writeable tree in $BUILDPLACE" +check_dirs +echo " -> running debootstrap" +export LANG=C +export LC_ALL=C +# debootstrap 1.0.7 has moved +WORK="/usr/share/debootstrap/" +# handle old versions of debootstrap so that we can migrate into testing. +if [ -f "/usr/lib/debootstrap/functions" ]; then + WORK="/usr/lib/debootstrap/"; +fi +FOREIGN= +INC= +if [ $CROSS -a $CROSS = $ARCH ]; then + echo " -> cross detected, using foreign." + FOREIGN="--foreign" + if [ ! $MIRROR ]; then + MIRROR="http://www.emdebian.org/crush/" + fi + if [ ! $PROXY ]; then + PROXY="http://www.emdebian.org/crush/" + fi + if [ $INCLUDE ]; then + INC="--include=$INCLUDE" + fi + # if SUITE is empty in packages.conf, reset the default + if [ ! $SUITE ]; then + SUITE=unstable + fi + BUILDD=$SCRIPT + if [ ! -f ${WORKDIR}/stamp-debootstrap ]; then + echo "DEBOOTSTRAP_DIR=$WORK debootstrap $INC --verbose $FOREIGN --arch ${ARCH} $SUITE $BUILDPLACE $PROXY $BUILDD" + DEBOOTSTRAP_DIR=$WORK debootstrap ${INC} --verbose $FOREIGN --arch ${ARCH} $SUITE $BUILDPLACE $PROXY $BUILDD + echo " -> debootstrap stage complete" + echo " -> Checking for machine:variant hooks" + # hooks + if [ $INC ]; then + echo "${INC}" >> $BUILDPLACE/debootstrap/machineincludes + fi + if [ -f ${MACHINEPATH}/$MACHINE/$VARIANT/setup.sh ]; then + if [ ! -z "$EXTRA" ]; then + if [ -e $EXTRA ]; then + cp $EXTRA $BUILDPLACE/ + fi + fi + echo " -> Running $MACHINE/$VARIANT/setup.sh $BUILDPLACE $ARCH" + sh ${MACHINEPATH}/$MACHINE/$VARIANT/setup.sh $BUILDPLACE $ARCH + fi + if [ -f ${MACHINEPATH}/$MACHINE/$VARIANT/config.sh ]; then + echo " -> Copying config.sh for $MACHINE:$VARIANT into tarball" + mkdir -p $BUILDPLACE/machine/ + cp ${MACHINEPATH}/$MACHINE/$VARIANT/config.sh $BUILDPLACE/machine/ + fi + touch ${WORKDIR}/stamp-debootstrap + fi # end of $CROSS +else # else if not $CROSS + # TODO this should be configurable - emdebian-tools will add a primary later. + # copy or use the ~/.apt-cross/sources.foo. files. + if [ ! $MIRROR ]; then + URL=`perl -e "use Emdebian::Tools; use Config::Auto; print &get_primary;"` + if [ ! -z "$URL" ]; then + MIRROR="http://${URL}/debian" + fi + fi + if [ ! $MIRROR ]; then + MIRROR="http://ftp.fr.debian.org/debian/" + fi + BUILDD=/usr/share/emdebian-tools/emdebian.buildd + if [ ! -f ${WORKDIR}/stamp-debootstrap ]; then + echo "DEBOOTSTRAP_DIR=$WORK debootstrap --verbose $SUITE $BUILDPLACE $MIRROR $BUILDD" + DEBOOTSTRAP_DIR=$WORK debootstrap --verbose $SUITE $BUILDPLACE $MIRROR $BUILDD + touch ${WORKDIR}/stamp-debootstrap + fi +fi +mkdir -p "$BUILDPLACE/tmp/buildd" + +copy_host_configuration + +# emdebian-tools will be reconfigured later. +# ensure src is available if not emsandbox +echo " -> Installing apt-lines for $MIRROR" +mkdir -p "$BUILDPLACE/etc/apt/sources.list.d/" +rm -f "$BUILDPLACE"/etc/apt/sources.list +if [ $CROSS -a $CROSS = $ARCH ]; then + cat >> "$BUILDPLACE"/etc/apt/sources.list.d/emdebian.sources.list << EOF +#emdebian target repository : default source list +# created by emsandbox +deb $MIRROR $SUITE main +#deb-src $MIRROR $SUITE main +EOF +else + cat >> "$BUILDPLACE"/etc/apt/sources.list << EOF +deb $MIRROR $SUITE main +deb-src $MIRROR $SUITE main +EOF +fi + +if [ $CROSS -a $CROSS = $ARCH ]; then + # copy our secure apt key into the chroot for apt-key + cp /usr/share/emdebian-tools/emdebian-archive-keyring.gpg $BUILDPLACE/ + # copy in our install helper + cp /usr/share/emdebian-tools/emsecondstage $BUILDPLACE/ + # only executable by root to allow debootstrap to work properly. + chmod 744 $BUILDPLACE/emsecondstage + rm -f $BUILDPLACE/debootstrap/debootstrap.log + # empty if using unpack but should still exist. + save_aptcache +else + echo "Refreshing the base.tgz " + echo " -> upgrading packages" + mountproc + chroot $BUILDPLACE /usr/bin/apt-get update + recover_aptcache + chroot $BUILDPLACE /usr/bin/apt-get -y --force-yes dist-upgrade + echo " -> adding the Emdebian repository key" + chroot $BUILDPLACE mkdir -p /home/$SUDO_USER/.gnupg + chroot $BUILDPLACE mkdir -p /home/$SUDO_USER/.dpkg-cross + if [ -f /home/$SUDO_USER/.devscripts ]; then + cp /home/$SUDO_USER/.devscripts $BUILDPLACE/home/$SUDO_USER/.devscripts + fi + cp /usr/share/emdebian-tools/emdebian-archive-keyring.gpg $BUILDPLACE/ + chroot $BUILDPLACE apt-key add emdebian-archive-keyring.gpg + if [ -f emdebian-archive-keyring.gpg ]; then + rm emdebian-archive-keyring.gpg + fi + echo " -> updating /etc/hosts" + cp /etc/hosts $BUILDPLACE/etc/hosts + # emdebian.buildd installs emdebian-tools which sets up apt for the emdebian repository + echo " -> updating the apt cache" + chroot "$BUILDPLACE" /usr/bin/apt-get update + # upgrade emdebian-tools and apt-cross before running emsetup + echo " -> upgrading emdebian-tools and apt-cross" + chroot "$BUILDPLACE" /usr/bin/apt-get -y --force-yes dist-upgrade + echo " -> updating apt-cross cache" + DPKG_CROSS="/home/$SUDO_USER/.dpkg-cross" + if [ ! -f $DPKG_CROSS/apt.conf-${SUITE} ]; then + chroot $BUILDPLACE /usr/bin/apt-cross -a $ARCH -S $SUITE -u + else + echo " -> copying existing apt-cross cache" + cp $DPKG_CROSS/apt.conf-$SUITE $BUILDPLACE/$DPKG_CROSS/ + cp $DPKG_CROSS/sources.$SUITE $BUILDPLACE/$DPKG_CROSS/ + cp $DPKG_CROSS/status-$SUITE $BUILDPLACE/$DPKG_CROSS/ + cp -r $DPKG_CROSS/$SUITE $BUILDPLACE/$DPKG_CROSS/ + fi + echo " -> running emsetup" + if chroot "$BUILDPLACE" /usr/bin/emsetup -v -a $ARCH --yes; then + : + else + echo " -> emsetup failed" + if [ "${LOGIN_AFTER_FAIL}" = "yes" ]; then + echo " -> Logging into the chroot" + echo " -> Build directory: /trunk/$SVN" + echobacktime + chroot $BUILDPLACE /bin/sh + save_aptcache + echo " -> emsetup failed" + chroot $BUILDPLACE /usr/bin/apt-get clean + umountproc + create_emdebiantgz + cleanbuildplace + rm ${WORKDIR}/stamp-debootstrap + exit 1; + fi + save_aptcache + umountproc + chroot $BUILDPLACE /usr/bin/apt-get clean + create_emdebiantgz + cleanbuildplace + rm ${WORKDIR}/stamp-debootstrap + echobacktime + echo " -> emsetup failed: exiting with an error!" + echo " Try --login-after-fail" + exit 1; + fi + umountproc + save_aptcache + chroot $BUILDPLACE /usr/bin/apt-get clean +fi + +create_emdebiantgz +cleanbuildplace +rm ${WORKDIR}/stamp-debootstrap diff --git a/emdebian-rootfs b/emdebian-rootfs new file mode 100644 index 0000000..4db7a90 --- /dev/null +++ b/emdebian-rootfs @@ -0,0 +1,93 @@ +# bash completion support +# +# Copyright (C) 2008 Neil Williams +# +# This package is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +_get_dpkg_cross_list() +{ + grep Choices: /var/lib/dpkg/info/dpkg-cross.templates \ + | cut -d':' -f2 | sed -e 's/None, //' | sed -e 's/,//g' +} + +_get_machine_name() +{ + WORK=`cat /etc/emsandbox.conf | grep workingdir | sed -e 's/workingdir: \(.*\)/\1\/machine/'` + ls $WORK +} + +_get_variant_name() +{ + WORK=`cat /etc/emsandbox.conf | grep workingdir | sed -e 's/workingdir: \(.*\)/\1\/machine/'` + ls -1 $WORK/* +} + +# rootfs cannot not support stable until Lenny is released. +_supported_suites() +{ + echo unstable testing sid lenny +} + +_emsandbox() +{ + local cur prev opts cmds help machine arch quiet + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + help="-h -? --help --version " + cmds="create --create " + arch="-a --arch " + opts="-s --script -S --suite" + machine="-m --machine -v --variant --machine-path " + case "$prev" in + -@(a|-arch)) + COMPREPLY=( $( _get_dpkg_cross_list $cur ) ) + ;; + -@(m|-machine)) + COMPREPLY=( $( _get_machine_name $cur ) ) + ;; + -@(V|-variant)) + COMPREPLY=( $( _get_variant_name $cur ) ) + ;; + -@(S|-suite)) + COMPREPLY=( $( _supported_suites $cur ) ) + ;; + *) + COMPREPLY=( $(compgen -W "${arch}${help}${opts}${machine}${cmds}" -- ${cur}) ) + ;; + esac +} +complete -F _emsandbox -o default emsandbox + +_em_multistrap() +{ + local cur prev opts cmds help machine arch quiet + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + help="-h -? --help --version " + arch="-a --arch " + opts="-f --file" + machine="" + case "$prev" in + -@(a|-arch)) + COMPREPLY=( $( _get_dpkg_cross_list $cur ) ) + ;; + *) + COMPREPLY=( $(compgen -W "${arch}${help}${opts}${machine}${cmds}" -- ${cur}) ) + ;; + esac +} +complete -F _em_multistrap -o default em_multistrap diff --git a/emdebian.busybox b/emdebian.busybox new file mode 100644 index 0000000..0c8b854 --- /dev/null +++ b/emdebian.busybox @@ -0,0 +1,87 @@ +# emdebian secondstage support (example only). +# busybox is not currently built with internal dpkg +# support so this package set might not work. +# +# Copyright (C) 2007-2008 Neil Williams +# +# This package is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +mirror_style release +download_style apt + +work_out_debs () { + required="busybox dpkg libstdc++6 libgcc1 libc6 cdebconf + debconf-shell libdebian-installer4 zlib1g + base-passwd tzdata" + + base="apt gpgv + debianutils makedev gnupg udev base-files + debian-archive-keyring udhcpc udhcpd + util-linux module-init-tools initscripts" +} + +first_stage_install () { + PRESERVE_BUILDPLACE="yes" + . /usr/share/emdebian-tools/emrootfslib + extract $required + make_dpkg_dirs + prepare_proc + prepare_var + info INSTCORE " -> Preparing basic defaults for $BUILDPLACE/etc" + basic_etc_fstab + basic_group_setup + basic_passwd_setup + basic_shadow_setup + basic_etc_profile + shell_update_rcd + set_approx_time + set_cdebconf_default + provide_empty_install_info + provide_var_lib_x11 + info INSTCORE " -> Setting up dpkg in $BUILDPLACE" + x_feign_install dpkg + info INSTCORE " -> Unpacking packages in $BUILDPLACE" + unpack_debootstrap + info INSTCORE " -> Adapting configuration for Emdebian" + busybox_symlinks + disable_updatercd + disable_invokercd + disable_apt_recommends + busybox_inittab + busybox_rcS + setup_devices + info INSTCORE " -> First stage install complete in $BUILDPLACE" +} + +second_stage_install () { + if [ -f /datestring ]; then + TIME=`cat /datestring` + echo "Setting approximate time of $TIME" + date -s $TIME + fi + info INSTCORE "Running ldconfig..." + in_target /sbin/ldconfig + in_target depmod + info INSTCORE "Setting cdebconf environment" + export DEBCONF_USE_CDEBCONF=true + DEBIAN_FRONTEND=noninteractive + DEBCONF_NONINTERACTIVE_SEEN=true + export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN + # bug: See #451130 + in_target /usr/lib/cdebconf/debconf-loadtemplate /usr/share/debconf/demo /usr/share/debconf/demo.templates + info INSTCORE "Configuring in $BUILDPLACE" + in_target dpkg --configure -a + info BASESUCCESS "Emdebian base system installed successfully." +} diff --git a/emdebian.coreutils b/emdebian.coreutils new file mode 100644 index 0000000..49a713d --- /dev/null +++ b/emdebian.coreutils @@ -0,0 +1,80 @@ +# emdebian secondstage support (Default busybox, dpkg and apt version) +# +# Copyright (C) 2007-2008 Neil Williams +# +# This package is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +mirror_style release +download_style apt + +work_out_debs () { + required="coreutils dpkg libstdc++6 libgcc1 libc6 cdebconf + debconf-shell libdebian-installer4 zlib1g libnewt0.52 + libslang2 base-passwd" + + base="apt gpgv libncurses5 libreadline5 readline-common + debianutils makedev whiptail gnupg udev base-files + debian-archive-keyring dhcp3-client + util-linux module-init-tools initscripts" +} + +first_stage_install () { + PRESERVE_BUILDPLACE="yes" + . /usr/share/emdebian-tools/emrootfslib + extract $required + make_dpkg_dirs + prepare_proc + prepare_var + info INSTCORE " -> Preparing basic defaults for $BUILDPLACE/etc" + basic_etc_fstab + basic_group_setup + basic_passwd_setup + basic_shadow_setup + basic_etc_profile + shell_update_rcd + set_approx_time + set_cdebconf_default + provide_empty_install_info + provide_var_lib_x11 + info INSTCORE " -> Setting up dpkg in $BUILDPLACE" + x_feign_install dpkg + info INSTCORE " -> Unpacking packages in $BUILDPLACE" + unpack_debootstrap + info INSTCORE " -> Adapting configuration for Emdebian" + disable_apt_recommends + setup_devices + info INSTCORE " -> First stage install complete in $BUILDPLACE" +} + +second_stage_install () { + if [ -f /datestring ]; then + TIME=`cat /datestring` + echo "Setting approximate time of $TIME" + date -s $TIME + fi + info INSTCORE "Running ldconfig..." + in_target /sbin/ldconfig + in_target depmod + info INSTCORE "Setting cdebconf environment" + export DEBCONF_USE_CDEBCONF=true + DEBIAN_FRONTEND=noninteractive + DEBCONF_NONINTERACTIVE_SEEN=true + export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN + # bug: See #451130 + in_target /usr/lib/cdebconf/debconf-loadtemplate /usr/share/debconf/demo /usr/share/debconf/demo.templates + info INSTCORE "Configuring in $BUILDPLACE" + in_target dpkg --configure -a + info BASESUCCESS "Emdebian base system installed successfully." +} diff --git a/emdebian.crossd b/emdebian.crossd new file mode 100644 index 0000000..54cb6c9 --- /dev/null +++ b/emdebian.crossd @@ -0,0 +1,85 @@ +# emdebian secondstage support (Default busybox, dpkg and apt version) +# +# Copyright (C) 2007-2008 Neil Williams +# +# This package is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +mirror_style release +download_style apt + +work_out_debs () { + required="busybox dpkg libstdc++6 libgcc1 libc6 cdebconf + debconf-shell libdebian-installer4 zlib1g libnewt0.52 + libslang2 base-passwd" + + base="apt gpgv libncurses5 libreadline5 readline-common + debianutils makedev whiptail gnupg udev base-files + debian-archive-keyring dhcp3-client + util-linux module-init-tools initscripts" +} + +first_stage_install () { + PRESERVE_BUILDPLACE="yes" + . /usr/share/emdebian-tools/emrootfslib + extract $required + make_dpkg_dirs + prepare_proc + prepare_var + info INSTCORE " -> Preparing basic defaults for $BUILDPLACE/etc" + basic_etc_fstab + basic_group_setup + basic_passwd_setup + basic_shadow_setup + basic_etc_profile + shell_update_rcd + set_approx_time + set_cdebconf_default + provide_empty_install_info + provide_var_lib_x11 + info INSTCORE " -> Setting up dpkg in $BUILDPLACE" + x_feign_install dpkg + info INSTCORE " -> Unpacking packages in $BUILDPLACE" + unpack_debootstrap + info INSTCORE " -> Adapting configuration for Emdebian" + busybox_symlinks + disable_updatercd + disable_invokercd + disable_apt_recommends + busybox_inittab + busybox_rcS + setup_devices + info INSTCORE " -> First stage install complete in $BUILDPLACE" +} + +second_stage_install () { + if [ -f /datestring ]; then + TIME=`cat /datestring` + echo "Setting approximate time of $TIME" + date -s $TIME + fi + info INSTCORE "Running ldconfig..." + in_target /sbin/ldconfig + in_target depmod + info INSTCORE "Setting cdebconf environment" + export DEBCONF_USE_CDEBCONF=true + DEBIAN_FRONTEND=noninteractive + DEBCONF_NONINTERACTIVE_SEEN=true + export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN + # bug: See #451130 + in_target /usr/lib/cdebconf/debconf-loadtemplate /usr/share/debconf/demo /usr/share/debconf/demo.templates + info INSTCORE "Configuring in $BUILDPLACE" + in_target dpkg --configure -a + info BASESUCCESS "Emdebian base system installed successfully." +} diff --git a/emdebian.gpe b/emdebian.gpe new file mode 100644 index 0000000..cf58efa --- /dev/null +++ b/emdebian.gpe @@ -0,0 +1,90 @@ +# emdebian secondstage support (busybox, dpkg, apt + gtk version) +# +# Copyright (C) 2007-2008 Neil Williams +# +# This package is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +mirror_style release +download_style apt + +work_out_debs () { + required="busybox dpkg libstdc++6 libgcc1 libc6 cdebconf + debconf-shell libdebian-installer4 zlib1g libnewt0.52 + libslang2 base-passwd" + + base="apt gpgv libncurses5 libreadline5 readline-common + debianutils makedev whiptail iptables initscripts + gnupg udev base-files debian-archive-keyring libgtk2.0-0 + libxfixes3 fontconfig-config ttf-bitstream-vera gpe + libsoup2.2-8 dbus xinit libice6 langupdate + libsm6 galculator dhcp3-client util-linux + module-init-tools sysvinit-utils xauth xserver-xorg-video-fbdev + xserver-xorg-input-tslib xfonts-base hicolor-icon-theme" +} + +first_stage_install () { + PRESERVE_BUILDPLACE="yes" + . /usr/share/emdebian-tools/emrootfslib + extract $required + make_dpkg_dirs + prepare_proc + prepare_var + info INSTCORE " -> Preparing basic defaults for $BUILDPLACE/etc" + basic_etc_fstab + basic_group_setup + basic_passwd_setup + basic_shadow_setup + basic_etc_profile + shell_update_rcd + set_approx_time + set_cdebconf_default + provide_empty_install_info + provide_var_lib_x11 + info INSTCORE " -> Setting up dpkg in $BUILDPLACE" + x_feign_install dpkg + info INSTCORE " -> Unpacking packages in $BUILDPLACE" + unpack_debootstrap + info INSTCORE " -> Adapting configuration for Emdebian" + busybox_symlinks + disable_updatercd + disable_invokercd + disable_apt_recommends + busybox_inittab + busybox_rcS + sample_xorg_conf + setup_devices + info INSTCORE " -> First stage install complete in $BUILDPLACE" +} + +second_stage_install () { + if [ -f /datestring ]; then + TIME=`cat /datestring` + echo "Setting approximate time of $TIME" + date -s $TIME + fi + info INSTCORE "Running ldconfig..." + in_target /sbin/ldconfig + in_target depmod + info INSTCORE "Setting cdebconf environment" + export DEBCONF_USE_CDEBCONF=true + DEBIAN_FRONTEND=noninteractive + DEBCONF_NONINTERACTIVE_SEEN=true + export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN + # bug: See #451130 + in_target /usr/lib/cdebconf/debconf-loadtemplate /usr/share/debconf/demo /usr/share/debconf/demo.templates + info INSTCORE "Configuring in $BUILDPLACE" + in_target dpkg --configure -a + info BASESUCCESS "Emdebian base system installed successfully." +} diff --git a/emdebian.grip b/emdebian.grip new file mode 100644 index 0000000..673f679 --- /dev/null +++ b/emdebian.grip @@ -0,0 +1,101 @@ +# emdebian secondstage support (Grip version) +# +# Copyright (C) 2007-2009 Neil Williams +# +# This package is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +mirror_style release +download_style apt +finddebs_style from-indices +variants - buildd fakechroot minbase + +if doing_variant fakechroot; then + test "$FAKECHROOT" = "true" || error 1 FAKECHROOTREQ "This variant requires fakechroot environment to be started" +fi + +LIBC=libc6 +if [ "$ARCH" = "alpha" ] || [ "$ARCH" = "ia64" ]; then + LIBC="libc6.1" +elif [ "$ARCH" = "hurd-i386" ]; then + LIBC="libc0.3" +fi + +work_out_debs () { + required="$(get_debs Priority: required)" + + if doing_variant - || doing_variant fakechroot; then + #required="$required $(get_debs Priority: important)" + # ^^ should be getting debconf here somehow maybe + base="$(get_debs Priority: important)" + elif doing_variant buildd; then + base="$(get_debs Build-Essential: yes)" + elif doing_variant minbase; then + base="apt" + fi + + if doing_variant fakechroot; then + # ldd.fake needs binutils + required="$required binutils" + fi +} + +first_stage_install () { + extract $required + PRESERVE_BUILDPLACE="yes" + . /usr/share/emdebian-tools/emrootfslib + make_dpkg_dirs + basic_etc_fstab + basic_etc_profile + + if [ -x "$TARGET/usr/bin/md5sum.textutils" ] && [ \! -e "$TARGET/usr/bin/md5sum" ]; then + cp "$TARGET/usr/bin/md5sum.textutils" "$TARGET/usr/bin/md5sum" + fi + + if doing_variant fakechroot; then + setup_devices_fakechroot + else + setup_devices + fi + + x_feign_install dpkg + info INSTCORE " -> Unpacking packages in $BUILDPLACE" + unpack_debootstrap + disable_apt_recommends + info INSTCORE " -> First stage install complete in $BUILDPLACE" +} + +second_stage_install () { + if [ -f /datestring ]; then + TIME=`cat /datestring` + echo "Setting approximate time of $TIME" + date -s $TIME + fi + info INSTCORE "Running ldconfig..." + in_target /sbin/ldconfig + in_target depmod + info INSTCORE "Setting debconf environment" + DEBIAN_FRONTEND=noninteractive + DEBCONF_NONINTERACTIVE_SEEN=true + export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN + + if doing_variant fakechroot; then + install_fakechroot_tools + fi + + setup_dselect_method apt + + info CONFBASE "Configuring packages..." + ./emsecondstage +} diff --git a/emdebian.gtk b/emdebian.gtk new file mode 100644 index 0000000..5c665da --- /dev/null +++ b/emdebian.gtk @@ -0,0 +1,84 @@ +# emdebian secondstage support (busybox, dpkg, apt + gtk version) +# +# Copyright (C) 2007-2008 Neil Williams +# +# This package is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +mirror_style release +download_style apt + +work_out_debs () { + required="busybox dpkg libstdc++6 libgcc1 libc6 cdebconf + libdebian-installer4 zlib1g libnewt0.52 libslang2" + + base="apt gpgv libncurses5 libreadline5 readline-common + debconf-shell debianutils makedev base-passwd whiptail + gnupg udev base-files debian-archive-keyring libgtk2.0-0 + fontconfig-config ttf-bitstream-vera xfonts-base" +} + +first_stage_install () { + PRESERVE_BUILDPLACE="yes" + . /usr/share/emdebian-tools/emrootfslib + extract $required + make_dpkg_dirs + prepare_proc + prepare_var + info INSTCORE " -> Preparing basic defaults for $BUILDPLACE/etc" + basic_etc_fstab + basic_group_setup + basic_passwd_setup + basic_etc_profile + shell_update_rcd + set_approx_time + set_cdebconf_default + provide_empty_install_info + provide_var_lib_x11 + info INSTCORE " -> Setting up dpkg in $BUILDPLACE" + x_feign_install dpkg + info INSTCORE " -> Unpacking packages in $BUILDPLACE" + unpack_debootstrap + info INSTCORE " -> Adapting configuration for Emdebian" + busybox_symlinks + disable_updatercd + disable_invokercd + disable_apt_recommends + busybox_inittab + busybox_rcS + sample_xorg_conf + setup_devices + info INSTCORE " -> First stage install complete in $BUILDPLACE" +} + +second_stage_install () { + if [ -f /datestring ]; then + TIME=`cat /datestring` + echo "Setting approximate time of $TIME" + date -s $TIME + fi + info INSTCORE "Running ldconfig..." + in_target /sbin/ldconfig + in_target depmod + info INSTCORE "Setting cdebconf environment" + export DEBCONF_USE_CDEBCONF=true + DEBIAN_FRONTEND=noninteractive + DEBCONF_NONINTERACTIVE_SEEN=true + export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN + # bug: See #451130 + in_target /usr/lib/cdebconf/debconf-loadtemplate /usr/share/debconf/demo /usr/share/debconf/demo.templates + info INSTCORE "Configuring in $BUILDPLACE" + in_target dpkg --configure -a + info BASESUCCESS "Emdebian base system installed successfully." +} diff --git a/empbuilderlib b/empbuilderlib new file mode 100644 index 0000000..3f7441c --- /dev/null +++ b/empbuilderlib @@ -0,0 +1,198 @@ +# empbuilderlib : shell library to support building chroots for Emdebian. +# +# Copyright (C) 2006-2008 Neil Williams +# Copyright (C) 2001-2007 Junichi Uekawa +# +# This package is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# This shell library requires perl and pbuilder (which means bash!) ! +# Draws in POSIX shell functions from emrootfslib to be able to call +# in functions from first_stage_install within debootstrap. The only +# reasons to continue putting new functions in here are if: +# 1. the functions are only useful to create cross-building chroots OR +# 2. the functions need to call pbuilder code directly. +# There should be no need to call pbuilder code within scripts that +# generate a root filesystem. + +# Intended solely for use on the build machine. Do not use these functions +# in second_stage_install ! + +. /usr/share/emdebian-tools/emrootfslib +. /usr/lib/pbuilder/pbuilder-modules + +WORKPLACE="${WORKDIR}/pbuilder" +BASETGZ="${WORKDIR}/emdebian.tgz" + +#pbuilder base values +DEBIAN_BUILDARCH=$ARCH +# cross-building chroot is same arch as host. +BUILDRESULT="$WORKPLACE/result/" +# tidy up // to / +BUILDRESULT=`echo $BUILDRESULT | tr -s \/` +APTCACHE="$WORKPLACE/aptcache/" +# tidy up // to / +APTCACHE=`echo $APTCACHE | tr -s \/` +AUTO_DEBSIGN=yes +APTCACHEHARDLINK="no" +BUILDPLACE="$WORKPLACE/build" + +# the default is to add a PID in the buildplace. +BASEBUILDPLACE="$BUILDPLACE" +if [ "${PRESERVE_BUILDPLACE}" != "yes" ]; then + BUILDPLACE="$BUILDPLACE/$$" +fi + +function extractembuildplace () { + # after calling this function, umountproc, and cleanbuildplace + # needs to be called. Please trap it. + if [ ! \( "${PRESERVE_BUILDPLACE}" = "yes" -a -d "$BUILDPLACE" \) ]; then + cleanbuildplace + echo "Building the Emdebian build Environment" + if ! mkdir -p "$BUILDPLACE"; then + echo "E: failed to build the directory to chroot" + exit 1 + fi + echo " -> extracting base tarball [${BASETGZ}]" + if [ ! -f "$BASETGZ" ]; then + echo "E: failed to find $BASETGZ, have you created your base tarball yet?" + exit 1 + fi + if ! (cd "$BUILDPLACE" && tar xfzp "$BASETGZ"); then + echo "E: failed to extract $BASETGZ to $BUILDPLACE" + exit 1 + fi + echo " -> creating local configuration" + if [ $CROSS -a $CROSS != $ARCH ]; then + hostname -f > "$BUILDPLACE/etc/mailname" + else + echo "emdebian-$ARCH" > "$BUILDPLACE/etc/mailname" + fi + if [ ! -f "$BUILDPLACE/etc/apt/apt.conf.d/10disablerecommends" ]; then + disable_apt_recommends + fi + fi + copy_local_configuration + mountproc + mkdir -p "$BUILDPLACE/tmp/buildd" + chmod 1777 "$BUILDPLACE/tmp" + if [ "$OVERRIDE_APTLINES" = "yes" ]; then + installaptlines + fi +} + +function autoclean_aptcache() { + if [ -n "$APTCACHE" ]; then + echo " -> Cleaning the cached apt archive" + chroot $BUILDPLACE /usr/bin/apt-get autoclean || true + find "$APTCACHE/" -maxdepth 1 -name \*.deb | \ + while read A; do + if [ ! -f "$BUILDPLACE/var/cache/apt/archives/"$(basename "$A") -a \ + -f "$A" ]; then + echo " -> obsolete cache content "$(basename "$A")" removed" + rm -f "$A" || true + fi + done + fi +} + +# intended only for chroots +function copy_host_configuration () { + echo " -> copying local configuration" + if [ $CROSS -a $CROSS != $ARCH ]; then + for a in hosts hostname resolv.conf; do + sudo rm -f "$BUILDPLACE/etc/$a" + if [ ! -f "/etc/$a" ]; then + echo "E: /etc/$a does not exist, your setup is insane. fix it" >&2 + sudo cp $( readlink -f "/etc/$a" ) "$BUILDPLACE/etc/$a"; + fi + done + else + # sandboxes need a different hostname + mkdir -p "$BUILDPLACE"/etc/ + cat > "$BUILDPLACE"/etc/hostname << EOF +emdebian-$ARCH +EOF + fi +} + +function createemchroot() +{ + if [ $SUITE == testing ]; then + BASETGZ="${WORKDIR}/emdebian-testing.tgz" + SUITE=testing + . /usr/share/emdebian-tools/embootstrap --arch $ARCH testing + echo "Creating an embootstrap testing chroot" + else + BASETGZ="$WORKDIR/emdebian.tgz" + . /usr/share/emdebian-tools/embootstrap --arch $ARCH + fi +} + +function checkembuilddep () { + # call satisfydepends + local BUILDOPT="--binary-all" + case "${BINARY_ARCH}" in + yes) BUILDOPT="--binary-arch";; + *) ;; + esac + PBUILDERSATISFYDEPENDSCMD=/usr/lib/pbuilder/pbuilder-satisfydepends + CONTROL=$BUILDPLACE/trunk/$SVN/debian/control + # this version parses debian/control, NOT the .dsc + # so that when Emdebian removes dependencies, the chroot does too. + echo "Running: $PBUILDERSATISFYDEPENDSCMD --control $CONTROL --chroot $BUILDPLACE ${BUILDOPT}" + if "$PBUILDERSATISFYDEPENDSCMD" --control "$CONTROL" --chroot "${BUILDPLACE}" "${BUILDOPT}" ; then + echo " -> installed ${HOST_ARCH} dependencies." + else + echo "E: pbuilder-satisfydepends failed." >&2 + exit 2 + fi + # install extra packages to the chroot + if [ -n "$EXTRAPACKAGES" ]; then + if echo "DEBIAN_FRONTEND=noninteractive usr/bin/apt-get -y --force-yes install ${EXTRAPACKAGES}" | chroot $BUILDPLACE /bin/sh; then + : + else + # if apt failed (maybe update needs to be run), save so far and exit cleanly + save_aptcache + umountproc + cleanbuildplace + exit 1; + fi + fi +} + +# get $ARCH .deb and put into /var/cache/apt/archives to +# allow these to be saved between builds. +function save_aptcrosscache() { + # save the current aptcache archive + # it is safe to call this function several times. + local doit + if [ -n "$APTCACHE" ]; then + echo "Copying back the cached apt-cross archive contents" + mkdir -p "$APTCACHE" ; + if [ "$APTCACHEHARDLINK" = "yes" ]; then + doit=ln + else + doit=cp + fi + # apt-cross puts the archives in the chroot / + find "$BUILDPLACE/" -maxdepth 1 -name \*.deb | \ + while read A ;do + if [ ! -f "$APTCACHE/"$(basename "$A") -a -f "$A" ]; then + echo " -> new cache content "$(basename "$A")" added" + $doit "$A" "$APTCACHE/" || true + fi + done + fi +} diff --git a/empdebuild b/empdebuild new file mode 100755 index 0000000..0f4a9bd --- /dev/null +++ b/empdebuild @@ -0,0 +1,619 @@ +#!/bin/bash +set -e +# empdebuild : emdebian version of pdebuild. +# +# Emdebian chroot builder - initially supporting the creation of a +# chroot capable of running emdebian-tools to reduce the number of +# cross dependencies that need to be installed on the build system. +# +# Copyright (C) 2006-2008 Neil Williams +# +# This package is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# Note 1: Most configuration values are calculated, not taken from the command line +# or an rc file. +# Note 2: emdebuild creates a build log for us - just the output of dpkg-buildpackage, +# not the rest of the chroot operations. + +. /usr/share/emdebian-tools/empbuilderlib + +SUITE=unstable + +function usagehelp () { + # print out help message + cat < updating apt-cross cache" + chroot $BUILDPLACE /usr/bin/apt-cross -a $ARCH -S $SUITE -u + echo " -> Attempting to parse the cross-build dependencies" + # read debian/xcontrol + for INSTALLPKGMULTI in $(cat ${DEBIAN_XCONTROL} | \ + awk ' +BEGIN{source=1} +/^$/ {source=0} +/^Source:/ {source=1} +/^[^ ]*:/ {p=0} +tolower($0) ~ /^'"${BD_REGEXP}"':/ {p=1} +{if(p && source) {print $0}}' | \ + sed 's/^[^: ]*://' | \ + tr " " "/" | \ + awk 'BEGIN{RS=","} {print}'); do + echo " -> Considering cross-build-dep$(echo "$INSTALLPKGMULTI" | tr "/" " " )" + # parse the list - removing commas etc. + for INSTALLPKG in $(echo "$INSTALLPKGMULTI" | \ + awk 'BEGIN{RS="|"} {print}'); do + CURRENTREALPKGNAME=$(echo "$INSTALLPKG" | sed -e 's/^[/]*//' -e 's/[[/(].*//') #)# syntax hack + INSTALLPKGLIST="${INSTALLPKGLIST} ${CURRENTREALPKGNAME}" + done; # end parse list + done; # end parse debian/xcontrol + if [ -n "${INSTALLPKGLIST}" ]; then + echo " -> Installing ${INSTALLPKGLIST}" + chroot $BUILDPLACE /usr/bin/apt-cross -q -k -a $ARCH --install ${INSTALLPKGLIST} + save_aptcrosscache + fi + echo " -> Finished parsing the cross build-deps" +} + +function update_emchroot () +{ + if [ $SUITE == testing ]; then + BASETGZ="${WORKDIR}/emdebian-testing.tgz" + SUITE=testing + echo "Updating the embootstrap testing chroot" + else + BASETGZ="$WORKDIR/emdebian.tgz" + fi + extractembuildplace + echo "File extracted to: $BUILDPLACE" + echo "" + echo " -> upgrading packages" + disable_apt_recommends + # force the sources list - a bit of a hack really. + # TODO this should be configurable - emdebian-tools will add a primary later. + cp /usr/share/emdebian-tools/emsources.$SUITE $BUILDPLACE/etc/apt/sources.list + if echo "/usr/bin/apt-get update" | chroot $BUILDPLACE /bin/sh; then + : + else + # if apt failed (maybe update needs to be run), save so far and exit cleanly + save_aptcache + # copy out the failed build here first. + umountproc + cleanbuildplace + exit 1; + fi + echo " -> updating apt-cross cache for $SUITE" + if echo "/usr/bin/apt-cross -a $ARCH -S $SUITE -u" | chroot $BUILDPLACE /bin/sh; then + : + else + # if apt failed (maybe update needs to be run), save so far and exit cleanly + save_aptcache + umountproc + cleanbuildplace + exit 1; + fi + recover_aptcache + # TODO persistent problems with the toolchains mean this needs to be optional. + if echo "DEBIAN_FRONTEND=noninteractive /usr/bin/apt-get $OPTIONS -y --force-yes upgrade" | chroot $BUILDPLACE /bin/sh; then + : + else + # if apt failed (maybe update needs to be run), save so far and exit cleanly + save_aptcache + umountproc + cleanbuildplace + exit 1; + fi + if echo "DEBIAN_FRONTEND=noninteractive /usr/bin/apt-get $OPTIONS -y --force-yes dist-upgrade" | chroot $BUILDPLACE /bin/sh; then + : + else + # if apt failed (maybe update needs to be run), save so far and exit cleanly + save_aptcache + umountproc + cleanbuildplace + exit 1; + fi + chroot $BUILDPLACE /usr/bin/apt-get $OPTIONS -y --force-yes install emdebian-tools || true + chroot $BUILDPLACE /usr/bin/apt-get $OPTIONS --purge -y --force-yes autoremove || true + autoclean_aptcache + save_aptcache + echo " -> updating devscripts configuration" + if [ -f /home/$SUDO_USER/.devscripts ]; then + cp /home/$SUDO_USER/.devscripts $BUILDPLACE/home/$SUDO_USER/.devscripts + fi + VAL=`chroot $BUILDPLACE hostname -f 2>&1` + if [ "$VAL" != "" ]; then + echo " -> updating /etc/hosts" + cp /etc/hosts $BUILDPLACE/etc/hosts + fi + # sometimes this returns non-zero + if echo "$COLOUR ARCH=$ARCH /usr/bin/emsetup --arch $ARCH --yes" | chroot $BUILDPLACE /bin/sh; then + : + fi + umountproc || true + chroot $BUILDPLACE /usr/bin/apt-get clean || true + create_emdebiantgz +} + +# very similar to emchrootbuild but calls emsource inside the +# chroot instead of copying the source in from outside. +# i.e. autobuilder mode (so it tries to be quiet). +function empautobuild() +{ + if [ $SUITE == testing ]; then + BASETGZ="${WORKDIR}/emdebian-testing.tgz" + SUITE=testing + echo "Building in the embootstrap testing chroot" + else + BASETGZ="$WORKDIR/emdebian.tgz" + fi + . /usr/lib/pbuilder/pbuilder-buildpackage-funcs + PACKAGE=$1 + BUILDRESULTUID="${BUILDRESULTUID:-${SUDO_UID:-0}}" + BUILDRESULTGID="${BUILDRESULTGID:-${SUDO_GID:-0}}" + INITIAL=`echo $PACKAGE | cut -b1` + TRUNK="$INITIAL/${PACKAGE}/trunk" + + echobacktime + extractembuildplace + echo "File extracted to: $BUILDPLACE" + echo "" + recover_aptcache + createbuilduser + if [ -f "/etc/devscripts.conf" ]; then + cp /etc/devscripts.conf $BUILDPLACE/etc/devscripts.conf + fi + if [ -f "/home/$SUDO_USER/.devscripts" ]; then + mkdir -p $BUILDPLACE/home/$SUDO_USER/ + cp /home/$SUDO_USER/.devscripts $BUILDPLACE/home/$SUDO_USER/.devscripts + fi + + COLOUR= + if [ $ANSI_COLORS_DISABLED ]; then + COLOUR=ANSI_COLORS_DISABLED=1 + fi + echo "Checking the Emdebian toolchain" + # fails with non-zero if no toolchain is found + if echo "$COLOUR /usr/bin/emsetup -q --arch $ARCH --report" | chroot $BUILDPLACE /bin/sh; then + : + else + umountproc + cleanbuildplace + exit 1; + fi + if echo "$COLOUR ARCH=$ARCH emsource -q -a $ARCH -b --build-dep $PACKAGE $EM_DPKG_OPTS" | chroot $BUILDPLACE /bin/sh; then + : + else + echo " -> emsource -b failed" + if [ "${LOGIN_AFTER_FAIL}" = "yes" ]; then + echo " -> Logging into the chroot" + echobacktime + chroot $BUILDPLACE /bin/sh + save_aptcache + umountproc + cleanbuildplace + exit 1; + fi + save_aptcache + umountproc + cleanbuildplace + exit 1; + fi + if [ $? -ne 0 ]; then + echo " -> emsource -b failed" + if [ "${LOGIN_AFTER_FAIL}" = "yes" ]; then + echo " -> Logging into the chroot" + echobacktime + chroot $BUILDPLACE /bin/sh + save_aptcache + umountproc + cleanbuildplace + exit 1; + fi + fi + FULLPATH="$BUILDPLACE/trunk/$TRUNK/" + FULLPATH=`echo $FULLPATH | tr -s \/` + PKGRESULT="${BUILDRESULT}${INITIAL}/${PACKAGE}/trunk" + echo "Copying build results to ${PKGRESULT}" + mkdir -p "$PKGRESULT" + if [ -d "${PKGRESULT}" ]; then + chown -R "${BUILDRESULTUID}:${BUILDRESULTGID}" "${BUILDRESULT}/"* + cp -p "${FULLPATH}"/* "${PKGRESULT}" 2>/dev/null || true + chown -R "${BUILDRESULTUID}:${BUILDRESULTGID}" "${BUILDRESULT}/"* + else + echo "E: BUILDRESULT=[$BUILDRESULT] is not a directory." >&2 + fi + save_aptcache + umountproc + cleanbuildplace + echobacktime +} + +function emchrootbuild() +{ + if [ $SUITE == testing ]; then + BASETGZ="${WORKDIR}/emdebian-testing.tgz" + SUITE=testing + echo "Building in the embootstrap testing chroot" + else + BASETGZ="$WORKDIR/emdebian.tgz" + fi + . /usr/lib/pbuilder/pbuilder-buildpackage-funcs + + BUILDRESULTUID="${BUILDRESULTUID:-${SUDO_UID:-0}}" + BUILDRESULTGID="${BUILDRESULTGID:-${SUDO_GID:-0}}" + + while ! test -d ./debian -o "$(pwd)" = "$WORKDIR" ; do + cd ..; + done + if test ! -d ./debian; then + echo "Cannot find ./debian dir" + cleanbuildplace + exit 1 + fi; + + PKG_SOURCENAME=`dpkg-parsechangelog|sed -n 's/^Source: //p'` + PKG_VERSION=`dpkg-parsechangelog|sed -n 's/^Version: \(.*:\|\)//p'` + HOST_ARCH=`dpkg-architecture -qDEB_HOST_ARCH` + + echo "Building ${PKG_SOURCENAME} ${PKG_VERSION} on ${HOST_ARCH} for $ARCH" + INITIAL=`echo $PKG_SOURCENAME | cut -b1` + PKG=`basename \$PWD`; + TRUNK="$INITIAL/${PKG_SOURCENAME}/trunk" + SVN="$TRUNK/${PKG}" + if [ "$LOGIN_AFTER_FAIL" == "yes" ]; then + echo " -> will attempt to login after build failure" + fi + echo " -> source location: trunk/$SVN" + # get the Debian .dsc + DEB_VER=`echo $PKG_VERSION | sed -n 's/em[0-9]*$//p'` + if [ "$DEB_VER" == "" ]; then + echo "$PKG_VERSION is not an Emdebian version string." + cleanbuildplace + exit 1; + fi + DSC="${PKG_SOURCENAME}_${DEB_VER}.dsc" + if [ ! -f "../$DSC" ]; then + echo "Cannot find ../$DSC" + cleanbuildplace + exit 1; + fi + echo " -> using $DSC" + + # don't duplicate the downloads made by emsource + DIFFS=`find ../ -name emdebian-*\.patch` + DEBDIFFS=`find ../ -maxdepth 1 -name debian-patch*` + OLDSRC="$PKG_SOURCENAME.old" + echobacktime + extractembuildplace + echo "File extracted to: $BUILDPLACE" + echo "" + recover_aptcache + createbuilduser + + if [ -f "/etc/devscripts.conf" ]; then + cp /etc/devscripts.conf $BUILDPLACE/etc/devscripts.conf + fi + if [ -f "/home/$SUDO_USER/.devscripts" ]; then + mkdir -p $BUILDPLACE/home/$SUDO_USER/ + cp /home/$SUDO_USER/.devscripts $BUILDPLACE/home/$SUDO_USER/.devscripts + fi + + COLOUR= + if [ $ANSI_COLORS_DISABLED ]; then + COLOUR=ANSI_COLORS_DISABLED=1 + fi + echo "Checking the Emdebian toolchain" + # fails with non-zero if no toolchain is found + if echo "$COLOUR /usr/bin/emsetup --arch $ARCH --report" | chroot $BUILDPLACE /bin/sh; then + : + else + umountproc + cleanbuildplace + exit 1; + fi + echo "Copying Debian source" + chroot $BUILDPLACE mkdir -p trunk/$TRUNK + copydsc "../$DSC" "$BUILDPLACE/trunk/${TRUNK}/" + chroot $BUILDPLACE /usr/bin/dpkg-source -x trunk/${TRUNK}/$DSC trunk/$SVN + + echo "Applying Emdebian changes" + for PATCH in $DEBDIFFS + do + if [ ! -d /trunk/$SVN/debian/patches/ ]; then + echo "Creating debian/patches directory" + mkdir -p $BUILDPLACE/trunk/$SVN/debian/patches/ + fi + NAME=`echo $PATCH | sed -e 's/..\/debian-patch-//'` + echo "Copying $PATCH to /trunk/$SVN/debian/patches/$NAME" + cp "$PATCH" "$BUILDPLACE/trunk/$SVN/debian/patches/$NAME" + done + for PATCH in $DIFFS + do + cp "$PATCH" "$BUILDPLACE/trunk/$TRUNK" + if echo "cd /trunk/$SVN; patch -p1 < $PATCH" | chroot $BUILDPLACE /bin/sh; then + : + else + umountproc + cleanbuildplace + exit 1; + fi + done + + # only check for dependencies AFTER debian/control has been patched for Emdebian. + echo " -> installing build dependencies for $PKG_SOURCENAME" + checkembuilddep + # new function to parse and install cross-depends. + # read debian/xcontrol, pass Build-Cross-Depends to apt-cross -i + get_cross_depends + save_aptcache + echo " -> copying ../$OLDSRC" + cp -r "../$OLDSRC" "$BUILDPLACE/trunk/$TRUNK" + echo "Running emdebuild -a $ARCH $EM_DPKG_OPTS " + COLOUR= + if [ $ANSI_COLORS_DISABLED ]; then + COLOUR=ANSI_COLORS_DISABLED=1 + fi + if echo "cd /trunk/$SVN; $COLOUR ARCH=$ARCH emdebuild -a $ARCH $EM_DPKG_OPTS" | chroot $BUILDPLACE /bin/sh; then + : + else + echo " -> emdebuild failed" + if [ "${LOGIN_AFTER_FAIL}" = "yes" ]; then + echo " -> Logging into the chroot" + echo " -> Build directory: /trunk/$SVN" + echobacktime + chroot $BUILDPLACE /bin/sh + save_aptcache + umountproc + cleanbuildplace + exit 1; + fi + save_aptcache + umountproc + cleanbuildplace + exit 1; + fi + if [ $? -ne 0 ]; then + echo " -> emdebuild failed" + if [ "${LOGIN_AFTER_FAIL}" = "yes" ]; then + echo " -> Logging into the chroot" + echo " -> Build directory: /trunk/$SVN" + echobacktime + chroot $BUILDPLACE /bin/sh + save_aptcache + umountproc + cleanbuildplace + exit 1; + fi + fi + FULLPATH="$BUILDPLACE/trunk/$TRUNK/" + FULLPATH=`echo $FULLPATH | tr -s \/` + PKGRESULT="${BUILDRESULT}${INITIAL}/${PKG_SOURCENAME}/trunk" + echo "Copying build results to ${PKGRESULT}" + mkdir -p "$PKGRESULT" + if [ -d "${PKGRESULT}" ]; then + chown -R "${BUILDRESULTUID}:${BUILDRESULTGID}" "${BUILDRESULT}/"* + cp -p "${FULLPATH}"/* "${PKGRESULT}" 2>/dev/null || true + chown -R "${BUILDRESULTUID}:${BUILDRESULTGID}" "${BUILDRESULT}/"* + else + echo "E: BUILDRESULT=[$BUILDRESULT] is not a directory." >&2 + fi + CHANGES=`find $PKGRESULT -name \*${PKG_VERSION}_${ARCH}.changes` + echo " -> .changes file : ${CHANGES}" + EMDSC=`find $PKGRESULT -name \*${PKG_VERSION}.dsc` + echo " -> .dsc file : ${EMDSC}" + EMDEBS=`find $PKGRESULT -name \*${PKG_VERSION}*deb | grep -c deb` + echo " -> ${EMDEBS} packages built." + save_aptcache + umountproc + cleanbuildplace + echobacktime +} + +function emlogin() +{ + if [ $SUITE == testing ]; then + BASETGZ="${WORKDIR}/emdebian-testing.tgz" + echo "Logging into the embootstrap testing chroot" + else + BASETGZ="$WORKDIR/emdebian.tgz" + fi + extractembuildplace + recover_aptcache + echo " -> entering the shell" + echo "File extracted to: $BUILDPLACE" + # login should be as close to failsafe as possible so do v.little else. + chroot $BUILDPLACE /bin/sh || true + save_aptcache + umountproc + # saving the buildplace afterwards + if [ "${SAVE_AFTER_LOGIN}" = "yes" ]; then + echo " -> Saving the results, modifications to this session will persist" + chroot $BUILDPLACE /usr/bin/apt-get clean || true + create_emdebiantgz + fi + cleanbuildplace +} + +# test for sudo - normally empdebuild is installed in /usr/sbin so this +# test is really only for SVN users. +# make sure sudo is in use. +# bash cannot seem to do this when set -e is enabled +# because grep returns non-zero on a non-match +# so I use perl. :-) +ISSUDOSET=`perl -e '$e=\`printenv\`; ($e =~ /SUDO_USER/) ? print "yes" : print "no";'` +if [ $ISSUDOSET == "no" ] ; then + AREWEROOT=`perl -e '$e=\`printenv\`; ($e =~ /LOGNAME=root/) ? print "yes" : print "no";'` + if [ $AREWEROOT == "no" ]; then + echo "empdebuild needs to be run under sudo or as root." + exit 2 + fi +fi + +if [ ! $1 ];then + usagehelp + exit; +fi + +USEDEVPTS="yes" +USEPROC="yes" + +while [ -n "$1" ]; do +case "$1" in + --help|-h|-?|--version) + usagehelp + exit; + ;; + -a|--arch) + shift + ARCH=$1 + # chomp the argument to --arch + shift + ;; + --testing) + shift + SUITE=testing + ;; + --create|create) + shift; + checkarch + createemchroot + exit; + ;; + --update|update) + shift; + checkarch + update_emchroot + exit; + ;; + --build|build) + shift; + checkarch + emchrootbuild + exit; + ;; + --autobuild|autobuild) + shift; + PACKAGE=$1 + shift; + checkarch + empautobuild $PACKAGE + exit; + ;; + --save-after-login) + shift + SAVE_AFTER_LOGIN="yes" + ;; + --login-after-fail) + shift + LOGIN_AFTER_FAIL="yes" + ;; + --login|login) + shift + checkarch + emlogin + exit; + ;; + --clean|clean) + shift + echo "Trying to ensure crashed chroots are unmounted" + CRASH=`mount | grep "$WORKDIR" | cut -d' ' -f3` + if [ "$CRASH" ]; then + echo "Trying to ensure crashed chroots are unmounted" + mount | grep "$WORKDIR" | cut -d' ' -f3 | xargs umount || true + fi + echo "Cleaning $BASEBUILDPLACE" + clean_subdirectories $BASEBUILDPLACE + # if debootstrap fails, we start again so remove the stamp. + if [ -f $WORKDIR/stamp-debootstrap ]; then + rm $WORKDIR/stamp-debootstrap + fi + exit; + ;; + --) + while [ -n "$1" ] + do + EM_DPKG_OPTS+="$1 " + shift + done + break + ;; + *) + echo "Unrecognised option: $1" + echo + usagehelp + exit; + ;; +esac +done diff --git a/emrootfslib b/emrootfslib new file mode 100644 index 0000000..b64c1c6 --- /dev/null +++ b/emrootfslib @@ -0,0 +1,658 @@ +# emrootfslib : shell library to support root filesystems for Emdebian. +# +# This file is POSIX shell, compatible with debootstrap. +# Do not include or reference pbuilder functions or bash code here. +# +# Copyright (C) 2006-2008 Neil Williams +# +# This package is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# This shell library requires perl ! + +# Intended solely for use on the build machine. Do not use these functions +# in second_stage_install ! + +OURVERSION=`perl -e 'use Emdebian::Tools; print &tools_version();'` + +get_default_arch () +{ + ARCH=`perl -e 'use Debian::DpkgCross; \ +&read_config(); \ +my $arch = &get_architecture(); \ +print (qq/None.\n/) if (!$arch); \ +print $arch;';` +} + + get_work_dir () +{ + WORKDIR=`perl -e 'use Cwd; use Emdebian::Tools; use Config::Auto; use Debian::DpkgCross; \ +&read_config; \ +my $w = &get_workdir; \ +$w = cwd if (! -d $w); \ +$w =~ s/\/$//; \ +print $w;';` +} + +get_work_dir +get_default_arch + +WORKPLACE="${WORKDIR}/pbuilder" +BASETGZ="${WORKDIR}/emdebian.tgz" + +#pbuilder base values +DEBIAN_BUILDARCH=$ARCH +# cross-building chroot is same arch as host. +BUILDRESULT="$WORKPLACE/result/" +# tidy up // to / +BUILDRESULT=`echo $BUILDRESULT | tr -s \/` +APTCACHE="$WORKPLACE/aptcache/" +# tidy up // to / +APTCACHE=`echo $APTCACHE | tr -s \/` +AUTO_DEBSIGN=yes +APTCACHEHARDLINK="no" +BUILDPLACE="$WORKPLACE/build" + +# the default is to add a PID in the buildplace. +BASEBUILDPLACE="$BUILDPLACE" +if [ "${PRESERVE_BUILDPLACE}" != "yes" ]; then + BUILDPLACE="$BUILDPLACE/$$" +fi + +checkarch () +{ + ARCH=$ARCH perl -e 'use Debian::DpkgCross; $arch = $ENV{ARCH}; $arch=~s/ //g; \ + die "Unsupported architecture: $arch Use --arch\n" if (not defined (&check_arch($arch)));' +} + +create_emdebiantgz() { + ( + if ! cd "$BUILDPLACE"; then + echo "Error: unexpected error in chdir to $BUILDPLACE" >&2 + exit 1; + fi + while test -f "${BASETGZ}.tmp"; do + echo " -> Someone else has lock over ${BASETGZ}.tmp, waiting" + sleep 10s + done + echo " -> creating base tarball [${BASETGZ}]" + if ! sudo tar cfz "${BASETGZ}.tmp" * ; then + echo " -> failed building base tarball" + rm -f "${BASETGZ}.tmp" + exit 1; + fi + mv "${BASETGZ}.tmp" "${BASETGZ}" + ) +} + +check_dirs() +{ + if [ ! -d $BUILDPLACE ] ; then + mkdir -p $BUILDPLACE + fi + if [ ! -d $BUILDRESULT ] ; then + mkdir -p $BUILDRESULT + fi + if [ ! -d $APTCACHE ] ; then + mkdir -p $APTCACHE + fi +} + +disable_apt_recommends () { + if [ -d "$BUILDPLACE/etc/apt/apt.conf.d/" ]; then + if [ ! -f "$BUILDPLACE/etc/apt/apt.conf.d/10disablerecommends" ]; then + echo " -> disabling Apt::Install-Recommends" + cat > $BUILDPLACE/etc/apt/apt.conf.d/10disablerecommends << 'EOF' +APT +{ + Install-Recommends "false" +}; +EOF + fi + fi +} + +disable_apt_pdiffs () { + if [ -d "$BUILDPLACE/etc/apt/apt.conf.d/" ]; then + if [ ! -f "$BUILDPLACE/etc/apt/apt.conf.d/12disablepdiffs" ]; then + echo " -> disabling Apt::Acquire::PDiffs" + cat > $BUILDPLACE/etc/apt/apt.conf.d/12disablepdiffs << 'EOF' +APT +{ + Acquire::PDiffs "false"; +}; +EOF + fi + fi +} + +apt_autoremove_always () { + if [ -d "$BUILDPLACE/etc/apt/apt.conf.d/" ]; then + if [ ! -f "$BUILDPLACE/etc/apt/apt.conf.d/11always_autoremove" ]; then + echo " -> enabling Apt::AutomaticRemove" + cat > $BUILDPLACE/etc/apt/apt.conf.d/11always_autoremove << 'EOF' +APT +{ + AutomaticRemove "true" +}; +EOF + fi + fi +} + +unpack_debootstrap () { + info INSTCORE "Starting unpacking in $BUILDPLACE" + for deb in `ls $BUILDPLACE/var/cache/apt/archives/*.deb`; do + ver=`dpkg -f $deb Version` + pkg=`dpkg -f $deb Package` + info INSTCORE "Unpacking $pkg ($ver) ...." + dpkg -x $deb $BUILDPLACE/ + # get the package listing with reduced parsing complexity + mkdir $BUILDPLACE/listing + ar -p $deb data.tar.gz > $BUILDPLACE/listing/data.tar.gz + tar -tzf $BUILDPLACE/listing/data.tar.gz | sed -e 's/^\.//' | sed -e 's/^\/$/\/\./' | sed -e 's/\/$//' > $BUILDPLACE/var/lib/dpkg/info/${pkg}.list + rm -rf $BUILDPLACE/listing + rm -rf $BUILDPLACE/tmp/* + dpkg -e $deb $BUILDPLACE/tmp/ + for maint in `ls $BUILDPLACE/tmp/`; do + mv $BUILDPLACE/tmp/$maint $BUILDPLACE/var/lib/dpkg/info/$pkg.$maint + if [ $maint = "control" ]; then + grep -v "^$" $BUILDPLACE/var/lib/dpkg/info/$pkg.$maint >> $BUILDPLACE/var/lib/dpkg/available + grep -v "^$" $BUILDPLACE/var/lib/dpkg/info/$pkg.$maint >> $BUILDPLACE/var/lib/dpkg/status + echo "" >> $BUILDPLACE/var/lib/dpkg/available + echo "Status: install ok unpacked" >> $BUILDPLACE/var/lib/dpkg/status + rm $BUILDPLACE/var/lib/dpkg/info/$pkg.$maint + fi + # need a dpkg filter to make this stick + if [ $maint = "symbols" ]; then + rm $BUILDPLACE/var/lib/dpkg/info/$pkg.symbols + fi + done + if [ -f $BUILDPLACE/var/lib/dpkg/info/$pkg.conffiles ]; then + echo "Conffiles:" >> $BUILDPLACE/var/lib/dpkg/status + info INSTCORE "Processing $pkg.conffiles" + for line in `cat $BUILDPLACE/var/lib/dpkg/info/$pkg.conffiles`; do + md5=`md5sum $BUILDPLACE/$line | cut -d" " -f1` + echo " $line $md5" >> $BUILDPLACE/var/lib/dpkg/status + done + fi + echo "" >> $BUILDPLACE/var/lib/dpkg/status + done + if [ ! -e "$BUILDPLACE/etc/localtime" ]; then + ln -sf /usr/share/zoneinfo/UTC "$BUILDPLACE/etc/localtime" + fi + info INSTCORE "Removing archives..." + rm -f $BUILDPLACE/var/cache/apt/archives/*.deb + # (skip stages in emsecondstage) + touch $BUILDPLACE/debootstrap/unpacked +} + +busybox_symlinks () +{ + # busybox symlinks are best managed in postinst so that dpkg + # does not complain when they are replaced by Debian packages. + # this allows more applets to be supported by default. + if [ -f $BUILDPLACE/usr/share/busybox/busybox.links ]; then + cd $BUILDPLACE + # setup busybox + cp usr/share/busybox/busybox.links . + cp usr/share/busybox/install.sh . + # link in the rest of its applets from OUTSIDE the chroot + info INSTCORE "Symlinking the busybox applets..." + sh ./install.sh $BUILDPLACE/ --symlinks + rm $BUILDPLACE/install.sh + rm $BUILDPLACE/busybox.links + else + info INSTCORE "busybox configuration not required" + fi +} + +disable_invokercd () +{ + # invoke-rc.d is usually shell but is being looked at in Debian. + if [ ! -f $BUILDPLACE/usr/sbin/invoke-rc.d ]; then + echo '#!/bin/sh' > $BUILDPLACE/usr/sbin/invoke-rc.d + echo 'exec /etc/init.d/$1 $2' > $BUILDPLACE/usr/sbin/invoke-rc.d + echo '' >> $BUILDPLACE/usr/sbin/invoke-rc.d + chmod 755 $BUILDPLACE/usr/sbin/invoke-rc.d + fi +} + +disable_updatercd () +{ + # a better fix for /usr/sbin/update-rc.d is available via sysv-rc + if [ ! -f $BUILDPLACE/usr/sbin/update-rc.d ]; then + echo "#!/bin/sh" > $BUILDPLACE/usr/sbin/update-rc.d + echo "" >> $BUILDPLACE/usr/sbin/update-rc.d + chmod 755 $BUILDPLACE/usr/sbin/update-rc.d + fi + RC=`head $BUILDPLACE/usr/sbin/update-rc.d | grep /usr/bin/perl || true` + if [ "$RC" != "" ]; then + info INSTCORE "Replacing perl update-rc.d" + echo "#!/bin/sh" > $BUILDPLACE/usr/sbin/update-rc.d + echo "" >> $BUILDPLACE/usr/sbin/update-rc.d + chmod 755 $BUILDPLACE/usr/sbin/update-rc.d + fi +} + +extra_etc_rcd () +{ + if [ ! -d $BUILDPLACE/etc/rcS.d ]; then + mkdir $BUILDPLACE/etc/rcS.d + fi + if [ ! -d $BUILDPLACE/etc/rc0.d ]; then + mkdir $BUILDPLACE/etc/rc0.d + fi + if [ ! -d $BUILDPLACE/etc/rc1.d ]; then + mkdir $BUILDPLACE/etc/rc1.d + fi + if [ ! -d $BUILDPLACE/etc/rc6.d ]; then + mkdir $BUILDPLACE/etc/rc6.d + fi +} + +provide_var_lib_x11 () +{ + if [ ! -d $BUILDPLACE/var/lib/x11 ]; then + mkdir -p $BUILDPLACE/var/lib/x11 + fi +} + +basic_group_setup () { + if [ ! -f $BUILDPLACE/etc/group ]; then + echo \ +"root:x:0: +daemon:x:1: +bin:x:2: +sys:x:3: +adm:x:4: +tty:x:5: +disk:x:6: +lp:x:7: +mail:x:8: +news:x:9: +uucp:x:10: +man:x:12: +proxy:x:13: +kmem:x:15: +audio:x:29: +utmp:x:43: +video:x:44: +" > $BUILDPLACE/etc/group + fi +} + +basic_passwd_setup () { + if [ ! -f $BUILDPLACE/etc/passwd ]; then + echo \ +"root:x:0:0:root:/root:/bin/sh +daemon:x:1:1:daemon:/usr/sbin:/bin/sh +bin:x:2:2:bin:/bin:/bin/sh +sys:x:3:3:sys:/dev:/bin/sh +sync:x:4:65534:sync:/bin:/bin/sync +games:x:5:60:games:/usr/games:/bin/sh +man:x:6:12:man:/var/cache/man:/bin/sh +lp:x:7:7:lp:/var/spool/lpd:/bin/sh +mail:x:8:8:mail:/var/mail:/bin/sh +news:x:9:9:news:/var/spool/news:/bin/sh +uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh +proxy:x:13:13:proxy:/bin:/bin/sh +www-data:x:33:33:www-data:/var/www:/bin/sh +backup:x:34:34:backup:/var/backups:/bin/sh +list:x:38:38:Mailing List Manager:/var/list:/bin/sh +irc:x:39:39:ircd:/var/run/ircd:/bin/sh +gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh +nobody:x:65534:65534:nobody:/nonexistent:/bin/sh +" > $BUILDPLACE/etc/passwd + fi +} + +# need /etc/shadow too +basic_shadow_setup () { + if [ ! -f $BUILDPLACE/etc/shadow ]; then + echo \ +"root:$1$Vu4M34LT$0L2BfH9nXbSG1zQWxUH8M1:0:::::: +daemon:*:13896:0:99999:7::: +bin:*:0:0:99999:7::: +sys:*:0:0:99999:7::: +sync:*:0:0:99999:7::: +games:*:0:0:99999:7::: +man:*:0:0:99999:7::: +lp:*:0:0:99999:7::: +mail:*:0:0:99999:7::: +news:*:0:0:99999:7::: +uucp:*:0:0:99999:7::: +proxy:*:0:0:99999:7::: +www-data:*:0:0:99999:7::: +backup:*:0:0:99999:7::: +list:*:0:0:99999:7::: +irc:*:0:0:99999:7::: +gnats:*:0:0:99999:7::: +nobody:*:0:0:99999:7:::" > $BUILDPLACE/etc/shadow + fi +} + +provide_empty_install_info () { + if [ ! -f $BUILDPLACE/usr/sbin/install-info ]; then + echo \ +'#!/bin/sh +exec /etc/init.d/$1 $2 +' > $BUILDPLACE/usr/sbin/install-info + chmod 755 $BUILDPLACE/usr/sbin/install-info + fi +} + +set_approx_time () { + if [ -d $BUILDPLACE/bin ]; then + DATE=`date` + ZERO=`date -d@0` + # if we have a usable date, store it. + if [ "$DATE" != "$ZERO" ]; then + APPROX=`stat -c%Y $BUILDPLACE/bin/` + STR=`date -d@$APPROX +%m%d%H%M%Y` + info INSTCORE "Storing approximate time '$STR' in './datestring'" + echo "$STR" > $BUILDPLACE/datestring + fi + fi +} + +basic_etc_fstab () { + if [ ! -f "$BUILDPLACE/etc/fstab" ]; then + cat > $BUILDPLACE/etc/fstab << 'EOF' +# /etc/fstab: static file system information. +# +# +proc /proc proc defaults 0 0 +sysfs /sys sysfs defaults 0 0 +devpts /dev/pts devpts mode=0620,gid=5 0 0 +usbdevfs /proc/bus/usb usbdevfs noauto 0 0 +EOF + chown 0.0 "$BUILDPLACE/etc/fstab"; + chmod 0644 "$BUILDPLACE/etc/fstab" + fi +} + +make_dpkg_dirs () { + mkdir -p "$BUILDPLACE/var/lib/dpkg" + : >"$BUILDPLACE/var/lib/dpkg/status" + echo >"$BUILDPLACE/var/lib/dpkg/available" + echo -n >"$BUILDPLACE/var/lib/dpkg/diversions" +} + +x_feign_install () { + local pkg="$1" + local deb="$(debfor $pkg)" + local ver="$( + ar -p "$BUILDPLACE/$deb" control.tar.gz | zcat | + tar -O -xf - control ./control 2>/dev/null | + sed -ne 's/^Version: *//Ip' | head -n 1 + )" + mkdir -p "$BUILDPLACE/var/lib/dpkg/info" + echo \ +"Package: $pkg +Version: $ver +Status: install ok installed + +" >> "$BUILDPLACE/var/lib/dpkg/status" + touch "$BUILDPLACE/var/lib/dpkg/info/${pkg}.list" +} + +prepare_proc () { + if [ ! -d $BUILDPLACE/proc ]; then + mkdir -p $BUILDPLACE/proc + fi + if [ ! -d $BUILDPLACE/sys ]; then + mkdir -p $BUILDPLACE/sys + fi +} + +prepare_var () { + if [ ! -d $BUILDPLACE/var/log ]; then + mkdir -p $BUILDPLACE/var/log + fi + if [ ! -d $BUILDPLACE/var/spool ]; then + mkdir -p $BUILDPLACE/var/spool + fi +} + +busybox_inittab () { + if [ ! -e "$BUILDPLACE/etc/inittab" ]; then + info INSTCORE "Adding default busybox inittab" + cat > $BUILDPLACE/etc/inittab << 'EOF' +# /etc/inittab +# +# Copyright (C) 2001 Erik Andersen +# +# Note: BusyBox init doesn't support runlevels. + +# Startup the system +null::sysinit:/bin/mount -o remount,rw / +null::sysinit:/bin/mount -t proc proc /proc +null::sysinit:/bin/mount -t sysfs sysfs /sys +null::sysinit:/bin/mount -t devpts devpts /dev/pts +null::sysinit:/bin/mount -a +null::sysinit:/bin/hostname -F /etc/hostname +null::sysinit:/sbin/ifconfig lo 127.0.0.1 up +null::sysinit:/sbin/route add -net 127.0.0.0 netmask 255.0.0.0 lo +# now run any rc scripts and then login +::sysinit:/etc/init.d/rcS + +# Set up a couple of getty's +tty1::respawn:/sbin/getty 38400 tty1 +tty2::respawn:/sbin/getty 38400 tty2 + +# Put a getty on the serial port +#ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100 +ttyS2::respawn:/sbin/getty -L ttyS2 115200 vt100 + +# Logging junk +null::sysinit:/bin/touch /var/log/messages +null::respawn:/sbin/syslogd -n -m 0 +null::respawn:/sbin/klogd -n +tty3::respawn:/usr/bin/tail -f /var/log/messages + +# Stuff to do for the 3-finger salute +::ctrlaltdel:/sbin/reboot + +# Stuff to do before rebooting +null::shutdown:/usr/bin/killall klogd +null::shutdown:/usr/bin/killall syslogd +null::shutdown:/bin/umount -a -r +null::shutdown:/sbin/swapoff -a + +EOF + fi +} + +busybox_rcS () { + if [ ! -d "$BUILDPLACE/etc/default" ]; then + mkdir -p $BUILDPLACE/etc/default + fi + if [ ! -d "$BUILDPLACE/etc/rc.d" ]; then + mkdir -p $BUILDPLACE/etc/rc.d + fi + if [ ! -f "$BUILDPLACE/etc/default/rcS" ]; then + echo "#!/bin/sh" > $BUILDPLACE/etc/default/rcS + echo >> $BUILDPLACE/etc/default/rcS + chown 0.0 "$BUILDPLACE/etc/default/rcS" + chmod 644 "$BUILDPLACE/etc/default/rcS" + fi + # derived from the buildroot version. + if [ ! -e "$BUILDPLACE/etc/init.d/rcS" ]; then + info INSTCORE "Adding default busybox rcS" + cat > $BUILDPLACE/etc/init.d/rcS << 'EOF' +#!/bin/sh +set -e +# Start all init scripts in /etc/rc.d/ +# +if [ ! -z "$SPAWNED" ]; then + /bin/login +fi +SPAWNED="$SPAWNED ." +export SPAWNED=\$SPAWNED +for i in /etc/rc.d/S??* ;do + # Ignore dangling symlinks (if any). + [ ! -f "$i" ] && continue + case "$i" in + *.sh) + # Source shell script for speed. + ( + trap - INT QUIT TSTP + set start + . $i + ) + ;; + *) + # No sh extension, so fork subprocess. + $i start + ;; + esac +done +EOF + chown 0.0 "$BUILDPLACE/etc/init.d/rcS" + chmod 0755 "$BUILDPLACE/etc/init.d/rcS" + fi +} + +# call repeatedly to create init symlinks. +# arg1 is the file in $BUILDPLACE/etc/init.d/ +# arg2 is the number for the link in the init sequence +# where 'foo 20' runs after 'bar 10' etc. +symlink_rcS () { + local file="$1" + local num="$2" + linkname="S$num$file" + if [ ! -d "$BUILDPLACE/etc/rc.d/" ]; then + mkdir $BUILDPLACE/etc/rc.d + fi + if [ -f $BUILDPLACE/etc/init.d/$file ]; then + ln -sf ../init.d/$file $BUILDPLACE/etc/rc.d/$linkname + fi +} + +symlink_rcK () { + local file="$1" + local num="$2" + linkname="K$num$file" + if [ ! -d "$BUILDPLACE/etc/rc.d/" ]; then + mkdir $BUILDPLACE/etc/rc.d + fi + if [ -f $BUILDPLACE/etc/init.d/$file ]; then + ln -sf ../init.d/$file $BUILDPLACE/etc/rc.d/$linkname + fi +} + +basic_etc_profile () { + if [ ! -e "$BUILDPLACE/etc/profile" ]; then + info INSTCORE "Adding a basic /etc/profile file" + cat > $BUILDPLACE/etc/profile << 'EOF' +if [ "`id -u`" -eq 0 ]; then + PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games/" +else + PATH="/usr/local/bin:/usr/bin:/bin:/usr/games" +fi + +if [ "$PS1" ]; then + if [ "`id -u`" -eq 0 ]; then + PS1='# ' + else + PS1='$ ' + fi +fi + +export PATH +export DISPLAY=:0 +umask 022 + +EOF + fi +} + +set_cdebconf_default () { + info INSTCORE "Setting cdebconf as default." + echo "export DEBCONF_USE_CDEBCONF=true" >> $BUILDPLACE/etc/profile +} + +set_tslib_pointercal () { + info INSTCORE "Setting location of tslib calibration file." + echo "export TSLIB_CALIBFILE=/etc/pointercal" >> $BUILDPLACE/etc/profile +} + +# this function is coded to match the sample_xorg_conf +# some devices might use /dev/input/event1 or event2 +set_tslib_tsdevice () { + info INSTCORE "Setting location of tslib touchscreen device." + echo "export TSLIB_TSDEVICE=/dev/input/event0" >> $BUILDPLACE/etc/profile +} + +sample_xorg_conf () { + if [ ! -e "$BUILDPLACE/etc/X11/xorg.conf" ]; then + info INSTCORE "Adding sample xorg.conf" + cat > $BUILDPLACE/etc/X11/xorg.conf << 'EOF' +# You probably want to change at least some of these +# lines and provide it via machine:variant customisations. +# This one comes from balloon3-config. +Section "Files" + FontPath "/usr/share/fonts/truetype/ttf-bitstream-vera/" +EndSection + +Section "InputDevice" + Identifier "Generic Keyboard" + Driver "kbd" +EndSection + +# /dev/input/event0 is kernel-module specific. +# You may need to change this. +Section "InputDevice" + Identifier "Touchscreen" + Driver "tslib" + Option "ScreenNumber" "0" + Option "Width" "0" + Option "Height" "0" + Option "Rotate" "NONE" + Option "TslibDevice" "/dev/input/event0" +EndSection + +Section "Device" + Identifier "Generic Video Card" + Driver "fbdev" + Option "UseFBDev" "true" +EndSection + +Section "Monitor" + Identifier "Configured Monitor" +EndSection + +Section "ServerLayout" + Identifier "Default Layout" + Screen "Default Screen" + InputDevice "Touchscreen" +EndSection + +Section "Screen" + Identifier "Default Screen" + Monitor "Configured Monitor" +EndSection + +EOF + fi +} + +shell_update_rcd () { + if [ ! -e "$BUILDPLACE/usr/sbin/update-rc.d" ]; then + info INSTCORE "Adding a /usr/sbin/update-rc.d shell script" + cp /usr/share/emdebian-tools/update-rc.d $BUILDPLACE/usr/sbin/ + chmod 0755 $BUILDPLACE/usr/sbin/update-rc.d + fi +} diff --git a/emsandbox b/emsandbox new file mode 100755 index 0000000..f3efa28 --- /dev/null +++ b/emsandbox @@ -0,0 +1,172 @@ +#!/bin/bash +set -e +# emsandbox : emdebian roots creation. +# +# Copyright (C) 2006-2008 Neil Williams +# +# This package is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# the name is not finalised +PROG=emsandbox + +function usagehelp () { + # print out help message + cat < embootstrap complete" +else + /usr/share/emdebian-tools/embootstrap --arch $ARCH --cross $CUSTOM +fi diff --git a/emsecondstage b/emsecondstage new file mode 100755 index 0000000..c519bc6 --- /dev/null +++ b/emsecondstage @@ -0,0 +1,133 @@ +#!/bin/sh + +set -e +# emsandbox : emdebian rootfs installer +# +# Copyright (C) 2007-2008 Neil Williams +# +# This package is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# simple wrapper to aid installation of the rootfs +# Provides a space for pre-installation custom commands as well as simplifying +# the command line. + +TARGET=`pwd` + +PROG=emsecondstage + +usagehelp () { + # print out help message + cat < Running second stage config.sh script for this machine variant" + sh $TARGET/machine/config.sh + rm -r $TARGET/machine/ +fi + +if [ -d $TARGET/debootstrap ]; then + rm -rf $TARGET/debootstrap +fi + +if [ -d $TARGET/machine ]; then + rm -rf $TARGET/machine +fi + +if [ -f $TARGET/0x97BB3B58.txt ]; then + rm $TARGET/0x97BB3B58.txt +fi + +# If there is no time or date, this will need to remain. +#if [ -f $TARGET/emdebian-archive-keyring.gpg ]; then +# rm $TARGET/emdebian-archive-keyring.gpg +#fi + +if [ -d $TARGET/tmp/buildd ]; then + rm -rf $TARGET/tmp/buildd +fi + +# finally, remove self +if [ -f $TARGET/emsecondstage ]; then + rm $TARGET/emsecondstage +fi + +echo "Emdebian base system installed successfully." diff --git a/examples/README b/examples/README new file mode 100644 index 0000000..57fe530 --- /dev/null +++ b/examples/README @@ -0,0 +1,12 @@ + MACHINE:VARIANT README + ====================== + + +The example files live machine/default so that you can copy +the files into the right place in your machine:variant hierarchy. + +$WORK/machine/$machine_name/default/packages.conf +$WORK/machine/$machine_name/default/config.sh +$WORK/machine/$machine_name/default/setup.sh + +http://www.emdebian.org/emdebian/customisation.html diff --git a/examples/config.sh b/examples/config.sh new file mode 100755 index 0000000..08b28d4 --- /dev/null +++ b/examples/config.sh @@ -0,0 +1,20 @@ +#!/bin/sh -e + +# This config script provides a method of adjusting the tarball +# contents immediately after the second stage install has completed. +# The script is copied into the tarball and unpacked to: +# $TARGET/machine/config.sh + +# NOTE: At this stage, the ./debootstrap/ directory has already been +# removed. Do not rely on the tarball itself being available either. +# If any other files or scripts are needed by your additions to this +# script, you must ensure that setup.sh includes them into the tarball. + +# It may be easier to create a normal Debian package that can do the +# job for you. + +# This example file can act as a skeleton for your own scripts. +# Copy into $WORK/machine/$MACHINE/$VARIANT/ and edit. +# ($WORK is your emdebian working directory, as set in debconf.) +# Use 'default' as the variant directory if no other variants exist. +# config.sh does not have to be executable. diff --git a/examples/packages.conf b/examples/packages.conf new file mode 100644 index 0000000..650790f --- /dev/null +++ b/examples/packages.conf @@ -0,0 +1,77 @@ +# This is a standard shell conf file, included directly into embootstrap + +# This example file can act as a skeleton for your own scripts. +# Copy into $WORK/machine/$MACHINE/$VARIANT/ and edit. +# ($WORK is your emdebian working directory, as set in debconf.) +# Use 'default' as the variant directory if no other variants exist. + +# packages.conf is intended to be the principal place for adjusting +# the emsandbox tarball to suit the needs of specific machine variants. +# setup.sh and config.sh can fine tune the results but in order to avoid +# reinventing the wheel, if more than a few machines need similar +# adjustments to the same files, future versions of packages.conf will +# collate those into a single configuration parameter available to all. +# More options and parameters will be added in due course, including +# support for additional sources for /etc/apt/sources.list and single +# parameter changes to certain files like /etc/inittab. + +# Due to limitations in the current debootstrap support, the only way +# of adding packages to the first stage is by providing a +# customised suite script. Even if emsandbox migrates to using a tool +# from Stag to overcome shortcomings in debootstrap, support for +# packages.conf, setup.sh and config.sh will remain. + +# INCLUDE adds a comma separated list of package names to the list +# of packages added to the tarball and installed in the second stage. +# Currently, debootstrap has problems with multiple repositories so +# either upload this package to the same repository as your other +# packages or create an apt-proxy that can serve as a local repository, +# set it in PROXY and specify a usable mirror for the device in MIRROR. +# DEFAULT: empty +INCLUDE= + +# SCRIPT overrides the default emsandbox suite-script that debootstrap +# uses to determine the base and required packages and the all important +# sequence in which the packages can be installed. SCRIPT can be overridden +# on the emsandbox command line. +# DEFAULT: /usr/share/emdebian-tools/emdebian.crossd +SCRIPT= + +# MIRROR overrides the default emsandbox mirror. This repository will +# will be set in /etc/apt/sources.list and will also be used by +# debootstrap to obtain all packages for the tarball unless +# PROXY is also set. +# DEFAULT: http://www.emdebian.org/emdebian/ +MIRROR= + +# PROXY specifies a separate repository to pass to debootstrap that may +# be local or otherwise not intended for use once the tarball is installed +# Use MIRROR to set the same value in debootstrap and /etc/apt/sources.list +# If PROXY is specified without MIRROR, the default emsandbox MIRROR will +# be written into /etc/apt/sources.list +# DEFAULT: empty +PROXY= + +# It is often useful to include a kernel image and/or modules or extra +# files but these may be in generated or variable paths - e.g. including +# a version string or in another part of the filesystem. To include these +# files in the emsandbox tarball, write out a list of paths into a file in +# $WORK/machine/$MACHINE/$VARIANT and read the contents into the +# setup.sh script. The files copied or unpacked into the $BUILDPLACE +# will then be included into the tarball. + +# If there are extra files with absolute paths that do not change +# between releases, specify them in EXTRA. Absolute paths only - +# wildcards supported by 'cp' are allowed. Files are copied into +# $BUILDPLACE unchanged to be processed by setup.sh (if it exists). +EXTRA= + +# TARBALL_NAME overrides the default name (emdebian-$ARCH) of the tarball +# Do not specify a path here, just a filename with the .tgz suffix +# DEFAULT: emdebian-$ARCH.tgz where $ARCH is specified to emsandbox or +# as the dpkg-cross default architecture. +TARBALL_NAME= + +# SUITE is not recommended to be changed. +# DEFAULT: unstable +SUITE= diff --git a/examples/setup.sh b/examples/setup.sh new file mode 100755 index 0000000..df818ef --- /dev/null +++ b/examples/setup.sh @@ -0,0 +1,29 @@ +#!/bin/sh -e + +# This setup script is an alternative method of adjusting the tarball +# contents immediately after the first stage install has completed. +# It may be easier to create a normal Debian package that can do the +# job for you. (Remember to use the postinst if you want to append +# to existing files instead of replacing the emsandbox versions. + +# The script is called by embootstrap with the following arguments: + +# $1 = $BUILDPLACE - the top directory of the debootstrapped system +# $2 = $ARCH - the specified architecture, already checked with dpkg-architecture. + +# This example file can act as a skeleton for your own scripts. +# Copy into $WORK/machine/$MACHINE/$VARIANT/ and edit. +# ($WORK is your emdebian working directory, as set in debconf.) +# Use 'default' as the variant directory if no other variants exist. +# setup.sh does not have to be executable. + +# Use any other scripts or files that you need for first stage install. +# To use any of those scripts or files in the second stage, ensure +# that this script copies the relevant files into the tarball at +# /machine/$MACHINE/$VARIANT/ + +# e.g. To pass the location of a kernel or other files to be added to the +# tarball, write out a file into $WORK/machine/$MACHINE/$VARIANT and +# read the contents into this script. + +# Nothing to do by default. diff --git a/multistrap b/multistrap index 13c4d88..d2dd4d1 100755 --- a/multistrap +++ b/multistrap @@ -5,6 +5,6 @@ use warnings; # Eventually, this will replace the em_ one or call em_ with # --arch and take over native duties. -#debug + my $str = join(" ", @ARGV); -system ("sudo /opt/working/emdebian/svn/current/em_multistrap $str"); +system ("/usr/sbin/em_multistrap $str"); diff --git a/update-rc.d b/update-rc.d new file mode 100755 index 0000000..1491d9d --- /dev/null +++ b/update-rc.d @@ -0,0 +1,68 @@ +#!/bin/sh +# +# Copyright 2008 Hands.com Ltd +# Copyright 2008 Neil Williams +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +initd="/etc/init.d" +etcd="/etc/rc.d" +bn=$1;shift +if [ "$bn" = '-f' ]; then + bn=$1 + shift +fi + +defaults () { + makelinks "S${1:-20}" + makelinks "K${2:-${1:-20}}" +} + +makelinks () { + echo " Adding symlink for $initd/$bn ..."; + echo "${etcd}/${1}${bn} -> ../init.d/$bn" + ln -s "../init.d/$bn" "${etcd}/${1}${bn}" +} + +if [ -z "$bn" -o -z "$1" ]; then + echo "Insufficient arguments" + exit 1 +fi +if [ ! -f "$initd/$bn" ]; then + echo "update-rc.d: $initd/$bn: file does not exist\n" + exit 1 +fi +if [ "$1" = 'remove' ]; then + shift + echo "rm -f /etc/rc.d/*${bn}" + rm -f "/etc/rc.d/*${bn}" + exit; +elif [ "$1" = 'defaults' ]; then + makelinks "S${2:-20}" + makelinks "K${3:-${2:-20}}" + exit 0; +else + if [ "$1" = 'start' ] + then + shift + num=$1 + # use two digit prefixes + if [ $num -lt 10 ]; then + num="0${num}" + fi + makelinks "S${num}" + while [ "$1" != "." ] + do + shift + done + shift + if [ "$1" = 'stop' ]; then + shift + makelinks "K${1}" + fi + fi + exit 0; +fi