summaryrefslogtreecommitdiff
path: root/cron/live-build-cron-images
diff options
context:
space:
mode:
authorDaniel Baumann <daniel@debian.org>2011-07-15 20:31:44 +0200
committerDaniel Baumann <daniel@debian.org>2011-07-15 20:38:39 +0200
commit7e4c34b6f2259425ed4258d8f36b55e6d468efdf (patch)
tree043237418591a3036d18eae06029d380586ef8bd /cron/live-build-cron-images
parente24497b72306d4519d8c2999c6b7c0dbec9166ef (diff)
downloadvyos-live-build-7e4c34b6f2259425ed4258d8f36b55e6d468efdf.tar.gz
vyos-live-build-7e4c34b6f2259425ed4258d8f36b55e6d468efdf.zip
Adding initial live-build-cron package.
Diffstat (limited to 'cron/live-build-cron-images')
-rwxr-xr-xcron/live-build-cron-images341
1 files changed, 341 insertions, 0 deletions
diff --git a/cron/live-build-cron-images b/cron/live-build-cron-images
new file mode 100755
index 000000000..6e89b77df
--- /dev/null
+++ b/cron/live-build-cron-images
@@ -0,0 +1,341 @@
+#!/bin/sh
+
+## live-build-cron-images(7) - FIXME
+## Copyright (C) 2006-2010 Daniel Baumann <daniel@debian.org>
+##
+## 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 <http://www.gnu.org/licenses/>.
+##
+## The complete text of the GNU General Public License
+## can be found in /usr/share/common-licenses/GPL-3 file.
+
+
+#set -e
+
+Init ()
+{
+ if [ -e /etc/live/build-cron.conf ]
+ then
+ . /etc/live/build-cron.conf
+ fi
+
+ if ls /etc/live/build-cron.d/* > /dev/null 2>&1
+ then
+ for _FILE in /etc/live/build-cron.d/*
+ do
+ . ${_FILE}
+ done
+ fi
+
+ if [ "${LIVE_BUILD_CRON_IMAGES}" != "true" ]
+ then
+ exit 0
+ fi
+
+ if [ -z "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}" ]
+ then
+ exit 1
+ fi
+
+ # FIXME: don't hardcode
+ BUILDS="daily"
+ DATE="$(date +%Y%m%d)"
+
+ ARCHITECTURE="$(dpkg --print-architecture)"
+ eval DISTRIBUTIONS="$`echo LIVE_BUILD_CRON_IMAGES_$(echo ${BUILDS} | tr [a-z] [A-Z])_DISTRIBUTIONS`"
+ eval FLAVOURS="$`echo LIVE_BUILD_CRON_IMAGES_$(echo ${BUILDS} | tr [a-z] [A-Z])_FLAVOURS`"
+}
+
+Setup ()
+{
+ TMPDIR="$(mktemp -d -t live-build-cron-images.XXXXXXXX)"
+
+ case "${LIVE_BUILD_CRON_IMAGES_BUILD}" in
+ git)
+ cd "${TMPDIR}"
+ git clone git://live.debian.net/git/live-build.git
+ git checkout debian-old-2.0
+
+ LB_BASE="${TMPDIR}/live-build"
+ export LB_BASE
+
+ PATH="${PATH}:${TMPDIR}/live-build/scripts/build"
+ export PATH
+ ;;
+
+ release)
+ # live-build
+ if [ -n "${LIVE_BUILD}" ]
+ then
+ if [ -x "$(which dget 2>/dev/null)" ]
+ then
+ dget "http://live.debian.net/archive/packages/live-build/${LIVE_BUILD}/live-build_${LIVE_BUILD}.dsc"
+ dpkg-source -x live-build_${LIVE_BUILD}.dsc
+
+ LB_BASE="${TMPDIR}/live-build-$(echo ${LIVE_BUILD} | awk -F- '{ print $1 }')"
+ export LB_BASE
+
+ PATH="${PATH}:${TMPDIR}/live-build-$(echo ${LIVE_BUILD} | awk -F- '{ print $1 }')/scripts/build"
+ export PATH
+ else
+ echo "E: dget - command not found"
+ echo "I: dget can be optained from: "
+ echo "I: http://git.debian.org/?p=devscripts/devscripts.git"
+ echo "I: On Debian based systems, dget can be installed with:"
+ echo "I: apt-get install devscripts"
+
+ exit 1
+ fi
+ fi
+ ;;
+ esac
+
+ mkdir -p "${TMPDIR}/build"
+ cd "${TMPDIR}/build"
+
+ # live-boot
+ if [ -n "${LIVE_BOOT}" ]
+ then
+ mkdir -p config/chroot_local-packages
+ cd config/chroot_local-packages
+
+ wget -c "http://live.debian.net/archive/packages/live-boot/${LIVE_BOOT}/live-boot_${LIVE_BOOT}.dsc"
+ wget -c "http://live.debian.net/archive/packages/live-boot/${LIVE_BOOT}/live-boot_${LIVE_BOOT}.diff.gz"
+ wget -c "http://live.debian.net/archive/packages/live-boot/${LIVE_BOOT}/live-boot_$(echo ${LIVE_BOOT} | awk -F- '{ print $1 }').orig.tar.gz"
+ wget -c "http://live.debian.net/archive/packages/live-boot/${LIVE_BOOT}/live-boot_${LIVE_BOOT}_all.deb"
+ wget -c "http://live.debian.net/archive/packages/live-boot/${LIVE_BOOT}/live-boot-initramfs-tools_${LIVE_BOOT}_all.deb"
+ wget -c "http://live.debian.net/archive/packages/live-boot/${LIVE_BOOT}/live-initramfs_${LIVE_BOOT}_all.deb"
+
+ cd "${OLDPWD}"
+ fi
+
+ # live-config
+ if [ -n "${LIVE_CONFIG}" ]
+ then
+ mkdir -p config/chroot_local-packages
+ cd config/chroot_local-packages
+
+ wget -c "http://live.debian.net/archive/packages/live-config/${LIVE_CONFIG}/live-config_${LIVE_CONFIG}.dsc"
+ wget -c "http://live.debian.net/archive/packages/live-config/${LIVE_CONFIG}/live-config_${LIVE_CONFIG}.diff.gz"
+ wget -c "http://live.debian.net/archive/packages/live-config/${LIVE_CONFIG}/live-config_$(echo ${LIVE_CONFIG} | awk -F- '{ print $1 }').orig.tar.gz"
+ wget -c "http://live.debian.net/archive/packages/live-config/${LIVE_CONFIG}/live-config_${LIVE_CONFIG}_all.deb"
+ wget -c "http://live.debian.net/archive/packages/live-config/${LIVE_CONFIG}/live-config-sysvinit_${LIVE_CONFIG}_all.deb"
+
+ cd "${OLDPWD}"
+ fi
+
+ # live-installer
+ if [ -n "${LIVE_INSTALLER}" ]
+ then
+ mkdir -p config/binary_local-udebs
+ cd config/binary_local-udebs
+
+ wget -c "http://ftp.debian.org/debian/pool/main/l/live-installer/live-installer_${LIVE_INSTALLER}.dsc"
+ wget -c "http://ftp.debian.org/debian/pool/main/l/live-installer/live-installer_${LIVE_INSTALLER}.tar.gz"
+ wget -c "http://ftp.debian.org/debian/pool/main/l/live-installer/live-installer_${LIVE_INSTALLER}_${ARCHITECTURE}.udeb"
+
+ cd "${OLDPWD}"
+ fi
+
+ # debian-installer-launcher
+ if [ -n "${DI_LAUNCHER}" ]
+ then
+ mkdir -p config/chroot_local-packages
+ cd config/chroot_local-packages
+
+ wget -c "http://ftp.debian.org/debian/pool/main/d/debian-installer-launcher/debian-installer-launcher_${DI_LAUNCHER}.dsc"
+ wget -c "http://ftp.debian.org/debian/pool/main/d/debian-installer-launcher/debian-installer-launcher_${DI_LAUNCHER}.tar.gz"
+ wget -c "http://ftp.debian.org/debian/pool/main/d/debian-installer-launcher/debian-installer-launcher_${DI_LAUNCHER}_all.deb"
+
+ cd "${OLDPWD}"
+ fi
+}
+
+Build ()
+{
+ cd "${TMPDIR}/build"
+
+ for DISTRIBUTION in ${DISTRIBUTIONS}
+ do
+ rm -rf cache/stages*
+
+ for FLAVOUR in ${FLAVOURS}
+ do
+ if [ -e .stage ]
+ then
+ lb clean
+ fi
+
+ rm -rf cache/stages_rootfs
+ rm -f config/* || true
+
+ # FIXME: cdebootstrap
+ lb config --clean \
+ --bootstrap cdebootstrap \
+ --cache-stages "bootstrap rootfs" \
+ --debian-installer ${DEBIAN_INSTALLER} \
+ --debian-installer-distribution ${DEBIAN_INSTALLER_DISTRIBUTION} \
+ --distribution ${DISTRIBUTION} \
+ --mirror-bootstrap ${MIRROR_BOOTSTRAP} \
+ --mirror-chroot ${MIRROR_CHROOT} \
+ --mirror-chroot-security ${MIRROR_CHROOT_SECURITY} \
+ --packages-lists ${FLAVOUR}
+
+ lb build 2>&1 | tee debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${FLAVOUR}.iso.log
+
+ mv binary*.iso debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${FLAVOUR}.iso
+ mv binary.list debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${FLAVOUR}.iso.list
+ mv binary.packages debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${FLAVOUR}.iso.packages
+
+ if [ "${ARCHITECTURE}" != "powerpc" ]
+ then
+ lb clean --binary
+ lb config --clean --binary-images usb-hdd
+ lb binary 2>&1 | tee debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${FLAVOUR}.img.log
+
+ mv binary.img debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${FLAVOUR}.img
+ mv binary.list debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${FLAVOUR}.img.list
+ mv binary.packages debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${FLAVOUR}.img.packages
+ fi
+
+ if [ "${ARCHITECTURE}" != "powerpc" ]
+ then
+ lb clean
+ rm -rf cache/stages_rootfs
+ lb config --clean --binary-images net
+
+ lb build 2>&1 | tee debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${FLAVOUR}.tar.gz.log
+
+ mv binary-net.tar.gz debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${FLAVOUR}.tar.gz
+ mv binary.list debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${FLAVOUR}.tar.gz.list
+ mv binary.packages debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${FLAVOUR}.tar.gz.packages
+
+ mv binary/*/filesystem.squashfs debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${FLAVOUR}.squashfs
+ for memtest in tftpboot/debian-live/${ARCHITECTURE}/memtest*; do cp -f ${memtest} debian-live-${DISTRIBUTION}-${ARCHITECTURE}.$(basename ${memtest}); done || true
+ for kernel in tftpboot/debian-live/${ARCHITECTURE}/vmlinuz*; do cp -f ${kernel} debian-live-${DISTRIBUTION}-${ARCHITECTURE}.$(basename ${kernel}); done
+ for initrd in tftpboot/debian-live/${ARCHITECTURE}/initrd*; do cp ${initrd} debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${FLAVOUR}.$(basename ${initrd}); done
+ cp debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${FLAVOUR}.tar.gz.packages debian-live-${DISTRIBUTION}-${ARCHITECTURE}-${FLAVOUR}.packages
+ fi
+
+ if [ "${LIVE_BUILD_CRON_IMAGES_SOURCE}" = "true" ]
+ then
+ lb config --clean --source true
+
+ lb source 2>&1 | tee debian-live-${DISTRIBUTION}-source-${FLAVOUR}.log
+
+ mv source.debian.tar.gz debian-live-${DISTRIBUTION}-source-${FLAVOUR}.debian.tar.gz
+ mv source.debian.list debian-live-${DISTRIBUTION}-source-${FLAVOUR}.debian.tar.gz.list
+ mv source.debian-live.tar.gz debian-live-${DISTRIBUTION}-source-${FLAVOUR}.debian-live.tar.gz
+ mv source.debian-live.list debian-live-${DISTRIBUTION}-source-${FLAVOUR}.debian-live.tar.gz.list
+ fi
+ done
+ done
+}
+
+Install ()
+{
+ BUILD="1"
+
+ while [ -e "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${DISTRIBUTION}/${DATE}-${BUILD}/${ARCHITECTURE}" ]
+ do
+ BUILD="$((${BUILD} + 1))"
+ done
+
+ cd "${TMPDIR}/build"
+
+ # Move iso images
+ if ls debian-live-${DISTRIBUTION}-${ARCHITECTURE}-*.iso* > /dev/null 2>&1
+ then
+ mkdir -p "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${DISTRIBUTION}/${DATE}-${BUILD}/${ARCHITECTURE}/iso-hybrid"
+ mv debian-live-${DISTRIBUTION}-${ARCHITECTURE}-*.iso* "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${DISTRIBUTION}/${DATE}-${BUILD}/${ARCHITECTURE}/iso-hybrid"
+ fi
+
+ # Move hdd images
+ if ls debian-live-${DISTRIBUTION}-${ARCHITECTURE}-*.img > /dev/null 2>&1
+ then
+ mkdir -p "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${DISTRIBUTION}/${DATE}-${BUILD}/${ARCHITECTURE}/usb-hdd"
+ mv debian-live-${DISTRIBUTION}-${ARCHITECTURE}-*.img* "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${DISTRIBUTION}/${DATE}-${BUILD}/${ARCHITECTURE}/usb-hdd"
+ fi
+
+ # Move net images
+ if ls debian-live-${DISTRIBUTION}-${ARCHITECTURE}-*.tar.gz* > /dev/null 2>&1
+ then
+ mkdir -p "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${DISTRIBUTION}/${DATE}-${BUILD}/${ARCHITECTURE}/net"
+ mv debian-live-${DISTRIBUTION}-${ARCHITECTURE}-*.tar.gz* "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${DISTRIBUTION}/${DATE}-${BUILD}/${ARCHITECTURE}/net"
+ fi
+
+ # Move web images
+ if ls debian-live-${DISTRIBUTION}-${ARCHITECTURE}-*.squashfs > /dev/null 2>&1
+ then
+ mkdir -p "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${DISTRIBUTION}/${DATE}-${BUILD}/${ARCHITECTURE}/web"
+ mv debian-live-${DISTRIBUTION}-${ARCHITECTURE}-*.squashfs "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${DISTRIBUTION}/${DATE}-${BUILD}/${ARCHITECTURE}/web"
+ mv debian-live-${DISTRIBUTION}-${ARCHITECTURE}-*.packages* "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${DISTRIBUTION}/${DATE}-${BUILD}/${ARCHITECTURE}/web"
+ mv debian-live-${DISTRIBUTION}-${ARCHITECTURE}-*.vmlinuz* "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${DISTRIBUTION}/${DATE}-${BUILD}/${ARCHITECTURE}/web"
+ mv debian-live-${DISTRIBUTION}-${ARCHITECTURE}-*.initrd.img* "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${DISTRIBUTION}/${DATE}-${BUILD}/${ARCHITECTURE}/web"
+ fi
+
+ # Move source images
+ if ls debian-live-${DISTRIBUTION}-source-* > /dev/null 2>&1 && \
+ [ ! -d "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${DISTRIBUTION}/${DATE}-${BUILD}/source" ]
+ then
+ mkdir -p "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${DISTRIBUTION}/${DATE}-${BUILD}/source/tar"
+ mv debian-live-${DISTRIBUTION}-source-* "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${DISTRIBUTION}/${DATE}-${BUILD}/source/tar"
+ fi
+
+ for DIR in "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${DISTRIBUTION}/${DATE}-${BUILD}/${ARCHITECTURE}"/* "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${DISTRIBUTION}/${DATE}-${BUILD}/source"/*
+ do
+ cd "${DIR}"
+
+ md5sum debian* > MD5SUMS
+ sha1sum debian* > SHA1SUMS
+ sha256sum debian* > SHA256SUMS
+ done
+
+ rm -f "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${DISTRIBUTION}/current"
+
+ cd "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${DISTRIBUTION}"
+ ln -s ${DATE}-${BUILD} current
+}
+
+Clean ()
+{
+ cd "${TMPDIR}/build"
+ lb clean --purge
+
+ cd "${CURDIR}"
+ rm -rf "${TMPDIR}"
+}
+
+Trace ()
+{
+
+cat > "${LIVE_BUILD_CRON_IMAGES_DIRECTORY}/${BUILDS}-builds/${BUILDS}-trace" << EOF
+${DATE}-${BUILD}
+$(LC_ALL=C date -R)
+EOF
+
+}
+
+Main ()
+{
+ Init
+ Setup
+
+ Build
+ Install
+ Clean
+
+ Trace
+}
+
+Main