diff options
Diffstat (limited to 'helpers/lh_buildsource')
-rwxr-xr-x | helpers/lh_buildsource | 84 |
1 files changed, 84 insertions, 0 deletions
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 |