diff options
author | Daniel Baumann <daniel@debian.org> | 2009-11-22 14:36:42 +0100 |
---|---|---|
committer | Daniel Baumann <daniel@debian.org> | 2009-11-22 14:38:00 +0100 |
commit | a62f12110b19a52a58d7eae871012202cfa16055 (patch) | |
tree | 0bd188079c808ee8956fb5304c46ce8266b49f75 /examples/cron | |
download | vyos-live-build-a62f12110b19a52a58d7eae871012202cfa16055.tar.gz vyos-live-build-a62f12110b19a52a58d7eae871012202cfa16055.zip |
Renaming categories to archive areas (Closes: #519690).
Diffstat (limited to 'examples/cron')
-rw-r--r-- | examples/cron/crontab | 8 | ||||
-rwxr-xr-x | examples/cron/images.sh | 111 | ||||
-rwxr-xr-x | examples/cron/manpages.sh | 100 | ||||
-rwxr-xr-x | examples/cron/snapshots.sh | 183 |
4 files changed, 402 insertions, 0 deletions
diff --git a/examples/cron/crontab b/examples/cron/crontab new file mode 100644 index 000000000..960f5e948 --- /dev/null +++ b/examples/cron/crontab @@ -0,0 +1,8 @@ +# /etc/crontab - system-wide crontab + +SHELL=/bin/sh +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin + +# m h dom mon dow user command +*/10 * * * * user /usr/share/doc/live-helper/examples/cron/manpages.sh > /dev/null 2>&1 +*/10 * * * * user /usr/share/doc/live-helper/examples/cron/snapshots.sh > /dev/null 2>&1 diff --git a/examples/cron/images.sh b/examples/cron/images.sh new file mode 100755 index 000000000..342f645eb --- /dev/null +++ b/examples/cron/images.sh @@ -0,0 +1,111 @@ +#!/bin/sh -e + +# Static variables +DISTRIBUTIONS="${DISTRIBUTIONS:-etch lenny sid}" +FLAVOURS="${FLAVOURS:-standard rescue gnome-desktop kde-desktop lxde-desktop xfce-desktop}" +SOURCE="${SOURCE:-enabled}" + +MIRROR="${MIRROR:-http://mirror/ftp.debian.org/debian/}" +MIRROR_SECURITY="${MIRROR_SECURITY:-http://mirror/ftp.debian.org/debian-security/}" + +# Dynamic variables +ARCHITECTURE="$(dpkg --print-architecture)" +DATE="$(date +%Y%m%d)" + +for DISTRIBUTION in ${DISTRIBUTIONS} +do + rm -rf cache/stages* + + for FLAVOUR in ${FLAVOURS} + do + mkdir -p config + + if [ -e .stage ] + then + lh clean + fi + + rm -rf config + rm -rf cache/packages* + rm -rf cache/stages_rootfs + + case "${ARCHITECTURE}" in + amd64) + case "${FLAVOUR}" in + gnome-desktop) + mkdir -p config/chroot_local-hooks + echo "apt-get remove --yes --purge openoffice.org-help-en-us" > config/chroot_local-hooks/package-removals + echo "apt-get remove --yes --purge epiphany-browser epiphany-browser-data epiphany-extensions epiphany-gecko" >> config/chroot_local-hooks/package-removals + echo "apt-get remove --yes --purge gnome-user-guide" >> config/chroot_local-hooks/package-removals + + INDICES="none" + ;; + + kde-desktop) + INDICES="none" + ;; + esac + ;; + + i386) + case "${FLAVOUR}" in + standard|rescue|lxde-desktop|xfce-desktop) + INDICES="enabled" + ;; + + gnome-desktop|kde-desktop) + KERNEL="-k 686" + INDICES="none" + ;; + esac + ;; + esac + + if [ "${SOURCE}" = "enabled" ] + then + lh config -d ${DISTRIBUTION} -p ${FLAVOUR} --cache-stages "bootstrap rootfs" --apt-recommends disabled --binary-indices ${INDICES} --tasksel aptitude ${KERNEL} --source enabled --mirror-bootstrap ${MIRROR} --mirror-chroot ${MIRROR} --mirror-chroot-security ${MIRROR_SECURITY} + else + lh config -d ${DISTRIBUTION} -p ${FLAVOUR} --cache-stages "bootstrap rootfs" --apt-recommends disabled --binary-indices ${INDICES} --tasksel aptitude ${KERNEL} --source disabled --mirror-bootstrap ${MIRROR} --mirror-chroot ${MIRROR} --mirror-chroot-security ${MIRROR_SECURITY} + fi + + if [ "${DISTRIBUTION}" = "sid" ] + then + echo 'deb http://live.debian.net/ sid/snapshots main' > config/chroot_sources/debian-live_sid-snapshots.chroot + echo 'deb http://live.debian.net/ sid/snapshots main' > config/chroot_sources/debian-live_sid-snapshots.boot + + wget http://live.debian.net/debian/project/openpgp/archive-key.asc -O config/chroot_sources/debian-live_sid-snapshots.chroot.gpg + wget http://live.debian.net/debian/project/openpgp/archive-key.asc -O config/chroot_sources/debian-live_sid-snapshots.binary.gpg + + fi + + lh 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 [ "${SOURCE}" = "enabled" ] + then + mv source.tar.gz debian-live-${DISTRIBUTION}-source-${FLAVOUR}.tar.gz + mv source.list debian-live-${DISTRIBUTION}-source-${FLAVOUR}.tar.gz.list + fi + + lh clean --binary + lh config -b usb-hdd + lh 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 + + lh clean --binary + lh config -b net + lh binary 2>&1 | tee debian-live-${DISTRIBUTION}-i386-${FLAVOUR}-net.tar.gz.log + + mv binary-net.tar.gz debian-live-${DISTRIBUTION}-i386-${FLAVOUR}-net.tar.gz + mv binary.list debian-live-${DISTRIBUTION}-i386-${FLAVOUR}-net.tar.gz.list + mv binary.packages debian-live-${DISTRIBUTION}-i386-${FLAVOUR}-net.tar.gz.packages + + mv binary/*/filesystem.squashfs debian-live-${DISTRIBUTION}-i386-${FLAVOUR}.squashfs + done +done diff --git a/examples/cron/manpages.sh b/examples/cron/manpages.sh new file mode 100755 index 000000000..00f49dfcd --- /dev/null +++ b/examples/cron/manpages.sh @@ -0,0 +1,100 @@ +#!/bin/sh + +# Needs: man2html git-core + +# Static variables +PACKAGES="live-helper live-initramfs" + +TEMPDIR="/srv/tmp/manpages" +SERVER="/srv/debian-live/www/other/manpages" + +DATE_START="$(date -R)" +HOST="$(hostname)" + +# Checking lock file +if [ -f "${SERVER}"/lock ] +then + echo "E: locked." + exit 1 +fi + +# Creating server directory +if [ ! -d "${SERVER}" ] +then + mkdir -p "${SERVER}" +fi + +# Creating lock trap +trap "test -f ${SERVER}/lock && rm -f ${SERVER}/lock; exit 0" 0 HUP INT QUIT KILL TERM + +# Creating lock file +echo "${DATE_START}" > "${SERVER}"/lock + +echo "$(date +%b\ %d\ %H:%M:%S) ${HOST} live-helper: begin manpage build." >> /var/log/live + +# Remove old manpages +rm -f "${SERVER}"/*.html + +# Processing packages +for PACKAGE in ${PACKAGES} +do + # Cleaning build directory + if [ -d "${TEMPDIR}" ] + then + rm -rf "${TEMPDIR}" + fi + + # Creating build directory + mkdir -p "${TEMPDIR}" + + # Getting sources + cd "${TEMPDIR}" + git clone git://git.debian.org/git/users/daniel/${PACKAGE}.git + + # Building manpages + for MANPAGE in "${TEMPDIR}"/${PACKAGE}/manpages/* + do + man2html -D "${SERVER}"/ -r ${MANPAGE} | \ + sed -e "s#Content-type: text/html##" \ + -e 's#HREF="../index.html"#HREF="./"#' \ + -e 's#HREF="../man1/#HREF="#g' \ + -e 's#HREF="../man2/#HREF="#g' \ + -e 's#HREF="../man3/#HREF="#g' \ + -e 's#HREF="../man4/#HREF="#g' \ + -e 's#HREF="../man5/#HREF="#g' \ + -e 's#HREF="../man6/#HREF="#g' \ + -e 's#HREF="../man7/#HREF="#g' \ + -e 's#HREF="../man8/#HREF="#g' \ + -e 's#HREF="../man9/#HREF="#g' \ + -e 's#/cgi-bin/man/man2html#http://packages.debian.org/man2html#' \ + > "${SERVER}"/$(basename ${MANPAGE}).html + done + + # Removing sources + rm -rf "${TEMPDIR}"/${PACKAGE} + + cd "${OLDPWD}" +done + +# Creating symlinks +for NUMBER in 1 2 3 4 5 6 7 8 9 +do + for MANPAGE in "${SERVER}"/*.en.${NUMBER}.html + do + if [ -f "${MANPAGE}" ] + then + ln -s $(basename ${MANPAGE}) "${SERVER}"/$(basename ${MANPAGE} .en.${NUMBER}.html).${NUMBER}.html + fi + done +done + +# Writing timestamp +cat > "${SERVER}"/LAST_BUILD << EOF +Last run begin: ${DATE_START} +Last run end: $(date -R) +EOF + +# Removing build directory +rm -rf "${TEMPDIR}" + +echo "$(date +%b\ %d\ %H:%M:%S) ${HOST} live-helper: end manpage build." >> /var/log/live diff --git a/examples/cron/snapshots.sh b/examples/cron/snapshots.sh new file mode 100755 index 000000000..4c6290fde --- /dev/null +++ b/examples/cron/snapshots.sh @@ -0,0 +1,183 @@ +#!/bin/sh -e + +# Static variables +if [ -n "${1}" ] +then + PACKAGES="${@}" +else + PACKAGES="live-helper live-initramfs live-initscripts live-webhelper live-magic debian-unofficial-archive-keyring" +fi + +DEBEMAIL="debian-live@lists.debian.org" +EMAIL="debian-live@lists.debian.org" +DEBFULLNAME="Debian Live Autobuilder" +NAME="Debian Live Autobuilder" +KEY="FDB8D39A" + +export DEBEMAIL EMAIL DEBFULLNAME NAME KEY + +TEMPDIR="$(mktemp -d -t debian-live.XXXXXXXX)" +SERVER="/mnt/daniel1/srv/debian-unofficial/live/debian" +LOGFILE="${SERVER}/build.log" + +DATE_START="$(date -R)" +HOST="$(hostname)" + +# Checking lock file +if [ -f "${SERVER}"/Archive-Update-in-Progress ] +then + echo "E: locked." + exit 1 +fi + +# Creating server directory +if [ ! -d "${SERVER}" ] +then + mkdir -p "${SERVER}" +fi + +# Creating lock trap +trap "test -f ${SERVER}/Archive-Update-in-Progress && rm -f ${SERVER}/Archive-Update-in-Progress; exit 0" 0 HUP INT QUIT KILL TERM + +# Creating lock file +echo "${DATE_START}" > "${SERVER}"/Archive-Update-in-Progress + +echo "$(date +%b\ %d\ %H:%M:%S) ${HOST} live-snapshots: begin build." >> "${LOGFILE}" + +# Processing packages +for PACKAGE in ${PACKAGES} +do + # Cleaning build directory + if [ -d "${TEMPDIR}" ] + then + rm -rf "${TEMPDIR}" + fi + + # Creating build directory + mkdir -p "${TEMPDIR}" + + # Getting sources + cd "${TEMPDIR}" + + case "${PACKAGE}" in + debian-unofficial-archive-keyring) + git clone git://git.debian.net/git/${PACKAGE}.git + ;; + + live-magic) + git clone git://git.debian.org/git/users/lamby-guest/${PACKAGE}.git + ;; + + *) + git clone git://git.debian.org/git/users/daniel/${PACKAGE}.git + ;; + esac + + # Getting version + cd "${TEMPDIR}"/${PACKAGE} + + for BRANCH in debian + do + if [ -n "$(git branch -r | grep ${BRANCH})" ] + then + git checkout -b ${BRANCH} origin/${BRANCH} || true + fi + done + + VERSION="$(dpkg-parsechangelog | awk '/Version:/ { print $2 }' | awk -F- '{ print $1 }')" + + # Getting revision + cd "${TEMPDIR}"/${PACKAGE} + REVISION="$(git log | grep -m1 Date | awk -FDate: '{ print $2 }' | awk '{ print $1 ",", $3, $2, $5, $4, $6 }')" + REVISION="$(date -d "${REVISION}" +%Y%m%d.%H%M%S)" + + # Check for existing package + if [ ! -f "${SERVER}"/${PACKAGE}_${VERSION}+${REVISION}.dsc ] || [ "${1}" = "--force" ] + then + UPDATE_INDICES="true" + + # Renaming directory + mv "${TEMPDIR}"/${PACKAGE} "${TEMPDIR}"/${PACKAGE}-${VERSION}+${REVISION} + + # Building package + cd "${TEMPDIR}"/${PACKAGE}-${VERSION}+${REVISION} + rm -rf .git + dch --force-bad-version --newversion ${VERSION}+${REVISION} --distribution UNRELEASED Autobuild snapshot of git ${REVISION}. + dpkg-buildpackage -rfakeroot -k${KEY} -sa + + # Removing sources + rm -rf "${TEMPDIR}"/${PACKAGE}-${VERSION}+${REVISION} + + # Creating directory + mkdir -p "${SERVER}" + + # Removing old packages + if [ -f "${SERVER}"/"${PACKAGE}"*.changes ] + then + for FILE in $(awk {'print $5'} "${SERVER}"/"${PACKAGE}"*.changes | grep -e ".*\.deb$" -e ".*\.diff.gz$" -e ".*\.dsc$" -e ".*\.tar.gz$" -e ".*\.udeb$") + do + rm -f "${SERVER}"/"${FILE}" + done + fi + + rm -f "${SERVER}"/"${PACKAGE}"*.changes + + # Installing new packages + for FILE in $(awk {'print $5'} "${TEMPDIR}"/"${PACKAGE}"*.changes | grep -e ".*\.deb$" -e ".*\.diff.gz$" -e ".*\.dsc$" -e ".*\.tar.gz$" -e ".*\.udeb$") + do + mv "${TEMPDIR}"/"${FILE}" "${SERVER}" + done + + mv "${TEMPDIR}"/"${PACKAGE}"*.changes "${SERVER}" + else + # Remove sources + rm -rf "${TEMPDIR}"/${PACKAGE} + fi +done + +if [ "${UPDATE_INDICES}" = "true" ] +then + LAST_UPDATE="$(date -R)" + + cd "${SERVER}" + + apt-ftparchive packages . /dev/null > Packages + gzip -9 -c Packages > Packages.gz + bzip2 -9 -c Packages > Packages.bz2 + + apt-ftparchive sources . /dev/null > Sources + gzip -9 -c Sources > Sources.gz + bzip2 -9 -c Sources > Sources.bz2 + + if [ -f release.conf ] + then + apt-ftparchive -c release.conf -o APT::FTPArchive::Release::Description="Last updated: `date -R`" release ./ >> Release.tmp + mv Release.tmp Release + + rm -f Release.gpg + gpg --default-key ${KEY} --quiet --output Release.gpg -ba Release + fi +fi + +# Reading timestamp +if [ -z "${LAST_UPDATE}" ] +then + LAST_UPDATE="$(awk -F: '/Last update:/ { print $2":"$3":"$4 }' ${SERVER}/LAST_BUILD | sed -e 's/ //')" +fi + +# Writing timestamp +cat > "${SERVER}"/LAST_BUILD << EOF +Last run begin: ${DATE_START} +Last run end: $(date -R) + +Last update: ${LAST_UPDATE} +EOF + +# Removing build directory +rm -rf "${TEMPDIR}" + +# Fixing permissions +chmod 0644 "${SERVER}"/* +chmod 0766 "${SERVER}"/*.sh + +echo "$(date +%b\ %d\ %H:%M:%S) ${HOST} live-snapshots: end build." >> "${LOGFILE}" |