diff options
Diffstat (limited to 'helpers')
34 files changed, 1306 insertions, 0 deletions
diff --git a/helpers/Makefile b/helpers/Makefile new file mode 100644 index 0000000..f2f31d4 --- /dev/null +++ b/helpers/Makefile @@ -0,0 +1,11 @@ +# Makefile + +all: install + +install: + install -d -m 0755 $(DESTDIR)/usr/sbin/ + install -m 0755 lh_* $(DESTDIR)/usr/sbin + +uninstall: + +reinstall: install diff --git a/helpers/lh_buildbinary b/helpers/lh_buildbinary new file mode 100755 index 0000000..48216e1 --- /dev/null +++ b/helpers/lh_buildbinary @@ -0,0 +1,200 @@ +#!/bin/sh + +# lh_buildbinary + +if [ ! -f "${LIVE_ROOT}"/.stage/image_binary ] +then + # Configure chroot + lh_patchchroot apply + lh_patchrunlevel apply + + # Configure network + lh_patchnetwork apply + + mkdir -p "${LIVE_ROOT}"/binary/casper + for MANIFEST in "${LIVE_ROOT}"/filesystem.manifest* + do + if [ -e "${MANIFEST}" ]; then + mv "${MANIFEST}" "${LIVE_ROOT}"/binary/casper/ + fi + done + + if [ "${LIVE_TYPE}" = "Net" ] + then + # Mount proc + mount proc-live -t proc "${LIVE_CHROOT}"/proc + + # Installing smbfs + lh_chroot "aptitude install --assume-yes smbfs" + + # Unmount proc + umount "${LIVE_CHROOT}"/proc + + if [ "${LIVE_ARCHITECTURE}" = "amd64" ] || [ "${LIVE_ARCHITECTURE}" = "i386" ] + then + if [ ! -d "${LIVE_CHROOT}"/etc/initramfs-tools ] + then + mkdir "${LIVE_CHROOT}"/etc/initramfs-tools + fi + + # Configuring initramfs for NFS +cat >> "${LIVE_CHROOT}"/etc/initramfs-tools/initramfs.conf << EOF +MODULES=netboot +BOOT=nfs +NFSROOT=auto +EOF + lh_chroot "update-initramfs -tu" + fi + fi + + lh_cleanapt + + # Switching package indices to default + if [ "${LIVE_GENERIC_INDICES}" = "yes" ] + then + lh_setupapt default + lh_configapt deapply-proxy + lh_configapt deapply-recommends + fi + + # Deconfigure network + lh_patchnetwork deapply + + # Deconfigure chroot + lh_patchrunlevel deapply + lh_patchchroot deapply + + # Generating rootfs image + lh_genrootfs + + # Configure chroot + lh_patchchroot apply + lh_patchrunlevel apply + + # Configure network + lh_patchnetwork apply + + lh_cleanapt + + # Switching package indices to custom + lh_setupapt custom + lh_configapt apply-proxy + lh_configapt apply-recommends + + case "${LIVE_TYPE}" in + Iso) + TYPE=iso + ;; + Usb) + TYPE=usb + ;; + Net) + TYPE=net + ;; + esac + + # Mount proc + mount proc-live -t proc "${LIVE_CHROOT}"/proc + + # Install depends + lh_depends install $TYPE + + # Installing syslinux + lh_installsyslinux $TYPE + + # Installing linux-image + lh_installlinux $TYPE + + # Installing memtest + lh_installmemtest86+ $TYPE + + # Deconfigure network + lh_patchnetwork deapply + + # Deconfigure chroot + lh_patchrunlevel deapply + lh_patchchroot deapply + + # Installing templates + if [ "${LIVE_FLAVOUR}" != "minimal" ] || [ "${LIVE_FLAVOUR}" != "mini" ] + then + if [ "${TYPE}" != "usb" ] + then + cp -r "${LIVE_TEMPLATES}"/common/* "${LIVE_ROOT}"/binary + fi + + if [ "${TYPE}" = "iso" ] || [ "${TYPE}" = "usb" ] + then + cp -r "${LIVE_TEMPLATES}"/iso/* "${LIVE_ROOT}"/binary + fi + fi + + # Calculating md5sums + lh_md5sums + + case "${TYPE}" in + iso) + if [ "${LIVE_ARCHITECTURE}" = "amd64" ] || [ "${LIVE_ARCHITECTURE}" = "i386" ] + then + # Create image + ${GENISOIMAGE} -A "Debian Live" -p "Debian Live; http://debian-live.alioth.debian.org/; debian-live-devel@lists.alioth.debian.org" -publisher "Debian Live; http://debian-live.alioth.debian.org/; debian-live-devel@lists.alioth.debian.org" -o "${LIVE_ROOT}"/"${LIVE_IMAGE}"binary.iso -r -J -l -V "${LIVE_DISK_VOLUME}" -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table "${LIVE_ROOT}"/binary ${LIVE_INCLUDE_IMAGE} + else + echo "W: Bootloader on your architecture not yet supported (Continuing in 5 seconds)." + sleep 5 + # Create image + ${GENISOIMAGE} -A "Debian Live" -p "Debian Live; http://debian-live.alioth.debian.org/; debian-live-devel@lists.alioth.debian.org" -publisher "Debian Live; http://debian-live.alioth.debian.org/; debian-live-devel@lists.alioth.debian.org" -o "${LIVE_ROOT}"/"${LIVE_IMAGE}"binary.iso -r -J -l -V "${LIVE_DISK_VOLUME}" "${LIVE_ROOT}"/binary ${LIVE_INCLUDE_IMAGE} + fi + ;; + + net) + cd "${LIVE_ROOT}" && \ + mv binary "`basename ${LIVE_SERVER_PATH}`" && \ + cd .. && \ + tar cfz binary.tar.gz "`basename ${LIVE_ROOT}`/`basename ${LIVE_SERVER_PATH}`" "`basename ${LIVE_ROOT}`/tftpboot" && \ + mv binary.tar.gz "${LIVE_ROOT}" && \ + cd "${OLDPWD}" && \ + mv "`basename ${LIVE_SERVER_PATH}`" binary + ;; + + usb) + # Everything which comes here needs to be cleaned up, + DU_DIM="`du -ms ${LIVE_ROOT}/binary | cut -f1`" + REAL_DIM="`expr ${DU_DIM} + ${DU_DIM} / 20`" # Just 5% more to be sure, need something more sophistcated here... + dd if=/dev/zero of="${LIVE_ROOT}"/binary.img bs=1024k count=${REAL_DIM} + + FREELO="`losetup -f`" + + echo "!!! The following error/warning messages can be ignored !!!" + lh_losetup $FREELO "${LIVE_ROOT}"/binary.img 0 + set +e + lh_chroot "parted -s ${FREELO} mklabel msdos" + lh_chroot "parted -s ${FREELO} mkpartfs primary fat16 0.0 100%" + lh_chroot "parted -s ${FREELO} set 1 boot on" + lh_chroot "parted -s ${FREELO} set 1 lba off" + set -e + cat "${LIVE_CHROOT}"/usr/lib/syslinux/mbr.bin > ${FREELO} + losetup -d ${FREELO} + + lh_losetup $FREELO "${LIVE_ROOT}"/binary.img 1 + lh_chroot "mkfs.msdos -n DEBIAN_LIVE ${FREELO}" + mkdir "${LIVE_ROOT}"/binary.tmp + mount ${FREELO} "${LIVE_ROOT}"/binary.tmp + cp -r "${LIVE_ROOT}"/binary/* "${LIVE_ROOT}"/binary.tmp + umount "${LIVE_ROOT}"/binary.tmp + rmdir "${LIVE_ROOT}"/binary.tmp + lh_chroot "syslinux ${FREELO}" + losetup -d ${FREELO} + + echo "!!! The above error/warning messages can be ignored !!!" + ;; + esac + + # Remove depends + lh_depends remove $TYPE + + # Unmount proc + umount "${LIVE_CHROOT}"/proc + + # Touching stage file + touch "${LIVE_ROOT}"/.stage/image_binary +fi diff --git a/helpers/lh_buildsource b/helpers/lh_buildsource new file mode 100755 index 0000000..836bd3c --- /dev/null +++ b/helpers/lh_buildsource @@ -0,0 +1,84 @@ +#!/bin/sh + +# lh_buildsource.sh <type> + +if [ ! -f "${LIVE_ROOT}"/.stage/image_source ] && [ "${LIVE_SOURCE}" = "yes" ] +then + # Configure chroot + lh_patchnetwork apply + + # Download sources + lh_chroot "dpkg --get-selections" | awk '{ print $1 }' > "${LIVE_CHROOT}"/root/dpkg-selection.txt + lh_chroot "xargs --arg-file=/root/dpkg-selection.txt apt-get source --download-only" + rm -f "${LIVE_CHROOT}"/root/dpkg-selection.txt + + # Sort sources + for DSC in "${LIVE_CHROOT}"/*.dsc + do + SOURCE="`awk '/Source:/ { print $2; }' ${DSC}`" + + if [ "`echo ${SOURCE} | cut -b 1-3`" == "lib" ] + then + LETTER="`echo ${SOURCE} | cut -b 1-4`" + else + LETTER="`echo ${SOURCE} | cut -b 1`" + fi + + # Install directory + install -d -m 0755 "${LIVE_ROOT}"/source/"${LETTER}"/"${SOURCE}" + + # Move files + mv "${LIVE_CHROOT}"/"${SOURCE}"_* "${LIVE_ROOT}"/source/"${LETTER}"/"${SOURCE}" + done + + case "${1}" in + generic) + # Create tarball + tar cf source.tar "$LIVE_ROOT"/source + ;; + + iso) + # Create image + ${GENISOIMAGE} -A "Debian Live" -p "Debian Live; http://debian-live.alioth.debian.org/; debian-live-devel@lists.alioth.debian.org" -publisher "Debian Live; http://debian-live.alioth.debian.org/; debian-live-devel@lists.alioth.debian.org" -o "${LIVE_ROOT}"/"${LIVE_IMAGE}"source.iso -r -J -l -V "${LIVE_DISK_VOLUME}" "${LIVE_ROOT}"/source + ;; + + net) + # Create tarball + tar cfz source.tar.gz "${LIVE_ROOT}"/source + ;; + + usb) + # Create image + DU_DIM="`du -ms ${LIVE_ROOT}/source | cut -f1`" + REAL_DIM="`expr ${DU_DIM} + ${DU_DIM} / 20`" # Just 5% more to be sure, need something more sophistcated here... + dd if=/dev/zero of="${LIVE_ROOT}"/source.img bs=1024k count=${REAL_DIM} + FREELO=`losetup -f` + + echo "!!! The following error/warning messages can be ignored !!!" + lh_losetup $FREELO "${LIVE_ROOT}"/source.img 0 + set +e + lh_chroot "parted -s ${FREELO} mklabel msdos" + lh_chroot "parted -s ${FREELO} mkpartfs primary fat16 0.0 100%" + lh_chroot "parted -s ${FREELO} set 1 lba off" + set -e + losetup -d ${FREELO} + + lh_losetup $FREELO "${LIVE_ROOT}"/source.img 1 + lh_chroot "mkfs.msdos -n DEBIAN_LIVE ${FREELO}" + mkdir "${LIVE_ROOT}"/source.tmp + mount ${FREELO} "${LIVE_ROOT}"/source.tmp + cp -r "${LIVE_ROOT}"/source/* "${LIVE_ROOT}"/source.tmp + umount "${LIVE_ROOT}"/source.tmp + rmdir "${LIVE_ROOT}"/source.tmp + losetup -d ${FREELO} + echo "!!! The above error/warning messages can be ignored !!!" + ;; + esac + + + # Deconfigure network + lh_patchnetwork deapply + + # Touching stage file + touch "${LIVE_ROOT}"/.stage/image_source +fi diff --git a/helpers/lh_cdebootstrap b/helpers/lh_cdebootstrap new file mode 100755 index 0000000..c1f0d7a --- /dev/null +++ b/helpers/lh_cdebootstrap @@ -0,0 +1,33 @@ +#!/bin/sh + +if [ ! -f "${LIVE_ROOT}"/.stage/bootstrap ] +then + # Create chroot directory + if [ ! -d "${LIVE_CHROOT}" ] + then + mkdir -p "${LIVE_CHROOT}" + fi + + if [ -n "${LIVE_BOOTSTRAP_CONFIG}" ]; then + SUITE_CONFIG="--suite-config ${LIVE_BOOTSTRAP_CONFIG}" + fi + + # Bootstrap system + if [ "${LIVE_FLAVOUR}" = "mini" ] + then + cdebootstrap --arch="${LIVE_ARCHITECTURE}" --flavour=minimal ${SUITE_CONFIG} "${LIVE_DISTRIBUTION}" "${LIVE_CHROOT}" "${LIVE_MIRROR}" + else + cdebootstrap --arch="${LIVE_ARCHITECTURE}" --flavour="${LIVE_FLAVOUR}" ${SUITE_CONFIG} "${LIVE_DISTRIBUTION}" "${LIVE_CHROOT}" "${LIVE_MIRROR}" + fi + + # Remove package cache + rm -rf "${LIVE_CHROOT}"/var/cache/bootstrap + + # Touching stage file + if [ ! -d "${LIVE_ROOT}"/.stage ] + then + mkdir "${LIVE_ROOT}"/.stage + fi + + touch "${LIVE_ROOT}"/.stage/bootstrap +fi diff --git a/helpers/lh_chroot b/helpers/lh_chroot new file mode 100755 index 0000000..511cdca --- /dev/null +++ b/helpers/lh_chroot @@ -0,0 +1,6 @@ +#!/bin/sh + +# lh_chroot.sh <command> + +# Execute commands chrooted +chroot "${LIVE_CHROOT}" /usr/bin/env -i HOME="/root" PATH="/usr/sbin:/usr/bin:/sbin:/bin" TERM="${TERM}" ftp_proxy="${LIVE_PROXY_FTP}" http_proxy="${LIVE_PPROXY_HTTP}" DEBIAN_FRONTEND="${LIVE_DEBCONF_FRONTEND}" DEBIAN_PRIORITY="${LIVE_DEBCONF_PRIORITY}" ${1} diff --git a/helpers/lh_cleanapt b/helpers/lh_cleanapt new file mode 100755 index 0000000..ec28865 --- /dev/null +++ b/helpers/lh_cleanapt @@ -0,0 +1,17 @@ +#!/bin/sh + +# lh_cleanapt + +# Clean apt packages cache +rm -rf "${LIVE_CHROOT}"/var/cache/apt +mkdir -p "${LIVE_CHROOT}"/var/cache/apt/archives/partial + +# Clean apt list cache +rm -rf "${LIVE_CHROOT}"/var/lib/apt/lists/* +mkdir -p "${LIVE_CHROOT}"/var/lib/apt/lists/partial + +# Remove old files +rm -f "${LIVE_CHROOT}"/var/lib/dpkg/available-old +rm -f "${LIVE_CHROOT}"/var/lib/dpkg/diversions-old +rm -f "${LIVE_CHROOT}"/var/lib/dpkg/statoverride-old +rm -f "${LIVE_CHROOT}"/var/lib/dpkg/status-old diff --git a/helpers/lh_clone b/helpers/lh_clone new file mode 100755 index 0000000..d89eba4 --- /dev/null +++ b/helpers/lh_clone @@ -0,0 +1,25 @@ +#!/bin/sh + +# lh_clone + +# Cloning existing system configuration +if [ -d "${LIVE_CLONE}" ] +then + # Swapping chroot directories + LIVE_CHROOT_TMP="${LIVE_CHROOT}" + LIVE_CHROOT="${LIVE_CLONE}" + + # Extract debconf settings + lh_chroot "aptitude install --assume-yes debconf-utils" + lh_chroot "debconf-get-selections" > "${LIVE_ROOT}"/preseed.cloned + + # Extract package selection + lh_chroot "dpkg --get-selections" | grep -v deinstall | cut -f1 > "${LIVE_ROOT}"/package-list.cloned + + # Restoring chroot directories + LIVE_CHROOT="${LIVE_CHROOT_TMP}" + LIVE_CHROOT_TMP="" + + LIVE_PRESEED="${LIVE_ROOT}/preseed.cloned" + LIVE_PACKAGE_LIST_CLONED="${LIVE_ROOT}/package-list.cloned" +fi diff --git a/helpers/lh_config b/helpers/lh_config new file mode 100755 index 0000000..a664988 --- /dev/null +++ b/helpers/lh_config @@ -0,0 +1,26 @@ +#!/bin/sh + +# lh_config + +case "${1}" in + disable-daemons) + if [ "${LIVE_DAEMONS}" = "no" ] + then + # Disable all + for FILE in "${LIVE_CHROOT}"/etc/init.d/* + do + lh_chroot "update-rc.d -f `basename ${FILE}` remove" + done + + # Re-enable all required (taken from -f standard chroot) + for PACKAGE in casper console-common cron dpkg ifupdown initscripts kbd klogd libc6 libdevmapper1.02 libselinux1 libsepol1 login makedev module-init-tools netbase openbsd-inetd procps sudo sysklogd udev util-linux + do + # Re-configure if existing + if [ -f "${LIVE_CHROOT}"/var/lib/dpkg/info/${PACKAGE}.postinst ] + then + lh_chroot "/var/lib/dpkg/info/${PACKAGE}.postinst configure" + fi + done + fi + ;; +esac diff --git a/helpers/lh_configapt b/helpers/lh_configapt new file mode 100755 index 0000000..81ff23a --- /dev/null +++ b/helpers/lh_configapt @@ -0,0 +1,51 @@ +#!/bin/sh + +# lh_configapt.sh <action> + +case "${1}" in + apply-proxy) + # Configure ftp proxy + if [ -n "${LIVE_PROXY_FTP}" ] + then + echo "Acquire::ftp::Proxy \"${LIVE_PROXY_FTP}\";" > "${LIVE_CHROOT}"/etc/apt/apt.conf.d/00make-live_ftp-proxy.conf + fi + + # Configure http proxy + if [ -n "${LIVE_PROXY_HTTP}" ] + then + echo "Acquire::http::Proxy \"${LIVE_PROXY_HTTP}\";" > "${LIVE_CHROOT}"/etc/apt/apt.conf.d/00make-live_http-proxy.conf + fi + ;; + + apply-recommends) + # Configure recommends + if [ "${LIVE_RECOMMENDS}" = "yes" ] + then + echo "Aptitude::Recommends-Important \"true\";" > "${LIVE_CHROOT}"/etc/apt/apt.conf.d/00make-live_recommends.conf + else + echo "Aptitude::Recommends-Important \"false\";" > "${LIVE_CHROOT}"/etc/apt/apt.conf.d/00make-live_recommends.conf + fi + ;; + + deapply-proxy) + # Deconfigure ftp proxy + if [ -f "${LIVE_CHROOT}"/etc/apt/apt.conf.d/00make-live_ftp-proxy.conf ] + then + rm -f "${LIVE_CHROOT}"/etc/apt/apt.conf.d/00make-live_ftp-proxy.conf + fi + + # Deconfigure http proxy + if [ -f "${LIVE_CHROOT}"/etc/apt/apt.conf.d/00make-live_http-proxy.conf ] + then + rm -f "${LIVE_CHROOT}"/etc/apt/apt.conf.d/00make-live_http-proxy.conf + fi + ;; + + deapply-recommends) + # Deconfigure recommends + if [ -f "${LIVE_CHROOT}"/etc/apt/apt.conf.d/00make-live_recommends.conf ] + then + rm -f "${LIVE_CHROOT}"/etc/apt/apt.conf.d/00make-live_recommends.conf + fi + ;; +esac diff --git a/helpers/lh_confignetwork b/helpers/lh_confignetwork new file mode 100755 index 0000000..892020d --- /dev/null +++ b/helpers/lh_confignetwork @@ -0,0 +1,60 @@ +#!/bin/sh + +# lh_patchnetwork.sh <action> + +# Packages which are manually installed inside the chroot are installed +# from the network. Therefore, we need to be able to resolv hosts. + +case "${1}" in + apply-hosts) + # Save host lookup table + if [ -f "${LIVE_CHROOT}"/etc/hosts ] + then + cp "${LIVE_CHROOT}"/etc/hosts \ + "${LIVE_CHROOT}"/etc/hosts.orig + fi + + # Copy host lookup table + if [ -f /etc/hosts ] + then + cp /etc/hosts "${LIVE_CHROOT}"/etc/hosts + fi + ;; + + apply-resolv) + # Save resolver configuration + if [ -f "${LIVE_CHROOT}"/etc/resolv.conf ] + then + cp "${LIVE_CHROOT}"/etc/resolv.conf \ + "${LIVE_CHROOT}"/etc/resolv.conf.orig + fi + + # Copy resolver configuration + if [ -f /etc/resolv.conf ] + then + cp /etc/resolv.conf "${LIVE_CHROOT}"/etc/resolv.conf + fi + ;; + + deapply-hosts) + # Restore host lookup table + if [ -f "${LIVE_CHROOT}"/etc/hosts.orig ] + then + mv "${LIVE_CHROOT}"/etc/hosts.orig \ + "${LIVE_CHROOT}"/etc/hosts + else + rm -f "${LIVE_CHROOT}"/etc/hosts + fi + ;; + + deapply-resolv) + # Restore resolver configuration + if [ -f "${LIVE_CHROOT}"/etc/resolv.conf.orig ] + then + mv "${LIVE_CHROOT}"/etc/resolv.conf.orig \ + "${LIVE_CHROOT}"/etc/resolv.conf + else + rm -f "${LIVE_CHROOT}"/etc/resolv.conf + fi + ;; +esac diff --git a/helpers/lh_debootstrap b/helpers/lh_debootstrap new file mode 100755 index 0000000..738179b --- /dev/null +++ b/helpers/lh_debootstrap @@ -0,0 +1,20 @@ +#!/bin/sh + +if [ ! -f "${LIVE_ROOT}"/.stage/bootstrap ] +then + # Create chroot directory + if [ ! -d "${LIVE_CHROOT}" ] + then + mkdir -p "${LIVE_CHROOT}" + fi + + debootstrap --arch="${LIVE_ARCHITECTURE}" --variant=buildd "${LIVE_DISTRIBUTION}" "${LIVE_CHROOT}" "${LIVE_MIRROR}" + + # Touching stage file + if [ ! -d "${LIVE_ROOT}"/.stage ] + then + mkdir "${LIVE_ROOT}"/.stage + fi + + touch "${LIVE_ROOT}"/.stage/bootstrap +fi diff --git a/helpers/lh_depends b/helpers/lh_depends new file mode 100755 index 0000000..1cb1f52 --- /dev/null +++ b/helpers/lh_depends @@ -0,0 +1,86 @@ +#!/bin/sh + +# lh_depends.sh <action> <type> + +case "${1}" in + install) + if [ -z "${KEEP_MEMTEST86}" ] + then + if [ "${LIVE_ARCHITECTURE}" = "amd64" ] || [ "${LIVE_ARCHITECTURE}" = "i386" ] + then + lh_chroot "aptitude install --assume-yes memtest86+" + fi + fi + + if [ -z "${KEEP_SYSLINUX}" ] + then + lh_chroot "aptitude install --assume-yes syslinux" + fi + + case "${2}" in + usb) + if [ -z "${KEEP_DOSFSTOOLS}" ] + then + lh_chroot "aptitude install --assume-yes dosfstools" + fi + + if [ -z "${KEEP_MTOOLS}" ] + then + lh_chroot "aptitude install --assume-yes mtools" + fi + + if [ -z "${KEEP_PARTED}" ] + then + lh_chroot "aptitude install --assume-yes parted" + fi + ;; + esac + ;; + + remove) + if [ -z "${KEEP_MEMTEST86}" ] + then + if [ "${LIVE_ARCHITECTURE}" = "amd64" ] || [ "${LIVE_ARCHITECTURE}" = "i386" ] + then + lh_chroot "aptitude purge --assume-yes memtest86+" + fi + fi + + if [ -z "${KEEP_SYSLINUX}" ] + then + lh_chroot "aptitude purge --assume-yes syslinux" + fi + + case "${2}" in + usb) + if [ -z "${KEEP_DOSFSTOOLS}" ] + then + lh_chroot "aptitude purge --assume-yes dosfstools" + fi + + if [ -z "${KEEP_MEMTEST86}" ] + then + if [ "${LIVE_ARCHITECTURE}" = "amd64" ] || [ "${LIVE_ARCHITECTURE}" = "i386" ] + then + lh_chroot "aptitude purge --assume-yes memtest86+" + fi + fi + + if [ -z "${KEEP_MTOOLS}" ] + then + lh_chroot "aptitude purge --assume-yes mtools" + fi + + if [ -z "${KEEP_PARTED}" ] + then + lh_chroot "aptitude purge --assume-yes parted" + fi + + if [ -z "${KEEP_SYSLINUX}" ] + then + lh_chroot "aptitude purge --assume-yes syslinux" + fi + ;; + esac + ;; +esac diff --git a/helpers/lh_genrootfs b/helpers/lh_genrootfs new file mode 100755 index 0000000..9ba4b31 --- /dev/null +++ b/helpers/lh_genrootfs @@ -0,0 +1,71 @@ +#!/bin/sh + +# lh_genrootfs.sh <filesystem> + +case "${LIVE_FILESYSTEM}" in + ext2) + DU_DIM="`du -ks ${LIVE_CHROOT} | cut -f1`" + REAL_DIM="`expr ${DU_DIM} + ${DU_DIM} / 20`" # Just 5% more to be sure, need something more sophistcated here... + + if [ -z "${LIVE_ENCRYPTION}" ] + then + genext2fs --size-in-blocks=${REAL_DIM} --reserved-blocks=0 --root="${LIVE_CHROOT}" "${LIVE_ROOT}"/binary/casper/filesystem.ext2 + else + echo "Encrypting ${LIVE_ROOT}/binary/casper/filesystem.ext2 with ${LIVE_ENCRYPTION}..." + + while true + do + genext2fs --size-in-blocks=${REAL_DIM} --reserved-blocks=0 --root="${LIVE_CHROOT}" | aespipe -e "${LIVE_ENCRYPTION}" -T > "${LIVE_ROOT}"/binary/casper/filesystem.ext2 && break + + echo -n "Something went wrong... Retry? [YES/no] " + read ANSWER + + if [ 'no' = "${ANSWER}" ] + then + unset ANSWER + break + fi + done + fi + ;; + + plain) + if [ -n "${LIVE_ENCRYPTION}" ] + then + echo "Error: encryption is not supported for filesystem type 'plain'" + exit 1 + fi + + cd "${LIVE_CHROOT}" + find . | cpio -pumd "${LIVE_ROOT}"/binary/casper/filesystem.dir + cd "${OLDPWD}" + ;; + + squashfs) + if [ -f "${LIVE_ROOT}"/binary/casper/filesystem.squashfs ] + then + rm "${LIVE_ROOT}"/binary/casper/filesystem.squashfs + fi + + mksquashfs "${LIVE_CHROOT}" "${LIVE_ROOT}"/binary/casper/filesystem.squashfs + + if [ -n "$LIVE_ENCRYPTION" ] + then + echo "Encrypting ${LIVE_ROOT}/binary/casper/filesystem.squashfs with ${LIVE_ENCRYPTION}..." + + while true + do + cat "${LIVE_ROOT}"/binary/casper/filesystem.squashfs | aespipe -e "${LIVE_ENCRYPTION}" -T > "${LIVE_ROOT}"/binary/casper/filesystem.squashfs.encrypted && mv "${LIVE_ROOT}"/binary/casper/filesystem.squashfs.encrypted "${LIVE_ROOT}"/binary/casper/filesystem.squashfs && break + + echo -n "Something went wrong... Retry? [YES/no] " + read ANSWER + + if [ 'no' = "${ANSWER}" ] + then + unset ANSWER + break + fi + done + fi + ;; +esac diff --git a/helpers/lh_hook b/helpers/lh_hook new file mode 100755 index 0000000..084a385 --- /dev/null +++ b/helpers/lh_hook @@ -0,0 +1,21 @@ +#!/bin/sh + +# lh_hook + +# Process flavour specific hooks +if [ -r "${BASE}"/hooks/"${LIVE_FLAVOUR}" ] +then + grep -v "^#" "${BASE}"/hooks/"${LIVE_FLAVOUR}" > "${LIVE_CHROOT}"/root/"${LIVE_FLAVOUR}" + LIVE_DEBCONF_FRONTEND="readline" LIVE_DEBCONF_PRIORITY="low" lh_chroot "sh /root/${LIVE_FLAVOUR}" + rm -f "${LIVE_CHROOT}"/root/"${LIVE_FLAVOUR}" +fi + +# Execute extra command in the chroot +if [ -r "${LIVE_HOOK}" ] +then + # FIXME + LIVE_DEBCONF_FRONTEND="readline" LIVE_DEBCONF_PRIORITY="low" lh_chroot "`cat ${LIVE_HOOK}`" +elif [ -n "${LIVE_HOOK}" ] +then + LIVE_DEBCONF_FRONTEND="readline" LIVE_DEBCONF_PRIORITY="low" lh_chroot "${LIVE_HOOK}" +fi diff --git a/helpers/lh_includechroot b/helpers/lh_includechroot new file mode 100755 index 0000000..eedd31d --- /dev/null +++ b/helpers/lh_includechroot @@ -0,0 +1,11 @@ +#!/bin/sh + +# lh_includechroot + +# Copy external directory into the chroot +if [ -d "${LIVE_INCLUDE_CHROOT}" ] +then + cd "${LIVE_INCLUDE_CHROOT}" + find . | cpio -pumd "${LIVE_CHROOT}" + cd "${OLDPWD}" +fi diff --git a/helpers/lh_installapt b/helpers/lh_installapt new file mode 100755 index 0000000..5324402 --- /dev/null +++ b/helpers/lh_installapt @@ -0,0 +1,32 @@ +#!/bin/sh + +# lh_installapt + +# Install aptitude +lh_chroot "apt-get install --yes --force-yes aptitude" + +# Install secure apt +if [ "${LIVE_DISTRIBUTION}" = "unstable" ] || [ "${LIVE_DISTRIBUTION}" = "${CODENAME_UNSTABLE}" ] || \ +[ "${LIVE_DISTRIBUTION}" = "testing" ] || [ "${LIVE_DISTRIBUTION}" = "${CODENAME_TESTING}" ] +then + if [ "${LIVE_FLAVOUR}" != "minimal" ] || [ "${LIVE_FLAVOUR}" != "mini" ] + then + lh_chroot "apt-get install --yes --force-yes ${LIVE_REPOSITORY_KEYRING}" + + for NAME in ${LIVE_REPOSITORIES} + do + eval REPOSITORY_KEY="$`echo LIVE_REPOSITORY_KEY_$NAME`" + eval REPOSITORY_KEYRING="$`echo LIVE_REPOSITORY_KEYRING_$NAME`" + + if [ -n "${REPOSITORY_KEYRING}" ] + then + lh_chroot "aptiude install ${REPOSITORY_KEYRING}" + elif [ -n "${REPOSITORY_KEY}" ] + then + lh_chroot "wget ${REPOSITORY_KEY}" + lh_chroot "apt-key add `basename ${REPOSITORY_KEY}`" + lh_chroot "rm -f `basename ${REPOSITORY_KEY}`" + fi + done + fi +fi diff --git a/helpers/lh_installlinux b/helpers/lh_installlinux new file mode 100755 index 0000000..40897d8 --- /dev/null +++ b/helpers/lh_installlinux @@ -0,0 +1,32 @@ +#!/bin/sh + +# lh_installinux <type> + +# Removing initrd backup files +rm -f "${LIVE_CHROOT}"/boot/initrd*bak* + +# Setting destination directory +case "${1}" in + iso) + DESTDIR="${LIVE_ROOT}/binary/isolinux" + ;; + + net) + DESTDIR="${LIVE_ROOT}/tftpboot" + ;; + + usb) + DESTDIR="${LIVE_ROOT}/binary" + ;; +esac + +# Installing linux image +if [ "${LIVE_FLAVOUR}" = "minimal" ] || [ "${LIVE_FLAVOUR}" = "mini" ] +then + mv "${LIVE_CHROOT}"/boot/vmlinuz* "${DESTDIR}"/vmlinuz + mv "${LIVE_CHROOT}"/boot/initrd.img* "${DESTDIR}"/initrd.gz + rm -f "${LIVE_CHROOT}"/vmlinuz "${LIVE_CHROOT}"/initrd.img +else + cp "${LIVE_CHROOT}"/boot/vmlinuz* "${DESTDIR}"/vmlinuz + cp "${LIVE_CHROOT}"/boot/initrd.img* "${DESTDIR}"/initrd.gz +fi diff --git a/helpers/lh_installmemtest86+ b/helpers/lh_installmemtest86+ new file mode 100755 index 0000000..b35b26a --- /dev/null +++ b/helpers/lh_installmemtest86+ @@ -0,0 +1,24 @@ +#!/bin/sh + +# lh_installmemtest86+.sh <type> + +# Setting destination directory +case "${1}" in + iso) + DESTDIR="${LIVE_ROOT}/binary/isolinux" + ;; + + net) + DESTDIR="${LIVE_ROOT}/tftpboot" + ;; + + usb) + DESTDIR="${LIVE_ROOT}/binary" + ;; +esac + +# Installing memtest86+ +if [ "${LIVE_ARCHITECTURE}" = "amd64" ] || [ "${LIVE_ARCHITECTURE}" = "i386" ] +then + cp "${LIVE_ROOT}"/chroot/boot/memtest86+.bin "${DESTDIR}"/memtest +fi diff --git a/helpers/lh_installpackagelists b/helpers/lh_installpackagelists new file mode 100755 index 0000000..71ba2fa --- /dev/null +++ b/helpers/lh_installpackagelists @@ -0,0 +1,29 @@ +#!/bin/sh + +# lh_installpackagelists + +# Install packages list +if [ -n "${LIVE_PACKAGE_LIST}" ] +then + if [ "${LIVE_PACKAGE_LIST}" = "everything" ] + then + #for FILE in "${LIVE_CHROOT}"/var/lib/apt/lists/*_Packages + #do + # awk '/Package: / { print $2 }' "${FILE}" | grep -v ".*-dbg$" >> "${LIVE_CHROOT}"/root/everything + #done + + #lh_chroot "xargs --arg-file=/root/everything aptitude install --assume-yes" + #rm -f "${LIVE_CHROOT}"/root/everything + + # FIXME + + for SECTION in admin base comm devel doc editors electronics embedded games gnome graphics hamradio interpreters kde libs libdevel mail math misc net news oldlibs otherosfs perl python science shells sound tex text utils web x11 + do + lh_chroot "aptitude install --assume-yes ~s${SECTION}" + done + else + grep -v "^#" "${LIVE_PACKAGE_LIST}" > "${LIVE_CHROOT}"/root/"`basename ${LIVE_PACKAGE_LIST}`" + lh_chroot "xargs --arg-file=/root/`basename ${LIVE_PACKAGE_LIST}` aptitude install --assume-yes" + rm -f "${LIVE_CHROOT}"/root/"`basename ${LIVE_PACKAGE_LIST}`" + fi +fi diff --git a/helpers/lh_installpackages b/helpers/lh_installpackages new file mode 100755 index 0000000..4cce341 --- /dev/null +++ b/helpers/lh_installpackages @@ -0,0 +1,9 @@ +#!/bin/sh + +# lh_installpackages + +# Install extra packages +if [ -n "${LIVE_PACKAGES}" ] +then + lh_chroot "aptitude install --assume-yes ${LIVE_PACKAGES}" +fi diff --git a/helpers/lh_installsyslinux b/helpers/lh_installsyslinux new file mode 100755 index 0000000..76a7ad7 --- /dev/null +++ b/helpers/lh_installsyslinux @@ -0,0 +1,79 @@ +#!/bin/sh + +# lh_installsyslinux.sh <type> + +if [ "${LIVE_ARCHITECTURE}" = "amd64" ] || [ "${LIVE_ARCHITECTURE}" = "i386" ] +then + if [ -n "${LIVE_ENCRYPTION}" ] + then + LIVE_BOOTAPPEND="${LIVE_BOOTAPPEND} live-media-encryption=${LIVE_ENCRYPTION}" + fi + + case "${1}" in + iso) + # Copy syslinux + mkdir -p "${LIVE_ROOT}"/binary/isolinux + cp "${LIVE_CHROOT}"/usr/lib/syslinux/isolinux.bin "${LIVE_ROOT}"/binary/isolinux + cp -r "${LIVE_TEMPLATES}"/syslinux/* "${LIVE_ROOT}"/binary/isolinux + + # Copy splash screen + if [ -n "${LIVE_ISOLINUX_SPLASH}" ]; then + cp "${LIVE_ISOLINUX_SPLASH}" "${LIVE_ROOT}/binary/isolinux/splash.rle" + fi + + # Configure syslinux templates + sed -i -e "s#LIVE_BOOTAPPEND#${LIVE_BOOTAPPEND}#" "${LIVE_ROOT}"/binary/isolinux/isolinux.cfg + sed -i -e "s/LIVE_DATE/`date +%Y%m%d`/" "${LIVE_ROOT}"/binary/isolinux/f1.txt + sed -i -e "s/LIVE_VERSION/${VERSION}/" "${LIVE_ROOT}"/binary/isolinux/f10.txt + + # Remove unused files + rm -f "${LIVE_ROOT}"/binary/isolinux/pxelinux.cfg + ;; + + net) + # Copy syslinux + mkdir -p "${LIVE_ROOT}"/tftpboot + cp "${LIVE_ROOT}"/chroot/usr/lib/syslinux/pxelinux.0 "${LIVE_ROOT}"/tftpboot + + # Install syslinux templates + mkdir -p "${LIVE_ROOT}"/tftpboot/pxelinux.cfg + cp -r "${LIVE_TEMPLATES}"/syslinux/* "${LIVE_ROOT}"/tftpboot/pxelinux.cfg + mv "${LIVE_ROOT}"/tftpboot/pxelinux.cfg/pxelinux.cfg "${LIVE_ROOT}"/tftpboot/pxelinux.cfg/default + sed -i -e 's#splash.rle#pxelinux.cfg/splash.rle#' "${LIVE_ROOT}"/tftpboot/pxelinux.cfg/isolinux.txt + + # Copy splash screen + if [ -n "${LIVE_ISOLINUX_SPLASH}" ]; then + cp "${LIVE_ISOLINUX_SPLASH}" "${LIVE_ROOT}/tftpboot/pxelinux.cfg/splash.rle" + fi + + # Configure syslinux templates + sed -i -e "s/LIVE_SERVER_ADDRESS/${LIVE_SERVER_ADDRESS}/" -e "s#LIVE_SERVER_PATH#${LIVE_SERVER_PATH}#" -e "s#LIVE_BOOTAPPEND#${LIVE_BOOTAPPEND}#" "${LIVE_ROOT}"/tftpboot/pxelinux.cfg/default + sed -i -e "s/LIVE_DATE/`date +%Y%m%d`/" "${LIVE_ROOT}"/tftpboot/pxelinux.cfg/f1.txt + sed -i -e "s/LIVE_VERSION/${VERSION}/" "${LIVE_ROOT}"/tftpboot/pxelinux.cfg/f10.txt + + # Remove unused files + rm -f "${LIVE_ROOT}"/tftpboot/pxelinux.cfg/isolinux.cfg + ;; + + usb) + # Copy syslinux + mkdir -p "${LIVE_ROOT}"/binary + cp "${LIVE_CHROOT}"/usr/lib/syslinux/isolinux.bin "${LIVE_ROOT}"/binary/syslinux.bin + cp -r "${LIVE_TEMPLATES}"/syslinux/* "${LIVE_ROOT}"/binary + mv "${LIVE_ROOT}"/binary/isolinux.cfg "${LIVE_ROOT}"/binary/syslinux.cfg + + # Copy splash screen + if [ -n "${LIVE_ISOLINUX_SPLASH}" ]; then + cp "${LIVE_ISOLINUX_SPLASH}" "${LIVE_ROOT}/binary/splash.rle" + fi + + # Configure syslinux templates + sed -i -e "s#LIVE_BOOTAPPEND#${LIVE_BOOTAPPEND}#" "${LIVE_ROOT}"/binary/syslinux.cfg + sed -i -e "s/LIVE_DATE/`date +%Y%m%d`/" "${LIVE_ROOT}"/binary/f1.txt + sed -i -e "s/LIVE_VERSION/${VERSION}/" "${LIVE_ROOT}"/binary/f10.txt + + # Remove unused files + rm -f "${LIVE_ROOT}"/binary/isolinux/pxelinux.cfg + ;; + esac +fi diff --git a/helpers/lh_installtasks b/helpers/lh_installtasks new file mode 100755 index 0000000..0a21a4a --- /dev/null +++ b/helpers/lh_installtasks @@ -0,0 +1,12 @@ +#!/bin/sh + +# lh_installtasks + +# Install aptitude tasks +if [ -n "${LIVE_TASKS}" ] +then + for TASK in ${LIVE_TASKS} + do + lh_chroot "aptitude install --assume-yes ${TASK}" + done +fi diff --git a/helpers/lh_localdeb b/helpers/lh_localdeb new file mode 100755 index 0000000..0fe71aa --- /dev/null +++ b/helpers/lh_localdeb @@ -0,0 +1,10 @@ +#!/bin/sh + +# lh_localdeb + +if [ `ls "${LIVE_ROOT}"/localdeb/*.deb` ] +then + cp "${LIVE_ROOT}"/localdeb/*.deb "${LIVE_CHROOT}"/root + lh_chroot "dpkg -i /root/*.deb" + rm -f "${LIVE_CHROOT}"/root/*.deb +fi diff --git a/helpers/lh_losetup b/helpers/lh_losetup new file mode 100755 index 0000000..e99f9e0 --- /dev/null +++ b/helpers/lh_losetup @@ -0,0 +1,25 @@ +#!/bin/sh + +# lh_losetup <device> <file> <partition> + +DEVICE="${1}" +FILE="${2}" +PARTITION="${3}" + +losetup "${DEVICE}" "${FILE}" +FDISK_OUT="`fdisk -l -u ${DEVICE} 2>&1`" +losetup -d "${DEVICE}" + +LOOPDEVICE="`echo ${DEVICE}p${PARTITION:=1}`" +CYL="`echo ${FDISK_OUT} | sed -ne "s_^${LOOPDEVICE}[ *]*\([0-9]*\).*_\1_p" `" +#OFFSET="`expr ${CYL}*512`" +OFFSET="$((CYL*512))" + +echo loop $DEVICE at offset $OFFSET + +if [ "${PARTITION}" = "0" ] +then + losetup "${DEVICE}" "${FILE}" +else + losetup -o "${OFFSET}" "${DEVICE}" "${FILE}" +fi diff --git a/helpers/lh_manifest b/helpers/lh_manifest new file mode 100755 index 0000000..9979552 --- /dev/null +++ b/helpers/lh_manifest @@ -0,0 +1,12 @@ +#!/bin/sh + +# lh_manifest + +# Add filesystem.manifest +lh_chroot "dpkg-query -W \*" | awk '$2 ~ /./ {print $1 " " $2 }' > "${LIVE_ROOT}"/filesystem.manifest + +if [ ! -z "${LIVE_MANIFEST}" ] +then + lh_chroot "aptitude install --assume-yes ${LIVE_MANIFEST}" + lh_chroot "dpkg-query -W \*" | awk '$2 ~ /./ {print $1 " " $2 }' > "${LIVE_ROOT}"/filesystem.manifest-desktop +fi diff --git a/helpers/lh_md5sums b/helpers/lh_md5sums new file mode 100755 index 0000000..8097e6c --- /dev/null +++ b/helpers/lh_md5sums @@ -0,0 +1,17 @@ +#!/bin/sh + +# lh_md5sums.sh + +# Calculating md5sums +cd "${LIVE_ROOT}"/binary +find . -type f -print0 | xargs -0 md5sum > "${LIVE_ROOT}"/md5sum.txt +cd "${OLDPWD}" + +if [ -d "${LIVE_INCLUDE_IMAGE}" ] +then + cd "${LIVE_INCLUDE_IMAGE}" + find . -type f -print0 | xargs -0 md5sum >> "${LIVE_ROOT}"/md5sum.txt + cd "${OLDPWD}" +fi + +mv "${LIVE_ROOT}"/md5sum.txt "${LIVE_ROOT}"/binary diff --git a/helpers/lh_patchchroot b/helpers/lh_patchchroot new file mode 100755 index 0000000..ae99997 --- /dev/null +++ b/helpers/lh_patchchroot @@ -0,0 +1,18 @@ +#!/bin/sh + +# lh_patchchroot.sh <action> + +# Some maintainer scripts can detect if they are in a chrooted system. +# Therefore, we create the needed file. + +case "${1}" in + apply) + # Create chroot file + echo "debian-live" > "${LIVE_CHROOT}"/etc/debian_chroot + ;; + + deapply) + # Remove chroot file + rm -f "${LIVE_CHROOT}"/etc/debian_chroot + ;; +esac diff --git a/helpers/lh_patchlinux b/helpers/lh_patchlinux new file mode 100755 index 0000000..7193f23 --- /dev/null +++ b/helpers/lh_patchlinux @@ -0,0 +1,32 @@ +#!/bin/sh + +# lh_patchlinux.sh <action> + +# The linux-image package asks interactively for initial ramdisk +# creation. Therefore, we preconfigure /etc/kernel-img.conf. +# FIXME: preseeding? + +case "${1}" in + apply) + # Save kernel configuration + if [ -f "${LIVE_CHROOT}"/etc/kernel-img.conf ] + then + cp "${LIVE_CHROOT}"/etc/kernel-img.conf \ + "${LIVE_CHROOT}"/etc/kernel-img.conf.old + fi + + # Configure kernel-img.conf + echo "do_initrd = Yes" >> "${LIVE_CHROOT}"/etc/kernel-img.conf + ;; + + deapply) + # Restore kernel configuration + if [ -f "${LIVE_CHROOT}"/etc/kernel-img.conf.old ] + then + mv "${LIVE_CHROOT}"/etc/kernel-img.conf.old \ + "${LIVE_CHROOT}"/etc/kernel-img.conf + else + rm -f "${LIVE_CHROOT}"/etc/kernel-img.conf + fi + ;; +esac diff --git a/helpers/lh_patchnetwork b/helpers/lh_patchnetwork new file mode 100755 index 0000000..9d0b4b0 --- /dev/null +++ b/helpers/lh_patchnetwork @@ -0,0 +1,18 @@ +#!/bin/sh + +# lh_patchnetwork.sh <action> + +# Packages which are manually installed inside the chroot are installed +# from the network. Therefore, we need to be able to resolv hosts. + +case "${1}" in + apply) + lh_confignetwork apply-hosts + lh_confignetwork apply-resolv + ;; + + deapply) + lh_confignetwork deapply-hosts + lh_confignetwork deapply-resolv + ;; +esac diff --git a/helpers/lh_patchrunlevel b/helpers/lh_patchrunlevel new file mode 100755 index 0000000..05fa9fb --- /dev/null +++ b/helpers/lh_patchrunlevel @@ -0,0 +1,27 @@ +#!/bin/sh + +# lh_patchrunlevel.sh <action> + +# Disabling all init scripts with a blocking policy as in +# /usr/share/doc/sysv-rc/README.policy-rc.d.gz. + +case "${1}" in + apply) + # Create init policy + cat > "${LIVE_CHROOT}"/usr/sbin/policy-rc.d << EOF +#!/bin/sh + +echo +echo "Warning: invoke-rc.d policy in action. Skiping daemon starting" + +exit 101 +EOF + + chmod 0755 "${LIVE_CHROOT}"/usr/sbin/policy-rc.d + ;; + + deapply) + # Removing init policy + rm -f "${LIVE_CHROOT}"/usr/sbin/policy-rc.d + ;; +esac diff --git a/helpers/lh_preseed b/helpers/lh_preseed new file mode 100755 index 0000000..bcad060 --- /dev/null +++ b/helpers/lh_preseed @@ -0,0 +1,23 @@ +#!/bin/sh + +# lh_preseed + +# Restore preseed configuration +if [ -f "${LIVE_PRESEED}" ] +then + lh_chroot "aptitude install --assume-yes debconf-utils" + cp "${LIVE_PRESEED}" "${LIVE_CHROOT}"/root/preseed + lh_chroot "debconf-set-selections /root/preseed" + rm -f "${LIVE_CHROOT}"/root/preseed +else + if [ -n "${LIVE_PRESEED}" ]; then + echo "'${LIVE_PRESEED}' file doesn't exists. Exiting..." + exit 1 + fi +fi + +# Restore cloned package selection +if [ -f "${LIVE_PACKAGE_LIST_CLONED}" ] +then + lh_chroot "xargs --arg-file=/root/`basename ${LIVE_PACKAGE_LIST_CLONED}` aptitude install --assume-yes" +fi diff --git a/helpers/lh_setupapt b/helpers/lh_setupapt new file mode 100755 index 0000000..37a3dbd --- /dev/null +++ b/helpers/lh_setupapt @@ -0,0 +1,124 @@ +#!/bin/sh + +case "${1}" in + custom) + # Configure custom sources.list + case "${LIVE_DISTRIBUTION}" in + stable|"${CODENAME_STABLE}"|testing|"${CODENAME_TESTING}") + echo "deb ${LIVE_MIRROR} ${LIVE_DISTRIBUTION} ${LIVE_SECTIONS}" > "${LIVE_CHROOT}"/etc/apt/sources.list + + if [ "${LIVE_SOURCE}" = "yes" ] + then + echo "deb-src ${LIVE_MIRROR} ${LIVE_DISTRIBUTION} ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list + fi + + echo "deb ${LIVE_MIRROR_SECURITY} ${LIVE_DISTRIBUTION}/updates ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list + + if [ "${LIVE_SOURCE}" = "yes" ] + then + echo "deb-src ${LIVE_MIRROR_SECURITY} ${LIVE_DISTRIBUTION}/updates ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list + fi + ;; + + unstable|"${CODENAME_UNSTABLE}") + echo "deb ${LIVE_MIRROR} unstable ${LIVE_SECTIONS}" > "${LIVE_CHROOT}"/etc/apt/sources.list + + if [ "${LIVE_SOURCE}" = "yes" ] + then + echo "deb-src ${LIVE_MIRROR} unstable ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list + fi + + if [ "${LIVE_DISTRIBUTION_EXPERIMENTAL}" = "yes" ] + then + echo "deb ${LIVE_MIRROR} experimental ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list + + if [ "${LIVE_SOURCE}" = "yes" ] + then + echo "deb-src ${LIVE_MIRROR} experimental ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list + fi + +cat > "${LIVE_CHROOT}"/etc/apt/preferences << EOF +Package: * +Pin: release a=experimental +Pin-Priority: 999 +EOF + fi + ;; + esac + ;; + + default) + # Configure default sources.list + case "${LIVE_DISTRIBUTION}" in + oldstable|"${CODENAME_OLDSTABLE}"|stable|"${CODENAME_STABLE}"|testing|"${CODENAME_TESTING}") + echo "deb http://ftp.debian.org/debian/ ${LIVE_DISTRIBUTION} ${LIVE_SECTIONS}" > "${LIVE_CHROOT}"/etc/apt/sources.list + + if [ "${LIVE_SOURCE}" = "yes" ] + then + echo "deb-src http://ftp.debian.org/debian/ ${LIVE_DISTRIBUTION} ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list + fi + + echo "deb http://security.debian.org/ ${LIVE_DISTRIBUTION}/updates ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list + + if [ "${LIVE_SOURCE}" = "yes" ] + then + echo "deb-src http://security.debian.org/ ${LIVE_DISTRIBUTION}/updates ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list + fi + ;; + + unstable|"${CODENAME_UNSTABLE}") + echo "deb http://ftp.debian.org/debian/ unstable ${LIVE_SECTIONS}" > "${LIVE_CHROOT}"/etc/apt/sources.list + + if [ "${LIVE_SOURCE}" = "yes" ] + then + echo "deb-src http://ftp.debian.org/debian/ unstable ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list + fi + + if [ "${LIVE_DISTRIBUTION_EXPERIMENTAL}" = "yes" ] + then + echo "deb http://ftp.debian.org/debian/ experimental ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list + + if [ "${LIVE_SOURCE}" = "yes" ] + then + echo "deb-src http://ftp.debian.org/debian/ experimental ${LIVE_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list + fi + fi + ;; + esac + ;; +esac + +# Add custom repositories +echo "" >> "${LIVE_CHROOT}"/etc/apt/sources.list +echo "# Custom repositories" >> "${LIVE_CHROOT}"/etc/apt/sources.list + +for NAME in ${LIVE_REPOSITORIES} +do + eval REPOSITORY="$`echo LIVE_REPOSITORY_$NAME`" + eval REPOSITORY_DISTRIBUTION="$`echo LIVE_REPOSITORY_DISTRIBUTION_$NAME`" + eval REPOSITORY_SECTIONS="$`echo LIVE_REPOSITORY_SECTIONS_$NAME`" + + # Configure /etc/apt/sources.list + if [ -n "${REPOSITORY_DISTRIBUTION}" ] + then + echo "deb ${REPOSITORY} ${REPOSITORY_DISTRIBUTION} ${REPOSITORY_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list + else + echo "deb ${REPOSITORY} ${LIVE_DISTRIBUTION} ${REPOSITORY_SECTIONS}" >> "${LIVE_CHROOT}"/etc/apt/sources.list + fi +done + +# Update indices +if [ "${2}" = "initial" ] +then + lh_chroot "apt-get update" +else + lh_chroot "aptitude update" +fi + +if [ "${LIVE_DISTRIBUTION_EXPERIMENTAL}" = "yes" ] +then + # experimental is sometimes broken, + # therefore this is intentionally kept interactive. + lh_chroot "aptitude upgrade" || return 0 + lh_chroot "aptitude dist-upgrade" || return 0 +fi diff --git a/helpers/lh_testroot b/helpers/lh_testroot new file mode 100755 index 0000000..6725850 --- /dev/null +++ b/helpers/lh_testroot @@ -0,0 +1,10 @@ +#!/bin/sh + +# lh_testroot.sh + +# Checking user account +if [ "`id -u`" -ne "0" ] +then + echo "E: need root privileges" + exit 1 +fi diff --git a/helpers/overview.txt b/helpers/overview.txt new file mode 100644 index 0000000..f84421f --- /dev/null +++ b/helpers/overview.txt @@ -0,0 +1,51 @@ +Overview +======== + +The basic concept is threefold: + + 1. Create a chroot + 2. Install additional packages + 3. Create images + +In detail: + +We start make-live, which handels configuration file, commandline paramters and defaults. Then, we start the helpers: + + * lh_testroot + + Tests if we are root, and fails if not. + + * lh_cdebootstrap + + Creates a bootstrap with cdebootstrap. + + * Configure chroot + * Configure policy-id + * Configure network + * Mount proc + * Configure sources.list + * Configure apt: proxy and recommends + * install aptitude + * install secure apt + * aptitude update + * Configure linux-image + * Install linux-image squashfs/unionfs + * Deconfigure linux-image + * CLONING/PRESEEDING + * Install tasks lists + * Install packages lists + * Install LIVE_PACKAGES + * Copy INCLUDE_ROOT + * Process hooks + * Save packages list + * Disable daemons + * Add manifest + * Clean apt cache + * Binfmt hack + * Unmount proc + * Deconfigure network + * Deconfigure chroot + * Check the chroot for depends + + build binary + build source |